@leav/ui 1.5.0-fd91b119 → 1.5.1-10050692
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/__mocks__/common/attribute.js +1 -0
- package/dist/__mocks__/common/attribute.js.map +1 -1
- package/dist/_gqlTypes/index.d.ts +117 -18
- package/dist/_gqlTypes/index.js +88 -0
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/_queries/attributes/attributeDetailsFragment.js +1 -0
- package/dist/_queries/attributes/attributeDetailsFragment.js.map +1 -1
- package/dist/components/Explorer/DataView.js +4 -3
- package/dist/components/Explorer/DataView.js.map +1 -1
- package/dist/components/Explorer/Explorer.d.ts +1 -1
- package/dist/components/Explorer/Explorer.js +16 -4
- package/dist/components/Explorer/Explorer.js.map +1 -1
- package/dist/components/Explorer/ExplorerFiltersAndSorts.d.ts +1 -0
- package/dist/components/Explorer/ExplorerFiltersAndSorts.js +2 -2
- package/dist/components/Explorer/ExplorerFiltersAndSorts.js.map +1 -1
- package/dist/components/Explorer/ExplorerToolbar.d.ts +1 -0
- package/dist/components/Explorer/ExplorerToolbar.js +2 -2
- package/dist/components/Explorer/ExplorerToolbar.js.map +1 -1
- package/dist/components/Explorer/IdCard.js +2 -2
- package/dist/components/Explorer/IdCard.js.map +1 -1
- 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/edit-attribute/EditAttributeMassActionModal.d.ts +13 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js +20 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.d.ts +10 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js +38 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.d.ts +8 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js +16 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.d.ts +10 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js +28 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.d.ts +5 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js +12 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.d.ts +5 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js +20 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js.map +1 -0
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.d.ts +11 -0
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +106 -0
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -0
- package/dist/components/Explorer/actions-mass/useExportMassAction.js +5 -6
- package/dist/components/Explorer/actions-mass/useExportMassAction.js.map +1 -1
- package/dist/components/Filters/context/filtersReducer.js +0 -1
- package/dist/components/Filters/context/filtersReducer.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/TextAttributeDropDown.js +24 -7
- package/dist/components/Filters/filter-items/filter-type/TextAttributeDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js +15 -17
- package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js.map +1 -1
- package/dist/components/Filters/index.js.map +1 -1
- package/dist/components/Filters/prepareFiltersForRequest.js +1 -1
- package/dist/components/Filters/prepareFiltersForRequest.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.js +10 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeList.js +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeList.js.map +1 -1
- package/dist/components/RecordHistory/RecordHistory.js +11 -6
- package/dist/components/RecordHistory/RecordHistory.js.map +1 -1
- package/dist/components/RecordHistory/RecordHistoryLogEntry.js +13 -7
- package/dist/components/RecordHistory/RecordHistoryLogEntry.js.map +1 -1
- package/dist/components/SelectTreeNode/SelectTreeNodeContent.js +3 -0
- package/dist/components/SelectTreeNode/SelectTreeNodeContent.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/messageHandlers.d.ts +3 -1
- package/dist/hooks/useIFrameMessenger/messageHandlers.js +12 -0
- package/dist/hooks/useIFrameMessenger/messageHandlers.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/schema.d.ts +38 -4
- package/dist/hooks/useIFrameMessenger/schema.js +10 -5
- package/dist/hooks/useIFrameMessenger/schema.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/types.d.ts +18 -3
- package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +2 -0
- package/dist/hooks/useIFrameMessengerClient/iFrameMessengerClientContext.d.ts +2 -0
- package/dist/hooks/useIFrameMessengerClient/useIFrameMessengerClient.d.ts +2 -0
- package/dist/locales/en/shared.json +14 -2
- package/dist/locales/fr/shared.json +14 -2
- package/package.json +5 -5
|
@@ -1,28 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
3
|
+
// This file is released under LGPL V3
|
|
4
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
2
6
|
import styled from 'styled-components';
|
|
3
7
|
import { KitInput, KitSelect } from 'aristid-ds';
|
|
4
8
|
import { AttributeConditionFilter } from '../../../../types';
|
|
5
9
|
import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
|
|
6
10
|
import { useConditionsOptionsByType } from './useConditionOptionsByType';
|
|
11
|
+
import { useDebouncedValue } from '../../../../hooks/useDebouncedValue';
|
|
7
12
|
const InputStyled = styled(KitInput) `
|
|
8
13
|
width: 100%;
|
|
9
14
|
`;
|
|
10
15
|
export const TextAttributeDropDown = ({ filter, onFilterChange, selectDropDownRef, }) => {
|
|
11
16
|
const { t } = useSharedTranslation();
|
|
12
17
|
const { conditionOptionsByType } = useConditionsOptionsByType(filter);
|
|
18
|
+
const [inputValue, setInputValue] = useState(filter.value || '');
|
|
19
|
+
const debouncedInputValue = useDebouncedValue(inputValue, 300);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
setInputValue(filter.value || '');
|
|
22
|
+
}, [filter.value]);
|
|
23
|
+
// Only apply onFilterChange when the input is empty or there are more than 2 characters
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const valueToApply = debouncedInputValue;
|
|
26
|
+
if (valueToApply.length === 0 && filter.value !== null) {
|
|
27
|
+
onFilterChange({ ...filter, value: null });
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (valueToApply.length >= 3 && filter.value !== valueToApply) {
|
|
31
|
+
onFilterChange({ ...filter, value: valueToApply });
|
|
32
|
+
}
|
|
33
|
+
}, [debouncedInputValue, onFilterChange, filter]);
|
|
13
34
|
const _onConditionChanged = condition => {
|
|
14
35
|
onFilterChange({ ...filter, condition });
|
|
15
36
|
};
|
|
16
|
-
// TODO debounce ?
|
|
17
37
|
const _onInputChanged = event => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
onFilterChange({ ...filter, value: event.target.value.length === 0 ? null : event.target.value });
|
|
38
|
+
const newInputValue = event.target.value;
|
|
39
|
+
setInputValue(newInputValue);
|
|
23
40
|
};
|
|
24
41
|
const showSearch = filter.condition !== AttributeConditionFilter.IS_EMPTY &&
|
|
25
42
|
filter.condition !== AttributeConditionFilter.IS_NOT_EMPTY;
|
|
26
|
-
return (_jsxs(_Fragment, { children: [_jsx(KitSelect, { options: conditionOptionsByType, onChange: _onConditionChanged, value: filter.condition, getPopupContainer: () => selectDropDownRef?.current ?? document.body, "aria-label": String(t('explorer.filter-condition')) }), showSearch && (_jsx(InputStyled, { placeholder: String(t('explorer.type-a-value')), value:
|
|
43
|
+
return (_jsxs(_Fragment, { children: [_jsx(KitSelect, { options: conditionOptionsByType, onChange: _onConditionChanged, value: filter.condition, getPopupContainer: () => selectDropDownRef?.current ?? document.body, "aria-label": String(t('explorer.filter-condition')) }), showSearch && (_jsx(InputStyled, { placeholder: String(t('explorer.type-a-value')), value: inputValue, onChange: _onInputChanged }))] }));
|
|
27
44
|
};
|
|
28
45
|
//# sourceMappingURL=TextAttributeDropDown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAttributeDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/TextAttributeDropDown.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TextAttributeDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/TextAttributeDropDown.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAA8C,SAAS,EAAE,QAAQ,EAAC,MAAM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I,YAAY,CAAC,MAAM,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,KAAK,YAAY,EAAE,CAAC;YAC5D,cAAc,CAAC,EAAC,GAAG,MAAM,EAAE,KAAK,EAAE,YAAY,EAAC,CAAC,CAAC;QACrD,CAAC;IACL,CAAC,EAAE,CAAC,mBAAmB,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;IAElD,MAAM,mBAAmB,GAAiD,SAAS,CAAC,EAAE;QAClF,cAAc,CAAC,EAAC,GAAG,MAAM,EAAE,SAAS,EAAC,CAAC,CAAC;IAC3C,CAAC,CAAC;IAEF,MAAM,eAAe,GAAgD,KAAK,CAAC,EAAE;QACzE,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACzC,aAAa,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC,CAAC;IAEF,MAAM,UAAU,GACZ,MAAM,CAAC,SAAS,KAAK,wBAAwB,CAAC,QAAQ;QACtD,MAAM,CAAC,SAAS,KAAK,wBAAwB,CAAC,YAAY,CAAC;IAE/D,OAAO,CACH,8BACI,KAAC,SAAS,IACN,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,mBAAmB,EAC7B,KAAK,EAAE,MAAM,CAAC,SAAS,EACvB,iBAAiB,EAAE,GAAG,EAAE,CAAC,iBAAiB,EAAE,OAAO,IAAI,QAAQ,CAAC,IAAI,gBACxD,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,GACpD,EACD,UAAU,IAAI,CACX,KAAC,WAAW,IACR,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,EAC/C,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,eAAe,GAC3B,CACL,IACF,CACN,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 ComponentProps, type FunctionComponent, useEffect, useState} from 'react';\nimport styled from 'styled-components';\nimport {KitInput, KitSelect} from 'aristid-ds';\nimport {AttributeConditionFilter} from '_ui/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IFilterChildrenDropDownProps} from './_types';\nimport {useConditionsOptionsByType} from './useConditionOptionsByType';\nimport {useDebouncedValue} from '_ui/hooks/useDebouncedValue';\n\nconst InputStyled = styled(KitInput)`\n width: 100%;\n`;\n\nexport const TextAttributeDropDown: FunctionComponent<IFilterChildrenDropDownProps> = ({\n filter,\n onFilterChange,\n selectDropDownRef,\n}) => {\n const {t} = useSharedTranslation();\n\n const {conditionOptionsByType} = useConditionsOptionsByType(filter);\n const [inputValue, setInputValue] = useState(filter.value || '');\n const debouncedInputValue = useDebouncedValue(inputValue, 300);\n\n useEffect(() => {\n setInputValue(filter.value || '');\n }, [filter.value]);\n\n // Only apply onFilterChange when the input is empty or there are more than 2 characters\n useEffect(() => {\n const valueToApply = debouncedInputValue;\n\n if (valueToApply.length === 0 && filter.value !== null) {\n onFilterChange({...filter, value: null});\n return;\n }\n\n if (valueToApply.length >= 3 && filter.value !== valueToApply) {\n onFilterChange({...filter, value: valueToApply});\n }\n }, [debouncedInputValue, onFilterChange, filter]);\n\n const _onConditionChanged: ComponentProps<typeof KitSelect>['onChange'] = condition => {\n onFilterChange({...filter, condition});\n };\n\n const _onInputChanged: ComponentProps<typeof KitInput>['onChange'] = event => {\n const newInputValue = event.target.value;\n setInputValue(newInputValue);\n };\n\n const showSearch =\n filter.condition !== AttributeConditionFilter.IS_EMPTY &&\n filter.condition !== AttributeConditionFilter.IS_NOT_EMPTY;\n\n return (\n <>\n <KitSelect\n options={conditionOptionsByType}\n onChange={_onConditionChanged}\n value={filter.condition}\n getPopupContainer={() => selectDropDownRef?.current ?? document.body}\n aria-label={String(t('explorer.filter-condition'))}\n />\n {showSearch && (\n <InputStyled\n placeholder={String(t('explorer.type-a-value'))}\n value={inputValue}\n onChange={_onInputChanged}\n />\n )}\n </>\n );\n};\n"]}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
3
|
-
// This file is released under LGPL V3
|
|
4
|
-
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
|
-
import { useEffect, useState } from 'react';
|
|
6
2
|
import { KitSelect } from 'aristid-ds';
|
|
7
3
|
import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
|
|
8
4
|
import { AttributeConditionFilter } from '../../../../types';
|
|
@@ -16,24 +12,22 @@ const DivStyled = styled.div `
|
|
|
16
12
|
`;
|
|
17
13
|
export const TreeAttributeDropDown = ({ filter, onFilterChange, selectDropDownRef, }) => {
|
|
18
14
|
const { t } = useSharedTranslation();
|
|
19
|
-
const
|
|
15
|
+
const selectedNodesIds = (filter.nodes ?? []).map(node => node.nodeId);
|
|
20
16
|
const { conditionOptionsByType: availableConditionsOptions } = useConditionsOptionsByType(filter);
|
|
21
17
|
const _handleOnSelect = (node, selected) => {
|
|
18
|
+
let newSelectedIds;
|
|
22
19
|
if (selected) {
|
|
23
|
-
|
|
20
|
+
newSelectedIds = [...selectedNodesIds, node.id];
|
|
24
21
|
}
|
|
25
22
|
else {
|
|
26
|
-
|
|
23
|
+
newSelectedIds = selectedNodesIds.filter(selectedValue => selectedValue !== node.id);
|
|
27
24
|
}
|
|
25
|
+
onFilterChange({
|
|
26
|
+
...filter,
|
|
27
|
+
nodes: newSelectedIds.map(id => ({ nodeId: id, libraryId: node.record.whoAmI.library.id })),
|
|
28
|
+
});
|
|
28
29
|
};
|
|
29
|
-
const _onConditionChanged = condition => {
|
|
30
|
-
onFilterChange({ ...filter, condition });
|
|
31
|
-
};
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (filter.value == null) {
|
|
34
|
-
setSelectedNodesIds([]);
|
|
35
|
-
}
|
|
36
|
-
}, [filter]);
|
|
30
|
+
const _onConditionChanged = condition => onFilterChange({ ...filter, condition });
|
|
37
31
|
const _getRecursiveChildrenRecord = (nodes) => {
|
|
38
32
|
const records = [];
|
|
39
33
|
const collectRecordIdsRecursively = (nodeList) => {
|
|
@@ -57,11 +51,15 @@ export const TreeAttributeDropDown = ({ filter, onFilterChange, selectDropDownRe
|
|
|
57
51
|
.filter(node => !!node.record?.whoAmI?.library?.id)
|
|
58
52
|
.map(node => `${filter.attribute.id}.${node.record?.whoAmI?.library?.id}.id`);
|
|
59
53
|
const _handleOnCheck = (selection) => {
|
|
60
|
-
|
|
54
|
+
const newSelectedNodes = selection.filter(node => !node?.disabled);
|
|
61
55
|
const records = _getRecursiveChildrenRecord(selection);
|
|
62
56
|
const fields = _getRecursiveFieldsFromLibraries(selection);
|
|
63
57
|
onFilterChange({
|
|
64
58
|
...filter,
|
|
59
|
+
nodes: newSelectedNodes.map(node => ({
|
|
60
|
+
nodeId: node.id,
|
|
61
|
+
libraryId: node.record?.whoAmI.library.id ?? records[0]?.whoAmI.library.id ?? '',
|
|
62
|
+
})),
|
|
65
63
|
value: records.map(record => record.id),
|
|
66
64
|
formattedValue: records.map(record => record.whoAmI.label).filter(Boolean),
|
|
67
65
|
condition: filter.condition ?? RecordFilterCondition.EQUAL,
|
|
@@ -70,6 +68,6 @@ export const TreeAttributeDropDown = ({ filter, onFilterChange, selectDropDownRe
|
|
|
70
68
|
};
|
|
71
69
|
const showSearch = filter.condition &&
|
|
72
70
|
![AttributeConditionFilter.IS_EMPTY, AttributeConditionFilter.IS_NOT_EMPTY].includes(filter.condition);
|
|
73
|
-
return (_jsxs(DivStyled, { children: [_jsx(KitSelect, { options: availableConditionsOptions, onChange: _onConditionChanged, value: filter.condition, getPopupContainer: () => selectDropDownRef?.current ?? document.body, "aria-label": String(t('explorer.filter-link-condition')) }), showSearch && (_jsx(SelectTreeNode, { treeId: filter.attribute.linkedTree?.id ?? '', selectedNodes: selectedNodesIds, onSelect: _handleOnSelect, onCheck: _handleOnCheck, multiple: true, canSelectRoot:
|
|
71
|
+
return (_jsxs(DivStyled, { children: [_jsx(KitSelect, { options: availableConditionsOptions, onChange: _onConditionChanged, value: filter.condition, getPopupContainer: () => selectDropDownRef?.current ?? document.body, "aria-label": String(t('explorer.filter-link-condition')) }), showSearch && (_jsx(SelectTreeNode, { treeId: filter.attribute.linkedTree?.id ?? '', selectedNodes: selectedNodesIds, onSelect: _handleOnSelect, onCheck: _handleOnCheck, multiple: true, canSelectRoot: false, checkStrictly: false, checkable: true, loadRecursively: true, noPagination: true }))] }));
|
|
74
72
|
};
|
|
75
73
|
//# sourceMappingURL=TreeAttributeDropDown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeAttributeDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/TreeAttributeDropDown.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TreeAttributeDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/TreeAttributeDropDown.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,wBAAwB,EAAiD,MAAM,WAAW,CAAC;AACnG,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAC,cAAc,EAAC,MAAM,+BAA+B,CAAC;AAC7D,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,0BAA0B,EAAC,MAAM,6BAA6B,CAAC;AAEvE,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAG3B,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAwD,CAAC,EACvF,MAAM,EACN,cAAc,EACd,iBAAiB,GACpB,EAAE,EAAE;IACD,MA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AE,KAAK,EACpB,SAAS,QACT,eAAe,EAAE,IAAI,EACrB,YAAY,EAAE,IAAI,GACpB,CACL,IACO,CACf,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 ComponentProps, type FunctionComponent, useEffect, useState} from 'react';\nimport {KitSelect} from 'aristid-ds';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {AttributeConditionFilter, type IRecordIdentity, type ITreeNodeWithRecord} from '_ui/types';\nimport {RecordFilterCondition} from '_ui/_gqlTypes';\nimport {type IFilterChildrenTreeDropDownProps} from './_types';\nimport {SelectTreeNode} from '_ui/components/SelectTreeNode';\nimport styled from 'styled-components';\nimport {useConditionsOptionsByType} from './useConditionOptionsByType';\n\nconst DivStyled = styled.div`\n max-height: 30rem;\n overflow: auto;\n`;\n\nexport const TreeAttributeDropDown: FunctionComponent<IFilterChildrenTreeDropDownProps> = ({\n filter,\n onFilterChange,\n selectDropDownRef,\n}) => {\n const {t} = useSharedTranslation();\n\n const selectedNodesIds = (filter.nodes ?? []).map(node => node.nodeId);\n\n const {conditionOptionsByType: availableConditionsOptions} = useConditionsOptionsByType(filter);\n\n const _handleOnSelect = (node: ITreeNodeWithRecord, selected: boolean) => {\n let newSelectedIds: string[];\n if (selected) {\n newSelectedIds = [...selectedNodesIds, node.id];\n } else {\n newSelectedIds = selectedNodesIds.filter(selectedValue => selectedValue !== node.id);\n }\n onFilterChange({\n ...filter,\n nodes: newSelectedIds.map(id => ({nodeId: id, libraryId: node.record.whoAmI.library.id})),\n });\n };\n\n const _onConditionChanged: ComponentProps<typeof KitSelect>['onChange'] = condition =>\n onFilterChange({...filter, condition});\n\n const _getRecursiveChildrenRecord = (nodes: ITreeNodeWithRecord[]): IRecordIdentity[] => {\n const records: IRecordIdentity[] = [];\n const collectRecordIdsRecursively = (nodeList: ITreeNodeWithRecord[]) => {\n for (const node of nodeList) {\n if (node.id === filter.attribute.linkedTree?.id) {\n continue;\n }\n if (node.record) {\n records.push(node.record);\n }\n if (node.children && node.children.length > 0) {\n collectRecordIdsRecursively(node.children);\n }\n }\n };\n collectRecordIdsRecursively(nodes);\n // Delete duplicates\n return Array.from(new Set(records));\n };\n const _getRecursiveFieldsFromLibraries = (nodes: ITreeNodeWithRecord[]): string[] =>\n nodes\n .filter(node => !!node.record?.whoAmI?.library?.id)\n .map(node => `${filter.attribute.id}.${node.record?.whoAmI?.library?.id}.id`);\n\n const _handleOnCheck = (selection: ITreeNodeWithRecord[]) => {\n const newSelectedNodes = selection.filter(node => !node?.disabled);\n\n const records = _getRecursiveChildrenRecord(selection);\n const fields = _getRecursiveFieldsFromLibraries(selection);\n\n onFilterChange({\n ...filter,\n nodes: newSelectedNodes.map(node => ({\n nodeId: node.id,\n libraryId: node.record?.whoAmI.library.id ?? records[0]?.whoAmI.library.id ?? '',\n })),\n value: records.map(record => record.id),\n formattedValue: records.map(record => record.whoAmI.label).filter(Boolean),\n condition: filter.condition ?? RecordFilterCondition.EQUAL,\n field: fields,\n });\n };\n\n const showSearch =\n filter.condition &&\n ![AttributeConditionFilter.IS_EMPTY, AttributeConditionFilter.IS_NOT_EMPTY].includes(filter.condition);\n\n return (\n <DivStyled>\n <KitSelect\n options={availableConditionsOptions}\n onChange={_onConditionChanged}\n value={filter.condition}\n getPopupContainer={() => selectDropDownRef?.current ?? document.body}\n aria-label={String(t('explorer.filter-link-condition'))}\n />\n {showSearch && (\n <SelectTreeNode\n treeId={filter.attribute.linkedTree?.id ?? ''}\n selectedNodes={selectedNodesIds}\n onSelect={_handleOnSelect}\n onCheck={_handleOnCheck}\n multiple\n canSelectRoot={false}\n checkStrictly={false}\n checkable\n loadRecursively={true}\n noPagination={true}\n />\n )}\n </DivStyled>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Filters/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Filters/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AACjE,cAAc,UAAU,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\nexport {useFilters} from './useFilters';\nexport {useFiltersContext} from './useFiltersContext';\nexport {useTransformFilters} from './useTransformFilters';\nexport {FiltersProvider} from './FiltersProvider';\nexport {prepareFiltersForRequest} from './prepareFiltersForRequest';\nexport {useFiltersReducer} from './context/useFiltersReducer';\nexport {CommonFilterItem} from './filter-items/CommonFilterItem';\nexport * from './_types';\n"]}
|
|
@@ -85,7 +85,7 @@ const _generateConditionsFromMultipleValues = (filter) => {
|
|
|
85
85
|
filtersWithOperators.push({
|
|
86
86
|
value: recordId,
|
|
87
87
|
condition: filter.condition,
|
|
88
|
-
field: `${filter.attribute.id}.${filter.nodes[
|
|
88
|
+
field: `${filter.attribute.id}.${filter.nodes[0].libraryId}.id`,
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareFiltersForRequest.js","sourceRoot":"","sources":["../../../src/components/Filters/pr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AC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK;wBACnE,SAAS,EAAE,MAAM,CAAC,SAAS;wBAC3B,KAAK,EAAE,IAAI;qBACd;iBACJ,CAAC;YACN,CAAC;YACD,OAAO,qCAAqC,CAAC,MAA4C,CAAC,CAAC;QAC/F,CAAC;QAED,IAAI,kBAAkB,CAAC,MAAkB,CAAC,EAAE,CAAC;YACzC,QAAQ,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;gBAC9B,KAAK,eAAe,CAAC,IAAI;oBACrB,OAAO,sBAAsB,CAAC,MAA2B,CAAC,CAAC;gBAC/D,KAAK,eAAe,CAAC,OAAO;oBACxB,OAAO,yBAAyB,CAAC,MAA2B,CAAC,CAAC;gBAClE;oBACI,MAAM;YACd,CAAC;QACL,CAAC;QACD,OAAO;YACH;gBACI,KAAK,EAAE,MAAM,CAAC,KAAe;gBAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;aACtB;SACJ,CAAC;IACN,CAAC,CAAC,CACT,CAAC;IAEF,OAAO;QACH,GAAG,gBAAgB;QACnB,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAE,oBAAoB,CAAC,GAAG,EAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5F,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9D,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 dayjs from 'dayjs';\nimport {AttributeFormat, RecordFilterCondition, type RecordFilterInput, RecordFilterOperator} from '_ui/_gqlTypes';\nimport {interleaveElement} from '_ui/_utils/interleaveElement';\nimport {AttributeConditionFilter} from '_ui/types';\nimport {\n type UIFilter,\n type IUIFilterStandard,\n type IUIFilterTree,\n isUIFilterStandard,\n isUIFilterThrough,\n isUIFilterTree,\n isUIFilterValueList,\n type IUIFilterValueList,\n type FiltersOperator,\n isUIFilterLinkWithValueList,\n} from './_types';\nimport {nullValueConditions} from './conditionsHelper';\n\nexport const dateValuesSeparator = '\\n';\n\nconst _getDateAtNoon = (date: number): string => dayjs.unix(Number(date)).add(12, 'hour').unix().toString();\n\nconst _getDateRequestFilters = ({field, condition, value}: IUIFilterStandard): RecordFilterInput[] => {\n switch (condition) {\n case RecordFilterCondition.BETWEEN:\n const [from, to] = value!.split(dateValuesSeparator);\n return [\n {\n field,\n condition,\n value: JSON.stringify({\n from,\n to,\n }),\n },\n ];\n case RecordFilterCondition.NOT_EQUAL:\n return [\n {\n field,\n condition: RecordFilterCondition.NOT_EQUAL,\n value: _getDateAtNoon(Number(value)),\n },\n ];\n case RecordFilterCondition.EQUAL:\n return [\n {\n field,\n condition,\n value: _getDateAtNoon(Number(value)),\n },\n ];\n default:\n return [\n {\n field,\n condition,\n value,\n },\n ];\n }\n};\n\nconst _getBooleanRequestFilters = (filter: IUIFilterStandard): RecordFilterInput[] => {\n if (filter.value === 'false') {\n return [\n {\n field: filter.field,\n condition: AttributeConditionFilter.NOT_EQUAL,\n value: 'true',\n },\n ];\n }\n\n return [{field: filter.field, condition: filter.condition, value: filter.value}];\n};\n\nconst _addValuesListForFilters = (valuesList: string[]): RecordFilterInput[] => [\n {operator: RecordFilterOperator.OPEN_BRACKET},\n ...(interleaveElement(\n {operator: RecordFilterOperator.OR},\n valuesList.map(value => [\n {\n field: 'id',\n condition: AttributeConditionFilter.EQUAL,\n value,\n },\n ]),\n ) as RecordFilterInput[]),\n {operator: RecordFilterOperator.CLOSE_BRACKET},\n];\n\nconst _generateConditionsFromMultipleValues = (filter: IUIFilterTree | IUIFilterValueList): RecordFilterInput[] => {\n if (!filter.value || filter.value.length === 0) {\n return [];\n }\n const filtersWithOperators: RecordFilterInput[] = [];\n filter.value.forEach((recordId, idx) => {\n if (idx === 0 && filter.value && filter.value.length > 1) {\n filtersWithOperators.push({operator: RecordFilterOperator.OPEN_BRACKET});\n }\n if (isUIFilterTree(filter) && filter.nodes && filter.nodes.length > 0) {\n filtersWithOperators.push({\n value: recordId,\n condition: filter.condition,\n field: `${filter.attribute.id}.${filter.nodes[idx].libraryId}.id`,\n });\n } else {\n filtersWithOperators.push({\n value: recordId,\n condition: filter.condition,\n field: Array.isArray(filter.field) ? filter.field[idx] : filter.field,\n });\n }\n if (filter.value && idx < filter.value.length - 1) {\n filtersWithOperators.push({\n operator:\n filter.condition === RecordFilterCondition.NOT_EQUAL\n ? RecordFilterOperator.AND\n : RecordFilterOperator.OR,\n });\n }\n if (filter.value && filter.value.length > 1 && idx >= filter.value.length - 1) {\n filtersWithOperators.push({operator: RecordFilterOperator.CLOSE_BRACKET});\n }\n });\n return filtersWithOperators;\n};\n\nexport const prepareFiltersForRequest = (\n filters: UIFilter[],\n filtersOperator?: FiltersOperator,\n valuesList?: string[],\n): RecordFilterInput[] => {\n const interleaveFilter = interleaveElement(\n {operator: filtersOperator === 'OR' ? RecordFilterOperator.OR : RecordFilterOperator.AND},\n filters\n .filter(filter => {\n if (isUIFilterThrough(filter)) {\n return (\n filter.subField &&\n filter.subCondition &&\n (filter.value !== null || nullValueConditions.includes(filter.subCondition))\n );\n }\n\n if (isUIFilterValueList(filter)) {\n return (\n (!!filter.condition && filter.value?.length) ||\n (filter.condition && nullValueConditions.includes(filter.condition))\n );\n }\n\n return filter.value !== null || (filter.condition && nullValueConditions.includes(filter.condition));\n })\n .map(filter => {\n if (isUIFilterTree(filter)) {\n return filter;\n }\n const condition =\n filter.condition === AttributeConditionFilter.THROUGH ? filter.subCondition : filter.condition;\n let field =\n filter.condition === AttributeConditionFilter.THROUGH\n ? `${filter.field}.${filter.subField}`\n : filter.field;\n\n // When a link attribute has a values list, we must filter on the linked record id\n if (isUIFilterLinkWithValueList(filter) && typeof field === 'string' && !field.endsWith('.id')) {\n field = `${field}.id`;\n }\n\n return {...filter, condition, field};\n })\n .map(filter => {\n //@ts-ignore typscript does not recognize filter as a UIFilter\n if (isUIFilterValueList(filter) || isUIFilterTree(filter)) {\n if (filter.condition && nullValueConditions.includes(filter.condition)) {\n return [\n {\n field: Array.isArray(filter.field) ? filter.field[0] : filter.field,\n condition: filter.condition,\n value: null,\n },\n ];\n }\n return _generateConditionsFromMultipleValues(filter as IUIFilterTree | IUIFilterValueList);\n }\n\n if (isUIFilterStandard(filter as UIFilter)) {\n switch (filter.attribute.format) {\n case AttributeFormat.date:\n return _getDateRequestFilters(filter as IUIFilterStandard);\n case AttributeFormat.boolean:\n return _getBooleanRequestFilters(filter as IUIFilterStandard);\n default:\n break;\n }\n }\n return [\n {\n field: filter.field as string,\n condition: filter.condition,\n value: filter.value,\n },\n ];\n }),\n );\n\n return [\n ...interleaveFilter,\n ...(interleaveFilter.length > 0 && valuesList ? [{operator: RecordFilterOperator.AND}] : []),\n ...(valuesList ? _addValuesListForFilters(valuesList) : []),\n ];\n};\n"]}
|
|
1
|
+
{"version":3,"file":"prepareFiltersForRequest.js","sourceRoot":"","sources":["../../../src/components/Filters/prepareFiltersForRequest.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,eAAe,EAAE,qBAAqB,EAA0B,oBAAoB,EAAC,MAAM,eAAe,CAAC;AACnH,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AACnD,OAAO,EAIH,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EAGnB,2BAA2B,GAC9B,MAAM,UAAU,CAAC;AA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,CAAC,MAA2B,CAAC,CAAC;gBAC/D,KAAK,eAAe,CAAC,OAAO;oBACxB,OAAO,yBAAyB,CAAC,MAA2B,CAAC,CAAC;gBAClE;oBACI,MAAM;YACd,CAAC;QACL,CAAC;QACD,OAAO;YACH;gBACI,KAAK,EAAE,MAAM,CAAC,KAAe;gBAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;aACtB;SACJ,CAAC;IACN,CAAC,CAAC,CACT,CAAC;IAEF,OAAO;QACH,GAAG,gBAAgB;QACnB,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAE,oBAAoB,CAAC,GAAG,EAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5F,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9D,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 dayjs from 'dayjs';\nimport {AttributeFormat, RecordFilterCondition, type RecordFilterInput, RecordFilterOperator} from '_ui/_gqlTypes';\nimport {interleaveElement} from '_ui/_utils/interleaveElement';\nimport {AttributeConditionFilter} from '_ui/types';\nimport {\n type UIFilter,\n type IUIFilterStandard,\n type IUIFilterTree,\n isUIFilterStandard,\n isUIFilterThrough,\n isUIFilterTree,\n isUIFilterValueList,\n type IUIFilterValueList,\n type FiltersOperator,\n isUIFilterLinkWithValueList,\n} from './_types';\nimport {nullValueConditions} from './conditionsHelper';\n\nexport const dateValuesSeparator = '\\n';\n\nconst _getDateAtNoon = (date: number): string => dayjs.unix(Number(date)).add(12, 'hour').unix().toString();\n\nconst _getDateRequestFilters = ({field, condition, value}: IUIFilterStandard): RecordFilterInput[] => {\n switch (condition) {\n case RecordFilterCondition.BETWEEN:\n const [from, to] = value!.split(dateValuesSeparator);\n return [\n {\n field,\n condition,\n value: JSON.stringify({\n from,\n to,\n }),\n },\n ];\n case RecordFilterCondition.NOT_EQUAL:\n return [\n {\n field,\n condition: RecordFilterCondition.NOT_EQUAL,\n value: _getDateAtNoon(Number(value)),\n },\n ];\n case RecordFilterCondition.EQUAL:\n return [\n {\n field,\n condition,\n value: _getDateAtNoon(Number(value)),\n },\n ];\n default:\n return [\n {\n field,\n condition,\n value,\n },\n ];\n }\n};\n\nconst _getBooleanRequestFilters = (filter: IUIFilterStandard): RecordFilterInput[] => {\n if (filter.value === 'false') {\n return [\n {\n field: filter.field,\n condition: AttributeConditionFilter.NOT_EQUAL,\n value: 'true',\n },\n ];\n }\n\n return [{field: filter.field, condition: filter.condition, value: filter.value}];\n};\n\nconst _addValuesListForFilters = (valuesList: string[]): RecordFilterInput[] => [\n {operator: RecordFilterOperator.OPEN_BRACKET},\n ...(interleaveElement(\n {operator: RecordFilterOperator.OR},\n valuesList.map(value => [\n {\n field: 'id',\n condition: AttributeConditionFilter.EQUAL,\n value,\n },\n ]),\n ) as RecordFilterInput[]),\n {operator: RecordFilterOperator.CLOSE_BRACKET},\n];\n\nconst _generateConditionsFromMultipleValues = (filter: IUIFilterTree | IUIFilterValueList): RecordFilterInput[] => {\n if (!filter.value || filter.value.length === 0) {\n return [];\n }\n const filtersWithOperators: RecordFilterInput[] = [];\n filter.value.forEach((recordId, idx) => {\n if (idx === 0 && filter.value && filter.value.length > 1) {\n filtersWithOperators.push({operator: RecordFilterOperator.OPEN_BRACKET});\n }\n if (isUIFilterTree(filter) && filter.nodes && filter.nodes.length > 0) {\n filtersWithOperators.push({\n value: recordId,\n condition: filter.condition,\n field: `${filter.attribute.id}.${filter.nodes[0].libraryId}.id`,\n });\n } else {\n filtersWithOperators.push({\n value: recordId,\n condition: filter.condition,\n field: Array.isArray(filter.field) ? filter.field[idx] : filter.field,\n });\n }\n if (filter.value && idx < filter.value.length - 1) {\n filtersWithOperators.push({\n operator:\n filter.condition === RecordFilterCondition.NOT_EQUAL\n ? RecordFilterOperator.AND\n : RecordFilterOperator.OR,\n });\n }\n if (filter.value && filter.value.length > 1 && idx >= filter.value.length - 1) {\n filtersWithOperators.push({operator: RecordFilterOperator.CLOSE_BRACKET});\n }\n });\n return filtersWithOperators;\n};\n\nexport const prepareFiltersForRequest = (\n filters: UIFilter[],\n filtersOperator?: FiltersOperator,\n valuesList?: string[],\n): RecordFilterInput[] => {\n const interleaveFilter = interleaveElement(\n {operator: filtersOperator === 'OR' ? RecordFilterOperator.OR : RecordFilterOperator.AND},\n filters\n .filter(filter => {\n if (isUIFilterThrough(filter)) {\n return (\n filter.subField &&\n filter.subCondition &&\n (filter.value !== null || nullValueConditions.includes(filter.subCondition))\n );\n }\n\n if (isUIFilterValueList(filter)) {\n return (\n (!!filter.condition && filter.value?.length) ||\n (filter.condition && nullValueConditions.includes(filter.condition))\n );\n }\n\n return filter.value !== null || (filter.condition && nullValueConditions.includes(filter.condition));\n })\n .map(filter => {\n if (isUIFilterTree(filter)) {\n return filter;\n }\n const condition =\n filter.condition === AttributeConditionFilter.THROUGH ? filter.subCondition : filter.condition;\n let field =\n filter.condition === AttributeConditionFilter.THROUGH\n ? `${filter.field}.${filter.subField}`\n : filter.field;\n\n // When a link attribute has a values list, we must filter on the linked record id\n if (isUIFilterLinkWithValueList(filter) && typeof field === 'string' && !field.endsWith('.id')) {\n field = `${field}.id`;\n }\n\n return {...filter, condition, field};\n })\n .map(filter => {\n //@ts-ignore typscript does not recognize filter as a UIFilter\n if (isUIFilterValueList(filter) || isUIFilterTree(filter)) {\n if (filter.condition && nullValueConditions.includes(filter.condition)) {\n return [\n {\n field: Array.isArray(filter.field) ? filter.field[0] : filter.field,\n condition: filter.condition,\n value: null,\n },\n ];\n }\n return _generateConditionsFromMultipleValues(filter as IUIFilterTree | IUIFilterValueList);\n }\n\n if (isUIFilterStandard(filter as UIFilter)) {\n switch (filter.attribute.format) {\n case AttributeFormat.date:\n return _getDateRequestFilters(filter as IUIFilterStandard);\n case AttributeFormat.boolean:\n return _getBooleanRequestFilters(filter as IUIFilterStandard);\n default:\n break;\n }\n }\n return [\n {\n field: filter.field as string,\n condition: filter.condition,\n value: filter.value,\n },\n ];\n }),\n );\n\n return [\n ...interleaveFilter,\n ...(interleaveFilter.length > 0 && valuesList ? [{operator: RecordFilterOperator.AND}] : []),\n ...(valuesList ? _addValuesListForFilters(valuesList) : []),\n ];\n};\n"]}
|
|
@@ -7,7 +7,15 @@ import { Form } from 'antd';
|
|
|
7
7
|
import { KitRichText } from 'aristid-ds';
|
|
8
8
|
import { useSharedTranslation } from '../../../../../../hooks/useSharedTranslation';
|
|
9
9
|
import { EMPTY_INITIAL_VALUE_STRING } from '../../../antdUtils';
|
|
10
|
-
const
|
|
10
|
+
const LEADING_EMPTY_P_TAG = /^<p>(\s| )*<\/p>/;
|
|
11
|
+
const TRAILING_EMPTY_P_TAG = /(<p>(\s| )*<\/p>)+$/;
|
|
12
|
+
const cleanRichTextValue = (value) => {
|
|
13
|
+
if (!value) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const cleanedValue = value.replace(LEADING_EMPTY_P_TAG, '').replace(TRAILING_EMPTY_P_TAG, '').trim();
|
|
17
|
+
return cleanedValue === '' ? null : cleanedValue;
|
|
18
|
+
};
|
|
11
19
|
export const DSRichTextWrapper = ({ value, presentationValue, isLastValueOfMultivalues, removeLastValueOfMultivalues, onChange, attribute, readonly, handleSubmit, calculatedFlags, inheritedFlags, }) => {
|
|
12
20
|
if (!onChange) {
|
|
13
21
|
throw Error('DSRichTextWrapper should be used inside a antd Form.Item');
|
|
@@ -35,7 +43,7 @@ export const DSRichTextWrapper = ({ value, presentationValue, isLastValueOfMulti
|
|
|
35
43
|
};
|
|
36
44
|
const _handleOnBlur = async (inputValue) => {
|
|
37
45
|
setHasChanged(false);
|
|
38
|
-
const valueToSubmit =
|
|
46
|
+
const valueToSubmit = cleanRichTextValue(inputValue);
|
|
39
47
|
if (!hasChanged) {
|
|
40
48
|
onChange(valueToSubmit);
|
|
41
49
|
setIsFocused(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DSRichTextWrapper.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,0BAA0B,EAAC,MAAM,oBAAoB,CAAC;AAE9D,MAAM,YAAY,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"DSRichTextWrapper.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,0BAA0B,EAAC,MAAM,oBAAoB,CAAC;AAE9D,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AACpD,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AAExD,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,EAAE;IACzC,I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AAC,CAAC;QACpB,QAAQ,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,OAAO,CACH,KAAC,WAAW,IACR,EAAE,EAAE,SAAS,CAAC,EAAE,EAChB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAChD,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACtC,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,CAAC,CAAC,yCAAyC,CAAC,EACzD,SAAS,EAAE,SAAS,CAAC,eAAe,IAAI,SAAS,EACjD,SAAS,SACX,CACL,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, useState} from 'react';\nimport {Form} from 'antd';\nimport {KitRichText} from 'aristid-ds';\nimport {type IStandFieldValueContentProps} from './_types';\nimport {type KitRichTextProps} from 'aristid-ds/dist/Kit/DataEntry/RichText/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {EMPTY_INITIAL_VALUE_STRING} from '../../../antdUtils';\n\nconst LEADING_EMPTY_P_TAG = /^<p>(\\s| )*<\\/p>/;\nconst TRAILING_EMPTY_P_TAG = /(<p>(\\s| )*<\\/p>)+$/;\n\nconst cleanRichTextValue = (value: string) => {\n if (!value) {\n return null;\n }\n const cleanedValue = value.replace(LEADING_EMPTY_P_TAG, '').replace(TRAILING_EMPTY_P_TAG, '').trim();\n\n return cleanedValue === '' ? null : cleanedValue;\n};\n\nexport const DSRichTextWrapper: FunctionComponent<IStandFieldValueContentProps<KitRichTextProps>> = ({\n value,\n presentationValue,\n isLastValueOfMultivalues,\n removeLastValueOfMultivalues,\n onChange,\n attribute,\n readonly,\n handleSubmit,\n calculatedFlags,\n inheritedFlags,\n}) => {\n if (!onChange) {\n throw Error('DSRichTextWrapper should be used inside a antd Form.Item');\n }\n\n const isNewValueOfMultivalues = isLastValueOfMultivalues && value === EMPTY_INITIAL_VALUE_STRING;\n const focusedDefaultValue = attribute.multiple_values ? isNewValueOfMultivalues : false;\n\n const [hasChanged, setHasChanged] = useState(false);\n const [isFocused, setIsFocused] = useState(focusedDefaultValue);\n const {errors} = Form.Item.useStatus();\n const {t} = useSharedTranslation();\n\n const isErrors = errors.length > 0;\n const valueToDisplay = isFocused || isErrors || !presentationValue ? value : presentationValue;\n\n const _resetToInheritedOrCalculatedValue = async () => {\n setHasChanged(false);\n if (inheritedFlags.isInheritedValue) {\n onChange(inheritedFlags.inheritedValue.raw_payload);\n } else if (calculatedFlags.isCalculatedValue) {\n onChange(calculatedFlags.calculatedValue.raw_payload);\n }\n await handleSubmit(null, attribute.id);\n };\n\n const _handleFocus = () => {\n setIsFocused(true);\n };\n\n const _handleOnBlur = async (inputValue: string) => {\n setHasChanged(false);\n const valueToSubmit = cleanRichTextValue(inputValue);\n if (!hasChanged) {\n onChange(valueToSubmit);\n setIsFocused(false);\n\n if (isNewValueOfMultivalues) {\n removeLastValueOfMultivalues();\n }\n return;\n }\n\n if (valueToSubmit === null && (inheritedFlags.isInheritedValue || calculatedFlags.isCalculatedValue)) {\n _resetToInheritedOrCalculatedValue();\n return;\n }\n\n onChange(valueToSubmit);\n await handleSubmit(valueToSubmit, attribute.id);\n setIsFocused(false);\n };\n\n const _handleOnChange = inputValue => {\n setHasChanged(true);\n onChange(inputValue);\n };\n\n return (\n <KitRichText\n id={attribute.id}\n autoFocus={isFocused}\n helper={isErrors ? String(errors[0]) : undefined}\n status={isErrors ? 'error' : undefined}\n value={valueToDisplay}\n readonly={readonly}\n onChange={_handleOnChange}\n onFocus={_handleFocus}\n onBlur={_handleOnBlur}\n placeholder={t('record_edition.placeholder.enter_a_text')}\n maxLength={attribute.character_limit ?? undefined}\n showCount\n />\n );\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import TreeNodeItem from './TreeNodeItem';
|
|
3
3
|
import { TreeFieldWrapper } from './TreeFieldWrapper';
|
|
4
|
-
export const TreeNodeList = ({ attribute, backendValues, removeTreeNode, isReadOnly, }) => (_jsx(TreeFieldWrapper, { children: backendValues.map((value, index) => (_jsx(TreeNodeItem, { isReadOnly: isReadOnly, color: value.treeValue
|
|
4
|
+
export const TreeNodeList = ({ attribute, backendValues, removeTreeNode, isReadOnly, }) => (_jsx(TreeFieldWrapper, { children: backendValues.map((value, index) => (_jsx(TreeNodeItem, { isReadOnly: isReadOnly, color: value.treeValue?.record.whoAmI.color, label: value.treeValue?.record.whoAmI.label, ancestors: value.treeValue?.ancestors, canDelete: !isReadOnly &&
|
|
5
5
|
((attribute.required && attribute.multiple_values && backendValues.length > 1) ||
|
|
6
6
|
!attribute.required), onClickToDelete: () => removeTreeNode(value) }, index))) }));
|
|
7
7
|
//# sourceMappingURL=TreeNodeList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeList.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeList.tsx"],"names":[],"mappings":";AAMA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AASpD,MAAM,CAAC,MAAM,YAAY,GAA6C,CAAC,EACnE,SAAS,EACT,aAAa,EACb,cAAc,EACd,UAAU,GACb,EAAE,EAAE,CAAC,CACF,KAAC,gBAAgB,cACZ,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CACjC,KAAC,YAAY,IAET,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,KAAK,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"TreeNodeList.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeList.tsx"],"names":[],"mappings":";AAMA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AASpD,MAAM,CAAC,MAAM,YAAY,GAA6C,CAAC,EACnE,SAAS,EACT,aAAa,EACb,cAAc,EACd,UAAU,GACb,EAAE,EAAE,CAAC,CACF,KAAC,gBAAgB,cACZ,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CACjC,KAAC,YAAY,IAET,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAC3C,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAC3C,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,SAAS,EACrC,SAAS,EACL,CAAC,UAAU;YACX,CAAC,CAAC,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,eAAe,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;gBAC1E,CAAC,SAAS,CAAC,QAAQ,CAAC,EAE5B,eAAe,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,IAVvC,KAAK,CAWZ,CACL,CAAC,GACa,CACtB,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 RecordFormElementsValueTreeValue} from '_ui/hooks/useGetRecordForm';\nimport {type RecordFormAttributeTreeAttributeFragment} from '_ui/_gqlTypes';\nimport TreeNodeItem from './TreeNodeItem';\nimport {TreeFieldWrapper} from './TreeFieldWrapper';\n\ninterface IDisplayTreeNodeProps {\n attribute: RecordFormAttributeTreeAttributeFragment;\n backendValues: RecordFormElementsValueTreeValue[];\n removeTreeNode: (nodeValue: RecordFormElementsValueTreeValue) => void;\n isReadOnly: boolean;\n}\n\nexport const TreeNodeList: FunctionComponent<IDisplayTreeNodeProps> = ({\n attribute,\n backendValues,\n removeTreeNode,\n isReadOnly,\n}) => (\n <TreeFieldWrapper>\n {backendValues.map((value, index) => (\n <TreeNodeItem\n key={index}\n isReadOnly={isReadOnly}\n color={value.treeValue?.record.whoAmI.color}\n label={value.treeValue?.record.whoAmI.label}\n ancestors={value.treeValue?.ancestors}\n canDelete={\n !isReadOnly &&\n ((attribute.required && attribute.multiple_values && backendValues.length > 1) ||\n !attribute.required)\n }\n onClickToDelete={() => removeTreeNode(value)}\n />\n ))}\n </TreeFieldWrapper>\n);\n"]}
|
|
@@ -13,13 +13,16 @@ import { useFetchRecordHistory } from './hooks/useFetchRecordHistory';
|
|
|
13
13
|
import { RecordHistoryGoUpButton } from './RecordHistoryGoUpButton';
|
|
14
14
|
import { RecordHistoryLogEntry } from './RecordHistoryLogEntry';
|
|
15
15
|
const StyledDivContentWrapper = styled.div `
|
|
16
|
-
margin-top: calc(var(--general-spacing-
|
|
16
|
+
margin-top: calc(var(--general-spacing-xs) * 1px);
|
|
17
17
|
flex: 1 1 0;
|
|
18
18
|
overflow-y: auto;
|
|
19
19
|
`;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
// TODO: This component should be moved to /apps/app-studio/src/modules/information-and-history/record-history/ when he will no longer be used by RecordSummary and ValuesSummary (those components will be removed in the future)
|
|
21
|
+
// Also when component will be moved
|
|
22
|
+
// - put together translations with information_and_history
|
|
23
|
+
// - remove usage of styled-components
|
|
24
|
+
// - instead of a record we could receive a recordId and a libraryId directly
|
|
25
|
+
// - remove styling of StyledDivContentWrapper that will no longer be necessary
|
|
23
26
|
export const RecordHistory = ({ record, attributeId }) => {
|
|
24
27
|
const { t } = useSharedTranslation();
|
|
25
28
|
const [showAllHistory, setShowAllHistory] = useState(false);
|
|
@@ -31,17 +34,19 @@ export const RecordHistory = ({ record, attributeId }) => {
|
|
|
31
34
|
attributeId,
|
|
32
35
|
});
|
|
33
36
|
if (loading && logs.length === 0) {
|
|
37
|
+
// TODO: Add a better loading state
|
|
34
38
|
return _jsx(Loading, {});
|
|
35
39
|
}
|
|
36
40
|
if (inError) {
|
|
41
|
+
//TODO: Add a better error state
|
|
37
42
|
return _jsx(ErrorDisplay, { message: t('record_history.error_fetching') });
|
|
38
43
|
}
|
|
39
44
|
if (logs.length === 0) {
|
|
40
45
|
return (_jsx(StyledDivContentWrapper, { children: _jsx(KitTypography.Text, { children: t('record_history.empty_history') }) }));
|
|
41
46
|
}
|
|
42
|
-
return (_jsx(StyledDivContentWrapper, { children: _jsx(RecordHistoryGoUpButton, { children: _jsxs(KitSpace, { size: "s", direction: "vertical", children: [total > 1 && (_jsx(
|
|
47
|
+
return (_jsx(StyledDivContentWrapper, { children: _jsx(RecordHistoryGoUpButton, { children: _jsxs(KitSpace, { size: "s", direction: "vertical", children: [showAllHistory && (_jsxs(_Fragment, { children: [logs.map((logEntry, index) => (_jsx(RecordHistoryLogEntry, { index: index, logEntry: logEntry }, index))), _jsx(ShowMore, { hasMore: hasMore, fetchMore: fetchMore })] })), !showAllHistory && _jsx(RecordHistoryLogEntry, { index: 0, logEntry: logs[0] }, 0), total > 1 && (_jsx(KitButton, { type: "secondary", size: "s", onClick: () => setShowAllHistory(!showAllHistory), children: showAllHistory
|
|
43
48
|
? t('record_history.hide_history', { total })
|
|
44
|
-
: t('record_history.show_history', { total }) }))
|
|
49
|
+
: t('record_history.show_history', { total }) }))] }) }) }));
|
|
45
50
|
};
|
|
46
51
|
export default RecordHistory;
|
|
47
52
|
//# sourceMappingURL=RecordHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordHistory.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistory.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAyB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAO9D,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAIzC,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"RecordHistory.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistory.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAyB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OA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A8B,CAAC,GAAsB,GACtD,CAC7B,CAAC;IACN,CAAC;IAED,OAAO,CACH,KAAC,uBAAuB,cACpB,KAAC,uBAAuB,cACpB,MAAC,QAAQ,IAAC,IAAI,EAAC,GAAG,EAAC,SAAS,EAAC,UAAU,aAClC,cAAc,IAAI,CACf,8BACK,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,CAC3B,KAAC,qBAAqB,IAAa,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,IAAvC,KAAK,CAAsC,CAC1E,CAAC,EACF,KAAC,QAAQ,IAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAI,IACrD,CACN,EACA,CAAC,cAAc,IAAI,KAAC,qBAAqB,IAAS,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,IAA9B,CAAC,CAAiC,EACjF,KAAK,GAAG,CAAC,IAAI,CACV,KAAC,SAAS,IAAC,IAAI,EAAC,WAAW,EAAC,IAAI,EAAC,GAAG,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC,cAAc,CAAC,YACjF,cAAc;4BACX,CAAC,CAAC,CAAC,CAAC,6BAA6B,EAAE,EAAC,KAAK,EAAC,CAAC;4BAC3C,CAAC,CAAC,CAAC,CAAC,6BAA6B,EAAE,EAAC,KAAK,EAAC,CAAC,GACvC,CACf,IACM,GACW,GACJ,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 {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IRecordIdentityWhoAmI} from '_ui/types';\nimport {KitButton, KitSpace, KitTypography} from 'aristid-ds';\nimport {type FunctionComponent, useState} from 'react';\nimport styled from 'styled-components';\nimport {ErrorDisplay} from '../ErrorDisplay';\nimport {Loading} from '../Loading';\nimport {ShowMore} from '../ShowMore';\nimport {useFetchRecordHistory} from './hooks/useFetchRecordHistory';\nimport {RecordHistoryGoUpButton} from './RecordHistoryGoUpButton';\nimport {RecordHistoryLogEntry} from './RecordHistoryLogEntry';\n\ninterface IRecordHistoryProps {\n record: IRecordIdentityWhoAmI;\n attributeId?: string;\n}\n\nconst StyledDivContentWrapper = styled.div`\n margin-top: calc(var(--general-spacing-xs) * 1px);\n flex: 1 1 0;\n overflow-y: auto;\n`;\n\n// TODO: This component should be moved to /apps/app-studio/src/modules/information-and-history/record-history/ when he will no longer be used by RecordSummary and ValuesSummary (those components will be removed in the future)\n// Also when component will be moved\n// - put together translations with information_and_history\n// - remove usage of styled-components\n// - instead of a record we could receive a recordId and a libraryId directly\n// - remove styling of StyledDivContentWrapper that will no longer be necessary\nexport const RecordHistory: FunctionComponent<IRecordHistoryProps> = ({record, attributeId}) => {\n const {t} = useSharedTranslation();\n const [showAllHistory, setShowAllHistory] = useState<boolean>(false);\n const {loading, inError, logs, total, hasMore, fetchMore} = useFetchRecordHistory({\n record: {\n id: record.id,\n libraryId: record.library.id,\n },\n attributeId,\n });\n\n if (loading && logs.length === 0) {\n // TODO: Add a better loading state\n return <Loading />;\n }\n\n if (inError) {\n //TODO: Add a better error state\n return <ErrorDisplay message={t('record_history.error_fetching')} />;\n }\n\n if (logs.length === 0) {\n return (\n <StyledDivContentWrapper>\n <KitTypography.Text>{t('record_history.empty_history')}</KitTypography.Text>\n </StyledDivContentWrapper>\n );\n }\n\n return (\n <StyledDivContentWrapper>\n <RecordHistoryGoUpButton>\n <KitSpace size=\"s\" direction=\"vertical\">\n {showAllHistory && (\n <>\n {logs.map((logEntry, index) => (\n <RecordHistoryLogEntry key={index} index={index} logEntry={logEntry} />\n ))}\n <ShowMore hasMore={hasMore} fetchMore={fetchMore} />\n </>\n )}\n {!showAllHistory && <RecordHistoryLogEntry key={0} index={0} logEntry={logs[0]} />}\n {total > 1 && (\n <KitButton type=\"secondary\" size=\"s\" onClick={() => setShowAllHistory(!showAllHistory)}>\n {showAllHistory\n ? t('record_history.hide_history', {total})\n : t('record_history.show_history', {total})}\n </KitButton>\n )}\n </KitSpace>\n </RecordHistoryGoUpButton>\n </StyledDivContentWrapper>\n );\n};\n\nexport default RecordHistory;\n"]}
|
|
@@ -6,8 +6,14 @@ import { localizedTranslation } from '@leav/utils';
|
|
|
6
6
|
import { AttributeFormat, LogAction } from '../../_gqlTypes';
|
|
7
7
|
import { useLang } from '../../hooks';
|
|
8
8
|
import { useSharedTranslation } from '../../hooks/useSharedTranslation';
|
|
9
|
-
import { KitSpace, KitTypography } from 'aristid-ds';
|
|
9
|
+
import { KitButton, KitSpace, KitTypography } from 'aristid-ds';
|
|
10
10
|
import dayjs from 'dayjs';
|
|
11
|
+
import styled from 'styled-components';
|
|
12
|
+
const StyledLinkButton = styled(KitButton) `
|
|
13
|
+
&[role='link'] {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
11
17
|
export const RecordHistoryLogEntry = ({ index, logEntry }) => {
|
|
12
18
|
const { t } = useSharedTranslation();
|
|
13
19
|
const { lang } = useLang();
|
|
@@ -18,7 +24,7 @@ export const RecordHistoryLogEntry = ({ index, logEntry }) => {
|
|
|
18
24
|
const hasAfter = hasValue(after);
|
|
19
25
|
const getUserString = () => {
|
|
20
26
|
const email = user?.properties[0]?.values[0]?.payload;
|
|
21
|
-
return email ? (_jsx("
|
|
27
|
+
return email ? (_jsx(StyledLinkButton, { type: "link", href: `mailto:${email}`, children: email })) : (user?.id || t('record_history.unknown_user'));
|
|
22
28
|
};
|
|
23
29
|
const getDateString = () => dayjs.unix(time).format('DD/MM/YYYY HH:mm:ss'); // Maybe use https://day.js.org/docs/en/display/format#localized-formats if needed
|
|
24
30
|
const getActionString = () => {
|
|
@@ -35,24 +41,24 @@ export const RecordHistoryLogEntry = ({ index, logEntry }) => {
|
|
|
35
41
|
const getAttributeLabel = () => localizedTranslation(attribute?.label, lang) || attribute?.id || t('record_history.unknown_attribute');
|
|
36
42
|
const formatValue = (logData) => {
|
|
37
43
|
if (attribute?.format === AttributeFormat.rich_text) {
|
|
38
|
-
return (_jsx(KitTypography.AdvancedParagraph, { size: "
|
|
44
|
+
return (_jsx(KitTypography.AdvancedParagraph, { size: "fontSize5", ellipsis: { rows: 4, expandable: true }, children: logData.asString }));
|
|
39
45
|
}
|
|
40
|
-
return _jsx(KitTypography.Text, { size: "
|
|
46
|
+
return _jsx(KitTypography.Text, { size: "fontSize5", children: logData.asString });
|
|
41
47
|
};
|
|
42
48
|
const formatValueChange = () => {
|
|
43
|
-
const noValue = _jsx(KitTypography.Text, { size: "
|
|
49
|
+
const noValue = _jsx(KitTypography.Text, { size: "fontSize5", children: t('record_history.no_value') });
|
|
44
50
|
if (attribute?.multiple_values) {
|
|
45
51
|
const uniqValue = !hasBefore && hasAfter ? after : hasBefore && !hasAfter ? before : null;
|
|
46
52
|
if (uniqValue != null) {
|
|
47
53
|
return (_jsx(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: formatValue(uniqValue) }));
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
|
-
return (_jsxs(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: [hasBefore ? formatValue(before) : noValue, _jsx(KitTypography.Text, { size: "
|
|
56
|
+
return (_jsxs(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: [hasBefore ? formatValue(before) : noValue, _jsx(KitTypography.Text, { size: "fontSize5", children: " \u2192 " }), hasAfter ? formatValue(after) : noValue] }));
|
|
51
57
|
};
|
|
52
58
|
switch (action) {
|
|
53
59
|
case LogAction.VALUE_SAVE:
|
|
54
60
|
case LogAction.VALUE_DELETE:
|
|
55
|
-
return (_jsxs(KitSpace, { size: "
|
|
61
|
+
return (_jsxs(KitSpace, { size: "xxs", direction: "vertical", children: [_jsxs(KitTypography.Text, { size: "fontSize5", children: [getUserString(), " ", getActionString(), " ", _jsx("strong", { children: getAttributeLabel() })] }), _jsx(KitTypography.Text, { size: "fontSize5", children: getDateString() }), formatValueChange()] }, index));
|
|
56
62
|
}
|
|
57
63
|
};
|
|
58
64
|
export default RecordHistoryLogEntry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordHistoryLogEntry.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistoryLogEntry.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,eAAe,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AACzD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"RecordHistoryLogEntry.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistoryLogEntry.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,eAAe,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AACzD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAOvC,MAAM,gBAAgB,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;;;;CAIzC,CAAC;AAEF,MAAM,CAAC,MAAM,q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AE,CAAC;gBACpB,OAAO,CACH,KAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,YAAY,EAAC,IAAI,kBAC3C,WAAW,CAAC,SAAS,CAAC,GAChB,CACd,CAAC;YACN,CAAC;QACL,CAAC;QAED,OAAO,CACH,MAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,YAAY,EAAC,IAAI,mBAC3C,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAC1C,KAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,yBAAyB,EAC5D,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,IACjC,CACd,CAAC;IACN,CAAC,CAAC;IAEF,QAAQ,MAAM,EAAE,CAAC;QACb,KAAK,SAAS,CAAC,UAAU,CAAC;QAC1B,KAAK,SAAS,CAAC,YAAY;YACvB,OAAO,CACH,MAAC,QAAQ,IAAa,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,UAAU,aACjD,MAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,aAC/B,aAAa,EAAE,OAAG,eAAe,EAAE,OAAE,2BAAS,iBAAiB,EAAE,GAAU,IAC3D,EACrB,KAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,YAAE,aAAa,EAAE,GAAsB,EAC1E,iBAAiB,EAAE,KALT,KAAK,CAMT,CACd,CAAC;IACV,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,qBAAqB,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 {localizedTranslation} from '@leav/utils';\nimport {AttributeFormat, LogAction} from '_ui/_gqlTypes';\nimport {useLang} from '_ui/hooks';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitButton, KitSpace, KitTypography} from 'aristid-ds';\nimport dayjs from 'dayjs';\nimport {type FunctionComponent} from 'react';\nimport {type LogEntry, type LogEntryAttribute, type LogEntryData, type LogEntryValue} from './_types';\nimport styled from 'styled-components';\n\ninterface IRecordHistoryLogEntryProps {\n index: number;\n logEntry: LogEntry;\n}\n\nconst StyledLinkButton = styled(KitButton)`\n &[role='link'] {\n display: inline-flex;\n }\n`;\n\nexport const RecordHistoryLogEntry: FunctionComponent<IRecordHistoryLogEntryProps> = ({index, logEntry}) => {\n const {t} = useSharedTranslation();\n const {lang} = useLang();\n const {action, time, user, topic, before, after} = logEntry as LogEntryValue;\n const attribute: LogEntryAttribute | undefined = topic?.attribute;\n\n const hasValue = (value: LogEntryData) => value != null && 'asString' in value && value.asString != null;\n const hasBefore = hasValue(before);\n const hasAfter = hasValue(after);\n\n const getUserString = () => {\n const email = user?.properties[0]?.values[0]?.payload;\n return email ? (\n <StyledLinkButton type=\"link\" href={`mailto:${email}`}>\n {email}\n </StyledLinkButton>\n ) : (\n user?.id || t('record_history.unknown_user')\n );\n };\n const getDateString = () => dayjs.unix(time).format('DD/MM/YYYY HH:mm:ss'); // Maybe use https://day.js.org/docs/en/display/format#localized-formats if needed\n const getActionString = () => {\n if (attribute?.multiple_values) {\n if (!hasBefore && hasAfter) {\n return t('record_history.action.value_add');\n }\n if (hasBefore && !hasAfter) {\n return t('record_history.action.value_delete');\n }\n }\n return t('record_history.action.value_modify');\n };\n\n const getAttributeLabel = () =>\n localizedTranslation(attribute?.label, lang) || attribute?.id || t('record_history.unknown_attribute');\n\n const formatValue = (logData: LogEntryData) => {\n if (attribute?.format === AttributeFormat.rich_text) {\n return (\n <KitTypography.AdvancedParagraph size=\"fontSize5\" ellipsis={{rows: 4, expandable: true}}>\n {logData.asString}\n </KitTypography.AdvancedParagraph>\n );\n }\n return <KitTypography.Text size=\"fontSize5\">{logData.asString}</KitTypography.Text>;\n };\n\n const formatValueChange = () => {\n const noValue = <KitTypography.Text size=\"fontSize5\">{t('record_history.no_value')}</KitTypography.Text>;\n\n if (attribute?.multiple_values) {\n const uniqValue = !hasBefore && hasAfter ? after : hasBefore && !hasAfter ? before : null;\n if (uniqValue != null) {\n return (\n <KitSpace size=\"xxs\" direction=\"horizontal\" wrap>\n {formatValue(uniqValue)}\n </KitSpace>\n );\n }\n }\n\n return (\n <KitSpace size=\"xxs\" direction=\"horizontal\" wrap>\n {hasBefore ? formatValue(before) : noValue}\n <KitTypography.Text size=\"fontSize5\"> → </KitTypography.Text>\n {hasAfter ? formatValue(after) : noValue}\n </KitSpace>\n );\n };\n\n switch (action) {\n case LogAction.VALUE_SAVE:\n case LogAction.VALUE_DELETE:\n return (\n <KitSpace key={index} size=\"xxs\" direction=\"vertical\">\n <KitTypography.Text size=\"fontSize5\">\n {getUserString()} {getActionString()} <strong>{getAttributeLabel()}</strong>\n </KitTypography.Text>\n <KitTypography.Text size=\"fontSize5\">{getDateString()}</KitTypography.Text>\n {formatValueChange()}\n </KitSpace>\n );\n }\n};\n\nexport default RecordHistoryLogEntry;\n"]}
|
|
@@ -157,6 +157,9 @@ export const SelectTreeNodeContent = ({ treeData: tree, childrenAsRecordValuePer
|
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
159
|
const _handleCheck = selection => {
|
|
160
|
+
if (!canSelectRoot && Array.isArray(selection) && selection.includes(tree.id)) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
160
163
|
const checkedKeys = _isObjectSelection(selection) ? selection.checked : selection;
|
|
161
164
|
const nodes = checkedKeys.map(key => treeMap[key]);
|
|
162
165
|
onCheck(nodes);
|