@blaze-cms/plugin-data-ui 0.147.0-rc-eagle.2 → 0.147.0-rc-eagle.6
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/README.md +9 -2
- package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js +181 -0
- package/lib/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js.map +1 -0
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js +338 -49
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js +6 -2
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/helpers.js +41 -8
- package/lib/components/ListingTable/SearchFilter/helpers.js.map +1 -1
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/get-default-query-params.js +17 -5
- package/lib/utils/get-default-query-params.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js +173 -0
- package/lib-es/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js.map +1 -0
- package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js +340 -51
- package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js +7 -3
- package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/helpers.js +39 -8
- package/lib-es/components/ListingTable/SearchFilter/helpers.js.map +1 -1
- package/lib-es/index.js +1 -0
- package/lib-es/index.js.map +1 -1
- package/lib-es/utils/get-default-query-params.js +17 -5
- package/lib-es/utils/get-default-query-params.js.map +1 -1
- package/package.json +11 -12
- package/src/components/EntityManager/Entity/Entity.js +2 -3
- package/src/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js +160 -0
- package/src/components/ListingTable/SearchFilter/SearchContainer.js +396 -71
- package/src/components/ListingTable/SearchFilter/SearchFilter.js +5 -2
- package/src/components/ListingTable/SearchFilter/helpers.js +55 -8
- package/src/index.js +2 -0
- package/src/utils/get-default-query-params.js +21 -9
|
@@ -14,14 +14,32 @@ const updateListFilters = (searchTerm, selectedFilters, setListFilters, fields =
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
Object.entries(selectedFilters).forEach(([filterKey, filterValue]) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
const isEmptyArray = Array.isArray(filterValue) && filterValue.length === 0;
|
|
18
|
+
if (
|
|
19
|
+
filterValue == null ||
|
|
20
|
+
filterValue === '' ||
|
|
21
|
+
filterValue === DEFAULT_FILTER_OPTION_LABEL ||
|
|
22
|
+
isEmptyArray
|
|
23
|
+
)
|
|
24
|
+
return;
|
|
25
|
+
|
|
26
|
+
const field = `${filterKey}.keyword`;
|
|
27
|
+
|
|
28
|
+
if (Array.isArray(filterValue)) {
|
|
29
|
+
if (filterValue.length > 1) {
|
|
30
|
+
filters.push({
|
|
31
|
+
terms: { [field]: filterValue }
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
filters.push({
|
|
35
|
+
term: { [field]: filterValue[0] }
|
|
36
|
+
});
|
|
23
37
|
}
|
|
24
|
-
}
|
|
38
|
+
} else {
|
|
39
|
+
filters.push({
|
|
40
|
+
term: { [field]: filterValue }
|
|
41
|
+
});
|
|
42
|
+
}
|
|
25
43
|
});
|
|
26
44
|
|
|
27
45
|
setListFilters(filters);
|
|
@@ -52,9 +70,22 @@ const findSelectFilters = schema => {
|
|
|
52
70
|
return [...propertySelects, ...dynamicPropertySelects];
|
|
53
71
|
};
|
|
54
72
|
|
|
73
|
+
const findMultiSelectFilters = schema => {
|
|
74
|
+
if (!schema || !schema.properties) return [];
|
|
75
|
+
|
|
76
|
+
const { properties = {}, dynamicProperties = {} } = schema;
|
|
77
|
+
const propertyMultiSelect = Object.entries(properties).filter(isFilterMultiSelectItems);
|
|
78
|
+
const dynamicPropertyMultiSelect =
|
|
79
|
+
Object.entries(dynamicProperties).filter(isFilterMultiSelectItems);
|
|
80
|
+
return [...propertyMultiSelect, ...dynamicPropertyMultiSelect];
|
|
81
|
+
};
|
|
82
|
+
|
|
55
83
|
const isFilterSelectItem = ([, item]) =>
|
|
56
84
|
item.adminListingOptions && item.adminListingOptions.filterType === 'select';
|
|
57
85
|
|
|
86
|
+
const isFilterMultiSelectItems = ([, item]) =>
|
|
87
|
+
item.adminListingOptions && item.adminListingOptions.filterType === 'multiSelect';
|
|
88
|
+
|
|
58
89
|
const buildQueryFields = (selectFilters, entityId) => {
|
|
59
90
|
if (!Array.isArray(selectFilters) || selectFilters.length === 0) {
|
|
60
91
|
return { gqlFields: '', rawQuery: '{}' };
|
|
@@ -96,4 +127,20 @@ const buildQueryFields = (selectFilters, entityId) => {
|
|
|
96
127
|
return { gqlFields, rawQuery };
|
|
97
128
|
};
|
|
98
129
|
|
|
99
|
-
|
|
130
|
+
const getTidyLabel = (value, tidy) => {
|
|
131
|
+
if (!tidy) return value;
|
|
132
|
+
|
|
133
|
+
return value
|
|
134
|
+
.split(/[\s_-]+/)
|
|
135
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
136
|
+
.join(' ');
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
buildQueryFields,
|
|
141
|
+
updateListFilters,
|
|
142
|
+
getKeywordSearchFilters,
|
|
143
|
+
findSelectFilters,
|
|
144
|
+
findMultiSelectFilters,
|
|
145
|
+
getTidyLabel
|
|
146
|
+
};
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,8 @@ import EntityManager from './components/EntityManager';
|
|
|
14
14
|
// () => import(/* webpackChunkName: 'EntityManager' */ './components/EntityManager')
|
|
15
15
|
// );
|
|
16
16
|
|
|
17
|
+
export { default as SearchFilter } from './components/ListingTable/SearchFilter/SearchFilter';
|
|
18
|
+
|
|
17
19
|
export default async function load(app) {
|
|
18
20
|
app.events.once('admin:menu:config:load', getAddContentMenuItems(app));
|
|
19
21
|
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
const getDefaultQueryParams = schema => {
|
|
2
2
|
const updated = schema.properties && schema.properties.updated;
|
|
3
|
-
const { adminDefaultListingFilter: where } =
|
|
3
|
+
const { adminDefaultListingFilter: where, adminListings: { defaultSort } = {} } =
|
|
4
|
+
schema.displayProperties || {};
|
|
5
|
+
|
|
6
|
+
let sort = [];
|
|
7
|
+
|
|
8
|
+
if (defaultSort?.property) {
|
|
9
|
+
sort = [
|
|
10
|
+
{
|
|
11
|
+
property: defaultSort.property,
|
|
12
|
+
direction: defaultSort.direction || 'asc'
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
} else if (updated) {
|
|
16
|
+
sort = [
|
|
17
|
+
{
|
|
18
|
+
property: 'updated',
|
|
19
|
+
direction: 'desc'
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
}
|
|
4
23
|
|
|
5
24
|
return {
|
|
6
25
|
where,
|
|
7
26
|
limit: 10,
|
|
8
27
|
offset: 0,
|
|
9
|
-
sort
|
|
10
|
-
? [
|
|
11
|
-
{
|
|
12
|
-
property: 'updated',
|
|
13
|
-
direction: 'desc'
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
: []
|
|
28
|
+
sort
|
|
17
29
|
};
|
|
18
30
|
};
|
|
19
31
|
|