@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,127 @@
|
|
|
1
|
+
import { DEFAULT_FILTER_OPTION_LABEL } from '../../../constants';
|
|
2
|
+
const updateListFilters = (searchTerm, selectedFilters, setListFilters, fields = []) => {
|
|
3
|
+
const filters = [];
|
|
4
|
+
if (searchTerm) {
|
|
5
|
+
filters.push({
|
|
6
|
+
simple_query_string: {
|
|
7
|
+
query: `${searchTerm}`,
|
|
8
|
+
default_operator: 'AND',
|
|
9
|
+
fields: fields.map(field => field)
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
Object.entries(selectedFilters).forEach(([filterKey, filterValue]) => {
|
|
14
|
+
const isEmptyArray = Array.isArray(filterValue) && filterValue.length === 0;
|
|
15
|
+
if (filterValue == null || filterValue === '' || filterValue === DEFAULT_FILTER_OPTION_LABEL || isEmptyArray) return;
|
|
16
|
+
const field = `${filterKey}.keyword`;
|
|
17
|
+
if (Array.isArray(filterValue)) {
|
|
18
|
+
if (filterValue.length > 1) {
|
|
19
|
+
filters.push({
|
|
20
|
+
terms: {
|
|
21
|
+
[field]: filterValue
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
filters.push({
|
|
26
|
+
term: {
|
|
27
|
+
[field]: filterValue[0]
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
filters.push({
|
|
33
|
+
term: {
|
|
34
|
+
[field]: filterValue
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
setListFilters(filters);
|
|
40
|
+
};
|
|
41
|
+
const getKeywordSearchFilters = schema => {
|
|
42
|
+
if (!schema || !schema.properties) return [];
|
|
43
|
+
const {
|
|
44
|
+
properties = {},
|
|
45
|
+
dynamicProperties = {}
|
|
46
|
+
} = schema;
|
|
47
|
+
const propertyKeyword = Object.entries(properties).filter(isFilterKeywordItem);
|
|
48
|
+
const dynamicPropertyKeywords = Object.entries(dynamicProperties).filter(isFilterKeywordItem);
|
|
49
|
+
return [...propertyKeyword, ...dynamicPropertyKeywords];
|
|
50
|
+
};
|
|
51
|
+
const isFilterKeywordItem = ([, item]) => item.adminListingOptions && item.adminListingOptions.includeInKeywordSeach === true;
|
|
52
|
+
const findSelectFilters = schema => {
|
|
53
|
+
if (!schema || !schema.properties) return [];
|
|
54
|
+
const {
|
|
55
|
+
properties = {},
|
|
56
|
+
dynamicProperties = {}
|
|
57
|
+
} = schema;
|
|
58
|
+
const propertySelects = Object.entries(properties).filter(isFilterSelectItem);
|
|
59
|
+
const dynamicPropertySelects = Object.entries(dynamicProperties).filter(isFilterSelectItem);
|
|
60
|
+
return [...propertySelects, ...dynamicPropertySelects];
|
|
61
|
+
};
|
|
62
|
+
const findMultiSelectFilters = schema => {
|
|
63
|
+
if (!schema || !schema.properties) return [];
|
|
64
|
+
const {
|
|
65
|
+
properties = {},
|
|
66
|
+
dynamicProperties = {}
|
|
67
|
+
} = schema;
|
|
68
|
+
const propertyMultiSelect = Object.entries(properties).filter(isFilterMultiSelectItems);
|
|
69
|
+
const dynamicPropertyMultiSelect = Object.entries(dynamicProperties).filter(isFilterMultiSelectItems);
|
|
70
|
+
return [...propertyMultiSelect, ...dynamicPropertyMultiSelect];
|
|
71
|
+
};
|
|
72
|
+
const isFilterSelectItem = ([, item]) => item.adminListingOptions && item.adminListingOptions.filterType === 'select';
|
|
73
|
+
const isFilterMultiSelectItems = ([, item]) => item.adminListingOptions && item.adminListingOptions.filterType === 'multiSelect';
|
|
74
|
+
const buildQueryFields = (selectFilters, entityId) => {
|
|
75
|
+
if (!Array.isArray(selectFilters) || selectFilters.length === 0) {
|
|
76
|
+
return {
|
|
77
|
+
gqlFields: '',
|
|
78
|
+
rawQuery: '{}'
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const aggs = {};
|
|
82
|
+
selectFilters.forEach(([property, details]) => {
|
|
83
|
+
aggs[property] = {
|
|
84
|
+
terms: {
|
|
85
|
+
field: `${property}.keyword`,
|
|
86
|
+
// todo: handle different field types
|
|
87
|
+
size: 1000,
|
|
88
|
+
// todo: customise size
|
|
89
|
+
order: {
|
|
90
|
+
_key: 'asc'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
const docType = entityId;
|
|
96
|
+
const rawQueryObject = {
|
|
97
|
+
size: 0,
|
|
98
|
+
query: {
|
|
99
|
+
bool: {
|
|
100
|
+
filter: {
|
|
101
|
+
bool: {
|
|
102
|
+
must: [{
|
|
103
|
+
match: {
|
|
104
|
+
docType
|
|
105
|
+
}
|
|
106
|
+
}]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
aggs
|
|
112
|
+
};
|
|
113
|
+
const rawQuery = JSON.stringify(rawQueryObject);
|
|
114
|
+
const gqlFields = `
|
|
115
|
+
rawResults
|
|
116
|
+
`;
|
|
117
|
+
return {
|
|
118
|
+
gqlFields,
|
|
119
|
+
rawQuery
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
const getTidyLabel = (value, tidy) => {
|
|
123
|
+
if (!tidy) return value;
|
|
124
|
+
return value.split(/[\s_-]+/).map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
|
|
125
|
+
};
|
|
126
|
+
export { buildQueryFields, updateListFilters, getKeywordSearchFilters, findSelectFilters, findMultiSelectFilters, getTidyLabel };
|
|
127
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["DEFAULT_FILTER_OPTION_LABEL","updateListFilters","searchTerm","selectedFilters","setListFilters","fields","filters","push","simple_query_string","query","default_operator","map","field","Object","entries","forEach","filterKey","filterValue","isEmptyArray","Array","isArray","length","terms","term","getKeywordSearchFilters","schema","properties","dynamicProperties","propertyKeyword","filter","isFilterKeywordItem","dynamicPropertyKeywords","item","adminListingOptions","includeInKeywordSeach","findSelectFilters","propertySelects","isFilterSelectItem","dynamicPropertySelects","findMultiSelectFilters","propertyMultiSelect","isFilterMultiSelectItems","dynamicPropertyMultiSelect","filterType","buildQueryFields","selectFilters","entityId","gqlFields","rawQuery","aggs","property","details","size","order","_key","docType","rawQueryObject","bool","must","match","JSON","stringify","getTidyLabel","value","tidy","split","word","charAt","toUpperCase","slice","join"],"sources":["../../../../src/components/ListingTable/SearchFilter/helpers.js"],"sourcesContent":["import { DEFAULT_FILTER_OPTION_LABEL } from '../../../constants';\n\nconst updateListFilters = (searchTerm, selectedFilters, setListFilters, fields = []) => {\n const filters = [];\n\n if (searchTerm) {\n filters.push({\n simple_query_string: {\n query: `${searchTerm}`,\n default_operator: 'AND',\n fields: fields.map(field => field)\n }\n });\n }\n\n Object.entries(selectedFilters).forEach(([filterKey, filterValue]) => {\n const isEmptyArray = Array.isArray(filterValue) && filterValue.length === 0;\n if (\n filterValue == null ||\n filterValue === '' ||\n filterValue === DEFAULT_FILTER_OPTION_LABEL ||\n isEmptyArray\n )\n return;\n\n const field = `${filterKey}.keyword`;\n\n if (Array.isArray(filterValue)) {\n if (filterValue.length > 1) {\n filters.push({\n terms: { [field]: filterValue }\n });\n } else {\n filters.push({\n term: { [field]: filterValue[0] }\n });\n }\n } else {\n filters.push({\n term: { [field]: filterValue }\n });\n }\n });\n\n setListFilters(filters);\n};\n\nconst getKeywordSearchFilters = schema => {\n if (!schema || !schema.properties) return [];\n\n const { properties = {}, dynamicProperties = {} } = schema;\n\n const propertyKeyword = Object.entries(properties).filter(isFilterKeywordItem);\n const dynamicPropertyKeywords = Object.entries(dynamicProperties).filter(isFilterKeywordItem);\n\n return [...propertyKeyword, ...dynamicPropertyKeywords];\n};\n\nconst isFilterKeywordItem = ([, item]) =>\n item.adminListingOptions && item.adminListingOptions.includeInKeywordSeach === true;\n\nconst findSelectFilters = schema => {\n if (!schema || !schema.properties) return [];\n\n const { properties = {}, dynamicProperties = {} } = schema;\n\n const propertySelects = Object.entries(properties).filter(isFilterSelectItem);\n const dynamicPropertySelects = Object.entries(dynamicProperties).filter(isFilterSelectItem);\n\n return [...propertySelects, ...dynamicPropertySelects];\n};\n\nconst findMultiSelectFilters = schema => {\n if (!schema || !schema.properties) return [];\n\n const { properties = {}, dynamicProperties = {} } = schema;\n const propertyMultiSelect = Object.entries(properties).filter(isFilterMultiSelectItems);\n const dynamicPropertyMultiSelect =\n Object.entries(dynamicProperties).filter(isFilterMultiSelectItems);\n return [...propertyMultiSelect, ...dynamicPropertyMultiSelect];\n};\n\nconst isFilterSelectItem = ([, item]) =>\n item.adminListingOptions && item.adminListingOptions.filterType === 'select';\n\nconst isFilterMultiSelectItems = ([, item]) =>\n item.adminListingOptions && item.adminListingOptions.filterType === 'multiSelect';\n\nconst buildQueryFields = (selectFilters, entityId) => {\n if (!Array.isArray(selectFilters) || selectFilters.length === 0) {\n return { gqlFields: '', rawQuery: '{}' };\n }\n\n const aggs = {};\n selectFilters.forEach(([property, details]) => {\n aggs[property] = {\n terms: {\n field: `${property}.keyword`, // todo: handle different field types\n size: 1000, // todo: customise size\n order: {\n _key: 'asc'\n }\n }\n };\n });\n\n const docType = entityId;\n const rawQueryObject = {\n size: 0,\n query: {\n bool: {\n filter: {\n bool: {\n must: [{ match: { docType } }]\n }\n }\n }\n },\n aggs\n };\n const rawQuery = JSON.stringify(rawQueryObject);\n\n const gqlFields = `\n rawResults\n `;\n\n return { gqlFields, rawQuery };\n};\n\nconst getTidyLabel = (value, tidy) => {\n if (!tidy) return value;\n\n return value\n .split(/[\\s_-]+/)\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n};\n\nexport {\n buildQueryFields,\n updateListFilters,\n getKeywordSearchFilters,\n findSelectFilters,\n findMultiSelectFilters,\n getTidyLabel\n};\n"],"mappings":"AAAA,SAASA,2BAA2B,QAAQ,oBAAoB;AAEhE,MAAMC,iBAAiB,GAAGA,CAACC,UAAU,EAAEC,eAAe,EAAEC,cAAc,EAAEC,MAAM,GAAG,EAAE,KAAK;EACtF,MAAMC,OAAO,GAAG,EAAE;EAElB,IAAIJ,UAAU,EAAE;IACdI,OAAO,CAACC,IAAI,CAAC;MACXC,mBAAmB,EAAE;QACnBC,KAAK,EAAE,GAAGP,UAAU,EAAE;QACtBQ,gBAAgB,EAAE,KAAK;QACvBL,MAAM,EAAEA,MAAM,CAACM,GAAG,CAACC,KAAK,IAAIA,KAAK;MACnC;IACF,CAAC,CAAC;EACJ;EAEAC,MAAM,CAACC,OAAO,CAACX,eAAe,CAAC,CAACY,OAAO,CAAC,CAAC,CAACC,SAAS,EAAEC,WAAW,CAAC,KAAK;IACpE,MAAMC,YAAY,GAAGC,KAAK,CAACC,OAAO,CAACH,WAAW,CAAC,IAAIA,WAAW,CAACI,MAAM,KAAK,CAAC;IAC3E,IACEJ,WAAW,IAAI,IAAI,IACnBA,WAAW,KAAK,EAAE,IAClBA,WAAW,KAAKjB,2BAA2B,IAC3CkB,YAAY,EAEZ;IAEF,MAAMN,KAAK,GAAG,GAAGI,SAAS,UAAU;IAEpC,IAAIG,KAAK,CAACC,OAAO,CAACH,WAAW,CAAC,EAAE;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AChB3C,iBAAiB,EACjBuB,uBAAuB,EACvBW,iBAAiB,EACjBI,sBAAsB,EACtBuB,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"querys.js","names":["gql","NOOP_QUERY"],"sources":["../../../../src/components/ListingTable/SearchFilter/querys.js"],"sourcesContent":["import { gql } from '@apollo/client';\n\nconst NOOP_QUERY = gql`\n query NoOp {\n __typename\n }\n`;\n\nexport { NOOP_QUERY };\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AAEpC,MAAMC,UAAU,GAAGD,GAAG;AACtB;AACA;AACA;AACA,CAAC;AAED,SAASC,UAAU","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ import TableActions from '../TableActions';
|
|
|
8
8
|
import { ACTIONS } from '../../../constants';
|
|
9
9
|
import InfoBoxValue from '../../InfoBoxes/presentational/InfoBoxValue';
|
|
10
10
|
import InfoBoxLabel from '../../InfoBoxes/presentational/InfoBoxLabel';
|
|
11
|
+
import InfoBoxTooltip from '../../InfoBoxes/InfoBoxTooltip';
|
|
11
12
|
const formatRows = ({
|
|
12
13
|
rows,
|
|
13
14
|
url,
|
|
@@ -60,6 +61,8 @@ const buildArrayRowContent = rowData => /*#__PURE__*/React.createElement("div",
|
|
|
60
61
|
className: "table-row-list__group__item__value"
|
|
61
62
|
}, /*#__PURE__*/React.createElement(InfoBoxValue, {
|
|
62
63
|
item: item
|
|
64
|
+
}), /*#__PURE__*/React.createElement(InfoBoxTooltip, {
|
|
65
|
+
info: item
|
|
63
66
|
})))));
|
|
64
67
|
}));
|
|
65
68
|
const buildArrayRowData = rowData => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populate-rows.js","names":["React","Link","RenderHook","TableActions","ACTIONS","InfoBoxValue","InfoBoxLabel","formatRows","rows","url","toggleModal","label","firstColumn","isEnquiry","entitySchema","map","data","editUrl","id","rowProps","_objectSpread","createElement","Fragment","to","role","hookKey","schema","value","column","actions","showDeleteModal","getSanitizedColumnLabel","columnProp","sanitizedChar","index","length","toUpperCase","toLowerCase","buildArrayRowContent","rowData","className","rowGroup","item","buildArrayRowData","groupSize","Math","ceil","group1","slice","group2","group3","dataGroups","getParsedRowData","Object","keys","reduce","acc","key","parsedData","Array","isArray","getColumnsAndLabels","listingProperties","allProperties","columns","labels","forEach","listingProperty","propKey","includes","split","push","parsedRowData","populateRows","schemaId","properties","dynamicProperties","formProperties","columnOptions","identification","sort","orderBy"],"sources":["../../../../src/components/ListingTable/mappers/populate-rows.js"],"sourcesContent":["import React from 'react';\nimport { Link } from 'react-router-dom';\nimport { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';\nimport TableActions from '../TableActions';\nimport { ACTIONS } from '../../../constants';\nimport InfoBoxValue from '../../InfoBoxes/presentational/InfoBoxValue';\nimport InfoBoxLabel from '../../InfoBoxes/presentational/InfoBoxLabel';\n\nconst formatRows = ({\n rows,\n url,\n toggleModal,\n label,\n firstColumn = 'name',\n isEnquiry,\n entitySchema\n}) =>\n rows.map(data => {\n const editUrl = `${url}/update/${data.id}`;\n const rowProps = {\n ...data,\n [firstColumn]: (\n <>\n <Link to={editUrl} role=\"button\">\n {data[firstColumn]}\n </Link>\n <RenderHook\n hookKey=\"entity:listing:table:row:column:after\"\n schema={entitySchema}\n data={data}\n value={data[firstColumn]}\n column={firstColumn}\n />\n </>\n )\n };\n if (!isEnquiry)\n rowProps.actions = (\n <TableActions editUrl={editUrl} data={data} showDeleteModal={toggleModal} />\n );\n return rowProps;\n });\n\nconst getSanitizedColumnLabel = columnProp => {\n let sanitizedChar = '';\n\n for (let index = 0; index < columnProp.length; index += 1) {\n if (index && columnProp[index] === columnProp[index].toUpperCase())\n sanitizedChar = `${sanitizedChar} ${columnProp[index].toLowerCase()}`;\n else sanitizedChar += columnProp[index];\n }\n return sanitizedChar;\n};\n\nconst buildArrayRowContent = rowData => (\n <div className=\"table-row-list\">\n {rowData.map(rowGroup => {\n if (!rowGroup.length) return null;\n return (\n <div className=\"table-row-list__group\">\n {rowGroup.map(item => (\n <div className=\"table-row-list__group__item\">\n <span className=\"table-row-list__group__item__label\">\n <InfoBoxLabel item={item} />\n </span>\n <span className=\"table-row-list__group__item__value\">\n <InfoBoxValue item={item} />\n </span>\n </div>\n ))}\n </div>\n );\n })}\n </div>\n);\n\nconst buildArrayRowData = rowData => {\n const groupSize = Math.ceil(rowData.length / 3);\n const group1 = rowData.slice(0, groupSize);\n const group2 = rowData.slice(groupSize, groupSize * 2);\n const group3 = rowData.slice(groupSize * 2);\n const dataGroups = [group1, group2, group3];\n\n return buildArrayRowContent(dataGroups);\n};\n\nconst getParsedRowData = rows =>\n rows.map(rowData =>\n Object.keys(rowData).reduce((acc, key) => {\n const parsedData = Array.isArray(rowData[key])\n ? buildArrayRowData(rowData[key])\n : rowData[key];\n return { ...acc, [key]: parsedData };\n }, {})\n );\n\nconst getColumnsAndLabels = (listingProperties, allProperties, rows) => {\n const columns = [];\n const labels = {};\n\n listingProperties.forEach(listingProperty => {\n const propKey = listingProperty.includes(' ') ? listingProperty.split(' ')[0] : listingProperty;\n const { label } = allProperties[propKey] || {};\n columns.push(propKey);\n labels[propKey] = label || getSanitizedColumnLabel(propKey);\n });\n const parsedRowData = getParsedRowData(rows);\n\n return { columns, labels, parsedRowData };\n};\n\nconst populateRows = ({ toggleModal, url, entitySchema, rows }) => {\n const {\n id: schemaId,\n listingProperties,\n properties,\n dynamicProperties = {},\n formProperties\n } = entitySchema;\n\n const isEnquiry = schemaId === 'enquiry';\n const columnOptions = !isEnquiry ? [...listingProperties, ACTIONS] : [...listingProperties];\n\n const allProperties = { ...properties, ...dynamicProperties };\n const { columns, labels, parsedRowData } = getColumnsAndLabels(\n columnOptions,\n allProperties,\n rows\n );\n const [firstColumn] = columns;\n\n return {\n identification: 'id',\n sort: null,\n columns,\n labels,\n orderBy: [...formProperties],\n rows: formatRows({\n firstColumn,\n rows: parsedRowData,\n url,\n toggleModal,\n isEnquiry,\n entitySch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AAG;MACHC,WAAW;MACXG,SAAS;MACTC;IACF,CAAC,CAAC;IACFD;EACF,CAAC;AACH,CAAC;AAED,SAAS4D,YAAY,EAAElE,UAAU,EAAE6C,gBAAgB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"populate-rows.js","names":["React","Link","RenderHook","TableActions","ACTIONS","InfoBoxValue","InfoBoxLabel","InfoBoxTooltip","formatRows","rows","url","toggleModal","label","firstColumn","isEnquiry","entitySchema","map","data","editUrl","id","rowProps","_objectSpread","createElement","Fragment","to","role","hookKey","schema","value","column","actions","showDeleteModal","getSanitizedColumnLabel","columnProp","sanitizedChar","index","length","toUpperCase","toLowerCase","buildArrayRowContent","rowData","className","rowGroup","item","info","buildArrayRowData","groupSize","Math","ceil","group1","slice","group2","group3","dataGroups","getParsedRowData","Object","keys","reduce","acc","key","parsedData","Array","isArray","getColumnsAndLabels","listingProperties","allProperties","columns","labels","forEach","listingProperty","propKey","includes","split","push","parsedRowData","populateRows","schemaId","properties","dynamicProperties","formProperties","columnOptions","identification","sort","orderBy"],"sources":["../../../../src/components/ListingTable/mappers/populate-rows.js"],"sourcesContent":["import React from 'react';\nimport { Link } from 'react-router-dom';\nimport { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';\nimport TableActions from '../TableActions';\nimport { ACTIONS } from '../../../constants';\nimport InfoBoxValue from '../../InfoBoxes/presentational/InfoBoxValue';\nimport InfoBoxLabel from '../../InfoBoxes/presentational/InfoBoxLabel';\nimport InfoBoxTooltip from '../../InfoBoxes/InfoBoxTooltip';\n\nconst formatRows = ({\n rows,\n url,\n toggleModal,\n label,\n firstColumn = 'name',\n isEnquiry,\n entitySchema\n}) =>\n rows.map(data => {\n const editUrl = `${url}/update/${data.id}`;\n\n const rowProps = {\n ...data,\n [firstColumn]: (\n <>\n <Link to={editUrl} role=\"button\">\n {data[firstColumn]}\n </Link>\n <RenderHook\n hookKey=\"entity:listing:table:row:column:after\"\n schema={entitySchema}\n data={data}\n value={data[firstColumn]}\n column={firstColumn}\n />\n </>\n )\n };\n if (!isEnquiry)\n rowProps.actions = (\n <TableActions editUrl={editUrl} data={data} showDeleteModal={toggleModal} />\n );\n return rowProps;\n });\n\nconst getSanitizedColumnLabel = columnProp => {\n let sanitizedChar = '';\n\n for (let index = 0; index < columnProp.length; index += 1) {\n if (index && columnProp[index] === columnProp[index].toUpperCase())\n sanitizedChar = `${sanitizedChar} ${columnProp[index].toLowerCase()}`;\n else sanitizedChar += columnProp[index];\n }\n return sanitizedChar;\n};\n\nconst buildArrayRowContent = rowData => (\n <div className=\"table-row-list\">\n {rowData.map(rowGroup => {\n if (!rowGroup.length) return null;\n return (\n <div className=\"table-row-list__group\">\n {rowGroup.map(item => (\n <div className=\"table-row-list__group__item\">\n <span className=\"table-row-list__group__item__label\">\n <InfoBoxLabel item={item} />\n </span>\n <span className=\"table-row-list__group__item__value\">\n <InfoBoxValue item={item} />\n <InfoBoxTooltip info={item} />\n </span>\n </div>\n ))}\n </div>\n );\n })}\n </div>\n);\n\nconst buildArrayRowData = rowData => {\n const groupSize = Math.ceil(rowData.length / 3);\n const group1 = rowData.slice(0, groupSize);\n const group2 = rowData.slice(groupSize, groupSize * 2);\n const group3 = rowData.slice(groupSize * 2);\n const dataGroups = [group1, group2, group3];\n\n return buildArrayRowContent(dataGroups);\n};\n\nconst getParsedRowData = rows =>\n rows.map(rowData =>\n Object.keys(rowData).reduce((acc, key) => {\n const parsedData = Array.isArray(rowData[key])\n ? buildArrayRowData(rowData[key])\n : rowData[key];\n return { ...acc, [key]: parsedData };\n }, {})\n );\n\nconst getColumnsAndLabels = (listingProperties, allProperties, rows) => {\n const columns = [];\n const labels = {};\n\n listingProperties.forEach(listingProperty => {\n const propKey = listingProperty.includes(' ') ? listingProperty.split(' ')[0] : listingProperty;\n const { label } = allProperties[propKey] || {};\n columns.push(propKey);\n labels[propKey] = label || getSanitizedColumnLabel(propKey);\n });\n const parsedRowData = getParsedRowData(rows);\n\n return { columns, labels, parsedRowData };\n};\n\nconst populateRows = ({ toggleModal, url, entitySchema, rows }) => {\n const {\n id: schemaId,\n listingProperties,\n properties,\n dynamicProperties = {},\n formProperties\n } = entitySchema;\n\n const isEnquiry = schemaId === 'enquiry';\n const columnOptions = !isEnquiry ? [...listingProperties, ACTIONS] : [...listingProperties];\n\n const allProperties = { ...properties, ...dynamicProperties };\n const { columns, labels, parsedRowData } = getColumnsAndLabels(\n columnOptions,\n allProperties,\n rows\n );\n const [firstColumn] = columns;\n\n return {\n identification: 'id',\n sort: null,\n columns,\n labels,\n orderBy: [...formProperties],\n rows: formatRows({\n firstColumn,\n rows: parsedRowData,\n url,\n toggleModal,\n isEnquiry,\n entitySchema\n }),\n isEnquiry\n };\n};\n\nexport { populateRows, formatRows, getParsedRowData };\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,kBAAkB;AACvC,SAASC,UAAU,QAAQ,mCAAmC;AAC9D,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,OAAOC,YAAY,MAAM,6CAA6C;AACtE,OAAOC,YAAY,MAAM,6CAA6C;AACtE,OAAOC,cAAc,MAAM,gCAAgC;AAE3D,MAAMC,UAAU,GAAGA,CAAC;EAClBC,IAAI;EACJC,GAAG;EACHC,WAAW;EACXC,KAAK;EACLC,WAAW,GAAG,MAAM;EACpBC,SAAS;EACTC;AACF,CAAC,KACCN,IAAI,CAACO,GAAG,CAACC,IAAI,IAAI;EACf,MAAMC,OAAO,GAAG,GAAGR,GAAG,WAAWO,IAAI,CAACE,EAAE,EAAE;EAE1C,MAAMC,QAAQ,GAAAC,aAAA,CAAAA,aAAA,KACTJ,IAAI;IACP,CAACJ,WAAW,gBACVb,KAAA,CAAAsB,aAAA,CAAAtB,KAAA,CAAAuB,QAAA,qBACEvB,KAAA,CAAAsB,aAAA,CAACrB,IAAI;MAACuB,EAAE,EAAEN,OAAQ;MAACO,IAAI,EAAC;IAAQ,GA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B,EAAE5D,OAAO,CAAC,GAAG,CAAC,GAAG4D,iBAAiB,CAAC;EAE3F,MAAMC,aAAa,GAAA5C,aAAA,CAAAA,aAAA,KAAQwD,UAAU,GAAKC,iBAAiB,CAAE;EAC7D,MAAM;IAAEZ,OAAO;IAAEC,MAAM;IAAEO;EAAc,CAAC,GAAGX,mBAAmB,CAC5DiB,aAAa,EACbf,aAAa,EACbxD,IACF,CAAC;EACD,MAAM,CAACI,WAAW,CAAC,GAAGqD,OAAO;EAE7B,OAAO;IACLe,cAAc,EAAE,IAAI;IACpBC,IAAI,EAAE,IAAI;IACVhB,OAAO;IACPC,MAAM;IACNgB,OAAO,EAAE,CAAC,GAAGJ,cAAc,CAAC;IAC5BtE,IAAI,EAAED,UAAU,CAAC;MACfK,WAAW;MACXJ,IAAI,EAAEiE,aAAa;MACnBhE,GAAG;MACHC,WAAW;MACXG,SAAS;MACTC;IACF,CAAC,CAAC;IACFD;EACF,CAAC;AACH,CAAC;AAED,SAAS6D,YAAY,EAAEnE,UAAU,EAAE8C,gBAAgB","ignoreList":[]}
|
|
@@ -54,13 +54,14 @@ const fetchData = async ({
|
|
|
54
54
|
displayProperties: {
|
|
55
55
|
adminListings: {
|
|
56
56
|
dataSource: {
|
|
57
|
-
source
|
|
57
|
+
source,
|
|
58
|
+
index
|
|
58
59
|
} = {}
|
|
59
60
|
} = {}
|
|
60
61
|
} = {}
|
|
61
62
|
} = entitySchema;
|
|
62
63
|
const isSearchQuery = source === 'search';
|
|
63
|
-
const query = buildListingQuery(entitySchema, isSearchQuery);
|
|
64
|
+
const query = buildListingQuery(entitySchema, index, isSearchQuery);
|
|
64
65
|
const variables = buildVariables({
|
|
65
66
|
entitySchema,
|
|
66
67
|
listFilters,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["buildListingQuery","buildVariables","entitySchema","isSearchQuery","listFilters","queryParams","identifier","sort","offset","limit","where","property","direction","parsedOffset","_objectSpread","Array","isArray","rawQuery","bool","must","filter","term","entityIdentifier","JSON","stringify","fetchData","client","querySettings","displayProperties","adminListings","dataSource","source","query","variables","data","fetchPolicy","searchResults","listingData","results","totalRecords","total"],"sources":["../../../../src/components/ListingTable/service/index.js"],"sourcesContent":["import buildListingQuery from '../../../utils/build-listing-query';\n\nfunction buildVariables({ entitySchema, isSearchQuery, listFilters = [], queryParams = {} }) {\n const { identifier } = entitySchema;\n const { sort, offset, limit, where } = queryParams;\n const [{ property, direction }] = sort;\n const parsedOffset = `${property}:${direction}`;\n\n if (!isSearchQuery)\n return {\n ...queryParams,\n where: !Array.isArray(listFilters) ? listFilters : where\n };\n\n const rawQuery = {\n bool: {\n must: listFilters || [],\n filter: [\n {\n term: {\n entityIdentifier: identifier\n }\n }\n ]\n }\n };\n\n return {\n limit,\n offset,\n sort: parsedOffset,\n where: JSON.stringify(rawQuery)\n };\n}\n\nconst fetchData = async ({ client, querySettings: { entitySchema, queryParams }, listFilters }) => {\n const { displayProperties: { adminListings: { dataSource: { source } = {} } = {} } = {} } =\n entitySchema;\n\n const isSearchQuery = source === 'search';\n const query = buildListingQuery(entitySchema, isSearchQuery);\n const variables = buildVariables({ entitySchema, listFilters, queryParams, isSearchQuery });\n\n const { data = {} } = await client.query({\n query,\n variables,\n fetchPolicy: 'network-only'\n });\n\n if (data.searchResults) {\n return {\n listingData: data.searchResults.results,\n totalRecords: data.searchResults.total\n };\n }\n return data;\n};\n\nexport { fetchData };\n"],"mappings":";;;AAAA,OAAOA,iBAAiB,MAAM,oCAAoC;AAElE,SAASC,cAAcA,CAAC;EAAEC,YAAY;EAAEC,aAAa;EAAEC,WAAW,GAAG,EAAE;EAAEC,WAAW,GAAG,CAAC;AAAE,CAAC,EAAE;EAC3F,MAAM;IAAEC;EAAW,CAAC,GAAGJ,YAAY;EACnC,MAAM;IAAEK,IAAI;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGL,WAAW;EAClD,MAAM,CAAC;IAAEM,QAAQ;IAAEC;EAAU,CAAC,CAAC,GAAGL,IAAI;EACtC,MAAMM,YAAY,GAAG,GAAGF,QAAQ,IAAIC,SAAS,EAAE;EAE/C,IAAI,CAACT,aAAa,EAChB,OAAAW,aAAA,CAAAA,aAAA,KACKT,WAAW;IACdK,KAAK,EAAE,CAACK,KAAK,CAACC,OAAO,CAACZ,WAAW,CAAC,GAAGA,WAAW,GAAGM;EAAK;EAG5D,MAAMO,QAAQ,GAAG;IACfC,IAAI,EAAE;MACJC,IAAI,EAAEf,WAAW,IAAI,EAAE;MACvBgB,MAAM,EAAE,CACN;QACEC,IAAI,EAAE;UACJC,gBAAgB,EAAEhB;QACpB;MACF,CAAC;IAEL;EACF,CAAC;EAED,OAAO;IACLG,KAAK;IACLD,MAAM;IACND,IAAI,EAAEM,YAAY;IAClBH,KAAK,EAAEa,IAAI,CAACC,SAAS,CAACP,QAAQ;EAChC,CAAC;AACH;AAEA,MAAMQ,SAAS,GAAG,MAAAA,CAAO;EAAEC,MAAM;EAAEC,aAAa,EAAE;IAAEzB,YAAY;IAAEG;EAAY,CAAC;EAAED;AAAY,CAAC,KAAK;EACjG,MAAM;IAAEwB,iBAAiB,EAAE;MAAEC,aAAa,EAAE;QAAEC,UAAU,EAAE;UAAEC;
|
|
1
|
+
{"version":3,"file":"index.js","names":["buildListingQuery","buildVariables","entitySchema","isSearchQuery","listFilters","queryParams","identifier","sort","offset","limit","where","property","direction","parsedOffset","_objectSpread","Array","isArray","rawQuery","bool","must","filter","term","entityIdentifier","JSON","stringify","fetchData","client","querySettings","displayProperties","adminListings","dataSource","source","index","query","variables","data","fetchPolicy","searchResults","listingData","results","totalRecords","total"],"sources":["../../../../src/components/ListingTable/service/index.js"],"sourcesContent":["import buildListingQuery from '../../../utils/build-listing-query';\n\nfunction buildVariables({ entitySchema, isSearchQuery, listFilters = [], queryParams = {} }) {\n const { identifier } = entitySchema;\n const { sort, offset, limit, where } = queryParams;\n const [{ property, direction }] = sort;\n const parsedOffset = `${property}:${direction}`;\n\n if (!isSearchQuery)\n return {\n ...queryParams,\n where: !Array.isArray(listFilters) ? listFilters : where\n };\n\n const rawQuery = {\n bool: {\n must: listFilters || [],\n filter: [\n {\n term: {\n entityIdentifier: identifier\n }\n }\n ]\n }\n };\n\n return {\n limit,\n offset,\n sort: parsedOffset,\n where: JSON.stringify(rawQuery)\n };\n}\n\nconst fetchData = async ({ client, querySettings: { entitySchema, queryParams }, listFilters }) => {\n const { displayProperties: { adminListings: { dataSource: { source, index } = {} } = {} } = {} } =\n entitySchema;\n\n const isSearchQuery = source === 'search';\n const query = buildListingQuery(entitySchema, index, isSearchQuery);\n const variables = buildVariables({ entitySchema, listFilters, queryParams, isSearchQuery });\n\n const { data = {} } = await client.query({\n query,\n variables,\n fetchPolicy: 'network-only'\n });\n\n if (data.searchResults) {\n return {\n listingData: data.searchResults.results,\n totalRecords: data.searchResults.total\n };\n }\n return data;\n};\n\nexport { fetchData };\n"],"mappings":";;;AAAA,OAAOA,iBAAiB,MAAM,oCAAoC;AAElE,SAASC,cAAcA,CAAC;EAAEC,YAAY;EAAEC,aAAa;EAAEC,WAAW,GAAG,EAAE;EAAEC,WAAW,GAAG,CAAC;AAAE,CAAC,EAAE;EAC3F,MAAM;IAAEC;EAAW,CAAC,GAAGJ,YAAY;EACnC,MAAM;IAAEK,IAAI;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGL,WAAW;EAClD,MAAM,CAAC;IAAEM,QAAQ;IAAEC;EAAU,CAAC,CAAC,GAAGL,IAAI;EACtC,MAAMM,YAAY,GAAG,GAAGF,QAAQ,IAAIC,SAAS,EAAE;EAE/C,IAAI,CAACT,aAAa,EAChB,OAAAW,aAAA,CAAAA,aAAA,KACKT,WAAW;IACdK,KAAK,EAAE,CAACK,KAAK,CAACC,OAAO,CAACZ,WAAW,CAAC,GAAGA,WAAW,GAAGM;EAAK;EAG5D,MAAMO,QAAQ,GAAG;IACfC,IAAI,EAAE;MACJC,IAAI,EAAEf,WAAW,IAAI,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'prop-types';
|
|
3
3
|
import { Tab, TabItem } from '@blaze-react/tab';
|
|
4
|
-
import {
|
|
4
|
+
import { useTabsContext, TabsContextProvider } from '@blaze-cms/admin-ui-utils';
|
|
5
5
|
import { PAGE_BUILDER_TAB, PAGE_BUILDER_TAB_INDEX, EDITOR_VIEW_TAB, EDITOR_VIEW_TAB_INDEX } from '../../constants';
|
|
6
6
|
const Tabs = ({
|
|
7
7
|
children,
|
|
@@ -9,12 +9,11 @@ const Tabs = ({
|
|
|
9
9
|
enabled
|
|
10
10
|
}) => {
|
|
11
11
|
const {
|
|
12
|
-
currentTabId
|
|
13
|
-
} =
|
|
14
|
-
query: GET_CURRENT_TAB_ID
|
|
15
|
-
}) || EDITOR_VIEW_TAB_INDEX;
|
|
12
|
+
currentTabId = EDITOR_VIEW_TAB_INDEX
|
|
13
|
+
} = useTabsContext() || {};
|
|
16
14
|
const [activeAccordions, setActiveAccordions] = useState([]);
|
|
17
|
-
|
|
15
|
+
if (!enabled) return children;
|
|
16
|
+
return /*#__PURE__*/React.createElement(TabsContextProvider, {
|
|
18
17
|
value: {
|
|
19
18
|
currentTabId,
|
|
20
19
|
activeAccordions,
|
|
@@ -28,7 +27,7 @@ const Tabs = ({
|
|
|
28
27
|
}, children), /*#__PURE__*/React.createElement(TabItem, {
|
|
29
28
|
title: PAGE_BUILDER_TAB,
|
|
30
29
|
action: () => onTabChange(PAGE_BUILDER_TAB_INDEX)
|
|
31
|
-
}, children)))
|
|
30
|
+
}, children)));
|
|
32
31
|
};
|
|
33
32
|
Tabs.propTypes = {
|
|
34
33
|
children: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.object)]).isRequired,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useState","PropTypes","Tab","TabItem","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useState","PropTypes","Tab","TabItem","useTabsContext","TabsContextProvider","PAGE_BUILDER_TAB","PAGE_BUILDER_TAB_INDEX","EDITOR_VIEW_TAB","EDITOR_VIEW_TAB_INDEX","Tabs","children","onTabChange","enabled","currentTabId","activeAccordions","setActiveAccordions","createElement","value","selected","title","action","propTypes","oneOfType","object","arrayOf","isRequired","func","bool"],"sources":["../../../src/components/Tabs/index.js"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { Tab, TabItem } from '@blaze-react/tab';\nimport { useTabsContext, TabsContextProvider } from '@blaze-cms/admin-ui-utils';\nimport {\n PAGE_BUILDER_TAB,\n PAGE_BUILDER_TAB_INDEX,\n EDITOR_VIEW_TAB,\n EDITOR_VIEW_TAB_INDEX\n} from '../../constants';\n\nconst Tabs = ({ children, onTabChange, enabled }) => {\n const { currentTabId = EDITOR_VIEW_TAB_INDEX } = useTabsContext() || {};\n const [activeAccordions, setActiveAccordions] = useState([]);\n\n if (!enabled) return children;\n\n return (\n <TabsContextProvider value={{ currentTabId, activeAccordions, setActiveAccordions }}>\n <Tab selected={currentTabId}>\n <TabItem title={EDITOR_VIEW_TAB} action={() => onTabChange(EDITOR_VIEW_TAB_INDEX)}>\n {children}\n </TabItem>\n <TabItem title={PAGE_BUILDER_TAB} action={() => onTabChange(PAGE_BUILDER_TAB_INDEX)}>\n {children}\n </TabItem>\n </Tab>\n </TabsContextProvider>\n );\n};\n\nTabs.propTypes = {\n children: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.object)]).isRequired,\n onTabChange: PropTypes.func.isRequired,\n enabled: PropTypes.bool.isRequired\n};\n\nexport default Tabs;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,GAAG,EAAEC,OAAO,QAAQ,kBAAkB;AAC/C,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,2BAA2B;AAC/E,SACEC,gBAAgB,EAChBC,sBAAsB,EACtBC,eAAe,EACfC,qBAAqB,QAChB,iBAAiB;AAExB,MAAMC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DER_TAB_INDEX = 1;
|
|
28
28
|
const EDITOR_VIEW_TAB = 'Editor view';
|
|
29
29
|
const EDITOR_VIEW_TAB_INDEX = 0;
|
|
30
|
+
const ENTER_KEY = 'Enter';
|
|
30
31
|
const ICON_SIZE = {
|
|
31
32
|
WIDTH: '25px',
|
|
32
33
|
HEIGHT: '25px'
|
|
@@ -35,5 +36,7 @@ const ICON_COLOR = {
|
|
|
35
36
|
STROKE: '#63779C',
|
|
36
37
|
FILL: '#63779C'
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
+
const DEFAULT_FILTER_OPTION_LABEL = 'Any';
|
|
40
|
+
const DEBUG_PARAM = 'blaze_debug=1';
|
|
41
|
+
export { DATA_LISTING_PREFIX, DEBUG_PARAM, ENTITY_PUBLISHED, KEY_TO_CHECK, LEAVE_PAGE_MESSAGE, MENU_PERMISSIONS, PAGE_BUILDER, PLUGIN_NAME, PREVIEW_INTERFACE, SELECT_DEFAULT_VALUE, TEXT_CONTENT_TYPE, PAGE_BUILDER_FIELD_ID, PAGE_BUILDER_TEMPLATE_FIELD_ID, ERROR, SUCCESS, PUBLISHED, UNPUBLISHED, SAVE_BUTTON_TEXTS, ACTIONS, PAGE_BUILDER_TAB_INDEX, EDITOR_VIEW_TAB_INDEX, EDITOR_VIEW_TAB, PAGE_BUILDER_TAB, UNPUBLISHED_WARNING, SAVE_BEFORE_PUBLISH_MESSAGE, ICON_SIZE, ICON_COLOR, PAGE_NOT_FOUND, ENTER_KEY, DEFAULT_FILTER_OPTION_LABEL };
|
|
39
42
|
//# sourceMappingURL=constants.js.map
|
package/lib-es/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["PLUGIN_NAME","DATA_LISTING_PREFIX","PAGE_BUILDER","TEXT_CONTENT_TYPE","ENTITY_PUBLISHED","SELECT_DEFAULT_VALUE","LEAVE_PAGE_MESSAGE","KEY_TO_CHECK","MENU_PERMISSIONS","PREVIEW_INTERFACE","PAGE_BUILDER_FIELD_ID","PAGE_BUILDER_TEMPLATE_FIELD_ID","ERROR","SUCCESS","PUBLISHED","UNPUBLISHED","SAVE_BUTTON_TEXTS","save","saved","saving","ACTIONS","UNPUBLISHED_WARNING","PAGE_NOT_FOUND","SAVE_BEFORE_PUBLISH_MESSAGE","PAGE_BUILDER_TAB","PAGE_BUILDER_TAB_INDEX","EDITOR_VIEW_TAB","EDITOR_VIEW_TAB_INDEX","ICON_SIZE","WIDTH","HEIGHT","ICON_COLOR","STROKE","FILL"],"sources":["../src/constants.js"],"sourcesContent":["const PLUGIN_NAME = 'data-ui';\nconst DATA_LISTING_PREFIX = '/data-listing';\nconst PAGE_BUILDER = 'pageBuilder';\nconst TEXT_CONTENT_TYPE = 'Publish';\nconst ENTITY_PUBLISHED = 'published';\nconst SELECT_DEFAULT_VALUE = 'Please Choose...';\nconst LEAVE_PAGE_MESSAGE = 'You are going to leave without saving. Are you sure you want to leave?';\nconst KEY_TO_CHECK = 'values.slug';\nconst MENU_PERMISSIONS = ['update:any', 'update:own', 'create:any', 'create:own'];\nconst PREVIEW_INTERFACE = 'preview/can-preview';\nconst PAGE_BUILDER_FIELD_ID = 'pageBuilder';\nconst PAGE_BUILDER_TEMPLATE_FIELD_ID = 'pageBuilderTemplateId';\nconst ERROR = 'error';\nconst SUCCESS = 'success';\nconst PUBLISHED = 'published';\nconst UNPUBLISHED = 'unpublished';\nconst SAVE_BUTTON_TEXTS = { save: 'save', saved: 'saved', saving: 'saving' };\nconst ACTIONS = 'actions';\nconst UNPUBLISHED_WARNING = 'Page already unpublished';\nconst PAGE_NOT_FOUND = 'Page not found';\nconst SAVE_BEFORE_PUBLISH_MESSAGE =\n 'You have to click save to create the record before you can publish';\n\nconst PAGE_BUILDER_TAB = 'Page builder';\nconst PAGE_BUILDER_TAB_INDEX = 1;\nconst EDITOR_VIEW_TAB = 'Editor view';\nconst EDITOR_VIEW_TAB_INDEX = 0;\n\nconst ICON_SIZE = {\n WIDTH: '25px',\n HEIGHT: '25px'\n};\n\nconst ICON_COLOR = {\n STROKE: '#63779C',\n FILL: '#63779C'\n};\n\nexport {\n DATA_LISTING_PREFIX,\n ENTITY_PUBLISHED,\n KEY_TO_CHECK,\n LEAVE_PAGE_MESSAGE,\n MENU_PERMISSIONS,\n PAGE_BUILDER,\n PLUGIN_NAME,\n PREVIEW_INTERFACE,\n SELECT_DEFAULT_VALUE,\n TEXT_CONTENT_TYPE,\n PAGE_BUILDER_FIELD_ID,\n PAGE_BUILDER_TEMPLATE_FIELD_ID,\n ERROR,\n SUCCESS,\n PUBLISHED,\n UNPUBLISHED,\n SAVE_BUTTON_TEXTS,\n ACTIONS,\n PAGE_BUILDER_TAB_INDEX,\n EDITOR_VIEW_TAB_INDEX,\n EDITOR_VIEW_TAB,\n PAGE_BUILDER_TAB,\n UNPUBLISHED_WARNING,\n SAVE_BEFORE_PUBLISH_MESSAGE,\n ICON_SIZE,\n ICON_COLOR,\n PAGE_NOT_FOUND\n};\n"],"mappings":"AAAA,MAAMA,WAAW,GAAG,SAAS;AAC7B,MAAMC,mBAAmB,GAAG,eAAe;AAC3C,MAAMC,YAAY,GAAG,aAAa;AAClC,MAAMC,iBAAiB,GAAG,SAAS;AACnC,MAAMC,gBAAgB,GAAG,WAAW;AACpC,MAAMC,oBAAoB,GAAG,kBAAkB;AAC/C,MAAMC,kBAAkB,GAAG,wEAAwE;AACnG,MAAMC,YAAY,GAAG,aAAa;AAClC,MAAMC,gBAAgB,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC;AACjF,MAAMC,iBAAiB,GAAG,qBAAqB;AAC/C,MAAMC,qBAAqB,GAAG,aAAa;AAC3C,MAAMC,8BAA8B,GAAG,uBAAuB;AAC9D,MAAMC,KAAK,GAAG,OAAO;AACrB,MAAMC,OAAO,GAAG,SAAS;AACzB,MAAMC,SAAS,GAAG,WAAW;AAC7B,MAAMC,WAAW,GAAG,aAAa;AACjC,MAAMC,iBAAiB,GAAG;EAAEC,IAAI,EAAE,MAAM;EAAEC,KAAK,EAAE,OAAO;EAAEC,MAAM,EAAE;AAAS,CAAC;AAC5E,MAAMC,OAAO,GAAG,SAAS;AACzB,MAAMC,mBAAmB,GAAG,0BAA0B;AACtD,MAAMC,cAAc,GAAG,gBAAgB;AACvC,MAAMC,2BAA2B,GAC/B,oEAAoE;AAEtE,MAAMC,gBAAgB,GAAG,cAAc;AACvC,MAAMC,sBAAsB,GAAG,CAAC;AAChC,MAAMC,eAAe,GAAG,aAAa;AACrC,MAAMC,qBAAqB,GAAG,CAAC;AAE/B,MAAMC,SAAS,GAAG;EAChBC,KAAK,EAAE,MAAM;EACbC,MAAM,EAAE;AACV,CAAC;AAED,MAAMC,UAAU,GAAG;EACjBC,MAAM,EAAE,SAAS;EACjBC,IAAI,EAAE;AACR,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"constants.js","names":["PLUGIN_NAME","DATA_LISTING_PREFIX","PAGE_BUILDER","TEXT_CONTENT_TYPE","ENTITY_PUBLISHED","SELECT_DEFAULT_VALUE","LEAVE_PAGE_MESSAGE","KEY_TO_CHECK","MENU_PERMISSIONS","PREVIEW_INTERFACE","PAGE_BUILDER_FIELD_ID","PAGE_BUILDER_TEMPLATE_FIELD_ID","ERROR","SUCCESS","PUBLISHED","UNPUBLISHED","SAVE_BUTTON_TEXTS","save","saved","saving","ACTIONS","UNPUBLISHED_WARNING","PAGE_NOT_FOUND","SAVE_BEFORE_PUBLISH_MESSAGE","PAGE_BUILDER_TAB","PAGE_BUILDER_TAB_INDEX","EDITOR_VIEW_TAB","EDITOR_VIEW_TAB_INDEX","ENTER_KEY","ICON_SIZE","WIDTH","HEIGHT","ICON_COLOR","STROKE","FILL","DEFAULT_FILTER_OPTION_LABEL","DEBUG_PARAM"],"sources":["../src/constants.js"],"sourcesContent":["const PLUGIN_NAME = 'data-ui';\nconst DATA_LISTING_PREFIX = '/data-listing';\nconst PAGE_BUILDER = 'pageBuilder';\nconst TEXT_CONTENT_TYPE = 'Publish';\nconst ENTITY_PUBLISHED = 'published';\nconst SELECT_DEFAULT_VALUE = 'Please Choose...';\nconst LEAVE_PAGE_MESSAGE = 'You are going to leave without saving. Are you sure you want to leave?';\nconst KEY_TO_CHECK = 'values.slug';\nconst MENU_PERMISSIONS = ['update:any', 'update:own', 'create:any', 'create:own'];\nconst PREVIEW_INTERFACE = 'preview/can-preview';\nconst PAGE_BUILDER_FIELD_ID = 'pageBuilder';\nconst PAGE_BUILDER_TEMPLATE_FIELD_ID = 'pageBuilderTemplateId';\nconst ERROR = 'error';\nconst SUCCESS = 'success';\nconst PUBLISHED = 'published';\nconst UNPUBLISHED = 'unpublished';\nconst SAVE_BUTTON_TEXTS = { save: 'save', saved: 'saved', saving: 'saving' };\nconst ACTIONS = 'actions';\nconst UNPUBLISHED_WARNING = 'Page already unpublished';\nconst PAGE_NOT_FOUND = 'Page not found';\nconst SAVE_BEFORE_PUBLISH_MESSAGE =\n 'You have to click save to create the record before you can publish';\n\nconst PAGE_BUILDER_TAB = 'Page builder';\nconst PAGE_BUILDER_TAB_INDEX = 1;\nconst EDITOR_VIEW_TAB = 'Editor view';\nconst EDITOR_VIEW_TAB_INDEX = 0;\n\nconst ENTER_KEY = 'Enter';\n\nconst ICON_SIZE = {\n WIDTH: '25px',\n HEIGHT: '25px'\n};\n\nconst ICON_COLOR = {\n STROKE: '#63779C',\n FILL: '#63779C'\n};\n\nconst DEFAULT_FILTER_OPTION_LABEL = 'Any';\nconst DEBUG_PARAM = 'blaze_debug=1';\n\nexport {\n DATA_LISTING_PREFIX,\n DEBUG_PARAM,\n ENTITY_PUBLISHED,\n KEY_TO_CHECK,\n LEAVE_PAGE_MESSAGE,\n MENU_PERMISSIONS,\n PAGE_BUILDER,\n PLUGIN_NAME,\n PREVIEW_INTERFACE,\n SELECT_DEFAULT_VALUE,\n TEXT_CONTENT_TYPE,\n PAGE_BUILDER_FIELD_ID,\n PAGE_BUILDER_TEMPLATE_FIELD_ID,\n ERROR,\n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AMC,eAAe,GAAG,aAAa;AACrC,MAAMC,qBAAqB,GAAG,CAAC;AAE/B,MAAMC,SAAS,GAAG,OAAO;AAEzB,MAAMC,SAAS,GAAG;EAChBC,KAAK,EAAE,MAAM;EACbC,MAAM,EAAE;AACV,CAAC;AAED,MAAMC,UAAU,GAAG;EACjBC,MAAM,EAAE,SAAS;EACjBC,IAAI,EAAE;AACR,CAAC;AAED,MAAMC,2BAA2B,GAAG,KAAK;AACzC,MAAMC,WAAW,GAAG,eAAe;AAEnC,SACEnC,mBAAmB,EACnBmC,WAAW,EACXhC,gBAAgB,EAChBG,YAAY,EACZD,kBAAkB,EAClBE,gBAAgB,EAChBN,YAAY,EACZF,WAAW,EACXS,iBAAiB,EACjBJ,oBAAoB,EACpBF,iBAAiB,EACjBO,qBAAqB,EACrBC,8BAA8B,EAC9BC,KAAK,EACLC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,iBAAiB,EACjBI,OAAO,EACPK,sBAAsB,EACtBE,qBAAqB,EACrBD,eAAe,EACfF,gBAAgB,EAChBH,mBAAmB,EACnBE,2BAA2B,EAC3BM,SAAS,EACTG,UAAU,EACVV,cAAc,EACdM,SAAS,EACTO,2BAA2B","ignoreList":[]}
|
package/lib-es/index.js
CHANGED
|
@@ -1,11 +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';
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import EntityDataListing from './components/EntityDataListing';
|
|
7
|
+
import EntityManager from './components/EntityManager';
|
|
8
|
+
|
|
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';
|
|
9
18
|
export default async function load(app) {
|
|
10
19
|
app.events.once('admin:menu:config:load', getAddContentMenuItems(app));
|
|
11
20
|
app.events.once('load:custom:field:type', addFieldType => {
|
package/lib-es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getFormBuilderLookup","formFieldTypes","
|
|
1
|
+
{"version":3,"file":"index.js","names":["getFormBuilderLookup","formFieldTypes","pkg","DATA_LISTING_PREFIX","PLUGIN_NAME","getAddContentMenuItems","UserIcon","TaxonomyIcon","ContentIcon","SettingsIcon","EntityDataListing","EntityManager","default","SearchFilter","load","app","events","once","addFieldType","Object","keys","forEach","type","component","emitAsync","addConfig","main","items","content","label","loadOpen","icon","order","taxonomy","user","settings","entityDataListingRoute","path","key","exact","editEntityRoute","addEntityRoute","addRoute","name","version","pluginName"],"sources":["../src/index.js"],"sourcesContent":["import { getFormBuilderLookup, formFieldTypes } from '@blaze-cms/react-form-builder';\nimport pkg from '../package.json';\nimport { DATA_LISTING_PREFIX, PLUGIN_NAME } from './constants';\nimport getAddContentMenuItems from './utils/add-content-menu-items';\nimport { UserIcon, TaxonomyIcon, ContentIcon, SettingsIcon } from './icons';\nimport EntityDataListing from './components/EntityDataListing';\nimport EntityManager from './components/EntityManager';\n\n// todo: renable lazy loading after bundler optimisations, currently they are too slow in dev mode\n// const EntityDataListing = React.lazy(\n// () => import(/* webpackChunkName: 'EntityDataListing' */ './components/EntityDataListing')\n// );\n// const EntityManager = React.lazy(\n// () => import(/* webpackChunkName: 'EntityManager' */ './components/EntityManager')\n// );\n\nexport { default as SearchFilter } from './components/ListingTable/SearchFilter/SearchFilter';\n\nexport default async function load(app) {\n app.events.once('admin:menu:config:load', getAddContentMenuItems(app));\n\n app.events.once('load:custom:field:type', addFieldType => {\n Object.keys(formFieldTypes).forEach(type => {\n addFieldType({ type, component: formFieldTypes[type] });\n });\n });\n\n app.events.once('plugin:data-ui:load:loaded', async () => {\n await app.events.emitAsync('load:custom:field:type', getFormBuilderLookup.addFieldType);\n });\n\n app.events.once('admin:menu:config:load', ({ addConfig }) => {\n addConfig({\n main: {\n items: {\n content: {\n label: 'content',\n loadOpen: true,\n items: {},\n icon: ContentIcon,\n order: 10\n },\n taxonomy: {\n label: 'Taxonomy',\n items: {},\n icon: TaxonomyIcon,\n order: 40\n },\n user: {\n label: 'User',\n items: {},\n icon: UserIcon,\n order: 90\n },\n settings: {\n label: 'Settings',\n items: {},\n icon: SettingsIcon,\n order: 100\n }\n }\n }\n });\n });\n\n const entityDataListingRoute = {\n path: `${DATA_LISTING_PREFIX}/:entityIdentifier`,\n key: 'entityDataListing',\n component: EntityDataListing,\n exact: true\n };\n\n const editEntityRoute = {\n path: `${DATA_LISTING_PREFIX}/:entityIdentifier/:action/:id`,\n key: 'editEntity',\n component: EntityManager,\n exact: true\n };\n\n const addEntityRoute = {\n path: `${DATA_LISTING_PREFIX}/:entityIdentifier/:action`,\n key: 'createEntity',\n component: EntityManager,\n exact: true\n };\n\n app.addRoute(entityDataListingRoute);\n app.addRoute(editEntityRoute);\n app.addRoute(addEntityRoute);\n\n return {\n name: PLUGIN_NAME,\n version: pkg.version\n };\n}\n\nload.pluginName = PLUGIN_NAME;\n"],"mappings":"AAAA,SAASA,oBAAoB,EAAEC,cAAc,QAAQ,+BAA+B;AACpF,OAAOC,GAAG,MAAM,iBAAiB;AACjC,SAASC,mBAAmB,EAAEC,WAAW,QAAQ,aAAa;AAC9D,OAAOC,sBAAsB,MAAM,gCAAgC;AACnE,SAASC,QAAQ,EAAEC,YAAY,EAAEC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AE;YACJL,KAAK,EAAE,MAAM;YACbF,KAAK,EAAE,CAAC,CAAC;YACTI,IAAI,EAAEzB,QAAQ;YACd0B,KAAK,EAAE;UACT,CAAC;UACDG,QAAQ,EAAE;YACRN,KAAK,EAAE,UAAU;YACjBF,KAAK,EAAE,CAAC,CAAC;YACTI,IAAI,EAAEtB,YAAY;YAClBuB,KAAK,EAAE;UACT;QACF;MACF;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,MAAMI,sBAAsB,GAAG;IAC7BC,IAAI,EAAE,GAAGlC,mBAAmB,oBAAoB;IAChDmC,GAAG,EAAE,mBAAmB;IACxBf,SAAS,EAAEb,iBAAiB;IAC5B6B,KAAK,EAAE;EACT,CAAC;EAED,MAAMC,eAAe,GAAG;IACtBH,IAAI,EAAE,GAAGlC,mBAAmB,gCAAgC;IAC5DmC,GAAG,EAAE,YAAY;IACjBf,SAAS,EAAEZ,aAAa;IACxB4B,KAAK,EAAE;EACT,CAAC;EAED,MAAME,cAAc,GAAG;IACrBJ,IAAI,EAAE,GAAGlC,mBAAmB,4BAA4B;IACxDmC,GAAG,EAAE,cAAc;IACnBf,SAAS,EAAEZ,aAAa;IACxB4B,KAAK,EAAE;EACT,CAAC;EAEDxB,GAAG,CAAC2B,QAAQ,CAACN,sBAAsB,CAAC;EACpCrB,GAAG,CAAC2B,QAAQ,CAACF,eAAe,CAAC;EAC7BzB,GAAG,CAAC2B,QAAQ,CAACD,cAAc,CAAC;EAE5B,OAAO;IACLE,IAAI,EAAEvC,WAAW;IACjBwC,OAAO,EAAE1C,GAAG,CAAC0C;EACf,CAAC;AACH;AAEA9B,IAAI,CAAC+B,UAAU,GAAGzC,WAAW","ignoreList":[]}
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!entitySchema || !entitySchema.actions || !entitySchema.actions.create || !entitySchema.properties) {
|
|
7
|
-
throw new BlazeError('Create entity query requires create action and properties from entity schema');
|
|
8
|
-
}
|
|
9
|
-
const actionInput = upperfirst(`${entitySchema.actions.create}Input`);
|
|
10
|
-
const dataProperties = getDataProperties(entitySchema);
|
|
11
|
-
return gql`mutation createEntity($input: ${actionInput}) {
|
|
12
|
-
createdEntity: ${entitySchema.actions.create}(input: $input){
|
|
13
|
-
result {
|
|
14
|
-
id,
|
|
15
|
-
${dataProperties.join(',\n')}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}`;
|
|
19
|
-
}
|
|
1
|
+
import { getDynamicMutation } from '@blaze-cms/admin-ui-utils';
|
|
2
|
+
|
|
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 => getDynamicMutation('CREATE_ENTITY_MUTATION')(entitySchema);
|
|
20
6
|
export default buildCreateEntityMutation;
|
|
21
7
|
//# sourceMappingURL=build-create-entity-mutation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-create-entity-mutation.js","names":["
|
|
1
|
+
{"version":3,"file":"build-create-entity-mutation.js","names":["getDynamicMutation","buildCreateEntityMutation","entitySchema"],"sources":["../../src/utils/build-create-entity-mutation.js"],"sourcesContent":["import { getDynamicMutation } from '@blaze-cms/admin-ui-utils';\n\n// Kept for back-compat: the builder now lives in the admin-ui-utils dynamic\n// mutation registry so packages that cannot depend on this plugin can use it.\nconst buildCreateEntityMutation = entitySchema =>\n getDynamicMutation('CREATE_ENTITY_MUTATION')(entitySchema);\n\nexport default buildCreateEntityMutation;\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,2BAA2B;;AAE9D;AACA;AACA,MAAMC,yBAAyB,GAAGC,YAAY,IAC5CF,kBAAkB,CAAC,wBAAwB,CAAC,CAACE,YAAY,CAAC;AAE5D,eAAeD,yBAAyB","ignoreList":[]}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
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
|
-
const buildAdminSearchQuery = entitySchema => {
|
|
4
|
+
const buildAdminSearchQuery = (entitySchema, index) => {
|
|
5
5
|
const {
|
|
6
6
|
listingProperties = []
|
|
7
7
|
} = entitySchema || {};
|
|
8
8
|
const parsedProperties = `id, ${listingProperties.join(' ') || 'id name'}`;
|
|
9
|
-
return getDynamicQuery('ADMIN_SEARCH')([entitySchema], parsedProperties, true);
|
|
9
|
+
return getDynamicQuery('ADMIN_SEARCH')([entitySchema], parsedProperties, true, index);
|
|
10
10
|
};
|
|
11
|
-
function buildListingQuery(entitySchema, isSearchQuery) {
|
|
11
|
+
function buildListingQuery(entitySchema, index, isSearchQuery) {
|
|
12
12
|
if (!entitySchema.actions || !entitySchema.actions.getAll || !entitySchema.listingProperties) {
|
|
13
13
|
throw new BlazeError('Listing query requires getAll action and listingProperties from entity schema');
|
|
14
14
|
}
|
|
15
|
-
if (isSearchQuery) return buildAdminSearchQuery(entitySchema);
|
|
15
|
+
if (isSearchQuery) return buildAdminSearchQuery(entitySchema, index);
|
|
16
16
|
const sortType = entitySchema.actions.getAll[0].toUpperCase() + entitySchema.actions.getAll.substr(1);
|
|
17
17
|
return gql`
|
|
18
18
|
query ${entitySchema.actions.getAll}($where: JSON, $limit: Int, $offset:Int, $sort: [${sortType}SortItem]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-listing-query.js","names":["gql","BlazeError","getDynamicQuery","buildAdminSearchQuery","entitySchema","listingProperties","parsedProperties","join","buildListingQuery","isSearchQuery","actions","getAll","sortType","toUpperCase","substr","countAll"],"sources":["../../src/utils/build-listing-query.js"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { BlazeError } from '@blaze-cms/core-errors';\nimport { getDynamicQuery } from '@blaze-cms/admin-ui-utils';\n\nconst buildAdminSearchQuery = entitySchema => {\n const { listingProperties = [] } = entitySchema || {};\n const parsedProperties = `id, ${listingProperties.join(' ') || 'id name'}`;\n\n return getDynamicQuery('ADMIN_SEARCH')([entitySchema], parsedProperties, true);\n};\n\nfunction buildListingQuery(entitySchema, isSearchQuery) {\n if (!entitySchema.actions || !entitySchema.actions.getAll || !entitySchema.listingProperties) {\n throw new BlazeError(\n 'Listing query requires getAll action and listingProperties from entity schema'\n );\n }\n\n if (isSearchQuery) return buildAdminSearchQuery(entitySchema);\n\n const sortType =\n entitySchema.actions.getAll[0].toUpperCase() + entitySchema.actions.getAll.substr(1);\n\n return gql`\n query ${\n entitySchema.actions.getAll\n }($where: JSON, $limit: Int, $offset:Int, $sort: [${sortType}SortItem]) {\n listingData: ${\n entitySchema.actions.getAll\n }(where: $where, limit: $limit, offset:$offset, sort:$sort){\n id,\n ${entitySchema.listingProperties.join(',\\n')}\n }\n totalRecords: ${entitySchema.actions.countAll}(where: $where)\n }\n `;\n}\n\nexport default buildListingQuery;\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SAASC,eAAe,QAAQ,2BAA2B;AAE3D,MAAMC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"build-listing-query.js","names":["gql","BlazeError","getDynamicQuery","buildAdminSearchQuery","entitySchema","index","listingProperties","parsedProperties","join","buildListingQuery","isSearchQuery","actions","getAll","sortType","toUpperCase","substr","countAll"],"sources":["../../src/utils/build-listing-query.js"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { BlazeError } from '@blaze-cms/core-errors';\nimport { getDynamicQuery } from '@blaze-cms/admin-ui-utils';\n\nconst buildAdminSearchQuery = (entitySchema, index) => {\n const { listingProperties = [] } = entitySchema || {};\n const parsedProperties = `id, ${listingProperties.join(' ') || 'id name'}`;\n\n return getDynamicQuery('ADMIN_SEARCH')([entitySchema], parsedProperties, true, index);\n};\n\nfunction buildListingQuery(entitySchema, index, isSearchQuery) {\n if (!entitySchema.actions || !entitySchema.actions.getAll || !entitySchema.listingProperties) {\n throw new BlazeError(\n 'Listing query requires getAll action and listingProperties from entity schema'\n );\n }\n\n if (isSearchQuery) return buildAdminSearchQuery(entitySchema, index);\n\n const sortType =\n entitySchema.actions.getAll[0].toUpperCase() + entitySchema.actions.getAll.substr(1);\n\n return gql`\n query ${\n entitySchema.actions.getAll\n }($where: JSON, $limit: Int, $offset:Int, $sort: [${sortType}SortItem]) {\n listingData: ${\n entitySchema.actions.getAll\n }(where: $where, limit: $limit, offset:$offset, sort:$sort){\n id,\n ${entitySchema.listingProperties.join(',\\n')}\n }\n totalRecords: ${entitySchema.actions.countAll}(where: $where)\n }\n `;\n}\n\nexport default buildListingQuery;\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SAASC,eAAe,QAAQ,2BAA2B;AAE3D,MAAMC,qBAAqB,GAAGA,CAACC,YAAY,EAAEC,KAAK,KAAK;EACrD,MAAM;IAAEC,iBAAiB,GAAG;EAAG,CAAC,GAAGF,YAAY,IAAI,CAAC,CAAC;EACrD,MAAMG,gBAAgB,GAAG,OAAOD,iBAAiB,CAACE,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE;EAE1E,OAAON,eAAe,CAAC,cAAc,CAAC,CAAC,CAACE,YAAY,CAAC,EAAEG,gBAAgB,EAAE,IAAI,EAAEF,KAAK,CAAC;AACvF,CAAC;AAED,SAASI,iBAAiBA,CAACL,YAAY,EAAEC,KAAK,EAAEK,aAAa,EAAE;EAC7D,IAAI,CAACN,YAAY,CAACO,OAAO,IAAI,CAACP,YAAY,CAACO,OAAO,CAACC,MAAM,IAAI,CAACR,YAAY,CAACE,iBAAiB,EAAE;IAC5F,MAAM,IAAIL,UAAU,CAClB,+EACF,CAAC;EACH;EAEA,IAAIS,aAAa,EAAE,OAAOP,qBAAqB,CAACC,YAAY,EAAEC,KAAK,CAAC;EAEpE,MAAMQ,QAAQ,GACZT,YAAY,CAACO,OAAO,CAACC,MAAM,CAAC,CAAC,CAAC,CAACE,WAAW,CAAC,CAAC,GAAGV,YAAY,CAACO,OAAO,CAACC,MAAM,CAACG,MAAM,CAAC,CAAC,CAAC;EAEtF,OAAOf,GAAG;AACZ,YACMI,YAAY,CAACO,OAAO,CAACC,MAAM,oDACuBC,QAAQ;AAChE,qBACQT,YAAY,CAACO,OAAO,CAACC,MAAM;AACnC;AACA,UACUR,YAAY,CAACE,iBAAiB,CAACE,IAAI,CAAC,KAAK,CAAC;AACpD;AACA,sBAAsBJ,YAAY,CAACO,OAAO,CAACK,QAAQ;AACnD;AACA,GAAG;AACH;AAEA,eAAeP,iBAAiB","ignoreList":[]}
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
const getDefaultQueryParams = schema => {
|
|
2
2
|
const updated = schema.properties && schema.properties.updated;
|
|
3
3
|
const {
|
|
4
|
-
adminDefaultListingFilter: where
|
|
4
|
+
adminDefaultListingFilter: where,
|
|
5
|
+
adminListings: {
|
|
6
|
+
defaultSort
|
|
7
|
+
} = {}
|
|
5
8
|
} = schema.displayProperties || {};
|
|
9
|
+
let sort = [];
|
|
10
|
+
if (defaultSort === null || defaultSort === void 0 ? void 0 : defaultSort.property) {
|
|
11
|
+
sort = [{
|
|
12
|
+
property: defaultSort.property,
|
|
13
|
+
direction: defaultSort.direction || 'asc'
|
|
14
|
+
}];
|
|
15
|
+
} else if (updated) {
|
|
16
|
+
sort = [{
|
|
17
|
+
property: 'updated',
|
|
18
|
+
direction: 'desc'
|
|
19
|
+
}];
|
|
20
|
+
}
|
|
6
21
|
return {
|
|
7
22
|
where,
|
|
8
23
|
limit: 10,
|
|
9
24
|
offset: 0,
|
|
10
|
-
sort
|
|
11
|
-
property: 'updated',
|
|
12
|
-
direction: 'desc'
|
|
13
|
-
}] : []
|
|
25
|
+
sort
|
|
14
26
|
};
|
|
15
27
|
};
|
|
16
28
|
export { getDefaultQueryParams };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-default-query-params.js","names":["getDefaultQueryParams","schema","updated","properties","adminDefaultListingFilter","where","
|
|
1
|
+
{"version":3,"file":"get-default-query-params.js","names":["getDefaultQueryParams","schema","updated","properties","adminDefaultListingFilter","where","adminListings","defaultSort","displayProperties","sort","property","direction","limit","offset"],"sources":["../../src/utils/get-default-query-params.js"],"sourcesContent":["const getDefaultQueryParams = schema => {\n const updated = schema.properties && schema.properties.updated;\n const { adminDefaultListingFilter: where, adminListings: { defaultSort } = {} } =\n schema.displayProperties || {};\n\n let sort = [];\n\n if (defaultSort?.property) {\n sort = [\n {\n property: defaultSort.property,\n direction: defaultSort.direction || 'asc'\n }\n ];\n } else if (updated) {\n sort = [\n {\n property: 'updated',\n direction: 'desc'\n }\n ];\n }\n\n return {\n where,\n limit: 10,\n offset: 0,\n sort\n };\n};\n\nexport { getDefaultQueryParams };\n"],"mappings":"AAAA,MAAMA,qBAAqB,GAAGC,MAAM,IAAI;EACtC,MAAMC,OAAO,GAAGD,MAAM,CAACE,UAAU,IAAIF,MAAM,CAACE,UAAU,CAACD,OAAO;EAC9D,MAAM;IAAEE,yBAAyB,EAAEC,KAAK;IAAEC,aAAa,EAAE;MAAEC;IAAY,CAAC,GAAG,CAAC;EAAE,CAAC,GAC7EN,MAAM,CAACO,iBAAiB,IAAI,CAAC,CAAC;EAEhC,IAAIC,IAAI,GAAG,EAAE;EAEb,IAAIF,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEG,QAAQ,EAAE;IACzBD,IAAI,GAAG,CACL;MACEC,QAAQ,EAAEH,WAAW,CAACG,QAAQ;MAC9BC,SAAS,EAAEJ,WAAW,CAACI,SAAS,IAAI;IACtC,CAAC,CACF;EACH,CAAC,MAAM,IAAIT,OAAO,EAAE;IAClBO,IAAI,GAAG,CACL;MACEC,QAAQ,EAAE,SAAS;MACnBC,SAAS,EAAE;IACb,CAAC,CACF;EACH;EAEA,OAAO;IACLN,KAAK;IACLO,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,CAAC;IACTJ;EACF,CAAC;AACH,CAAC;AAED,SAAST,qBAAqB","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useMainContext, MainContext } from '@blaze-cms/admin-ui-utils';
|
|
4
|
-
export const withContext = Component => props
|
|
4
|
+
export const withContext = Component => function (props) {
|
|
5
5
|
const contexts = useMainContext(MainContext);
|
|
6
6
|
return /*#__PURE__*/React.createElement(Component, _extends({}, props, contexts));
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withContext.js","names":["React","useMainContext","MainContext","withContext","Component","props","contexts","createElement","_extends"],"sources":["../../../src/utils/hoc/withContext.js"],"sourcesContent":["import React from 'react';\nimport { useMainContext, MainContext } from '@blaze-cms/admin-ui-utils';\n\nexport const withContext = Component
|
|
1
|
+
{"version":3,"file":"withContext.js","names":["React","useMainContext","MainContext","withContext","Component","props","contexts","createElement","_extends"],"sources":["../../../src/utils/hoc/withContext.js"],"sourcesContent":["import React from 'react';\nimport { useMainContext, MainContext } from '@blaze-cms/admin-ui-utils';\n\nexport const withContext = Component =>\n function (props) {\n const contexts = useMainContext(MainContext);\n return <Component {...props} {...contexts} />;\n };\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,EAAEC,WAAW,QAAQ,2BAA2B;AAEvE,OAAO,MAAMC,WAAW,GAAGC,SAAS,IAClC,UAAUC,KAAK,EAAE;EACf,MAAMC,QAAQ,GAAGL,cAAc,CAACC,WAAW,CAAC;EAC5C,oBAAOF,KAAA,CAAAO,aAAA,CAACH,SAAS,EAAAI,QAAA,KAAKH,KAAK,EAAMC,QAAQ,CAAG,CAAC;AAC/C,CAAC","ignoreList":[]}
|