@blaze-cms/plugin-data-ui 0.146.0-node18.1 → 0.146.0-rc-eagle-3.0
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 +35 -12
- package/README.md +64 -0
- package/lib/components/EntityDataListing/EntityDataListing.js +21 -19
- package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
- package/lib/components/EntityDataListing/index.js +2 -3
- package/lib/components/EntityDataListing/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +18 -20
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +2 -3
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/Entity.js +290 -452
- package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js +62 -66
- package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +34 -50
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js +2 -3
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/index.js +2 -3
- package/lib/components/EntityManager/Entity/EntityHeader/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +20 -26
- package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +20 -18
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +34 -32
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js +105 -150
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +24 -24
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/create/index.js +2 -3
- package/lib/components/EntityManager/Entity/actions-handlers/create/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js +34 -59
- package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js +29 -45
- package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js +2 -3
- package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/index.js +7 -8
- package/lib/components/EntityManager/Entity/actions-handlers/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js +2 -3
- package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js +36 -57
- package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/update/index.js +2 -3
- package/lib/components/EntityManager/Entity/actions-handlers/update/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js +47 -66
- package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -1
- package/lib/components/EntityManager/Entity/index.js +2 -3
- package/lib/components/EntityManager/Entity/index.js.map +1 -1
- package/lib/components/EntityManager/EntityManager.js +92 -166
- package/lib/components/EntityManager/EntityManager.js.map +1 -1
- package/lib/components/EntityManager/index.js +2 -3
- package/lib/components/EntityManager/index.js.map +1 -1
- package/lib/components/EntityManager/utils/RecordEditContext/index.js +3 -4
- package/lib/components/EntityManager/utils/RecordEditContext/index.js.map +1 -1
- package/lib/components/EntityManager/utils/data-mappers.js +34 -46
- package/lib/components/EntityManager/utils/data-mappers.js.map +1 -1
- package/lib/components/EntityManager/utils/entity.js +36 -75
- package/lib/components/EntityManager/utils/entity.js.map +1 -1
- package/lib/components/EntityManager/utils/entityAvailableActions.js +51 -110
- package/lib/components/EntityManager/utils/entityAvailableActions.js.map +1 -1
- package/lib/components/EntityManager/utils/is-form-empty.js +6 -10
- package/lib/components/EntityManager/utils/is-form-empty.js.map +1 -1
- package/lib/components/EntityManager/utils/query.js +17 -10
- package/lib/components/EntityManager/utils/query.js.map +1 -1
- package/lib/components/InfoBoxes/InfoBoxTooltip.js +43 -0
- package/lib/components/InfoBoxes/InfoBoxTooltip.js.map +1 -0
- package/lib/components/InfoBoxes/InfoBoxes.js +19 -20
- package/lib/components/InfoBoxes/InfoBoxes.js.map +1 -1
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js +27 -38
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +21 -17
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
- package/lib/components/InfoBoxes/hooks/useData.js +33 -30
- package/lib/components/InfoBoxes/hooks/useData.js.map +1 -1
- package/lib/components/InfoBoxes/hooks/useInfoBox.js +10 -10
- package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +1 -1
- package/lib/components/InfoBoxes/index.js +2 -3
- package/lib/components/InfoBoxes/index.js.map +1 -1
- package/lib/components/InfoBoxes/presentational/InfoBox.js +28 -32
- package/lib/components/InfoBoxes/presentational/InfoBox.js.map +1 -1
- package/lib/components/InfoBoxes/presentational/InfoBoxLabel.js +11 -12
- package/lib/components/InfoBoxes/presentational/InfoBoxLabel.js.map +1 -1
- package/lib/components/InfoBoxes/presentational/InfoBoxValue.js +12 -12
- package/lib/components/InfoBoxes/presentational/InfoBoxValue.js.map +1 -1
- package/lib/components/ListingTable/ListingTable.js +164 -303
- package/lib/components/ListingTable/ListingTable.js.map +1 -1
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +62 -40
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib/components/ListingTable/ListingTableContent/index.js +2 -3
- package/lib/components/ListingTable/ListingTableContent/index.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js +182 -0
- package/lib/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js.map +1 -0
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js +505 -0
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -0
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js +53 -0
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -0
- package/lib/components/ListingTable/SearchFilter/helpers.js +138 -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/TableActions/TableActions.js +27 -31
- package/lib/components/ListingTable/TableActions/TableActions.js.map +1 -1
- package/lib/components/ListingTable/TableActions/index.js +2 -3
- package/lib/components/ListingTable/TableActions/index.js.map +1 -1
- package/lib/components/ListingTable/index.js +2 -3
- package/lib/components/ListingTable/index.js.map +1 -1
- package/lib/components/ListingTable/mappers/populate-rows.js +104 -120
- package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
- package/lib/components/ListingTable/service/index.js +66 -84
- package/lib/components/ListingTable/service/index.js.map +1 -1
- package/lib/components/Tabs/index.js +27 -42
- package/lib/components/Tabs/index.js.map +1 -1
- package/lib/components/hooks/useCallbackDebounce.js +5 -9
- package/lib/components/hooks/useCallbackDebounce.js.map +1 -1
- package/lib/constants.js +31 -29
- package/lib/constants.js.map +1 -1
- package/lib/icons/ContentIcon.js +17 -20
- package/lib/icons/ContentIcon.js.map +1 -1
- package/lib/icons/SettingsIcon.js +12 -15
- package/lib/icons/SettingsIcon.js.map +1 -1
- package/lib/icons/TaxonomyIcon.js +15 -18
- package/lib/icons/TaxonomyIcon.js.map +1 -1
- package/lib/icons/UsersIcon.js +11 -14
- package/lib/icons/UsersIcon.js.map +1 -1
- package/lib/icons/index.js +8 -9
- package/lib/icons/index.js.map +1 -1
- package/lib/index.js +88 -121
- package/lib/index.js.map +1 -1
- package/lib/utils/add-content-menu-items.js +67 -93
- package/lib/utils/add-content-menu-items.js.map +1 -1
- package/lib/utils/build-create-entity-mutation.js +5 -18
- package/lib/utils/build-create-entity-mutation.js.map +1 -1
- package/lib/utils/build-delete-entity-mutation.js +11 -8
- package/lib/utils/build-delete-entity-mutation.js.map +1 -1
- package/lib/utils/build-listing-query.js +20 -17
- package/lib/utils/build-listing-query.js.map +1 -1
- package/lib/utils/build-update-data-query.js +15 -9
- package/lib/utils/build-update-data-query.js.map +1 -1
- package/lib/utils/build-update-publish-unpublish-mutation.js +15 -8
- package/lib/utils/build-update-publish-unpublish-mutation.js.map +1 -1
- package/lib/utils/get-default-query-params.js +23 -10
- package/lib/utils/get-default-query-params.js.map +1 -1
- package/lib/utils/hoc/withContext.js +4 -6
- package/lib/utils/hoc/withContext.js.map +1 -1
- package/lib/utils/hooks/useToggle.js +4 -12
- package/lib/utils/hooks/useToggle.js.map +1 -1
- package/lib/utils/index.js +2 -3
- package/lib/utils/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/Entity.js +23 -30
- package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +6 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +2 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +26 -7
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +8 -2
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/create/submit.js +4 -14
- package/lib-es/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
- package/lib-es/components/EntityManager/utils/entity.js +8 -5
- package/lib-es/components/EntityManager/utils/entity.js.map +1 -1
- package/lib-es/components/InfoBoxes/InfoBoxTooltip.js +36 -0
- package/lib-es/components/InfoBoxes/InfoBoxTooltip.js.map +1 -0
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js +2 -0
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js +4 -1
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTable.js +12 -11
- package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +34 -16
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.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 +496 -0
- package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -0
- package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js +44 -0
- package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -0
- package/lib-es/components/ListingTable/SearchFilter/helpers.js +127 -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/mappers/populate-rows.js +3 -0
- package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
- package/lib-es/components/ListingTable/service/index.js +3 -2
- package/lib-es/components/ListingTable/service/index.js.map +1 -1
- package/lib-es/components/Tabs/index.js +6 -7
- package/lib-es/components/Tabs/index.js.map +1 -1
- package/lib-es/constants.js +4 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/index.js +12 -3
- package/lib-es/index.js.map +1 -1
- package/lib-es/utils/build-create-entity-mutation.js +5 -19
- package/lib-es/utils/build-create-entity-mutation.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/lib-es/utils/get-default-query-params.js +17 -5
- package/lib-es/utils/get-default-query-params.js.map +1 -1
- package/lib-es/utils/hoc/withContext.js +1 -1
- package/lib-es/utils/hoc/withContext.js.map +1 -1
- package/package.json +21 -17
- package/src/components/EntityManager/Entity/Entity.js +35 -40
- package/src/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +8 -1
- package/src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +2 -0
- package/src/components/EntityManager/Entity/SideBarRelations/index.js +51 -17
- package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +5 -3
- package/src/components/EntityManager/Entity/actions-handlers/create/submit.js +4 -11
- package/src/components/EntityManager/utils/entity.js +11 -6
- package/src/components/InfoBoxes/InfoBoxTooltip.js +32 -0
- package/src/components/InfoBoxes/helpers/build-dynamic-query.js +2 -0
- package/src/components/InfoBoxes/presentational/InfoBox.js +4 -2
- package/src/components/ListingTable/ListingTable.js +13 -18
- package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +43 -25
- package/src/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js +160 -0
- package/src/components/ListingTable/SearchFilter/SearchContainer.js +553 -0
- package/src/components/ListingTable/SearchFilter/SearchFilter.js +41 -0
- package/src/components/ListingTable/SearchFilter/helpers.js +146 -0
- package/src/components/ListingTable/SearchFilter/querys.js +9 -0
- package/src/components/ListingTable/mappers/populate-rows.js +3 -0
- package/src/components/ListingTable/service/index.js +2 -2
- package/src/components/Tabs/index.js +17 -21
- package/src/constants.js +9 -1
- package/src/index.js +11 -7
- package/src/utils/build-create-entity-mutation.js +5 -28
- package/src/utils/build-listing-query.js +4 -4
- package/src/utils/get-default-query-params.js +21 -9
- package/src/utils/hoc/withContext.js +5 -4
- package/babel.config.js +0 -3
- package/jest.config.js +0 -5
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { DEFAULT_FILTER_OPTION_LABEL } from '../../../constants';
|
|
2
|
+
|
|
3
|
+
const updateListFilters = (searchTerm, selectedFilters, setListFilters, fields = []) => {
|
|
4
|
+
const filters = [];
|
|
5
|
+
|
|
6
|
+
if (searchTerm) {
|
|
7
|
+
filters.push({
|
|
8
|
+
simple_query_string: {
|
|
9
|
+
query: `${searchTerm}`,
|
|
10
|
+
default_operator: 'AND',
|
|
11
|
+
fields: fields.map(field => field)
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Object.entries(selectedFilters).forEach(([filterKey, filterValue]) => {
|
|
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
|
+
});
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
filters.push({
|
|
40
|
+
term: { [field]: filterValue }
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
setListFilters(filters);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const getKeywordSearchFilters = schema => {
|
|
49
|
+
if (!schema || !schema.properties) return [];
|
|
50
|
+
|
|
51
|
+
const { properties = {}, dynamicProperties = {} } = schema;
|
|
52
|
+
|
|
53
|
+
const propertyKeyword = Object.entries(properties).filter(isFilterKeywordItem);
|
|
54
|
+
const dynamicPropertyKeywords = Object.entries(dynamicProperties).filter(isFilterKeywordItem);
|
|
55
|
+
|
|
56
|
+
return [...propertyKeyword, ...dynamicPropertyKeywords];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const isFilterKeywordItem = ([, item]) =>
|
|
60
|
+
item.adminListingOptions && item.adminListingOptions.includeInKeywordSeach === true;
|
|
61
|
+
|
|
62
|
+
const findSelectFilters = schema => {
|
|
63
|
+
if (!schema || !schema.properties) return [];
|
|
64
|
+
|
|
65
|
+
const { properties = {}, dynamicProperties = {} } = schema;
|
|
66
|
+
|
|
67
|
+
const propertySelects = Object.entries(properties).filter(isFilterSelectItem);
|
|
68
|
+
const dynamicPropertySelects = Object.entries(dynamicProperties).filter(isFilterSelectItem);
|
|
69
|
+
|
|
70
|
+
return [...propertySelects, ...dynamicPropertySelects];
|
|
71
|
+
};
|
|
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
|
+
|
|
83
|
+
const isFilterSelectItem = ([, item]) =>
|
|
84
|
+
item.adminListingOptions && item.adminListingOptions.filterType === 'select';
|
|
85
|
+
|
|
86
|
+
const isFilterMultiSelectItems = ([, item]) =>
|
|
87
|
+
item.adminListingOptions && item.adminListingOptions.filterType === 'multiSelect';
|
|
88
|
+
|
|
89
|
+
const buildQueryFields = (selectFilters, entityId) => {
|
|
90
|
+
if (!Array.isArray(selectFilters) || selectFilters.length === 0) {
|
|
91
|
+
return { gqlFields: '', rawQuery: '{}' };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const aggs = {};
|
|
95
|
+
selectFilters.forEach(([property, details]) => {
|
|
96
|
+
aggs[property] = {
|
|
97
|
+
terms: {
|
|
98
|
+
field: `${property}.keyword`, // todo: handle different field types
|
|
99
|
+
size: 1000, // todo: customise size
|
|
100
|
+
order: {
|
|
101
|
+
_key: 'asc'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const docType = entityId;
|
|
108
|
+
const rawQueryObject = {
|
|
109
|
+
size: 0,
|
|
110
|
+
query: {
|
|
111
|
+
bool: {
|
|
112
|
+
filter: {
|
|
113
|
+
bool: {
|
|
114
|
+
must: [{ match: { docType } }]
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
aggs
|
|
120
|
+
};
|
|
121
|
+
const rawQuery = JSON.stringify(rawQueryObject);
|
|
122
|
+
|
|
123
|
+
const gqlFields = `
|
|
124
|
+
rawResults
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
return { gqlFields, rawQuery };
|
|
128
|
+
};
|
|
129
|
+
|
|
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
|
+
};
|
|
@@ -5,6 +5,7 @@ import TableActions from '../TableActions';
|
|
|
5
5
|
import { ACTIONS } from '../../../constants';
|
|
6
6
|
import InfoBoxValue from '../../InfoBoxes/presentational/InfoBoxValue';
|
|
7
7
|
import InfoBoxLabel from '../../InfoBoxes/presentational/InfoBoxLabel';
|
|
8
|
+
import InfoBoxTooltip from '../../InfoBoxes/InfoBoxTooltip';
|
|
8
9
|
|
|
9
10
|
const formatRows = ({
|
|
10
11
|
rows,
|
|
@@ -17,6 +18,7 @@ const formatRows = ({
|
|
|
17
18
|
}) =>
|
|
18
19
|
rows.map(data => {
|
|
19
20
|
const editUrl = `${url}/update/${data.id}`;
|
|
21
|
+
|
|
20
22
|
const rowProps = {
|
|
21
23
|
...data,
|
|
22
24
|
[firstColumn]: (
|
|
@@ -65,6 +67,7 @@ const buildArrayRowContent = rowData => (
|
|
|
65
67
|
</span>
|
|
66
68
|
<span className="table-row-list__group__item__value">
|
|
67
69
|
<InfoBoxValue item={item} />
|
|
70
|
+
<InfoBoxTooltip info={item} />
|
|
68
71
|
</span>
|
|
69
72
|
</div>
|
|
70
73
|
))}
|
|
@@ -34,11 +34,11 @@ function buildVariables({ entitySchema, isSearchQuery, listFilters = [], queryPa
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const fetchData = async ({ client, querySettings: { entitySchema, queryParams }, listFilters }) => {
|
|
37
|
-
const { displayProperties: { adminListings: { dataSource: { source } = {} } = {} } = {} } =
|
|
37
|
+
const { displayProperties: { adminListings: { dataSource: { source, index } = {} } = {} } = {} } =
|
|
38
38
|
entitySchema;
|
|
39
39
|
|
|
40
40
|
const isSearchQuery = source === 'search';
|
|
41
|
-
const query = buildListingQuery(entitySchema, isSearchQuery);
|
|
41
|
+
const query = buildListingQuery(entitySchema, index, isSearchQuery);
|
|
42
42
|
const variables = buildVariables({ entitySchema, listFilters, queryParams, isSearchQuery });
|
|
43
43
|
|
|
44
44
|
const { data = {} } = await client.query({
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Tab, TabItem } from '@blaze-react/tab';
|
|
4
|
-
import {
|
|
5
|
-
useReadFromCache,
|
|
6
|
-
GET_CURRENT_TAB_ID,
|
|
7
|
-
TabsContextProvider
|
|
8
|
-
} from '@blaze-cms/admin-ui-utils';
|
|
4
|
+
import { useTabsContext, TabsContextProvider } from '@blaze-cms/admin-ui-utils';
|
|
9
5
|
import {
|
|
10
6
|
PAGE_BUILDER_TAB,
|
|
11
7
|
PAGE_BUILDER_TAB_INDEX,
|
|
@@ -14,25 +10,25 @@ import {
|
|
|
14
10
|
} from '../../constants';
|
|
15
11
|
|
|
16
12
|
const Tabs = ({ children, onTabChange, enabled }) => {
|
|
17
|
-
const { currentTabId } =
|
|
13
|
+
const { currentTabId = EDITOR_VIEW_TAB_INDEX } = useTabsContext() || {};
|
|
18
14
|
const [activeAccordions, setActiveAccordions] = useState([]);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<>{children}</>
|
|
15
|
+
|
|
16
|
+
if (!enabled) return children;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<TabsContextProvider value={{ currentTabId, activeAccordions, setActiveAccordions }}>
|
|
20
|
+
<Tab selected={currentTabId}>
|
|
21
|
+
<TabItem title={EDITOR_VIEW_TAB} action={() => onTabChange(EDITOR_VIEW_TAB_INDEX)}>
|
|
22
|
+
{children}
|
|
23
|
+
</TabItem>
|
|
24
|
+
<TabItem title={PAGE_BUILDER_TAB} action={() => onTabChange(PAGE_BUILDER_TAB_INDEX)}>
|
|
25
|
+
{children}
|
|
26
|
+
</TabItem>
|
|
27
|
+
</Tab>
|
|
28
|
+
</TabsContextProvider>
|
|
34
29
|
);
|
|
35
30
|
};
|
|
31
|
+
|
|
36
32
|
Tabs.propTypes = {
|
|
37
33
|
children: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.object)]).isRequired,
|
|
38
34
|
onTabChange: PropTypes.func.isRequired,
|
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,8 +38,12 @@ const ICON_COLOR = {
|
|
|
36
38
|
FILL: '#63779C'
|
|
37
39
|
};
|
|
38
40
|
|
|
41
|
+
const DEFAULT_FILTER_OPTION_LABEL = 'Any';
|
|
42
|
+
const DEBUG_PARAM = 'blaze_debug=1';
|
|
43
|
+
|
|
39
44
|
export {
|
|
40
45
|
DATA_LISTING_PREFIX,
|
|
46
|
+
DEBUG_PARAM,
|
|
41
47
|
ENTITY_PUBLISHED,
|
|
42
48
|
KEY_TO_CHECK,
|
|
43
49
|
LEAVE_PAGE_MESSAGE,
|
|
@@ -63,5 +69,7 @@ export {
|
|
|
63
69
|
SAVE_BEFORE_PUBLISH_MESSAGE,
|
|
64
70
|
ICON_SIZE,
|
|
65
71
|
ICON_COLOR,
|
|
66
|
-
PAGE_NOT_FOUND
|
|
72
|
+
PAGE_NOT_FOUND,
|
|
73
|
+
ENTER_KEY,
|
|
74
|
+
DEFAULT_FILTER_OPTION_LABEL
|
|
67
75
|
};
|
package/src/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { getFormBuilderLookup, formFieldTypes } from '@blaze-cms/react-form-builder';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import pkg from '../package.json';
|
|
4
3
|
import { DATA_LISTING_PREFIX, PLUGIN_NAME } from './constants';
|
|
5
4
|
import getAddContentMenuItems from './utils/add-content-menu-items';
|
|
6
5
|
import { UserIcon, TaxonomyIcon, ContentIcon, SettingsIcon } from './icons';
|
|
6
|
+
import EntityDataListing from './components/EntityDataListing';
|
|
7
|
+
import EntityManager from './components/EntityManager';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
9
|
+
// todo: renable lazy loading after bundler optimisations, currently they are too slow in dev mode
|
|
10
|
+
// const EntityDataListing = React.lazy(
|
|
11
|
+
// () => import(/* webpackChunkName: 'EntityDataListing' */ './components/EntityDataListing')
|
|
12
|
+
// );
|
|
13
|
+
// const EntityManager = React.lazy(
|
|
14
|
+
// () => import(/* webpackChunkName: 'EntityManager' */ './components/EntityManager')
|
|
15
|
+
// );
|
|
16
|
+
|
|
17
|
+
export { default as SearchFilter } from './components/ListingTable/SearchFilter/SearchFilter';
|
|
14
18
|
|
|
15
19
|
export default async function load(app) {
|
|
16
20
|
app.events.once('admin:menu:config:load', getAddContentMenuItems(app));
|
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BlazeError } from '@blaze-cms/core-errors';
|
|
3
|
-
import upperfirst from 'lodash.upperfirst';
|
|
4
|
-
import { getDataProperties } from '@blaze-cms/admin-ui-utils';
|
|
1
|
+
import { getDynamicMutation } from '@blaze-cms/admin-ui-utils';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
!entitySchema.actions.create ||
|
|
11
|
-
!entitySchema.properties
|
|
12
|
-
) {
|
|
13
|
-
throw new BlazeError(
|
|
14
|
-
'Create entity query requires create action and properties from entity schema'
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const actionInput = upperfirst(`${entitySchema.actions.create}Input`);
|
|
19
|
-
const dataProperties = getDataProperties(entitySchema);
|
|
20
|
-
|
|
21
|
-
return gql`mutation createEntity($input: ${actionInput}) {
|
|
22
|
-
createdEntity: ${entitySchema.actions.create}(input: $input){
|
|
23
|
-
result {
|
|
24
|
-
id,
|
|
25
|
-
${dataProperties.join(',\n')}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}`;
|
|
29
|
-
}
|
|
3
|
+
// Kept for back-compat: the builder now lives in the admin-ui-utils dynamic
|
|
4
|
+
// mutation registry so packages that cannot depend on this plugin can use it.
|
|
5
|
+
const buildCreateEntityMutation = entitySchema =>
|
|
6
|
+
getDynamicMutation('CREATE_ENTITY_MUTATION')(entitySchema);
|
|
30
7
|
|
|
31
8
|
export default buildCreateEntityMutation;
|
|
@@ -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);
|
|
@@ -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
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useMainContext, MainContext } from '@blaze-cms/admin-ui-utils';
|
|
3
3
|
|
|
4
|
-
export const withContext = Component =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
4
|
+
export const withContext = Component =>
|
|
5
|
+
function (props) {
|
|
6
|
+
const contexts = useMainContext(MainContext);
|
|
7
|
+
return <Component {...props} {...contexts} />;
|
|
8
|
+
};
|
package/babel.config.js
DELETED