@leav/ui 1.14.0-2fd28db5 → 1.14.0-b442287d
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/Filters/context/filtersReducer.js +43 -51
- package/dist/components/Filters/context/filtersReducer.js.map +1 -1
- package/dist/components/Filters/context/useFiltersReducer.js +21 -12
- package/dist/components/Filters/context/useFiltersReducer.js.map +1 -1
- package/dist/components/Filters/filter-items/CommonFilterItem.js +11 -7
- package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js +16 -3
- package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js.map +1 -1
- package/dist/components/Filters/prepareFiltersForRequest.js +148 -115
- package/dist/components/Filters/prepareFiltersForRequest.js.map +1 -1
- package/dist/components/Filters/useTransformFilters.d.ts +1 -3
- package/dist/components/Filters/useTransformFilters.js +135 -133
- package/dist/components/Filters/useTransformFilters.js.map +1 -1
- package/package.json +3 -3
|
@@ -5,7 +5,6 @@ import { localizedTranslation } from '@leav/utils';
|
|
|
5
5
|
import { useLang } from '../../hooks';
|
|
6
6
|
import { valueListTextConditions } from './filter-items/filter-type/useConditionOptionsByType';
|
|
7
7
|
import dayjs from 'dayjs';
|
|
8
|
-
// --- Type guards ---
|
|
9
8
|
const _isValidFieldFilter = (filter) => !!filter.field;
|
|
10
9
|
const _isValidFieldFilterThrough = (filter) => filter.condition === ThroughConditionFilter.THROUGH && !!filter.subCondition && !!filter.subField;
|
|
11
10
|
const _isValidFieldFilterStandardValuesList = (filter, attribute) => valueListTextConditions.includes(filter.condition) &&
|
|
@@ -16,118 +15,6 @@ const _isValidFieldFilterLinkValuesList = (filter, attribute) => valueListTextCo
|
|
|
16
15
|
[AttributeType.simple_link, AttributeType.advanced_link].includes(attribute.type) &&
|
|
17
16
|
'valuesList' in attribute &&
|
|
18
17
|
!!attribute.valuesList?.enable;
|
|
19
|
-
// --- Per-type converters (pure, module-level) ---
|
|
20
|
-
const _toStandardUIFilter = (filter, attributeData, base, t) => {
|
|
21
|
-
if (_isValidFieldFilterStandardValuesList(filter, attributeData)) {
|
|
22
|
-
const newFilter = {
|
|
23
|
-
field: filter.field,
|
|
24
|
-
// TODO: save filter values as string[] when filter and handle fields with libraries
|
|
25
|
-
value: filter.value ? [filter.value] : [],
|
|
26
|
-
hidden: filter.hidden ?? false,
|
|
27
|
-
id: window.crypto.randomUUID(),
|
|
28
|
-
condition: filter.condition ?? null,
|
|
29
|
-
attribute: {
|
|
30
|
-
...base,
|
|
31
|
-
format: attributeData.format,
|
|
32
|
-
valuesList: attributeData.valuesList,
|
|
33
|
-
},
|
|
34
|
-
withEmptyValues: filter.withEmptyValues ?? false,
|
|
35
|
-
};
|
|
36
|
-
return newFilter;
|
|
37
|
-
}
|
|
38
|
-
let formattedValue;
|
|
39
|
-
if (attributeData.format === AttributeFormat.boolean && filter.value) {
|
|
40
|
-
formattedValue = filter.value === 'true' ? t('explorer.true') : t('explorer.false');
|
|
41
|
-
}
|
|
42
|
-
if (attributeData.format === AttributeFormat.date && filter.value) {
|
|
43
|
-
formattedValue = dayjs(filter.value).format('YYYY-MM-DD');
|
|
44
|
-
}
|
|
45
|
-
const newFilter = {
|
|
46
|
-
field: filter.field,
|
|
47
|
-
value: filter.value ?? null,
|
|
48
|
-
formattedValue,
|
|
49
|
-
hidden: filter.hidden ?? false,
|
|
50
|
-
id: window.crypto.randomUUID(),
|
|
51
|
-
condition: filter.condition ?? null,
|
|
52
|
-
attribute: {
|
|
53
|
-
...base,
|
|
54
|
-
format: attributeData.format,
|
|
55
|
-
smartFilter: attributeData.smart_filter ?? undefined,
|
|
56
|
-
},
|
|
57
|
-
withEmptyValues: filter.withEmptyValues ?? false,
|
|
58
|
-
};
|
|
59
|
-
return newFilter;
|
|
60
|
-
};
|
|
61
|
-
const _toLinkUIFilter = (filter, attributeData, base) => {
|
|
62
|
-
if (_isValidFieldFilterThrough(filter)) {
|
|
63
|
-
const newFilter = {
|
|
64
|
-
field: filter.field,
|
|
65
|
-
value: filter.value ?? null,
|
|
66
|
-
hidden: filter.hidden ?? false,
|
|
67
|
-
id: window.crypto.randomUUID(),
|
|
68
|
-
condition: filter.condition,
|
|
69
|
-
attribute: {
|
|
70
|
-
...base,
|
|
71
|
-
linkedLibrary: attributeData.linked_library,
|
|
72
|
-
smartFilter: attributeData.smart_filter ?? undefined,
|
|
73
|
-
},
|
|
74
|
-
subCondition: filter.subCondition ?? null,
|
|
75
|
-
subField: filter.subField,
|
|
76
|
-
};
|
|
77
|
-
return newFilter;
|
|
78
|
-
}
|
|
79
|
-
if (_isValidFieldFilterLinkValuesList(filter, attributeData)) {
|
|
80
|
-
const newFilter = {
|
|
81
|
-
field: filter.field,
|
|
82
|
-
// TODO: save filter values as string[] when filter and handle fields with libraries
|
|
83
|
-
value: filter.value ? [filter.value] : [],
|
|
84
|
-
hidden: filter.hidden ?? false,
|
|
85
|
-
id: window.crypto.randomUUID(),
|
|
86
|
-
condition: filter.condition,
|
|
87
|
-
attribute: {
|
|
88
|
-
...base,
|
|
89
|
-
linkedLibrary: attributeData.linked_library,
|
|
90
|
-
valuesList: attributeData.valuesList,
|
|
91
|
-
smartFilter: attributeData.smart_filter ?? undefined,
|
|
92
|
-
},
|
|
93
|
-
withEmptyValues: filter.withEmptyValues ?? false,
|
|
94
|
-
};
|
|
95
|
-
return newFilter;
|
|
96
|
-
}
|
|
97
|
-
const newFilter = {
|
|
98
|
-
field: filter.field,
|
|
99
|
-
value: filter.value ?? null,
|
|
100
|
-
hidden: filter.hidden ?? false,
|
|
101
|
-
id: window.crypto.randomUUID(),
|
|
102
|
-
condition: filter.condition,
|
|
103
|
-
attribute: {
|
|
104
|
-
...base,
|
|
105
|
-
linkedLibrary: attributeData.linked_library,
|
|
106
|
-
smartFilter: attributeData.smart_filter ?? undefined,
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
return newFilter;
|
|
110
|
-
};
|
|
111
|
-
const _toTreeUIFilter = (filter, attributeData, base, treeFilters) => {
|
|
112
|
-
const treeData = treeFilters[filter.field];
|
|
113
|
-
const newFilter = {
|
|
114
|
-
field: [filter.field],
|
|
115
|
-
// TODO: save filter values as string[] when tree filter and handle fields with libraries
|
|
116
|
-
value: filter.value ? [filter.value] : (treeData?.map(tree => tree.value) ?? null),
|
|
117
|
-
formattedValue: filter.value ? [filter.value] : treeData?.map(tree => tree.label),
|
|
118
|
-
nodes: filter.value ? undefined : treeData?.map(tree => ({ libraryId: tree.libraryId, nodeId: tree.nodeId })),
|
|
119
|
-
hidden: filter.hidden ?? false,
|
|
120
|
-
id: window.crypto.randomUUID(),
|
|
121
|
-
attribute: {
|
|
122
|
-
...base,
|
|
123
|
-
linkedTree: attributeData.linked_tree,
|
|
124
|
-
},
|
|
125
|
-
condition: filter.condition ?? RecordFilterCondition.EQUAL,
|
|
126
|
-
withEmptyValues: filter.withEmptyValues ?? false,
|
|
127
|
-
};
|
|
128
|
-
return newFilter;
|
|
129
|
-
};
|
|
130
|
-
// --- Public exports ---
|
|
131
18
|
export const isLinkAttributeDetails = (linkAttributeData) => 'linked_library' in linkAttributeData;
|
|
132
19
|
export const useTransformFilters = () => {
|
|
133
20
|
const { lang } = useLang();
|
|
@@ -135,9 +22,10 @@ export const useTransformFilters = () => {
|
|
|
135
22
|
if (!_isValidFieldFilter(filter)) {
|
|
136
23
|
return acc;
|
|
137
24
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
//
|
|
25
|
+
const _isThroughFilter = filter.field.includes('.');
|
|
26
|
+
if (_isThroughFilter) {
|
|
27
|
+
// Hack because view filters does not have the necessary data to be transformed directly to UI filter,
|
|
28
|
+
// we need to split the field to get the subCondition and subField for through filter, may be fix after LEAVC-569
|
|
141
29
|
const [field, ...subFields] = filter.field.split('.');
|
|
142
30
|
const throughFilter = {
|
|
143
31
|
field,
|
|
@@ -155,29 +43,143 @@ export const useTransformFilters = () => {
|
|
|
155
43
|
return acc;
|
|
156
44
|
}, []);
|
|
157
45
|
const toUIFilters = ({ filters, treeFilters, attributesDataById, t, }) => (filters ?? []).reduce((acc, filter) => {
|
|
158
|
-
|
|
159
|
-
if (!attributeData) {
|
|
46
|
+
if (!attributesDataById[filter.field]) {
|
|
160
47
|
console.warn(`Attribute ${filter.field} from user view not found in database.`);
|
|
161
48
|
return acc;
|
|
162
49
|
}
|
|
163
|
-
const
|
|
164
|
-
id:
|
|
165
|
-
label: localizedTranslation(
|
|
166
|
-
type:
|
|
50
|
+
const filterAttributeBase = {
|
|
51
|
+
id: attributesDataById[filter.field].id,
|
|
52
|
+
label: localizedTranslation(attributesDataById[filter.field].label, lang),
|
|
53
|
+
type: attributesDataById[filter.field].type,
|
|
167
54
|
};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
55
|
+
// filter is standardFilter
|
|
56
|
+
if (isStandardAttribute(filterAttributeBase.type)) {
|
|
57
|
+
const attributeData = attributesDataById[filter.field];
|
|
58
|
+
if (_isValidFieldFilterStandardValuesList(filter, attributeData)) {
|
|
59
|
+
const newFilter = {
|
|
60
|
+
field: filter.field,
|
|
61
|
+
// TODO : save filter values as string[] when filter and handle fields with libraries
|
|
62
|
+
value: filter.value ? [filter.value] : [],
|
|
63
|
+
hidden: filter.hidden ?? false,
|
|
64
|
+
id: window.crypto.randomUUID(),
|
|
65
|
+
condition: filter.condition ?? null,
|
|
66
|
+
attribute: {
|
|
67
|
+
...filterAttributeBase,
|
|
68
|
+
format: attributeData.format,
|
|
69
|
+
valuesList: attributeData.valuesList,
|
|
70
|
+
},
|
|
71
|
+
withEmptyValues: filter.withEmptyValues ?? false,
|
|
72
|
+
};
|
|
73
|
+
acc.push(newFilter);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
let formattedValue;
|
|
77
|
+
if (attributeData.format === AttributeFormat.boolean && filter.value) {
|
|
78
|
+
formattedValue = filter.value === 'true' ? t('explorer.true') : t('explorer.false');
|
|
79
|
+
}
|
|
80
|
+
if (attributeData.format === AttributeFormat.date && filter.value) {
|
|
81
|
+
formattedValue = dayjs(filter.value).format('YYYY-MM-DD');
|
|
82
|
+
}
|
|
83
|
+
const newFilter = {
|
|
84
|
+
field: filter.field,
|
|
85
|
+
value: filter.value ?? null,
|
|
86
|
+
formattedValue,
|
|
87
|
+
hidden: filter.hidden ?? false,
|
|
88
|
+
id: window.crypto.randomUUID(),
|
|
89
|
+
condition: filter.condition ?? null,
|
|
90
|
+
attribute: {
|
|
91
|
+
...filterAttributeBase,
|
|
92
|
+
format: attributeData.format,
|
|
93
|
+
smartFilter: attributeData.smart_filter ?? undefined,
|
|
94
|
+
},
|
|
95
|
+
withEmptyValues: filter.withEmptyValues ?? false,
|
|
96
|
+
};
|
|
97
|
+
acc.push(newFilter);
|
|
98
|
+
}
|
|
171
99
|
}
|
|
172
|
-
if (isLinkAttribute(
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
100
|
+
if (isLinkAttribute(filterAttributeBase.type)) {
|
|
101
|
+
const attributeData = attributesDataById[filter.field];
|
|
102
|
+
if (_isValidFieldFilterThrough(filter)) {
|
|
103
|
+
const newFilter = {
|
|
104
|
+
field: filter.field,
|
|
105
|
+
value: filter.value ?? null,
|
|
106
|
+
hidden: filter.hidden ?? false,
|
|
107
|
+
id: window.crypto.randomUUID(),
|
|
108
|
+
condition: filter.condition,
|
|
109
|
+
attribute: {
|
|
110
|
+
...filterAttributeBase,
|
|
111
|
+
linkedLibrary: attributeData.linked_library,
|
|
112
|
+
smartFilter: attributeData.smart_filter ?? undefined,
|
|
113
|
+
},
|
|
114
|
+
subCondition: filter.subCondition ?? null,
|
|
115
|
+
subField: filter.subField,
|
|
116
|
+
};
|
|
117
|
+
acc.push(newFilter);
|
|
118
|
+
}
|
|
119
|
+
else if (_isValidFieldFilterLinkValuesList(filter, attributeData)) {
|
|
120
|
+
const newFilter = {
|
|
121
|
+
field: filter.field,
|
|
122
|
+
// TODO : save filter values as string[] when filter and handle fields with libraries
|
|
123
|
+
value: filter.value ? [filter.value] : [],
|
|
124
|
+
hidden: filter.hidden ?? false,
|
|
125
|
+
id: window.crypto.randomUUID(),
|
|
126
|
+
condition: filter.condition,
|
|
127
|
+
attribute: {
|
|
128
|
+
...filterAttributeBase,
|
|
129
|
+
linkedLibrary: attributeData.linked_library,
|
|
130
|
+
valuesList: attributeData.valuesList,
|
|
131
|
+
smartFilter: attributeData.smart_filter ?? undefined,
|
|
132
|
+
},
|
|
133
|
+
withEmptyValues: filter.withEmptyValues ?? false,
|
|
134
|
+
};
|
|
135
|
+
acc.push(newFilter);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const newFilter = {
|
|
139
|
+
field: filter.field,
|
|
140
|
+
value: filter.value ?? null,
|
|
141
|
+
hidden: filter.hidden ?? false,
|
|
142
|
+
id: window.crypto.randomUUID(),
|
|
143
|
+
condition: filter.condition,
|
|
144
|
+
attribute: {
|
|
145
|
+
...filterAttributeBase,
|
|
146
|
+
linkedLibrary: attributeData.linked_library,
|
|
147
|
+
smartFilter: attributeData.smart_filter ?? undefined,
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
acc.push(newFilter);
|
|
151
|
+
}
|
|
176
152
|
}
|
|
177
|
-
if (isTreeAttribute(
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
153
|
+
if (isTreeAttribute(filterAttributeBase.type) && !_isValidFieldFilterThrough(filter)) {
|
|
154
|
+
const attributeData = attributesDataById[filter.field];
|
|
155
|
+
const newFilter = {
|
|
156
|
+
field: [filter.field],
|
|
157
|
+
// TODO : save filter values as string[] when tree filter and handle fields with libraries
|
|
158
|
+
value: filter.value
|
|
159
|
+
? [filter.value]
|
|
160
|
+
: treeFilters[filter.field]
|
|
161
|
+
? treeFilters[filter.field].map(tree => tree.value)
|
|
162
|
+
: null,
|
|
163
|
+
formattedValue: filter.value
|
|
164
|
+
? [filter.value]
|
|
165
|
+
: treeFilters[filter.field]
|
|
166
|
+
? treeFilters[filter.field].map(tree => tree.label)
|
|
167
|
+
: undefined,
|
|
168
|
+
nodes: filter.value
|
|
169
|
+
? undefined
|
|
170
|
+
: treeFilters[filter.field]
|
|
171
|
+
? treeFilters[filter.field].map(tree => ({ libraryId: tree.libraryId, nodeId: tree.nodeId }))
|
|
172
|
+
: undefined,
|
|
173
|
+
hidden: filter.hidden ?? false,
|
|
174
|
+
id: window.crypto.randomUUID(),
|
|
175
|
+
attribute: {
|
|
176
|
+
...filterAttributeBase,
|
|
177
|
+
linkedTree: attributeData.linked_tree,
|
|
178
|
+
},
|
|
179
|
+
condition: filter.condition ?? RecordFilterCondition.EQUAL,
|
|
180
|
+
withEmptyValues: filter.withEmptyValues ?? false,
|
|
181
|
+
};
|
|
182
|
+
acc.push(newFilter);
|
|
181
183
|
}
|
|
182
184
|
return acc;
|
|
183
185
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransformFilters.js","sourceRoot":"","sources":["../../../src/components/Filters/useTransformFilters.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,eAAe,EACf,aAAa,EAKb,qBAAqB,GAGxB,MAAM,eAAe,CAAC;AAgBvB,OAAO,EAAC,sBAAsB,EAAC,MAAM,WAAW,CAAC;AACjD,OAAO,EAAC,eAAe,EAAE,mBAAmB,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,uBAAuB,EAAC,MAAM,sDAAsD,CAAC;AAC7F,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,sBAAsB;AAEtB,MAAM,mBAAmB,GAAG,CAAC,MAA4C,EAA8B,EAAE,CACrG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AAEnB,MAAM,0BAA0B,GAAG,CAAC,MAAmB,EAAqC,EAAE,CAC1F,MAAM,CAAC,SAAS,K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Ae,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;YAClD,OAAO,GAAG,CAAC;QACf,CAAC;QAED,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,EAAE,CAAC;YACpE,MAAM,QAAQ,GAAG,aAAqE,CAAC;YACvF,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;YAC/D,OAAO,GAAG,CAAC;QACf,CAAC;QAED,OAAO,GAAG,CAAC;IACf,CAAC,EAAE,EAAE,CAAC,CAAC;IAEX,OAAO;QACH,cAAc;QACd,WAAW;KACd,CAAC;AACN,CAAC,CAAC","sourcesContent":["import {\n type AttributeDetailsLinkAttributeFragment,\n type AttributeDetailsTreeAttributeFragment,\n AttributeFormat,\n AttributeType,\n type ExplorerAttributesQuery,\n type ExplorerLinkAttributeQuery,\n type GetViewsListQuery,\n type LinkAttributeDetailsFragment,\n RecordFilterCondition,\n type StandardAttributeDetailsFragment,\n type ViewDetailsFilterFragment,\n} from '_ui/_gqlTypes';\nimport {\n type UIFilter,\n type IUIFilterBaseAttribute,\n type IUIFilterLink,\n type IUIFilterLinkValueList,\n type IUIFilterStandard,\n type IUIFilterStandardValueList,\n type IUIFilterThrough,\n type IUIFilterTree,\n type ValidFieldFilter,\n type ValidFieldFilterLinkValuesList,\n type ValidFieldFilterStandardValuesList,\n type ValidFieldFilterThrough,\n type ValidFilter,\n} from './_types';\nimport {ThroughConditionFilter} from '_ui/types';\nimport {isLinkAttribute, isStandardAttribute, isTreeAttribute} from '_ui/_utils/attributeType';\nimport {localizedTranslation} from '@leav/utils';\nimport {useLang} from '_ui/hooks';\nimport {valueListTextConditions} from './filter-items/filter-type/useConditionOptionsByType';\nimport dayjs from 'dayjs';\nimport {type TFunction} from 'i18next';\nimport {type ITreeFilters} from './context/useGetTreeFilters';\n\n// --- Shared types ---\n\ntype QueryAttributeItem = NonNullable<ExplorerAttributesQuery['attributes']>['list'][number];\n\ntype AttributeDetailsLinkAttributeWithPermissionsFragment = AttributeDetailsLinkAttributeFragment & {\n permissions: {access_attribute: boolean};\n};\ntype AttributeDetailsTreeAttributeWithPermissionsFragment = AttributeDetailsTreeAttributeFragment & {\n permissions: {access_attribute: boolean};\n};\n\n// --- Type guards ---\n\nconst _isValidFieldFilter = (filter: ViewDetailsFilterFragment | UIFilter): filter is ValidFieldFilter =>\n !!filter.field;\n\nconst _isValidFieldFilterThrough = (filter: ValidFilter): filter is ValidFieldFilterThrough =>\n filter.condition === ThroughConditionFilter.THROUGH && !!filter.subCondition && !!filter.subField;\n\nconst _isValidFieldFilterStandardValuesList = (\n filter: ValidFilter,\n attribute: QueryAttributeItem,\n): filter is ValidFieldFilterStandardValuesList & {attribute: StandardAttributeDetailsFragment} =>\n valueListTextConditions.includes(filter.condition as RecordFilterCondition) &&\n [AttributeType.simple, AttributeType.advanced].includes(attribute.type) &&\n 'valuesList' in attribute &&\n !!attribute.valuesList?.enable;\n\nconst _isValidFieldFilterLinkValuesList = (\n filter: ValidFilter,\n attribute: QueryAttributeItem,\n): filter is ValidFieldFilterLinkValuesList & {attribute: LinkAttributeDetailsFragment} =>\n valueListTextConditions.includes(filter.condition as RecordFilterCondition) &&\n [AttributeType.simple_link, AttributeType.advanced_link].includes(attribute.type) &&\n 'valuesList' in attribute &&\n !!attribute.valuesList?.enable;\n\n// --- Per-type converters (pure, module-level) ---\n\nconst _toStandardUIFilter = (\n filter: ValidFilter,\n attributeData: QueryAttributeItem,\n base: IUIFilterBaseAttribute,\n t: TFunction,\n): IUIFilterStandard | IUIFilterStandardValueList => {\n if (_isValidFieldFilterStandardValuesList(filter, attributeData)) {\n const newFilter: IUIFilterStandardValueList = {\n field: filter.field,\n // TODO: save filter values as string[] when filter and handle fields with libraries\n value: filter.value ? [filter.value] : [],\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: (filter.condition as RecordFilterCondition) ?? null,\n attribute: {\n ...base,\n format: attributeData.format!,\n valuesList: (attributeData as StandardAttributeDetailsFragment).valuesList!,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n return newFilter;\n }\n\n let formattedValue: string;\n if (attributeData.format === AttributeFormat.boolean && filter.value) {\n formattedValue = filter.value === 'true' ? t('explorer.true') : t('explorer.false');\n }\n if (attributeData.format === AttributeFormat.date && filter.value) {\n formattedValue = dayjs(filter.value).format('YYYY-MM-DD');\n }\n\n const newFilter: IUIFilterStandard = {\n field: filter.field,\n value: filter.value ?? null,\n formattedValue,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: (filter.condition as RecordFilterCondition) ?? null,\n attribute: {\n ...base,\n format: attributeData.format!,\n smartFilter: (attributeData as StandardAttributeDetailsFragment).smart_filter ?? undefined,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n return newFilter;\n};\n\nconst _toLinkUIFilter = (\n filter: ValidFilter,\n attributeData: AttributeDetailsLinkAttributeWithPermissionsFragment,\n base: IUIFilterBaseAttribute,\n): IUIFilterThrough | IUIFilterLinkValueList | IUIFilterLink => {\n if (_isValidFieldFilterThrough(filter)) {\n const newFilter: IUIFilterThrough = {\n field: filter.field,\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...base,\n linkedLibrary: attributeData.linked_library!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n subCondition: (filter.subCondition as RecordFilterCondition) ?? null,\n subField: filter.subField,\n };\n return newFilter;\n }\n\n if (_isValidFieldFilterLinkValuesList(filter, attributeData)) {\n const newFilter: IUIFilterLinkValueList = {\n field: filter.field,\n // TODO: save filter values as string[] when filter and handle fields with libraries\n value: filter.value ? [filter.value] : [],\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...base,\n linkedLibrary: attributeData.linked_library!,\n valuesList: (attributeData as LinkAttributeDetailsFragment).valuesList!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n return newFilter;\n }\n\n const newFilter: IUIFilterLink = {\n field: filter.field,\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...base,\n linkedLibrary: attributeData.linked_library!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n };\n return newFilter;\n};\n\nconst _toTreeUIFilter = (\n filter: ValidFilter,\n attributeData: AttributeDetailsTreeAttributeWithPermissionsFragment,\n base: IUIFilterBaseAttribute,\n treeFilters: ITreeFilters,\n): IUIFilterTree => {\n const treeData = treeFilters[filter.field];\n\n const newFilter: IUIFilterTree = {\n field: [filter.field],\n // TODO: save filter values as string[] when tree filter and handle fields with libraries\n value: filter.value ? [filter.value] : (treeData?.map(tree => tree.value) ?? null),\n formattedValue: filter.value ? [filter.value] : treeData?.map(tree => tree.label),\n nodes: filter.value ? undefined : treeData?.map(tree => ({libraryId: tree.libraryId, nodeId: tree.nodeId})),\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n attribute: {\n ...base,\n linkedTree: attributeData.linked_tree!,\n },\n condition: (filter.condition as RecordFilterCondition) ?? RecordFilterCondition.EQUAL,\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n return newFilter;\n};\n\n// --- Public exports ---\n\nexport const isLinkAttributeDetails = (\n linkAttributeData: NonNullable<ExplorerLinkAttributeQuery['attributes']>['list'][number],\n): linkAttributeData is LinkAttributeDetailsFragment & {\n id: string;\n multiple_values: boolean;\n permissions: {\n access_attribute: boolean;\n edit_value: boolean;\n };\n} => 'linked_library' in linkAttributeData;\n\nexport type ValidFiltersArgument = GetViewsListQuery['views']['list'][number]['filters'] | UIFilter[];\n\nexport type AttributesById = Record<string, QueryAttributeItem>;\n\nexport const useTransformFilters = () => {\n const {lang} = useLang();\n\n const toValidFilters = (filters: ValidFiltersArgument): ValidFilter[] =>\n (filters ?? []).reduce<ValidFilter[]>((acc, filter) => {\n if (!_isValidFieldFilter(filter)) {\n return acc;\n }\n\n if (filter.field.includes('.')) {\n // Hack: view filters lack the data to transform directly to UI filter —\n // split the field to extract subCondition and subField. May be fixed after LEAVC-569.\n const [field, ...subFields] = filter.field.split('.');\n const throughFilter: ValidFieldFilterThrough = {\n field,\n subField: subFields.join('.'),\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n condition: ThroughConditionFilter.THROUGH,\n subCondition: filter.condition,\n };\n acc.push(throughFilter);\n } else {\n acc.push(filter);\n }\n\n return acc;\n }, []);\n\n const toUIFilters = ({\n filters,\n treeFilters,\n attributesDataById,\n t,\n }: {\n filters: ValidFilter[];\n treeFilters: ITreeFilters;\n attributesDataById: AttributesById;\n t: TFunction;\n }): UIFilter[] =>\n (filters ?? []).reduce<UIFilter[]>((acc, filter) => {\n const attributeData = attributesDataById[filter.field];\n if (!attributeData) {\n console.warn(`Attribute ${filter.field} from user view not found in database.`);\n return acc;\n }\n\n const base: IUIFilterBaseAttribute = {\n id: attributeData.id,\n label: localizedTranslation(attributeData.label, lang),\n type: attributeData.type,\n };\n\n if (isStandardAttribute(base.type)) {\n acc.push(_toStandardUIFilter(filter, attributeData, base, t));\n return acc;\n }\n\n if (isLinkAttribute(base.type)) {\n const linkAttr = attributeData as AttributeDetailsLinkAttributeWithPermissionsFragment;\n acc.push(_toLinkUIFilter(filter, linkAttr, base));\n return acc;\n }\n\n if (isTreeAttribute(base.type) && !_isValidFieldFilterThrough(filter)) {\n const treeAttr = attributeData as AttributeDetailsTreeAttributeWithPermissionsFragment;\n acc.push(_toTreeUIFilter(filter, treeAttr, base, treeFilters));\n return acc;\n }\n\n return acc;\n }, []);\n\n return {\n toValidFilters,\n toUIFilters,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"useTransformFilters.js","sourceRoot":"","sources":["../../../src/components/Filters/useTransformFilters.tsx"],"names":[],"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n AttributeFormat,\n AttributeType,\n type ExplorerAttributesQuery,\n type ExplorerLinkAttributeQuery,\n type GetViewsListQuery,\n type LinkAttributeDetailsFragment,\n RecordFilterCondition,\n type StandardAttributeDetailsFragment,\n type ViewDetailsFilterFragment,\n} from '_ui/_gqlTypes';\nimport {\n type UIFilter,\n type IUIFilterBaseAttribute,\n type IUIFilterLink,\n type IUIFilterLinkValueList,\n type IUIFilterStandard,\n type IUIFilterStandardValueList,\n type IUIFilterThrough,\n type IUIFilterTree,\n type ValidFieldFilter,\n type ValidFieldFilterLinkValuesList,\n type ValidFieldFilterStandardValuesList,\n type ValidFieldFilterThrough,\n type ValidFilter,\n} from './_types';\nimport {ThroughConditionFilter} from '_ui/types';\nimport {isLinkAttribute, isStandardAttribute, isTreeAttribute} from '_ui/_utils/attributeType';\nimport {localizedTranslation} from '@leav/utils';\nimport {useLang} from '_ui/hooks';\nimport {valueListTextConditions} from './filter-items/filter-type/useConditionOptionsByType';\nimport dayjs from 'dayjs';\nimport {type TFunction} from 'i18next';\nimport {type ITreeFilters} from './context/useGetTreeFilters';\n\nconst _isValidFieldFilter = (filter: ViewDetailsFilterFragment | UIFilter): filter is ValidFieldFilter =>\n !!filter.field;\n\nconst _isValidFieldFilterThrough = (filter: ValidFilter): filter is ValidFieldFilterThrough =>\n filter.condition === ThroughConditionFilter.THROUGH && !!filter.subCondition && !!filter.subField;\n\nconst _isValidFieldFilterStandardValuesList = (\n filter: ValidFilter,\n attribute: NonNullable<ExplorerAttributesQuery['attributes']>['list'][number],\n): filter is ValidFieldFilterStandardValuesList & {attribute: StandardAttributeDetailsFragment} =>\n valueListTextConditions.includes(filter.condition as RecordFilterCondition) &&\n [AttributeType.simple, AttributeType.advanced].includes(attribute.type) &&\n 'valuesList' in attribute &&\n !!attribute.valuesList?.enable;\n\nconst _isValidFieldFilterLinkValuesList = (\n filter: ValidFilter,\n attribute: NonNullable<ExplorerAttributesQuery['attributes']>['list'][number],\n): filter is ValidFieldFilterLinkValuesList & {attribute: LinkAttributeDetailsFragment} =>\n valueListTextConditions.includes(filter.condition as RecordFilterCondition) &&\n [AttributeType.simple_link, AttributeType.advanced_link].includes(attribute.type) &&\n 'valuesList' in attribute &&\n !!attribute.valuesList?.enable;\n\ntype AttributeDetailsLinkAttributeWithPermissionsFragment = AttributeDetailsLinkAttributeFragment & {\n permissions: {\n access_attribute: boolean;\n };\n};\ntype AttributeDetailsTreeAttributeWithPermissionsFragment = AttributeDetailsTreeAttributeFragment & {\n permissions: {\n access_attribute: boolean;\n };\n};\n\nexport const isLinkAttributeDetails = (\n linkAttributeData: NonNullable<ExplorerLinkAttributeQuery['attributes']>['list'][number],\n): linkAttributeData is LinkAttributeDetailsFragment & {\n id: string;\n multiple_values: boolean;\n permissions: {\n access_attribute: boolean;\n edit_value: boolean;\n };\n} => 'linked_library' in linkAttributeData;\n\nexport type ValidFiltersArgument = GetViewsListQuery['views']['list'][number]['filters'] | UIFilter[];\n\nexport type AttributesById = Record<string, NonNullable<ExplorerAttributesQuery['attributes']>['list'][number]>;\n\nexport const useTransformFilters = () => {\n const {lang} = useLang();\n\n const toValidFilters = (filters: ValidFiltersArgument): ValidFilter[] =>\n (filters ?? []).reduce<ValidFilter[]>((acc, filter) => {\n if (!_isValidFieldFilter(filter)) {\n return acc;\n }\n const _isThroughFilter = filter.field.includes('.');\n\n if (_isThroughFilter) {\n // Hack because view filters does not have the necessary data to be transformed directly to UI filter,\n // we need to split the field to get the subCondition and subField for through filter, may be fix after LEAVC-569\n const [field, ...subFields] = filter.field.split('.');\n const throughFilter: ValidFieldFilterThrough = {\n field,\n subField: subFields.join('.'),\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n condition: ThroughConditionFilter.THROUGH,\n subCondition: filter.condition,\n };\n acc.push(throughFilter);\n } else {\n acc.push(filter);\n }\n\n return acc;\n }, []);\n\n const toUIFilters = ({\n filters,\n treeFilters,\n attributesDataById,\n t,\n }: {\n filters: ValidFilter[];\n treeFilters: ITreeFilters;\n attributesDataById: AttributesById;\n t: TFunction;\n }): UIFilter[] =>\n (filters ?? []).reduce<UIFilter[]>((acc, filter) => {\n if (!attributesDataById[filter.field]) {\n console.warn(`Attribute ${filter.field} from user view not found in database.`);\n return acc;\n }\n\n const filterAttributeBase: IUIFilterBaseAttribute = {\n id: attributesDataById[filter.field].id,\n label: localizedTranslation(attributesDataById[filter.field].label, lang),\n type: attributesDataById[filter.field].type,\n };\n\n // filter is standardFilter\n if (isStandardAttribute(filterAttributeBase.type)) {\n const attributeData = attributesDataById[filter.field];\n if (_isValidFieldFilterStandardValuesList(filter, attributeData)) {\n const newFilter: IUIFilterStandardValueList = {\n field: filter.field,\n // TODO : save filter values as string[] when filter and handle fields with libraries\n value: filter.value ? [filter.value] : [],\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: (filter.condition as RecordFilterCondition) ?? null,\n attribute: {\n ...filterAttributeBase,\n format: attributeData.format!,\n valuesList: (attributeData as StandardAttributeDetailsFragment).valuesList!,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n acc.push(newFilter);\n } else {\n let formattedValue: string;\n if (attributeData.format === AttributeFormat.boolean && filter.value) {\n formattedValue = filter.value === 'true' ? t('explorer.true') : t('explorer.false');\n }\n\n if (attributeData.format === AttributeFormat.date && filter.value) {\n formattedValue = dayjs(filter.value).format('YYYY-MM-DD');\n }\n\n const newFilter: IUIFilterStandard = {\n field: filter.field,\n value: filter.value ?? null,\n formattedValue,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: (filter.condition as RecordFilterCondition) ?? null,\n attribute: {\n ...filterAttributeBase,\n format: attributeData.format!,\n smartFilter: (attributeData as StandardAttributeDetailsFragment).smart_filter ?? undefined,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n acc.push(newFilter);\n }\n }\n\n if (isLinkAttribute(filterAttributeBase.type)) {\n const attributeData = attributesDataById[\n filter.field\n ] as AttributeDetailsLinkAttributeWithPermissionsFragment;\n if (_isValidFieldFilterThrough(filter)) {\n const newFilter: IUIFilterThrough = {\n field: filter.field,\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...filterAttributeBase,\n linkedLibrary: attributeData.linked_library!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n subCondition: filter.subCondition ?? null,\n subField: filter.subField,\n };\n acc.push(newFilter);\n } else if (_isValidFieldFilterLinkValuesList(filter, attributeData)) {\n const newFilter: IUIFilterLinkValueList = {\n field: filter.field,\n // TODO : save filter values as string[] when filter and handle fields with libraries\n value: filter.value ? [filter.value] : [],\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...filterAttributeBase,\n linkedLibrary: attributeData.linked_library!,\n valuesList: (attributeData as LinkAttributeDetailsFragment).valuesList!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n\n acc.push(newFilter);\n } else {\n const newFilter: IUIFilterLink = {\n field: filter.field,\n value: filter.value ?? null,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n condition: filter.condition,\n attribute: {\n ...filterAttributeBase,\n linkedLibrary: attributeData.linked_library!,\n smartFilter: attributeData.smart_filter ?? undefined,\n },\n };\n\n acc.push(newFilter);\n }\n }\n\n if (isTreeAttribute(filterAttributeBase.type) && !_isValidFieldFilterThrough(filter)) {\n const attributeData = attributesDataById[\n filter.field\n ] as AttributeDetailsTreeAttributeWithPermissionsFragment;\n const newFilter: IUIFilterTree = {\n field: [filter.field],\n // TODO : save filter values as string[] when tree filter and handle fields with libraries\n value: filter.value\n ? [filter.value]\n : treeFilters[filter.field]\n ? treeFilters[filter.field].map(tree => tree.value)\n : null,\n formattedValue: filter.value\n ? [filter.value]\n : treeFilters[filter.field]\n ? treeFilters[filter.field].map(tree => tree.label)\n : undefined,\n nodes: filter.value\n ? undefined\n : treeFilters[filter.field]\n ? treeFilters[filter.field].map(tree => ({libraryId: tree.libraryId, nodeId: tree.nodeId}))\n : undefined,\n hidden: filter.hidden ?? false,\n id: window.crypto.randomUUID(),\n attribute: {\n ...filterAttributeBase,\n linkedTree: attributeData.linked_tree!,\n },\n condition: filter.condition ?? RecordFilterCondition.EQUAL,\n withEmptyValues: filter.withEmptyValues ?? false,\n };\n acc.push(newFilter);\n }\n\n return acc;\n }, []);\n\n return {\n toValidFilters,\n toUIFilters,\n };\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leav/ui",
|
|
3
|
-
"version": "1.14.0-
|
|
3
|
+
"version": "1.14.0-b442287d",
|
|
4
4
|
"description": "Shared React components and hooks",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublishOnly": "yarn build",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"react-dom": "18.2.0",
|
|
52
52
|
"react-i18next": "12",
|
|
53
53
|
"react-router-dom": "6.22.0",
|
|
54
|
-
"ts-jest": "29.4.
|
|
54
|
+
"ts-jest": "29.4.11",
|
|
55
55
|
"tsc-alias": "1.8.17",
|
|
56
56
|
"typescript": "5.9.3",
|
|
57
57
|
"vite": "7.3.3"
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@leav/utils": "1.14.0",
|
|
74
74
|
"@uidotdev/usehooks": "2.4.1",
|
|
75
75
|
"dayjs": "^1.11.13",
|
|
76
|
-
"dompurify": "3.4.
|
|
76
|
+
"dompurify": "3.4.5",
|
|
77
77
|
"html-react-parser": "4.2.10",
|
|
78
78
|
"i18next-resources-to-backend": "1.2.1",
|
|
79
79
|
"react-markdown": "5.0.3",
|