@blaze-cms/plugin-data-ui 0.146.0-core-styles.56 → 0.146.0-core-styles.61
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/CHANGELOG.md +27 -0
- package/README.md +36 -0
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +8 -2
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
- package/lib/components/EntityManager/utils/entity.js +8 -2
- package/lib/components/EntityManager/utils/entity.js.map +1 -1
- package/lib/components/ListingTable/ListingTable.js +9 -1
- package/lib/components/ListingTable/ListingTable.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js +313 -0
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -0
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js +58 -0
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -0
- package/lib/components/ListingTable/SearchFilter/helpers.js +120 -0
- package/lib/components/ListingTable/SearchFilter/helpers.js.map +1 -0
- package/lib/components/ListingTable/SearchFilter/querys.js +13 -0
- package/lib/components/ListingTable/SearchFilter/querys.js.map +1 -0
- package/lib/components/ListingTable/service/index.js +3 -3
- package/lib/components/ListingTable/service/index.js.map +1 -1
- package/lib/constants.js +3 -1
- package/lib/constants.js.map +1 -1
- package/lib/utils/build-listing-query.js +4 -4
- package/lib/utils/build-listing-query.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +4 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
- package/lib-es/components/EntityManager/utils/entity.js +4 -1
- package/lib-es/components/EntityManager/utils/entity.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTable.js +9 -1
- package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js +207 -0
- package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -0
- package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js +39 -0
- package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -0
- package/lib-es/components/ListingTable/SearchFilter/helpers.js +94 -0
- package/lib-es/components/ListingTable/SearchFilter/helpers.js.map +1 -0
- package/lib-es/components/ListingTable/SearchFilter/querys.js +8 -0
- package/lib-es/components/ListingTable/SearchFilter/querys.js.map +1 -0
- package/lib-es/components/ListingTable/service/index.js +3 -2
- package/lib-es/components/ListingTable/service/index.js.map +1 -1
- package/lib-es/constants.js +3 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/utils/build-listing-query.js +4 -4
- package/lib-es/utils/build-listing-query.js.map +1 -1
- package/package.json +5 -5
- package/src/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +4 -1
- package/src/components/EntityManager/utils/entity.js +4 -1
- package/src/components/ListingTable/ListingTable.js +9 -0
- package/src/components/ListingTable/SearchFilter/SearchContainer.js +238 -0
- package/src/components/ListingTable/SearchFilter/SearchFilter.js +37 -0
- package/src/components/ListingTable/SearchFilter/helpers.js +96 -0
- package/src/components/ListingTable/SearchFilter/querys.js +9 -0
- package/src/components/ListingTable/service/index.js +2 -2
- package/src/constants.js +7 -1
- package/src/utils/build-listing-query.js +4 -4
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { DEFAULT_FILTER_OPTION_LABEL } from '../../../constants';
|
|
2
|
+
|
|
3
|
+
const updateListFilters = (searchTerm, selectedFilters, setListFilters, fields = []) => {
|
|
4
|
+
const filters = [];
|
|
5
|
+
if (searchTerm) {
|
|
6
|
+
filters.push({
|
|
7
|
+
simple_query_string: {
|
|
8
|
+
query: `${searchTerm}*`,
|
|
9
|
+
fields
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Object.keys(selectedFilters).forEach(filterKey => {
|
|
15
|
+
const filterValue = selectedFilters[filterKey];
|
|
16
|
+
if (!filterValue || filterValue === DEFAULT_FILTER_OPTION_LABEL) return;
|
|
17
|
+
filters.push({
|
|
18
|
+
match: {
|
|
19
|
+
[filterKey]: filterValue
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
setListFilters(filters);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getKeywordSearchFilters = schema => {
|
|
28
|
+
if (!schema || !schema.properties) return [];
|
|
29
|
+
|
|
30
|
+
const { properties = {}, dynamicProperties = {} } = schema;
|
|
31
|
+
|
|
32
|
+
const propertyKeyword = Object.entries(properties).filter(isFilterKeywordItem);
|
|
33
|
+
const dynamicPropertyKeywords = Object.entries(dynamicProperties).filter(isFilterKeywordItem);
|
|
34
|
+
|
|
35
|
+
return [...propertyKeyword, ...dynamicPropertyKeywords];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const isFilterKeywordItem = ([, item]) =>
|
|
39
|
+
item.adminListingOptions && item.adminListingOptions.includeInKeywordSeach === true;
|
|
40
|
+
|
|
41
|
+
const findSelectFilters = schema => {
|
|
42
|
+
if (!schema || !schema.properties) return [];
|
|
43
|
+
|
|
44
|
+
const { properties = {}, dynamicProperties = {} } = schema;
|
|
45
|
+
|
|
46
|
+
const propertySelects = Object.entries(properties).filter(isFilterSelectItem);
|
|
47
|
+
const dynamicPropertySelects = Object.entries(dynamicProperties).filter(isFilterSelectItem);
|
|
48
|
+
|
|
49
|
+
return [...propertySelects, ...dynamicPropertySelects];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const isFilterSelectItem = ([, item]) =>
|
|
53
|
+
item.adminListingOptions && item.adminListingOptions.filterType === 'select';
|
|
54
|
+
|
|
55
|
+
const buildQueryFields = (selectFilters, entityId) => {
|
|
56
|
+
if (!Array.isArray(selectFilters) || selectFilters.length === 0) {
|
|
57
|
+
return { gqlFields: '', rawQuery: '{}' };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const aggs = {};
|
|
61
|
+
selectFilters.forEach(([property, details]) => {
|
|
62
|
+
aggs[property] = {
|
|
63
|
+
terms: {
|
|
64
|
+
field: `${property}.keyword`, // todo: handle different field types
|
|
65
|
+
size: 1000, // todo: customise size
|
|
66
|
+
order: {
|
|
67
|
+
_key: 'asc'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const docType = entityId;
|
|
74
|
+
const rawQueryObject = {
|
|
75
|
+
size: 0,
|
|
76
|
+
query: {
|
|
77
|
+
bool: {
|
|
78
|
+
filter: {
|
|
79
|
+
bool: {
|
|
80
|
+
must: [{ match: { docType } }]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
aggs
|
|
86
|
+
};
|
|
87
|
+
const rawQuery = JSON.stringify(rawQueryObject);
|
|
88
|
+
|
|
89
|
+
const gqlFields = `
|
|
90
|
+
rawResults
|
|
91
|
+
`;
|
|
92
|
+
|
|
93
|
+
return { gqlFields, rawQuery };
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export { buildQueryFields, updateListFilters, getKeywordSearchFilters, findSelectFilters };
|
|
@@ -35,11 +35,11 @@ function buildVariables({ entitySchema, isSearchQuery, listFilters = [], queryPa
|
|
|
35
35
|
|
|
36
36
|
const fetchData = async ({ client, querySettings: { entitySchema, queryParams }, listFilters }) => {
|
|
37
37
|
const {
|
|
38
|
-
displayProperties: { adminListings: { dataSource: { source } = {} } = {} } = {}
|
|
38
|
+
displayProperties: { adminListings: { dataSource: { source, index } = {} } = {} } = {}
|
|
39
39
|
} = entitySchema;
|
|
40
40
|
|
|
41
41
|
const isSearchQuery = source === 'search';
|
|
42
|
-
const query = buildListingQuery(entitySchema, isSearchQuery);
|
|
42
|
+
const query = buildListingQuery(entitySchema, index, isSearchQuery);
|
|
43
43
|
const variables = buildVariables({ entitySchema, listFilters, queryParams, isSearchQuery });
|
|
44
44
|
|
|
45
45
|
const { data = {} } = await client.query({
|
package/src/constants.js
CHANGED
|
@@ -26,6 +26,8 @@ const PAGE_BUILDER_TAB_INDEX = 1;
|
|
|
26
26
|
const EDITOR_VIEW_TAB = 'Editor view';
|
|
27
27
|
const EDITOR_VIEW_TAB_INDEX = 0;
|
|
28
28
|
|
|
29
|
+
const ENTER_KEY = 'Enter';
|
|
30
|
+
|
|
29
31
|
const ICON_SIZE = {
|
|
30
32
|
WIDTH: '25px',
|
|
31
33
|
HEIGHT: '25px'
|
|
@@ -36,6 +38,8 @@ const ICON_COLOR = {
|
|
|
36
38
|
FILL: '#63779C'
|
|
37
39
|
};
|
|
38
40
|
|
|
41
|
+
const DEFAULT_FILTER_OPTION_LABEL = 'Any';
|
|
42
|
+
|
|
39
43
|
export {
|
|
40
44
|
DATA_LISTING_PREFIX,
|
|
41
45
|
ENTITY_PUBLISHED,
|
|
@@ -63,5 +67,7 @@ export {
|
|
|
63
67
|
SAVE_BEFORE_PUBLISH_MESSAGE,
|
|
64
68
|
ICON_SIZE,
|
|
65
69
|
ICON_COLOR,
|
|
66
|
-
PAGE_NOT_FOUND
|
|
70
|
+
PAGE_NOT_FOUND,
|
|
71
|
+
ENTER_KEY,
|
|
72
|
+
DEFAULT_FILTER_OPTION_LABEL
|
|
67
73
|
};
|
|
@@ -2,21 +2,21 @@ import { gql } from '@apollo/client';
|
|
|
2
2
|
import { BlazeError } from '@blaze-cms/core-errors';
|
|
3
3
|
import { getDynamicQuery } from '@blaze-cms/admin-ui-utils';
|
|
4
4
|
|
|
5
|
-
const buildAdminSearchQuery = entitySchema => {
|
|
5
|
+
const buildAdminSearchQuery = (entitySchema, index) => {
|
|
6
6
|
const { listingProperties = [] } = entitySchema || {};
|
|
7
7
|
const parsedProperties = `id, ${listingProperties.join(' ') || 'id name'}`;
|
|
8
8
|
|
|
9
|
-
return getDynamicQuery('ADMIN_SEARCH')([entitySchema], parsedProperties, true);
|
|
9
|
+
return getDynamicQuery('ADMIN_SEARCH')([entitySchema], parsedProperties, true, index);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
function buildListingQuery(entitySchema, isSearchQuery) {
|
|
12
|
+
function buildListingQuery(entitySchema, index, isSearchQuery) {
|
|
13
13
|
if (!entitySchema.actions || !entitySchema.actions.getAll || !entitySchema.listingProperties) {
|
|
14
14
|
throw new BlazeError(
|
|
15
15
|
'Listing query requires getAll action and listingProperties from entity schema'
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
if (isSearchQuery) return buildAdminSearchQuery(entitySchema);
|
|
19
|
+
if (isSearchQuery) return buildAdminSearchQuery(entitySchema, index);
|
|
20
20
|
|
|
21
21
|
const sortType =
|
|
22
22
|
entitySchema.actions.getAll[0].toUpperCase() + entitySchema.actions.getAll.substr(1);
|