@leav/ui 1.5.1-fdd83a21 → 1.5.2-427ed078
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Explorer/_queries/useExplorerData.js +13 -2
- package/dist/components/Explorer/_queries/useExplorerData.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useExportMassAction.js +4 -6
- package/dist/components/Explorer/actions-mass/useExportMassAction.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/antdUtils.js +12 -3
- package/dist/components/RecordEdition/EditRecordContent/antdUtils.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.js +4 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/LinkField.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js +6 -3
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSBooleanWrapper.js +6 -5
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSBooleanWrapper.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSColorPickerWrapper.js +9 -8
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSColorPickerWrapper.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSDatePickerWrapper.js +8 -7
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSDatePickerWrapper.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputNumberWrapper.js +6 -5
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputNumberWrapper.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputWrapper.js +6 -5
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSInputWrapper.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRangePickerWrapper.js +12 -11
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRangePickerWrapper.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.js +16 -7
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/ValuesList/DSListSelect.js +6 -5
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/ValuesList/DSListSelect.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/useGetPresentationValues.d.ts +3 -3
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/useGetPresentationValues.js +10 -4
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/useGetPresentationValues.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.js +4 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.js +2 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/calculatedInheritedFlags.d.ts +24 -24
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/calculatedInheritedFlags.js +34 -35
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/calculatedInheritedFlags.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.js +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/ValuesSummary/ValuesSummary.d.ts +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/ValuesSummary/ValuesSummary.js +15 -10
- package/dist/components/RecordEdition/EditRecordSidebar/ValuesSummary/ValuesSummary.js.map +1 -1
- package/dist/components/RecordEdition/editRecordReducer/editRecordReducer.d.ts +1 -1
- package/dist/components/RecordEdition/editRecordReducer/editRecordReducer.js +4 -3
- package/dist/components/RecordEdition/editRecordReducer/editRecordReducer.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/schema.d.ts +11 -0
- package/dist/hooks/useIFrameMessenger/schema.js +4 -0
- package/dist/hooks/useIFrameMessenger/schema.js.map +1 -1
- package/dist/locales/en/shared.json +11 -10
- package/dist/locales/fr/shared.json +11 -10
- package/package.json +4 -4
|
@@ -4,11 +4,17 @@
|
|
|
4
4
|
import { AttributeFormat } from '../../../../../_gqlTypes';
|
|
5
5
|
import { useSharedTranslation } from '../../../../../hooks/useSharedTranslation';
|
|
6
6
|
const _isDateRangeValue = (value) => !!value && typeof value === 'object' && 'from' in value && 'to' in value;
|
|
7
|
-
export const useGetPresentationValues = ({ values, format,
|
|
7
|
+
export const useGetPresentationValues = ({ values, format, calculatedValues, inheritedValues, }) => {
|
|
8
8
|
const { t } = useSharedTranslation();
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const effectiveValues = values?.length > 0
|
|
10
|
+
? values
|
|
11
|
+
: calculatedValues?.length > 0
|
|
12
|
+
? calculatedValues
|
|
13
|
+
: inheritedValues?.length > 0
|
|
14
|
+
? inheritedValues
|
|
15
|
+
: [];
|
|
16
|
+
const presentationValues = effectiveValues.map(value => {
|
|
17
|
+
let presentationValue = value.payload || '';
|
|
12
18
|
switch (format) {
|
|
13
19
|
case AttributeFormat.date_range:
|
|
14
20
|
if (_isDateRangeValue(presentationValue)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetPresentationValues.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/StandardField/useGetPresentationValues.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAiC,MAAM,eAAe,CAAC;AAE9E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,MAAM,iBAAiB,GAAG,CAAC,KAAU,EAAuC,EAAE,CAC1E,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC;AAM7E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACrC,MAAM,EACN,MAAM,EACN,
|
|
1
|
+
{"version":3,"file":"useGetPresentationValues.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/StandardField/useGetPresentationValues.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAiC,MAAM,eAAe,CAAC;AAE9E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,MAAM,iBAAiB,GAAG,CAAC,KAAU,EAAuC,EAAE,CAC1E,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC;AAM7E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACrC,MAAM,EACN,MAAM,EACN,gBAAgB,EAChB,eAAe,GAMlB,EAA6B,EAAE;IAC5B,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,eAAe,GACjB,MAAM,EAAE,MAAM,GAAG,CAAC;QACd,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,gBAAgB,EAAE,MAAM,GAAG,CAAC;YAC5B,CAAC,CAAC,gBAAgB;YAClB,CAAC,CAAC,eAAe,EAAE,MAAM,GAAG,CAAC;gBAC3B,CAAC,CAAC,eAAe;gBACjB,CAAC,CAAC,EAAE,CAAC;IAEjB,MAAM,kBAAkB,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACnD,IAAI,iBAAiB,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;QAE5C,QAAQ,MAAM,EAAE,CAAC;YACb,KAAK,eAAe,CAAC,UAAU;gBAC3B,IAAI,iBAAiB,CAAC,iBAAiB,CAAC,EAAE,CAAC;oBACvC,MAAM,EAAC,IAAI,EAAE,EAAE,EAAC,GAAG,iBAAiB,CAAC;oBACrC,iBAAiB,GAAG,CAAC,CAAC,iCAAiC,EAAE;wBACrD,IAAI;wBACJ,EAAE;wBACF,aAAa,EAAE;4BACX,WAAW,EAAE,KAAK;yBACrB;qBACJ,CAAC,CAAC;gBACP,CAAC;qBAAM,CAAC;oBACJ,iBAAiB,GAAG,EAAE,CAAC;gBAC3B,CAAC;gBACD,MAAM;QACd,CAAC;QAED,OAAO,iBAAiB,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,OAAO,EAAC,kBAAkB,EAAC,CAAC;AAChC,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {AttributeFormat, type ValueDetailsValueFragment} from '_ui/_gqlTypes';\nimport {type RecordFormElementsValueStandardValue} from '_ui/hooks/useGetRecordForm';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\n\nconst _isDateRangeValue = (value: any): value is {from: string; to: string} =>\n !!value && typeof value === 'object' && 'from' in value && 'to' in value;\n\ninterface IUseGetPresentationValues {\n presentationValues: string[];\n}\n\nexport const useGetPresentationValues = ({\n values,\n format,\n calculatedValues,\n inheritedValues,\n}: {\n values: ValueDetailsValueFragment[];\n format: AttributeFormat;\n calculatedValues: RecordFormElementsValueStandardValue[];\n inheritedValues: RecordFormElementsValueStandardValue[];\n}): IUseGetPresentationValues => {\n const {t} = useSharedTranslation();\n\n const effectiveValues =\n values?.length > 0\n ? values\n : calculatedValues?.length > 0\n ? calculatedValues\n : inheritedValues?.length > 0\n ? inheritedValues\n : [];\n\n const presentationValues = effectiveValues.map(value => {\n let presentationValue = value.payload || '';\n\n switch (format) {\n case AttributeFormat.date_range:\n if (_isDateRangeValue(presentationValue)) {\n const {from, to} = presentationValue;\n presentationValue = t('record_edition.date_range_value', {\n from,\n to,\n interpolation: {\n escapeValue: false,\n },\n });\n } else {\n presentationValue = '';\n }\n break;\n }\n\n return presentationValue;\n });\n\n return {presentationValues};\n};\n"]}
|
|
@@ -49,7 +49,10 @@ const TreeField = ({ element, readonly, isFormCreationMode, onDeleteMultipleValu
|
|
|
49
49
|
const label = localizedTranslation(settings.label, lang);
|
|
50
50
|
const form = AntForm.useFormInstance();
|
|
51
51
|
const fieldErrors = form.getFieldError(attribute.id);
|
|
52
|
-
const
|
|
52
|
+
// TODO: Temporary const that should be removed (and all it's usages) when we will have a proper way to override multiple values
|
|
53
|
+
const tmpCantOverrideValues = attribute.multiple_values &&
|
|
54
|
+
(calculatedFlags.calculatedValues?.length > 1 || inheritedFlags.inheritedValues?.length > 1);
|
|
55
|
+
const isReadOnly = attribute.readonly || !attribute.permissions.edit_value || readonly || tmpCantOverrideValues;
|
|
53
56
|
const isFieldInError = fieldErrors.length > 0;
|
|
54
57
|
useEffect(() => {
|
|
55
58
|
if (state.activeAttribute?.attribute.id === attribute.id) {
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeField.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACt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CAAC,CAAC,CAAC,SAAS,yBACtC,UAAU,EAC/B,KAAK,EACD,8BACI,KAAC,yBAAyB,cACtB,KAAC,gBAAgB,IAAC,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,GAAI,GAC9D,EAC3B,kBAAkB,IACpB,aAGP,KAAC,YAAY,IACT,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,GACxB,EACD,CAAC,UAAU,IAAI,CACZ,KAAC,0BAA0B,IACvB,IAAI,EAAE,KAAC,MAAM,KAAG,EAChB,OAAO,EAAE,SAAS,EAClB,IAAI,EAAC,GAAG,iBACK,CAAC,aAAa,EAAE,MAAM,YAElC,iBAAiB,GACO,CAChC,EACA,mBAAmB,IACA,GACb,GACA,CACtB,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent, useEffect, useState} from 'react';\nimport styled, {css} from 'styled-components';\nimport {type ICommonFieldsSettings, localizedTranslation} from '@leav/utils';\nimport {AntForm, KitButton, KitInputWrapper} from 'aristid-ds';\nimport {FaList} from 'react-icons/fa';\nimport {useLang} from '_ui/hooks';\nimport {type IFormElementProps} from '../../_types';\nimport {\n type ChildrenAsRecordValuePermissionFilterInput,\n type RecordFormAttributeTreeAttributeFragment,\n RecordPermissionsActions,\n} from '_ui/_gqlTypes';\nimport {TREE_FIELD_ID_PREFIX} from '_ui/constants';\nimport {type RecordFormElementsValueTreeValue} from '_ui/hooks/useGetRecordForm';\nimport {TreeNodeList} from './display-tree-node/TreeNodeList';\nimport {useManageTreeNodeSelection} from './manage-tree-node-selection/useManageTreeNodeSelection';\nimport {useOutsideInteractionDetector} from '../shared/useOutsideInteractionDetector';\nimport {useEditRecordReducer} from '_ui/components/RecordEdition/editRecordReducer/useEditRecordReducer';\nimport {EditRecordReducerActionsTypes} from '_ui/components/RecordEdition/editRecordReducer/editRecordReducer';\nimport {computeCalculatedFlags, computeInheritedFlags} from '../shared/calculatedInheritedFlags';\nimport {ComputeIndicator} from '../shared/ComputeIndicator';\n\nconst StyledWrapperDiv = styled.div<{$metadataEdit: boolean}>`\n margin-bottom: ${props => (props.$metadataEdit ? 0 : '1.5em')};\n`;\n\nconst KitInputExtraAlignLeftDiv = styled.div`\n margin-right: auto;\n line-height: 12px;\n`;\n\nconst StyledFieldFooterKitButton = styled(KitButton)<{$hasNoValue: boolean}>`\n margin-top: ${props => (props.$hasNoValue ? 0 : 'calc((var(--general-spacing-xs)) * 1px)')};\n`;\n\nconst KitInputWrapperStyled = styled(KitInputWrapper)<{$readonlyBackground: boolean}>`\n .kit-input-wrapper-content {\n min-height: 48px;\n }\n\n ${props =>\n props.$readonlyBackground &&\n css`\n .kit-input-wrapper-content {\n background-color: var(--general-utilities-neutral-light);\n }\n `}\n`;\n\ntype TreeFieldProps = IFormElementProps<ICommonFieldsSettings>;\n\nconst TreeField: FunctionComponent<TreeFieldProps> = ({\n element,\n readonly,\n isFormCreationMode,\n onDeleteMultipleValues,\n onValueSubmit,\n onValueDelete,\n metadataEdit = false,\n}) => {\n const {state, dispatch} = useEditRecordReducer();\n const {lang} = useLang();\n const {\n settings,\n attribute,\n values,\n }: {\n settings: typeof element.settings;\n attribute?: RecordFormAttributeTreeAttributeFragment;\n values?: RecordFormElementsValueTreeValue[];\n } = element;\n\n const [backendValues, setBackendValues] = useState<RecordFormElementsValueTreeValue[]>(values);\n\n const calculatedFlags = computeCalculatedFlags(backendValues);\n const inheritedFlags = computeInheritedFlags(backendValues);\n const label = localizedTranslation(settings.label, lang);\n const form = AntForm.useFormInstance();\n const fieldErrors = form.getFieldError(attribute.id);\n\n const isReadOnly = attribute.readonly || !attribute.permissions.edit_value || readonly;\n const isFieldInError = fieldErrors.length > 0;\n\n useEffect(() => {\n if (state.activeAttribute?.attribute.id === attribute.id) {\n dispatch({\n type: EditRecordReducerActionsTypes.SET_ACTIVE_VALUE,\n values: backendValues,\n });\n }\n }, [backendValues]);\n\n useOutsideInteractionDetector({\n attribute,\n activeAttribute: state.activeAttribute,\n attributePrefix: TREE_FIELD_ID_PREFIX,\n dispatch,\n backendValues,\n allowedSelectors: ['.kit-modal-wrapper'],\n });\n\n const childrenAsRecordValuePermissionFilter: ChildrenAsRecordValuePermissionFilterInput = {\n libraryId: state.libraryId,\n attributeId: state.activeAttribute?.attribute?.id,\n action: RecordPermissionsActions.create_record,\n };\n\n const {openModal, removeTreeNode, actionButtonLabel, SelectTreeNodeModal, RemoveAllTreeNodes} =\n useManageTreeNodeSelection({\n modaleTitle: label,\n attribute,\n isFormCreationMode,\n backendValues,\n setBackendValues,\n onValueSubmit,\n onValueDelete,\n onDeleteMultipleValues,\n isReadOnly,\n isFieldInError,\n childrenAsRecordValuePermissionFilter,\n });\n\n return (\n <StyledWrapperDiv $metadataEdit={metadataEdit}>\n <AntForm.Item name={attribute.id} noStyle>\n <KitInputWrapperStyled\n id={TREE_FIELD_ID_PREFIX + attribute.id}\n data-testid=\"tree-field\"\n label={label}\n required={attribute.required}\n bordered\n status={isFieldInError ? 'error' : undefined}\n helper={isFieldInError ? String(fieldErrors[0]) : undefined}\n $readonlyBackground={isReadOnly}\n extra={\n <>\n <KitInputExtraAlignLeftDiv>\n <ComputeIndicator calculatedFlags={calculatedFlags} inheritedFlags={inheritedFlags} />\n </KitInputExtraAlignLeftDiv>\n {RemoveAllTreeNodes}\n </>\n }\n >\n <TreeNodeList\n attribute={attribute}\n backendValues={backendValues}\n removeTreeNode={removeTreeNode}\n isReadOnly={isReadOnly}\n />\n {!isReadOnly && (\n <StyledFieldFooterKitButton\n icon={<FaList />}\n onClick={openModal}\n size=\"m\"\n $hasNoValue={!backendValues?.length}\n >\n {actionButtonLabel}\n </StyledFieldFooterKitButton>\n )}\n {SelectTreeNodeModal}\n </KitInputWrapperStyled>\n </AntForm.Item>\n </StyledWrapperDiv>\n );\n};\n\nexport default TreeField;\n"]}
|
|
1
|
+
{"version":3,"file":"TreeField.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAClE,OAAO,MAAM,EAAE,EAAC,GAAG,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAA6B,oBAAoB,EAAC,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC,OAAO,EAGH,wBAAwB,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAC,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAC,0BAA0B,EAAC,MAAM,yDAAyD,CAAC;AACnG,OAAO,EAAC,6BAA6B,EAAC,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAC,oBAAoB,EAAC,MAAM,qEAAqE,CAAC;AACzG,OAAO,EAAC,6BAA6B,EAAC,MAAM,kEAAkE,CAAC;AAC/G,OAAO,EAAC,sBAAsB,EAAE,qBAAqB,EAAC,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAC,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAE5D,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAA0B;qBACxC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAA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qBAAgB,YAAY,YACzC,KAAC,OAAO,CAAC,IAAI,IAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,kBACrC,MAAC,qBAAqB,IAClB,EAAE,EAAE,oBAAoB,GAAG,SAAS,CAAC,EAAE,iBAC3B,YAAY,EACxB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,QAAQ,QACR,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAC5C,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,yBACtC,UAAU,EAC/B,KAAK,EACD,8BACI,KAAC,yBAAyB,cACtB,KAAC,gBAAgB,IAAC,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,GAAI,GAC9D,EAC3B,kBAAkB,IACpB,aAGP,KAAC,YAAY,IACT,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,GACxB,EACD,CAAC,UAAU,IAAI,CACZ,KAAC,0BAA0B,IACvB,IAAI,EAAE,KAAC,MAAM,KAAG,EAChB,OAAO,EAAE,SAAS,EAClB,IAAI,EAAC,GAAG,iBACK,CAAC,aAAa,EAAE,MAAM,YAElC,iBAAiB,GACO,CAChC,EACA,mBAAmB,IACA,GACb,GACA,CACtB,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent, useEffect, useState} from 'react';\nimport styled, {css} from 'styled-components';\nimport {type ICommonFieldsSettings, localizedTranslation} from '@leav/utils';\nimport {AntForm, KitButton, KitInputWrapper} from 'aristid-ds';\nimport {FaList} from 'react-icons/fa';\nimport {useLang} from '_ui/hooks';\nimport {type IFormElementProps} from '../../_types';\nimport {\n type ChildrenAsRecordValuePermissionFilterInput,\n type RecordFormAttributeTreeAttributeFragment,\n RecordPermissionsActions,\n} from '_ui/_gqlTypes';\nimport {TREE_FIELD_ID_PREFIX} from '_ui/constants';\nimport {type RecordFormElementsValueTreeValue} from '_ui/hooks/useGetRecordForm';\nimport {TreeNodeList} from './display-tree-node/TreeNodeList';\nimport {useManageTreeNodeSelection} from './manage-tree-node-selection/useManageTreeNodeSelection';\nimport {useOutsideInteractionDetector} from '../shared/useOutsideInteractionDetector';\nimport {useEditRecordReducer} from '_ui/components/RecordEdition/editRecordReducer/useEditRecordReducer';\nimport {EditRecordReducerActionsTypes} from '_ui/components/RecordEdition/editRecordReducer/editRecordReducer';\nimport {computeCalculatedFlags, computeInheritedFlags} from '../shared/calculatedInheritedFlags';\nimport {ComputeIndicator} from '../shared/ComputeIndicator';\n\nconst StyledWrapperDiv = styled.div<{$metadataEdit: boolean}>`\n margin-bottom: ${props => (props.$metadataEdit ? 0 : '1.5em')};\n`;\n\nconst KitInputExtraAlignLeftDiv = styled.div`\n margin-right: auto;\n line-height: 12px;\n`;\n\nconst StyledFieldFooterKitButton = styled(KitButton)<{$hasNoValue: boolean}>`\n margin-top: ${props => (props.$hasNoValue ? 0 : 'calc((var(--general-spacing-xs)) * 1px)')};\n`;\n\nconst KitInputWrapperStyled = styled(KitInputWrapper)<{$readonlyBackground: boolean}>`\n .kit-input-wrapper-content {\n min-height: 48px;\n }\n\n ${props =>\n props.$readonlyBackground &&\n css`\n .kit-input-wrapper-content {\n background-color: var(--general-utilities-neutral-light);\n }\n `}\n`;\n\ntype TreeFieldProps = IFormElementProps<ICommonFieldsSettings>;\n\nconst TreeField: FunctionComponent<TreeFieldProps> = ({\n element,\n readonly,\n isFormCreationMode,\n onDeleteMultipleValues,\n onValueSubmit,\n onValueDelete,\n metadataEdit = false,\n}) => {\n const {state, dispatch} = useEditRecordReducer();\n const {lang} = useLang();\n const {\n settings,\n attribute,\n values,\n }: {\n settings: typeof element.settings;\n attribute?: RecordFormAttributeTreeAttributeFragment;\n values?: RecordFormElementsValueTreeValue[];\n } = element;\n\n const [backendValues, setBackendValues] = useState<RecordFormElementsValueTreeValue[]>(values);\n\n const calculatedFlags = computeCalculatedFlags(backendValues);\n const inheritedFlags = computeInheritedFlags(backendValues);\n const label = localizedTranslation(settings.label, lang);\n const form = AntForm.useFormInstance();\n const fieldErrors = form.getFieldError(attribute.id);\n\n // TODO: Temporary const that should be removed (and all it's usages) when we will have a proper way to override multiple values\n const tmpCantOverrideValues =\n attribute.multiple_values &&\n (calculatedFlags.calculatedValues?.length > 1 || inheritedFlags.inheritedValues?.length > 1);\n\n const isReadOnly = attribute.readonly || !attribute.permissions.edit_value || readonly || tmpCantOverrideValues;\n const isFieldInError = fieldErrors.length > 0;\n\n useEffect(() => {\n if (state.activeAttribute?.attribute.id === attribute.id) {\n dispatch({\n type: EditRecordReducerActionsTypes.SET_ACTIVE_VALUE,\n values: backendValues,\n });\n }\n }, [backendValues]);\n\n useOutsideInteractionDetector({\n attribute,\n activeAttribute: state.activeAttribute,\n attributePrefix: TREE_FIELD_ID_PREFIX,\n dispatch,\n backendValues,\n allowedSelectors: ['.kit-modal-wrapper'],\n });\n\n const childrenAsRecordValuePermissionFilter: ChildrenAsRecordValuePermissionFilterInput = {\n libraryId: state.libraryId,\n attributeId: state.activeAttribute?.attribute?.id,\n action: RecordPermissionsActions.create_record,\n };\n\n const {openModal, removeTreeNode, actionButtonLabel, SelectTreeNodeModal, RemoveAllTreeNodes} =\n useManageTreeNodeSelection({\n modaleTitle: label,\n attribute,\n isFormCreationMode,\n backendValues,\n setBackendValues,\n onValueSubmit,\n onValueDelete,\n onDeleteMultipleValues,\n isReadOnly,\n isFieldInError,\n childrenAsRecordValuePermissionFilter,\n });\n\n return (\n <StyledWrapperDiv $metadataEdit={metadataEdit}>\n <AntForm.Item name={attribute.id} noStyle>\n <KitInputWrapperStyled\n id={TREE_FIELD_ID_PREFIX + attribute.id}\n data-testid=\"tree-field\"\n label={label}\n required={attribute.required}\n bordered\n status={isFieldInError ? 'error' : undefined}\n helper={isFieldInError ? String(fieldErrors[0]) : undefined}\n $readonlyBackground={isReadOnly}\n extra={\n <>\n <KitInputExtraAlignLeftDiv>\n <ComputeIndicator calculatedFlags={calculatedFlags} inheritedFlags={inheritedFlags} />\n </KitInputExtraAlignLeftDiv>\n {RemoveAllTreeNodes}\n </>\n }\n >\n <TreeNodeList\n attribute={attribute}\n backendValues={backendValues}\n removeTreeNode={removeTreeNode}\n isReadOnly={isReadOnly}\n />\n {!isReadOnly && (\n <StyledFieldFooterKitButton\n icon={<FaList />}\n onClick={openModal}\n size=\"m\"\n $hasNoValue={!backendValues?.length}\n >\n {actionButtonLabel}\n </StyledFieldFooterKitButton>\n )}\n {SelectTreeNodeModal}\n </KitInputWrapperStyled>\n </AntForm.Item>\n </StyledWrapperDiv>\n );\n};\n\nexport default TreeField;\n"]}
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.js
CHANGED
|
@@ -9,8 +9,8 @@ const ComputeIndicatorWrapper = styled.div `
|
|
|
9
9
|
`;
|
|
10
10
|
export const ComputeIndicator = ({ calculatedFlags, inheritedFlags }) => {
|
|
11
11
|
const { t } = useSharedTranslation();
|
|
12
|
-
const shouldDisplayComputedIcon = calculatedFlags.
|
|
13
|
-
const shouldDisplayOverridedIcon = calculatedFlags.
|
|
12
|
+
const shouldDisplayComputedIcon = calculatedFlags.isCalculatedNotOverrideValues || inheritedFlags.isInheritedNotOverrideValues;
|
|
13
|
+
const shouldDisplayOverridedIcon = calculatedFlags.isCalculatedOverrideValues || inheritedFlags.isInheritedOverrideValues;
|
|
14
14
|
return (_jsxs(ComputeIndicatorWrapper, { children: [shouldDisplayComputedIcon && (_jsx(KitTooltip, { title: t('record_edition.calculated_value'), mouseEnterDelay: TOOLTIP_DEFAULT_DELAY_IN_SECONDS, children: _jsx(FaSquareRootAlt, {}) })), shouldDisplayOverridedIcon && (_jsx(KitTooltip, { title: t('record_edition.overrided_value'), mouseEnterDelay: TOOLTIP_DEFAULT_DELAY_IN_SECONDS, children: _jsx(FaLayerGroup, {}) }))] }));
|
|
15
15
|
};
|
|
16
16
|
//# sourceMappingURL=ComputeIndicator.js.map
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComputeIndicator.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,YAAY,EAAE,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,gCAAgC,EAAC,MAAM,eAAe,CAAC;AAE/D,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA;;CAEzC,CAAC;AAOF,MAAM,CAAC,MAAM,gBAAgB,GAA8C,CAAC,EAAC,eAAe,EAAE,cAAc,EAAC,EAAE,EAAE;IAC7G,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,yBAAyB,GAC3B,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"ComputeIndicator.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,YAAY,EAAE,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,gCAAgC,EAAC,MAAM,eAAe,CAAC;AAE/D,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA;;CAEzC,CAAC;AAOF,MAAM,CAAC,MAAM,gBAAgB,GAA8C,CAAC,EAAC,eAAe,EAAE,cAAc,EAAC,EAAE,EAAE;IAC7G,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,yBAAyB,GAC3B,eAAe,CAAC,6BAA6B,IAAI,cAAc,CAAC,4BAA4B,CAAC;IACjG,MAAM,0BAA0B,GAC5B,eAAe,CAAC,0BAA0B,IAAI,cAAc,CAAC,yBAAyB,CAAC;IAE3F,OAAO,CACH,MAAC,uBAAuB,eACnB,yBAAyB,IAAI,CAC1B,KAAC,UAAU,IACP,KAAK,EAAE,CAAC,CAAC,iCAAiC,CAAC,EAC3C,eAAe,EAAE,gCAAgC,YAEjD,KAAC,eAAe,KAAG,GACV,CAChB,EACA,0BAA0B,IAAI,CAC3B,KAAC,UAAU,IACP,KAAK,EAAE,CAAC,CAAC,gCAAgC,CAAC,EAC1C,eAAe,EAAE,gCAAgC,YAEjD,KAAC,YAAY,KAAG,GACP,CAChB,IACqB,CAC7B,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent} from 'react';\nimport {type CalculatedFlags, type InheritedFlags} from './calculatedInheritedFlags';\nimport {KitTooltip} from 'aristid-ds';\nimport {FaLayerGroup, FaSquareRootAlt} from 'react-icons/fa';\nimport styled from 'styled-components';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {TOOLTIP_DEFAULT_DELAY_IN_SECONDS} from '_ui/constants';\n\nconst ComputeIndicatorWrapper = styled.div`\n font-size: calc(var(--general-typography-fontSize7) * 1px);\n`;\n\ninterface IComputeIndicatorProps {\n calculatedFlags: CalculatedFlags;\n inheritedFlags: InheritedFlags;\n}\n\nexport const ComputeIndicator: FunctionComponent<IComputeIndicatorProps> = ({calculatedFlags, inheritedFlags}) => {\n const {t} = useSharedTranslation();\n\n const shouldDisplayComputedIcon =\n calculatedFlags.isCalculatedNotOverrideValues || inheritedFlags.isInheritedNotOverrideValues;\n const shouldDisplayOverridedIcon =\n calculatedFlags.isCalculatedOverrideValues || inheritedFlags.isInheritedOverrideValues;\n\n return (\n <ComputeIndicatorWrapper>\n {shouldDisplayComputedIcon && (\n <KitTooltip\n title={t('record_edition.calculated_value')}\n mouseEnterDelay={TOOLTIP_DEFAULT_DELAY_IN_SECONDS}\n >\n <FaSquareRootAlt />\n </KitTooltip>\n )}\n {shouldDisplayOverridedIcon && (\n <KitTooltip\n title={t('record_edition.overrided_value')}\n mouseEnterDelay={TOOLTIP_DEFAULT_DELAY_IN_SECONDS}\n >\n <FaLayerGroup />\n </KitTooltip>\n )}\n </ComputeIndicatorWrapper>\n );\n};\n"]}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { type RecordFormElementsValueStandardValue } from '../../../../../hooks/useGetRecordForm';
|
|
2
2
|
interface IInheritedNotOverride {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
isInheritedValues: true;
|
|
4
|
+
isInheritedOverrideValues: false;
|
|
5
|
+
isInheritedNotOverrideValues: true;
|
|
6
|
+
inheritedValues: RecordFormElementsValueStandardValue[];
|
|
7
7
|
}
|
|
8
8
|
interface IInheritedOverride {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
isInheritedValues: true;
|
|
10
|
+
isInheritedOverrideValues: true;
|
|
11
|
+
isInheritedNotOverrideValues: false;
|
|
12
|
+
inheritedValues: RecordFormElementsValueStandardValue[];
|
|
13
13
|
}
|
|
14
14
|
interface INotInherited {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
isInheritedValues: false;
|
|
16
|
+
isInheritedOverrideValues: false;
|
|
17
|
+
isInheritedNotOverrideValues: false;
|
|
18
|
+
inheritedValues: null;
|
|
19
19
|
}
|
|
20
20
|
export type InheritedFlags = INotInherited | IInheritedOverride | IInheritedNotOverride;
|
|
21
21
|
export declare const computeInheritedFlags: (fieldValues: RecordFormElementsValueStandardValue[]) => InheritedFlags;
|
|
22
22
|
interface ICalculatedNotOverride {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
isCalculatedValues: true;
|
|
24
|
+
isCalculatedOverrideValues: false;
|
|
25
|
+
isCalculatedNotOverrideValues: true;
|
|
26
|
+
calculatedValues: RecordFormElementsValueStandardValue[];
|
|
27
27
|
}
|
|
28
28
|
interface ICalculatedOverride {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
isCalculatedValues: true;
|
|
30
|
+
isCalculatedOverrideValues: true;
|
|
31
|
+
isCalculatedNotOverrideValues: false;
|
|
32
|
+
calculatedValues: RecordFormElementsValueStandardValue[];
|
|
33
33
|
}
|
|
34
34
|
interface INotCalculated {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
isCalculatedValues: false;
|
|
36
|
+
isCalculatedOverrideValues: false;
|
|
37
|
+
isCalculatedNotOverrideValues: false;
|
|
38
|
+
calculatedValues: null;
|
|
39
39
|
}
|
|
40
40
|
export type CalculatedFlags = INotCalculated | ICalculatedOverride | ICalculatedNotOverride;
|
|
41
41
|
export declare const computeCalculatedFlags: (fieldValues: RecordFormElementsValueStandardValue[]) => CalculatedFlags;
|
|
@@ -1,56 +1,55 @@
|
|
|
1
1
|
export const computeInheritedFlags = (fieldValues) => {
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
if (
|
|
2
|
+
const inheritedValues = fieldValues.filter(fieldValue => fieldValue.isInherited);
|
|
3
|
+
const overrideValues = fieldValues.filter(fieldValue => !fieldValue.isInherited && !fieldValue.isCalculated && fieldValue.payload !== null);
|
|
4
|
+
if (inheritedValues.length === 0) {
|
|
5
5
|
return {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
inheritedValues: null,
|
|
7
|
+
isInheritedValues: false,
|
|
8
|
+
isInheritedOverrideValues: false,
|
|
9
|
+
isInheritedNotOverrideValues: false,
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
if (!overrideValue || overrideValue.payload === null) {
|
|
12
|
+
if (overrideValues.length === 0) {
|
|
14
13
|
return {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
inheritedValues,
|
|
15
|
+
isInheritedValues: true,
|
|
16
|
+
isInheritedNotOverrideValues: true,
|
|
17
|
+
isInheritedOverrideValues: false,
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
20
|
return {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
inheritedValues,
|
|
22
|
+
isInheritedValues: true,
|
|
23
|
+
isInheritedNotOverrideValues: false,
|
|
24
|
+
isInheritedOverrideValues: true,
|
|
26
25
|
};
|
|
27
26
|
};
|
|
28
27
|
export const computeCalculatedFlags = (fieldValues) => {
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
(fieldValue.isInherited === null || fieldValue.isInherited === undefined)
|
|
32
|
-
|
|
28
|
+
const calculatedValues = fieldValues.filter(fieldValue => fieldValue.isCalculated !== null && fieldValue.isCalculated !== undefined);
|
|
29
|
+
const overrideValues = fieldValues.filter(fieldValue => (fieldValue.isCalculated === null || fieldValue.isCalculated === undefined) &&
|
|
30
|
+
(fieldValue.isInherited === null || fieldValue.isInherited === undefined) &&
|
|
31
|
+
fieldValue.payload !== null);
|
|
32
|
+
if (calculatedValues.length === 0) {
|
|
33
33
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
calculatedValues: null,
|
|
35
|
+
isCalculatedValues: false,
|
|
36
|
+
isCalculatedOverrideValues: false,
|
|
37
|
+
isCalculatedNotOverrideValues: false,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
if (!overrideValue || overrideValue.payload === null) {
|
|
40
|
+
if (overrideValues.length === 0) {
|
|
42
41
|
return {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
calculatedValues,
|
|
43
|
+
isCalculatedValues: true,
|
|
44
|
+
isCalculatedNotOverrideValues: true,
|
|
45
|
+
isCalculatedOverrideValues: false,
|
|
47
46
|
};
|
|
48
47
|
}
|
|
49
48
|
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
calculatedValues,
|
|
50
|
+
isCalculatedValues: true,
|
|
51
|
+
isCalculatedNotOverrideValues: false,
|
|
52
|
+
isCalculatedOverrideValues: true,
|
|
54
53
|
};
|
|
55
54
|
};
|
|
56
55
|
//# sourceMappingURL=calculatedInheritedFlags.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculatedInheritedFlags.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/shared/calculatedInheritedFlags.ts"],"names":[],"mappings":"AA4BA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,WAAmD,EAAkB,EAAE;IACzG,MAAM,
|
|
1
|
+
{"version":3,"file":"calculatedInheritedFlags.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/shared/calculatedInheritedFlags.ts"],"names":[],"mappings":"AA4BA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,WAAmD,EAAkB,EAAE;IACzG,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,WAA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AC,EAAE,CAAC;QAChC,OAAO;YACH,gBAAgB,EAAE,IAAI;YACtB,kBAAkB,EAAE,KAAK;YACzB,0BAA0B,EAAE,KAAK;YACjC,6BAA6B,EAAE,KAAK;SACvC,CAAC;IACN,CAAC;IAED,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO;YACH,gBAAgB;YAChB,kBAAkB,EAAE,IAAI;YACxB,6BAA6B,EAAE,IAAI;YACnC,0BAA0B,EAAE,KAAK;SACpC,CAAC;IACN,CAAC;IAED,OAAO;QACH,gBAAgB;QAChB,kBAAkB,EAAE,IAAI;QACxB,6BAA6B,EAAE,KAAK;QACpC,0BAA0B,EAAE,IAAI;KACnC,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type RecordFormElementsValueStandardValue} from '_ui/hooks/useGetRecordForm';\n\ninterface IInheritedNotOverride {\n isInheritedValues: true;\n isInheritedOverrideValues: false;\n isInheritedNotOverrideValues: true;\n inheritedValues: RecordFormElementsValueStandardValue[];\n}\n\ninterface IInheritedOverride {\n isInheritedValues: true;\n isInheritedOverrideValues: true;\n isInheritedNotOverrideValues: false;\n inheritedValues: RecordFormElementsValueStandardValue[];\n}\n\ninterface INotInherited {\n isInheritedValues: false;\n isInheritedOverrideValues: false;\n isInheritedNotOverrideValues: false;\n inheritedValues: null;\n}\n\nexport type InheritedFlags = INotInherited | IInheritedOverride | IInheritedNotOverride;\n\nexport const computeInheritedFlags = (fieldValues: RecordFormElementsValueStandardValue[]): InheritedFlags => {\n const inheritedValues = fieldValues.filter(fieldValue => fieldValue.isInherited);\n const overrideValues = fieldValues.filter(\n fieldValue => !fieldValue.isInherited && !fieldValue.isCalculated && fieldValue.payload !== null,\n );\n\n if (inheritedValues.length === 0) {\n return {\n inheritedValues: null,\n isInheritedValues: false,\n isInheritedOverrideValues: false,\n isInheritedNotOverrideValues: false,\n };\n }\n\n if (overrideValues.length === 0) {\n return {\n inheritedValues,\n isInheritedValues: true,\n isInheritedNotOverrideValues: true,\n isInheritedOverrideValues: false,\n };\n }\n\n return {\n inheritedValues,\n isInheritedValues: true,\n isInheritedNotOverrideValues: false,\n isInheritedOverrideValues: true,\n };\n};\n\ninterface ICalculatedNotOverride {\n isCalculatedValues: true;\n isCalculatedOverrideValues: false;\n isCalculatedNotOverrideValues: true;\n calculatedValues: RecordFormElementsValueStandardValue[];\n}\n\ninterface ICalculatedOverride {\n isCalculatedValues: true;\n isCalculatedOverrideValues: true;\n isCalculatedNotOverrideValues: false;\n calculatedValues: RecordFormElementsValueStandardValue[];\n}\n\ninterface INotCalculated {\n isCalculatedValues: false;\n isCalculatedOverrideValues: false;\n isCalculatedNotOverrideValues: false;\n calculatedValues: null;\n}\n\nexport type CalculatedFlags = INotCalculated | ICalculatedOverride | ICalculatedNotOverride;\n\nexport const computeCalculatedFlags = (fieldValues: RecordFormElementsValueStandardValue[]): CalculatedFlags => {\n const calculatedValues = fieldValues.filter(\n fieldValue => fieldValue.isCalculated !== null && fieldValue.isCalculated !== undefined,\n );\n const overrideValues = fieldValues.filter(\n fieldValue =>\n (fieldValue.isCalculated === null || fieldValue.isCalculated === undefined) &&\n (fieldValue.isInherited === null || fieldValue.isInherited === undefined) &&\n fieldValue.payload !== null,\n );\n\n if (calculatedValues.length === 0) {\n return {\n calculatedValues: null,\n isCalculatedValues: false,\n isCalculatedOverrideValues: false,\n isCalculatedNotOverrideValues: false,\n };\n }\n\n if (overrideValues.length === 0) {\n return {\n calculatedValues,\n isCalculatedValues: true,\n isCalculatedNotOverrideValues: true,\n isCalculatedOverrideValues: false,\n };\n }\n\n return {\n calculatedValues,\n isCalculatedValues: true,\n isCalculatedNotOverrideValues: false,\n isCalculatedOverrideValues: true,\n };\n};\n"]}
|
|
@@ -29,7 +29,7 @@ const _getRecordSidebarContent = (state, onMetadataSubmit) => {
|
|
|
29
29
|
case 'none':
|
|
30
30
|
return null;
|
|
31
31
|
case 'valueDetails':
|
|
32
|
-
return (_jsxs(StyledDivContentWrapper, { children: [_jsx(AttributeSummary, { attribute: state.activeAttribute.attribute }), _jsx(ValuesSummary, { record: state.record, attributeId: state.activeAttribute.attribute.id, globalValues: state.activeAttribute.globalValues,
|
|
32
|
+
return (_jsxs(StyledDivContentWrapper, { children: [_jsx(AttributeSummary, { attribute: state.activeAttribute.attribute }), _jsx(ValuesSummary, { record: state.record, attributeId: state.activeAttribute.attribute.id, globalValues: state.activeAttribute.globalValues, calculatedValues: state.activeAttribute.calculatedValues })] }));
|
|
33
33
|
case 'valuesVersions':
|
|
34
34
|
return _jsx(ValuesVersions, {});
|
|
35
35
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditRecordSidebar.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,SAAS,EAAW,MAAM,EAAC,MAAM,OAAO,CAAC;AAEzE,OAAO,EAAC,oBAAoB,EAAC,MAAM,2CAA2C,CAAC;AAC/E,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,+BAA+B,EAA+B,MAAM,wCAAwC,CAAC;AACrH,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAExC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AAOjD,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAKzC,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,KAA8B,EAAE,gBAAyC,EAAE,EAAE;IAC3G,6DAA6D;IAC7D,QAAQ,KAAK,CAAC,cAAc,EAAE,CAAC;QAC3B,KAAK,MAAM;YACP,OAAO,IAAI,CAAC;QAChB,KAAK,cAAc;YACf,OAAO,CACH,MAAC,uBAAuB,eACpB,KAAC,gBAAgB,IAAC,SAAS,EAAE,KAAK,CAAC,eAAe,CAAC,SAAS,GAAI,EAChE,KAAC,aAAa,IACV,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,WAAW,EAAE,KAAK,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,EAC/C,YAAY,EAAE,KAAK,CAAC,eAAe,CAAC,YAAY,EAChD,
|
|
1
|
+
{"version":3,"file":"EditRecordSidebar.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,SAAS,EAAW,MAAM,EAAC,MAAM,OAAO,CAAC;AAEzE,OAAO,EAAC,oBAAoB,EAAC,MAAM,2CAA2C,CAAC;AAC/E,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,+BAA+B,EAA+B,MAAM,wCAAwC,CAAC;AACrH,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAExC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,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YAChC,CAAC;iBAAM,CAAC;gBACJ,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACjC,CAAC;QACL,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAErE,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,gBAAgB,KAAK,SAAS;QACjC,CAAC,CAAC,wBAAwB;QAC1B,CAAC,CAAC,YAAY,CAAC,wBAAwB,EAAE,gBAAgB,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent, useEffect, useMemo, useRef} from 'react';\nimport {type MetadataSubmitValueFunc} from '../EditRecordContent/_types';\nimport {useEditRecordReducer} from '../editRecordReducer/useEditRecordReducer';\nimport RecordSummary from './RecordSummary';\nimport ValuesVersions from './ValuesVersions';\nimport {createPortal} from 'react-dom';\nimport {EditRecordSidebarContentTypeMap, type IEditRecordReducerState} from '../editRecordReducer/editRecordReducer';\nimport {KitSidePanel} from 'aristid-ds';\nimport {type KitSidePanelRef} from 'aristid-ds/dist/Kit/Navigation/SidePanel/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {EDIT_RECORD_SIDEBAR_ID} from '_ui/constants';\nimport Breadcrumb from './Breacrumb';\nimport AttributeSummary from './AttributeSummary';\nimport ValuesSummary from './ValuesSummary';\nimport styled from 'styled-components';\nimport {useLang} from '_ui/hooks';\nimport {localizedTranslation} from '@leav/utils';\n\ninterface IEditRecordSidebarProps {\n onMetadataSubmit: MetadataSubmitValueFunc;\n sidebarContainer?: HTMLElement;\n}\n\nconst StyledDivContentWrapper = styled.div`\n display: flex;\n flex-direction: column;\n gap: calc(var(--general-spacing-s) * 1px);\n height: 100%;\n`;\n\nconst _getRecordSidebarContent = (state: IEditRecordReducerState, onMetadataSubmit: MetadataSubmitValueFunc) => {\n // TODO: ValuesVersions should be removed or refactored later\n switch (state.sidebarContent) {\n case 'none':\n return null;\n case 'valueDetails':\n return (\n <StyledDivContentWrapper>\n <AttributeSummary attribute={state.activeAttribute.attribute} />\n <ValuesSummary\n record={state.record}\n attributeId={state.activeAttribute.attribute.id}\n globalValues={state.activeAttribute.globalValues}\n calculatedValues={state.activeAttribute.calculatedValues}\n />\n </StyledDivContentWrapper>\n );\n case 'valuesVersions':\n return <ValuesVersions />;\n default:\n return <RecordSummary record={state.record} />;\n }\n};\n\nconst StyledKitSidePanel = styled(KitSidePanel)<{$hideBoxShadow: boolean; $isOpen: boolean}>`\n ${({$hideBoxShadow}) =>\n $hideBoxShadow &&\n `&&& section {\n box-shadow: none;\n }`}\n grid-area: sidebar;\n display: ${({$isOpen}) => ($isOpen ? 'block' : 'none')};\n`;\n\nexport const EditRecordSidebar: FunctionComponent<IEditRecordSidebarProps> = ({onMetadataSubmit, sidebarContainer}) => {\n const {t} = useSharedTranslation();\n const {lang} = useLang();\n const {state} = useEditRecordReducer();\n const sidePanelRef = useRef<KitSidePanelRef | null>(null);\n const sidePanelTitle =\n state.sidebarContent === EditRecordSidebarContentTypeMap.VALUE_DETAILS\n ? localizedTranslation(state.activeAttribute?.attribute.label, lang)\n : (state.record?.label ?? state.record?.id ?? t('record_summary.new_record'));\n\n const editRecordSidebarContent = (\n <StyledKitSidePanel\n ref={sidePanelRef}\n initialOpen={state.isOpenSidebar && state.enableSidebar}\n idCardProps={{title: sidePanelTitle}}\n id={EDIT_RECORD_SIDEBAR_ID}\n headerExtra={<Breadcrumb />}\n $hideBoxShadow={!sidebarContainer}\n $isOpen={state.isOpenSidebar}\n >\n {_getRecordSidebarContent(state, onMetadataSubmit)}\n </StyledKitSidePanel>\n );\n\n useEffect(() => {\n if (sidePanelRef.current && state.enableSidebar) {\n if (state.isOpenSidebar) {\n sidePanelRef.current.open();\n } else {\n sidePanelRef.current.close();\n }\n }\n }, [state.enableSidebar, state.isOpenSidebar, sidePanelRef.current]);\n\n if (!state.enableSidebar) {\n return null;\n }\n\n return sidebarContainer === undefined\n ? editRecordSidebarContent\n : createPortal(editRecordSidebarContent, sidebarContainer);\n};\n\nexport default EditRecordSidebar;\n"]}
|
|
@@ -5,7 +5,7 @@ interface IValuesSummaryProps {
|
|
|
5
5
|
record: IRecordIdentityWhoAmI | null;
|
|
6
6
|
attributeId: string;
|
|
7
7
|
globalValues?: Array<RecordFormElementsValueStandardValue['payload']>;
|
|
8
|
-
|
|
8
|
+
calculatedValues?: Array<RecordFormElementsValueStandardValue['payload']>;
|
|
9
9
|
}
|
|
10
10
|
export declare const ValuesSummary: FunctionComponent<IValuesSummaryProps>;
|
|
11
11
|
export default ValuesSummary;
|
|
@@ -20,7 +20,7 @@ const stripHtml = (html) => {
|
|
|
20
20
|
return doc.body.textContent || '';
|
|
21
21
|
};
|
|
22
22
|
const _isDateRangeValue = (value) => !!value && typeof value === 'object' && 'from' in value && 'to' in value;
|
|
23
|
-
export const ValuesSummary = ({ record, attributeId, globalValues = [],
|
|
23
|
+
export const ValuesSummary = ({ record, attributeId, globalValues = [], calculatedValues = [], }) => {
|
|
24
24
|
const { t } = useSharedTranslation();
|
|
25
25
|
const stringifyValue = (value) => {
|
|
26
26
|
if (typeof value === 'string') {
|
|
@@ -41,12 +41,12 @@ export const ValuesSummary = ({ record, attributeId, globalValues = [], calculat
|
|
|
41
41
|
return value;
|
|
42
42
|
};
|
|
43
43
|
const stripedGlobalValues = globalValues.map(stringifyValue);
|
|
44
|
-
const
|
|
44
|
+
const stripedCalculatedValues = calculatedValues.map(stringifyValue);
|
|
45
45
|
return (_jsx(StyledDivContentWrapper, { children: _jsx(KitTabs, { items: [
|
|
46
46
|
{
|
|
47
47
|
key: 'version_values',
|
|
48
48
|
label: t('record_summary.values_version'),
|
|
49
|
-
tabContent: (_jsx(InformationsWrapper, { children: _jsx(KitTree, { defaultExpandAll: true, selectedKeys:
|
|
49
|
+
tabContent: (_jsx(InformationsWrapper, { children: _jsx(KitTree, { defaultExpandAll: true, selectedKeys: calculatedValues.length > 0 && globalValues.length === 0
|
|
50
50
|
? [calculatedValueKey]
|
|
51
51
|
: [globalValueKey], treeData: [
|
|
52
52
|
{
|
|
@@ -55,13 +55,18 @@ export const ValuesSummary = ({ record, attributeId, globalValues = [], calculat
|
|
|
55
55
|
display: 'flex',
|
|
56
56
|
alignItems: 'center',
|
|
57
57
|
justifyContent: 'space-between',
|
|
58
|
-
}, children: [_jsxs("span", { children: [_jsx(FaSquareRootAlt, {}), " ", t('record_summary.calculated_value')] }), _jsx(KitBadge, { count:
|
|
59
|
-
children:
|
|
60
|
-
{
|
|
61
|
-
key: `${calculatedValueKey}
|
|
62
|
-
title:
|
|
63
|
-
}
|
|
64
|
-
|
|
58
|
+
}, children: [_jsxs("span", { children: [_jsx(FaSquareRootAlt, {}), " ", t('record_summary.calculated_value')] }), _jsx(KitBadge, { count: stripedCalculatedValues.length, color: "primary" })] })),
|
|
59
|
+
children: stripedCalculatedValues.length > 0
|
|
60
|
+
? stripedCalculatedValues.map((calculatedValue, index) => ({
|
|
61
|
+
key: `${calculatedValueKey}-${index}`,
|
|
62
|
+
title: calculatedValue,
|
|
63
|
+
}))
|
|
64
|
+
: [
|
|
65
|
+
{
|
|
66
|
+
key: `${calculatedValueKey}-${0}`,
|
|
67
|
+
title: _jsx("i", { children: t('record_summary.no_value') }),
|
|
68
|
+
},
|
|
69
|
+
],
|
|
65
70
|
},
|
|
66
71
|
{
|
|
67
72
|
key: globalValueKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValuesSummary.js","sourceRoot":"","sources":["../../../../../src/components/RecordEdition/EditRecordSidebar/ValuesSummary/ValuesSummary.tsx"],"names":[],"mappings":";AAKA,OAAO,E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 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent} from 'react';\nimport {type RecordFormElementsValueStandardValue} from '_ui/hooks/useGetRecordForm';\nimport {KitBadge, KitTabs, KitTree} from 'aristid-ds';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {FaLayerGroup, FaSquareRootAlt} from 'react-icons/fa';\nimport styled from 'styled-components';\nimport {type IRecordIdentityWhoAmI} from '_ui/types';\nimport {RecordHistory} from '../../../RecordHistory/RecordHistory';\n\nconst InformationsWrapper = styled.div`\n margin-top: calc(var(--general-spacing-s) * 1px);\n`;\n\nconst StyledDivContentWrapper = styled.div`\n display: flex;\n flex-direction: column;\n height: 100%;\n`;\n\ninterface IValuesSummaryProps {\n record: IRecordIdentityWhoAmI | null;\n attributeId: string;\n globalValues?: Array<RecordFormElementsValueStandardValue['payload']>;\n calculatedValue?: RecordFormElementsValueStandardValue['payload'];\n}\n\nconst calculatedValueKey = '0';\nconst globalValueKey = '1';\n\n// https://stackoverflow.com/questions/822452/strip-html-tags-from-text-using-plain-javascript\nconst stripHtml = (html: string): string => {\n const doc = new DOMParser().parseFromString(html, 'text/html');\n return doc.body.textContent || '';\n};\n\nconst _isDateRangeValue = (value: any): value is {from: string; to: string} =>\n !!value && typeof value === 'object' && 'from' in value && 'to' in value;\n\nexport const ValuesSummary: FunctionComponent<IValuesSummaryProps> = ({\n record,\n attributeId,\n globalValues = [],\n calculatedValue,\n}) => {\n const {t} = useSharedTranslation();\n\n const stringifyValue = (value: RecordFormElementsValueStandardValue['payload']): string => {\n if (typeof value === 'string') {\n return stripHtml(value);\n }\n\n if (typeof value === 'boolean') {\n return value ? t('global.yes') : t('global.no');\n }\n\n if (_isDateRangeValue(value)) {\n return t('record_edition.date_range_value', {\n from: value.from,\n to: value.to,\n interpolation: {\n escapeValue: false,\n },\n });\n }\n\n return value;\n };\n\n const stripedGlobalValues = globalValues.map(stringifyValue);\n const stripedCalculatedValue = stringifyValue(calculatedValue);\n\n return (\n <StyledDivContentWrapper>\n <KitTabs\n items={[\n {\n key: 'version_values',\n label: t('record_summary.values_version'),\n tabContent: (\n <InformationsWrapper>\n <KitTree\n defaultExpandAll\n selectedKeys={\n calculatedValue && globalValues.length === 0\n ? [calculatedValueKey]\n : [globalValueKey]\n }\n treeData={[\n {\n key: calculatedValueKey,\n title: (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n }}\n >\n <span>\n <FaSquareRootAlt /> {t('record_summary.calculated_value')}\n </span>\n <KitBadge\n count={stripedCalculatedValue ? 1 : undefined}\n color=\"primary\"\n />\n </div>\n ),\n children: [\n {\n key: `${calculatedValueKey}-0`,\n title: stripedCalculatedValue ?? (\n <i>{t('record_summary.no_value')}</i>\n ),\n },\n ],\n },\n {\n key: globalValueKey,\n title: (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n }}\n >\n <span>\n <FaLayerGroup /> {t('record_summary.global')}\n </span>\n <KitBadge count={stripedGlobalValues.length} color=\"primary\" />\n </div>\n ),\n children:\n stripedGlobalValues.length > 0\n ? stripedGlobalValues.map((value, index) => ({\n key: `${globalValueKey}-${index}`,\n title: value,\n }))\n : [\n {\n key: `${globalValueKey}-${0}`,\n title: <i>{t('record_summary.no_value')}</i>,\n },\n ],\n },\n ]}\n />\n </InformationsWrapper>\n ),\n },\n {\n key: 'history',\n label: t('record_summary.history'),\n tabContent: <RecordHistory record={record} attributeId={attributeId} />,\n },\n ]}\n />\n </StyledDivContentWrapper>\n );\n};\n\nexport default ValuesSummary;\n"]}
|
|
1
|
+
{"version":3,"file":"ValuesSummary.js","sourceRoot":"","sources":["../../../../../src/components/RecordEdition/EditRecordSidebar/ValuesSummary/ValuesSummary.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AACtD,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AE,KAAC,aAAa,IAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAI;iBAC1E;aACJ,GACH,GACoB,CAC7B,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent} from 'react';\nimport {type RecordFormElementsValueStandardValue} from '_ui/hooks/useGetRecordForm';\nimport {KitBadge, KitTabs, KitTree} from 'aristid-ds';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {FaLayerGroup, FaSquareRootAlt} from 'react-icons/fa';\nimport styled from 'styled-components';\nimport {type IRecordIdentityWhoAmI} from '_ui/types';\nimport {RecordHistory} from '../../../RecordHistory/RecordHistory';\n\nconst InformationsWrapper = styled.div`\n margin-top: calc(var(--general-spacing-s) * 1px);\n`;\n\nconst StyledDivContentWrapper = styled.div`\n display: flex;\n flex-direction: column;\n height: 100%;\n`;\n\ninterface IValuesSummaryProps {\n record: IRecordIdentityWhoAmI | null;\n attributeId: string;\n globalValues?: Array<RecordFormElementsValueStandardValue['payload']>;\n calculatedValues?: Array<RecordFormElementsValueStandardValue['payload']>;\n}\n\nconst calculatedValueKey = '0';\nconst globalValueKey = '1';\n\n// https://stackoverflow.com/questions/822452/strip-html-tags-from-text-using-plain-javascript\nconst stripHtml = (html: string): string => {\n const doc = new DOMParser().parseFromString(html, 'text/html');\n return doc.body.textContent || '';\n};\n\nconst _isDateRangeValue = (value: any): value is {from: string; to: string} =>\n !!value && typeof value === 'object' && 'from' in value && 'to' in value;\n\nexport const ValuesSummary: FunctionComponent<IValuesSummaryProps> = ({\n record,\n attributeId,\n globalValues = [],\n calculatedValues = [],\n}) => {\n const {t} = useSharedTranslation();\n\n const stringifyValue = (value: RecordFormElementsValueStandardValue['payload']): string => {\n if (typeof value === 'string') {\n return stripHtml(value);\n }\n\n if (typeof value === 'boolean') {\n return value ? t('global.yes') : t('global.no');\n }\n\n if (_isDateRangeValue(value)) {\n return t('record_edition.date_range_value', {\n from: value.from,\n to: value.to,\n interpolation: {\n escapeValue: false,\n },\n });\n }\n\n return value;\n };\n\n const stripedGlobalValues = globalValues.map(stringifyValue);\n const stripedCalculatedValues = calculatedValues.map(stringifyValue);\n\n return (\n <StyledDivContentWrapper>\n <KitTabs\n items={[\n {\n key: 'version_values',\n label: t('record_summary.values_version'),\n tabContent: (\n <InformationsWrapper>\n <KitTree\n defaultExpandAll\n selectedKeys={\n calculatedValues.length > 0 && globalValues.length === 0\n ? [calculatedValueKey]\n : [globalValueKey]\n }\n treeData={[\n {\n key: calculatedValueKey,\n title: (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n }}\n >\n <span>\n <FaSquareRootAlt /> {t('record_summary.calculated_value')}\n </span>\n <KitBadge count={stripedCalculatedValues.length} color=\"primary\" />\n </div>\n ),\n children:\n stripedCalculatedValues.length > 0\n ? stripedCalculatedValues.map((calculatedValue, index) => ({\n key: `${calculatedValueKey}-${index}`,\n title: calculatedValue,\n }))\n : [\n {\n key: `${calculatedValueKey}-${0}`,\n title: <i>{t('record_summary.no_value')}</i>,\n },\n ],\n },\n {\n key: globalValueKey,\n title: (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n }}\n >\n <span>\n <FaLayerGroup /> {t('record_summary.global')}\n </span>\n <KitBadge count={stripedGlobalValues.length} color=\"primary\" />\n </div>\n ),\n children:\n stripedGlobalValues.length > 0\n ? stripedGlobalValues.map((value, index) => ({\n key: `${globalValueKey}-${index}`,\n title: value,\n }))\n : [\n {\n key: `${globalValueKey}-${0}`,\n title: <i>{t('record_summary.no_value')}</i>,\n },\n ],\n },\n ]}\n />\n </InformationsWrapper>\n ),\n },\n {\n key: 'history',\n label: t('record_summary.history'),\n tabContent: <RecordHistory record={record} attributeId={attributeId} />,\n },\n ]}\n />\n </StyledDivContentWrapper>\n );\n};\n\nexport default ValuesSummary;\n"]}
|
|
@@ -4,7 +4,7 @@ import { type RecordFormElementsValueLinkValue, type RecordFormElementsValueStan
|
|
|
4
4
|
export interface IRecordPropertyWithAttribute {
|
|
5
5
|
attribute: RecordFormAttributeFragment;
|
|
6
6
|
globalValues?: Array<RecordFormElementsValueStandardValue['payload']>;
|
|
7
|
-
|
|
7
|
+
calculatedValues?: Array<RecordFormElementsValueStandardValue['payload']>;
|
|
8
8
|
}
|
|
9
9
|
export declare const EditRecordSidebarContentTypeMap: {
|
|
10
10
|
readonly SUMMARY: "summary";
|
|
@@ -82,8 +82,9 @@ const editRecordReducer = (state, action) => {
|
|
|
82
82
|
}
|
|
83
83
|
return value?.payload;
|
|
84
84
|
}),
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
calculatedValues: action.values
|
|
86
|
+
?.filter(value => value.isCalculated || value.isInherited)
|
|
87
|
+
.map(calculatedOrInheritedValue => {
|
|
87
88
|
if (TypeGuards.isRecordFormElementsValuesLinkValue(calculatedOrInheritedValue)) {
|
|
88
89
|
return (calculatedOrInheritedValue.linkValue.whoAmI.label ??
|
|
89
90
|
calculatedOrInheritedValue.linkValue.whoAmI.id);
|
|
@@ -93,7 +94,7 @@ const editRecordReducer = (state, action) => {
|
|
|
93
94
|
calculatedOrInheritedValue.treeValue.record.whoAmI.id);
|
|
94
95
|
}
|
|
95
96
|
return calculatedOrInheritedValue?.payload;
|
|
96
|
-
})
|
|
97
|
+
}) ?? [],
|
|
97
98
|
},
|
|
98
99
|
sidebarContent: newSidebarContent,
|
|
99
100
|
};
|