@blaze-cms/plugin-data-ui 0.146.0-translations.8 → 0.147.0-rc-eagle.4
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/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 -19
- 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 +284 -457
- 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 +32 -56
- 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 -17
- 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 +95 -158
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +23 -30
- 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 +42 -56
- 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 +91 -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 +35 -80
- 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 +19 -16
- package/lib/components/InfoBoxes/InfoBoxTooltip.js.map +1 -1
- package/lib/components/InfoBoxes/InfoBoxes.js +19 -19
- package/lib/components/InfoBoxes/InfoBoxes.js.map +1 -1
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js +26 -38
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +21 -16
- 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 +27 -34
- 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 +155 -296
- package/lib/components/ListingTable/ListingTable.js.map +1 -1
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +53 -58
- 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/SearchContainer.js +436 -262
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js +30 -37
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/helpers.js +82 -71
- package/lib/components/ListingTable/SearchFilter/helpers.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/querys.js +5 -5
- package/lib/components/ListingTable/SearchFilter/querys.js.map +1 -1
- 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 +103 -122
- package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
- package/lib/components/ListingTable/service/index.js +66 -83
- package/lib/components/ListingTable/service/index.js.map +1 -1
- package/lib/components/Tabs/index.js +26 -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 +30 -31
- 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 +12 -9
- 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 +17 -14
- 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 +7 -6
- 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 +8 -20
- package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -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.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +6 -3
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
- package/lib-es/components/EntityManager/EntityManager.js.map +1 -1
- package/lib-es/components/EntityManager/utils/entity.js.map +1 -1
- package/lib-es/components/EntityManager/utils/query.js.map +1 -1
- package/lib-es/components/InfoBoxes/InfoBoxTooltip.js.map +1 -1
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
- package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -1
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -1
- package/lib-es/components/InfoBoxes/presentational/InfoBoxLabel.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTable.js +2 -2
- package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +20 -17
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js +323 -51
- package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js +7 -3
- package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/helpers.js +39 -8
- package/lib-es/components/ListingTable/SearchFilter/helpers.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/querys.js.map +1 -1
- package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
- 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/index.js +12 -3
- package/lib-es/index.js.map +1 -1
- package/lib-es/utils/add-content-menu-items.js.map +1 -1
- package/lib-es/utils/build-create-entity-mutation.js.map +1 -1
- package/lib-es/utils/build-delete-entity-mutation.js.map +1 -1
- package/lib-es/utils/build-listing-query.js.map +1 -1
- package/lib-es/utils/build-update-data-query.js.map +1 -1
- package/lib-es/utils/build-update-publish-unpublish-mutation.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 +27 -22
- package/src/components/EntityManager/Entity/Entity.js +59 -77
- package/src/components/EntityManager/Entity/EntityHeader/EntityHeader.js +1 -2
- package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +9 -7
- package/src/components/EntityManager/Entity/SideBarRelations/index.js +64 -59
- package/src/components/EntityManager/EntityManager.js +52 -45
- package/src/components/InfoBoxes/container/InfoBoxContainer.js +3 -6
- package/src/components/InfoBoxes/hooks/useData.js +6 -1
- package/src/components/ListingTable/ListingTable.js +13 -21
- package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +38 -44
- package/src/components/ListingTable/SearchFilter/SearchContainer.js +411 -134
- package/src/components/ListingTable/SearchFilter/SearchFilter.js +5 -2
- package/src/components/ListingTable/SearchFilter/helpers.js +56 -8
- package/src/components/ListingTable/service/index.js +2 -3
- package/src/components/Tabs/index.js +17 -21
- package/src/index.js +11 -7
- package/src/utils/hoc/withContext.js +5 -4
- package/CHANGELOG.md +0 -1947
- package/babel.config.js +0 -3
- package/jest.config.js +0 -5
|
@@ -1,313 +1,487 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.js");
|
|
4
|
-
require("core-js/modules/es.object.define-properties.js");
|
|
5
|
-
require("core-js/modules/es.object.define-property.js");
|
|
6
|
-
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
7
|
-
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
8
|
-
require("core-js/modules/es.weak-map.js");
|
|
9
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
10
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
11
4
|
Object.defineProperty(exports, "__esModule", {
|
|
12
5
|
value: true
|
|
13
6
|
});
|
|
14
|
-
exports
|
|
15
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
16
|
-
require("core-js/modules/es.array.filter.js");
|
|
17
|
-
require("core-js/modules/es.array.find.js");
|
|
18
|
-
require("core-js/modules/es.array.for-each.js");
|
|
19
|
-
require("core-js/modules/es.array.is-array.js");
|
|
20
|
-
require("core-js/modules/es.array.iterator.js");
|
|
21
|
-
require("core-js/modules/es.array.join.js");
|
|
22
|
-
require("core-js/modules/es.array.map.js");
|
|
23
|
-
require("core-js/modules/es.array.reduce.js");
|
|
24
|
-
require("core-js/modules/es.function.name.js");
|
|
25
|
-
require("core-js/modules/es.object.entries.js");
|
|
26
|
-
require("core-js/modules/es.object.keys.js");
|
|
27
|
-
require("core-js/modules/es.object.to-string.js");
|
|
28
|
-
require("core-js/modules/es.promise.js");
|
|
29
|
-
require("core-js/modules/es.string.iterator.js");
|
|
30
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
31
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
7
|
+
exports.default = void 0;
|
|
32
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
33
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
34
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
35
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
36
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
37
11
|
var _select = _interopRequireDefault(require("@blaze-react/select"));
|
|
12
|
+
var _multiselect = _interopRequireDefault(require("@blaze-react/multiselect"));
|
|
13
|
+
var _lodash = _interopRequireDefault(require("lodash.debounce"));
|
|
14
|
+
var _lodash2 = _interopRequireDefault(require("lodash.unionby"));
|
|
38
15
|
var _client = require("@apollo/client");
|
|
39
16
|
var _adminUiUtils = require("@blaze-cms/admin-ui-utils");
|
|
17
|
+
var _utils = require("@blaze-cms/utils");
|
|
40
18
|
var _bs = require("react-icons/bs");
|
|
41
19
|
var _helpers = require("./helpers");
|
|
42
20
|
var _querys = require("./querys");
|
|
43
21
|
var _constants = require("../../../constants");
|
|
44
|
-
function
|
|
45
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
22
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
46
23
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
47
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
24
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25
|
+
const SearchContainer = ({
|
|
26
|
+
setListFilters,
|
|
27
|
+
keywordFiltersToUse = [],
|
|
28
|
+
selectFiltersToDisplay = [],
|
|
29
|
+
multiSelectFiltersToDisplay = [],
|
|
30
|
+
schema,
|
|
31
|
+
index,
|
|
32
|
+
values
|
|
33
|
+
}) => {
|
|
34
|
+
const client = (0, _client.useApolloClient)();
|
|
35
|
+
const [searchTerm, setSearchTerm] = (0, _react.useState)('');
|
|
36
|
+
const [selectedFilters, setSelectedFilters] = (0, _react.useState)({});
|
|
37
|
+
const [selectOptions, setSelectOptions] = (0, _react.useState)([]);
|
|
38
|
+
const [multiSelectOptions, setMultiSelectOptions] = (0, _react.useState)([]);
|
|
39
|
+
const [allEntitySchemas, setAllEntitySchemas] = (0, _react.useState)([]);
|
|
40
|
+
const displaySearchFilter = keywordFiltersToUse.length > 0;
|
|
41
|
+
const displaySelectFilters = selectFiltersToDisplay.length > 0;
|
|
42
|
+
const displayMultiSelectFilters = multiSelectFiltersToDisplay.length > 0;
|
|
43
|
+
const displayAggregations = displaySelectFilters || displayMultiSelectFilters;
|
|
44
|
+
(0, _react.useEffect)(() => {
|
|
45
|
+
(async () => {
|
|
46
|
+
try {
|
|
47
|
+
const all = await (0, _adminUiUtils.fetchAllEntities)({
|
|
48
|
+
client
|
|
49
|
+
});
|
|
50
|
+
setAllEntitySchemas(all || []);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
setAllEntitySchemas([]);
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
55
|
+
}, [client]);
|
|
56
|
+
const multiSelectPropertySet = (0, _react.useMemo)(() => new Set(multiSelectFiltersToDisplay.map(([property]) => property)), [multiSelectFiltersToDisplay]);
|
|
57
|
+
const {
|
|
58
|
+
keywordSearchProperties,
|
|
59
|
+
keywordSearchLabels
|
|
60
|
+
} = (0, _react.useMemo)(() => {
|
|
61
|
+
const labels = [];
|
|
62
|
+
const properties = [];
|
|
63
|
+
keywordFiltersToUse.forEach(([property, {
|
|
64
|
+
label
|
|
65
|
+
}]) => {
|
|
66
|
+
if (label) labels.push(label);
|
|
67
|
+
properties.push(property);
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
keywordSearchProperties: properties,
|
|
71
|
+
keywordSearchLabels: labels
|
|
72
|
+
};
|
|
73
|
+
}, [keywordFiltersToUse]);
|
|
74
|
+
const {
|
|
75
|
+
gqlFields,
|
|
76
|
+
rawQuery
|
|
77
|
+
} = (0, _react.useMemo)(() => (0, _helpers.buildQueryFields)([...selectFiltersToDisplay, ...multiSelectFiltersToDisplay], schema.id), [selectFiltersToDisplay, multiSelectFiltersToDisplay, schema.id]);
|
|
78
|
+
const action = displayAggregations ? (0, _adminUiUtils.getDynamicQuery)('ADMIN_SEARCH')([schema], gqlFields, false, index) : _querys.NOOP_QUERY;
|
|
79
|
+
const {
|
|
80
|
+
data
|
|
81
|
+
} = (0, _client.useQuery)(action, {
|
|
82
|
+
skip: !displayAggregations,
|
|
83
|
+
variables: {
|
|
84
|
+
where: rawQuery,
|
|
85
|
+
limit: 0
|
|
86
|
+
},
|
|
87
|
+
fetchPolicy: 'cache-and-network'
|
|
88
|
+
});
|
|
89
|
+
const buildRelationsIndex = (0, _react.useCallback)(schemaObj => {
|
|
90
|
+
const items = [];
|
|
91
|
+
if (schemaObj.properties) {
|
|
92
|
+
Object.entries(schemaObj.properties).forEach(([propName, definition]) => {
|
|
93
|
+
const {
|
|
94
|
+
relation
|
|
95
|
+
} = definition || {};
|
|
96
|
+
if (!relation) return;
|
|
97
|
+
const {
|
|
98
|
+
localField: relationLocalField,
|
|
99
|
+
entityIdentifier
|
|
100
|
+
} = relation;
|
|
101
|
+
const localField = relationLocalField || propName;
|
|
102
|
+
if (localField) items.push({
|
|
103
|
+
localField,
|
|
104
|
+
entityIdentifier
|
|
105
|
+
});
|
|
80
106
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
fetchPolicy: 'cache-and-network'
|
|
101
|
-
}),
|
|
102
|
-
data = _useQuery.data;
|
|
103
|
-
var filterData = (0, _react.useMemo)(function () {
|
|
104
|
-
var _ref4 = data || {},
|
|
105
|
-
_ref4$searchResults = _ref4.searchResults,
|
|
106
|
-
_ref4$searchResults2 = _ref4$searchResults === void 0 ? {} : _ref4$searchResults,
|
|
107
|
-
_ref4$searchResults2$ = _ref4$searchResults2.rawResults,
|
|
108
|
-
_ref4$searchResults2$2 = _ref4$searchResults2$ === void 0 ? {} : _ref4$searchResults2$,
|
|
109
|
-
_ref4$searchResults2$3 = _ref4$searchResults2$2.aggregations,
|
|
110
|
-
aggregations = _ref4$searchResults2$3 === void 0 ? {} : _ref4$searchResults2$3;
|
|
111
|
-
var proccessedData = [];
|
|
112
|
-
Object.entries(aggregations).forEach(function (_ref5) {
|
|
113
|
-
var _ref6 = (0, _slicedToArray2["default"])(_ref5, 2),
|
|
114
|
-
key = _ref6[0],
|
|
115
|
-
buckets = _ref6[1].buckets;
|
|
116
|
-
proccessedData.push(Array.isArray(buckets) ? [key, buckets.map(function (b) {
|
|
117
|
-
return b.key;
|
|
118
|
-
}).filter(Boolean)] : []);
|
|
107
|
+
}
|
|
108
|
+
if (Array.isArray(schemaObj.relations)) {
|
|
109
|
+
schemaObj.relations.forEach(relation => {
|
|
110
|
+
if (!relation.localField) return;
|
|
111
|
+
const {
|
|
112
|
+
localField,
|
|
113
|
+
entityIdentifier
|
|
114
|
+
} = relation;
|
|
115
|
+
items.push({
|
|
116
|
+
localField,
|
|
117
|
+
entityIdentifier
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const byKey = new Map();
|
|
122
|
+
items.forEach(item => {
|
|
123
|
+
const key = `${item.localField}|${item.entityIdentifier || ''}`;
|
|
124
|
+
if (!byKey.has(key)) byKey.set(key, item);
|
|
119
125
|
});
|
|
120
|
-
return
|
|
126
|
+
return Array.from(byKey.values());
|
|
127
|
+
}, []);
|
|
128
|
+
const relationsIndex = (0, _react.useMemo)(() => buildRelationsIndex(schema), [schema, buildRelationsIndex]);
|
|
129
|
+
const stringTypeProps = (0, _react.useMemo)(() => (0, _utils.getStringTypeProps)(schema.id, relationsIndex, allEntitySchemas), [schema.id, relationsIndex, allEntitySchemas]);
|
|
130
|
+
const aggregationsData = (0, _react.useMemo)(() => {
|
|
131
|
+
const {
|
|
132
|
+
searchResults: {
|
|
133
|
+
rawResults: {
|
|
134
|
+
aggregations = {}
|
|
135
|
+
} = {}
|
|
136
|
+
} = {}
|
|
137
|
+
} = data || {};
|
|
138
|
+
const processed = [];
|
|
139
|
+
Object.entries(aggregations).forEach(([key, {
|
|
140
|
+
buckets
|
|
141
|
+
}]) => {
|
|
142
|
+
processed.push(Array.isArray(buckets) ? [key, buckets.map(bucket => bucket.key).filter(Boolean)] : []);
|
|
143
|
+
});
|
|
144
|
+
return processed;
|
|
121
145
|
}, [data]);
|
|
122
|
-
(0, _react.
|
|
123
|
-
|
|
146
|
+
const findFilterConfig = (0, _react.useCallback)(property => {
|
|
147
|
+
var _selectFiltersToDispl, _multiSelectFiltersTo;
|
|
148
|
+
return ((_selectFiltersToDispl = selectFiltersToDisplay.find(([prop]) => prop === property)) === null || _selectFiltersToDispl === void 0 ? void 0 : _selectFiltersToDispl[1]) || ((_multiSelectFiltersTo = multiSelectFiltersToDisplay.find(([prop]) => prop === property)) === null || _multiSelectFiltersTo === void 0 ? void 0 : _multiSelectFiltersTo[1]);
|
|
149
|
+
}, [selectFiltersToDisplay, multiSelectFiltersToDisplay]);
|
|
150
|
+
(0, _react.useEffect)(() => {
|
|
151
|
+
if (!aggregationsData.length) {
|
|
124
152
|
setSelectOptions([]);
|
|
153
|
+
setMultiSelectOptions([]);
|
|
125
154
|
return;
|
|
126
155
|
}
|
|
127
|
-
(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
sort: [{
|
|
192
|
-
property: 'name',
|
|
193
|
-
direction: 'asc'
|
|
194
|
-
}]
|
|
195
|
-
}
|
|
196
|
-
})
|
|
197
|
-
// eslint-disable-next-line no-console
|
|
198
|
-
["catch"](function (e) {
|
|
199
|
-
return console.error(e);
|
|
200
|
-
});
|
|
201
|
-
case 17:
|
|
202
|
-
_yield$apolloClient$q3 = _context.sent;
|
|
203
|
-
_yield$apolloClient$q4 = _yield$apolloClient$q3.data.result;
|
|
204
|
-
selected = _yield$apolloClient$q4 === void 0 ? [] : _yield$apolloClient$q4;
|
|
205
|
-
return _context.abrupt("return", {
|
|
206
|
-
id: property,
|
|
207
|
-
label: selectionDetails.label,
|
|
208
|
-
options: selected.map(function (item) {
|
|
209
|
-
return [item.id, item.name];
|
|
210
|
-
})
|
|
211
|
-
});
|
|
212
|
-
case 23:
|
|
213
|
-
_context.prev = 23;
|
|
214
|
-
_context.t0 = _context["catch"](1);
|
|
215
|
-
return _context.abrupt("return", null);
|
|
216
|
-
case 26:
|
|
217
|
-
case "end":
|
|
218
|
-
return _context.stop();
|
|
219
|
-
}
|
|
220
|
-
}, _callee, null, [[1, 23]]);
|
|
221
|
-
}));
|
|
222
|
-
return function (_x) {
|
|
223
|
-
return _ref9.apply(this, arguments);
|
|
224
|
-
};
|
|
225
|
-
}()));
|
|
226
|
-
case 2:
|
|
227
|
-
results = _context2.sent;
|
|
228
|
-
setSelectOptions(results.filter(Boolean));
|
|
229
|
-
case 4:
|
|
230
|
-
case "end":
|
|
231
|
-
return _context2.stop();
|
|
156
|
+
(async () => {
|
|
157
|
+
const results = await Promise.all(aggregationsData.map(async ([property, ids]) => {
|
|
158
|
+
try {
|
|
159
|
+
if (!ids || !ids.length) return null;
|
|
160
|
+
const config = findFilterConfig(property);
|
|
161
|
+
if (!config) return null;
|
|
162
|
+
const {
|
|
163
|
+
adminListingOptions: {
|
|
164
|
+
tidyLabel
|
|
165
|
+
} = {}
|
|
166
|
+
} = config;
|
|
167
|
+
if (!config.relation) {
|
|
168
|
+
const baseOptions = ids.map(value => [value, (0, _helpers.getTidyLabel)(value, tidyLabel)]);
|
|
169
|
+
return {
|
|
170
|
+
property,
|
|
171
|
+
label: config.label,
|
|
172
|
+
type: multiSelectPropertySet.has(property) ? 'multi' : 'single',
|
|
173
|
+
options: baseOptions,
|
|
174
|
+
selected: values && values[property]
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const schemaQuery = (0, _adminUiUtils.getQuery)('GET_ENTITY_SCHEMA');
|
|
178
|
+
const {
|
|
179
|
+
data: {
|
|
180
|
+
getEntitySchemas: [relationSchema]
|
|
181
|
+
}
|
|
182
|
+
} = await client.query({
|
|
183
|
+
query: schemaQuery,
|
|
184
|
+
variables: {
|
|
185
|
+
identifier: config.relation.entityIdentifier
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
const {
|
|
189
|
+
data: {
|
|
190
|
+
result: selected = []
|
|
191
|
+
}
|
|
192
|
+
} = await client.query({
|
|
193
|
+
query: (0, _adminUiUtils.getDynamicQuery)('GET_ALL_ENTITIES')(relationSchema),
|
|
194
|
+
variables: {
|
|
195
|
+
where: {
|
|
196
|
+
id: {
|
|
197
|
+
_in: ids
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
sort: [{
|
|
201
|
+
property: 'name',
|
|
202
|
+
direction: 'asc'
|
|
203
|
+
}]
|
|
204
|
+
}
|
|
205
|
+
})
|
|
206
|
+
// eslint-disable-next-line no-console
|
|
207
|
+
.catch(error => console.error(error));
|
|
208
|
+
const baseOptions = selected.map(item => [item.id, (0, _helpers.getTidyLabel)(item.name, tidyLabel)]);
|
|
209
|
+
return {
|
|
210
|
+
property,
|
|
211
|
+
label: config.label || config.relation.label,
|
|
212
|
+
type: multiSelectPropertySet.has(property) ? 'multi' : 'single',
|
|
213
|
+
options: baseOptions,
|
|
214
|
+
selected: values && values[property]
|
|
215
|
+
};
|
|
216
|
+
} catch {
|
|
217
|
+
return null;
|
|
232
218
|
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
219
|
+
}));
|
|
220
|
+
const valid = results.filter(Boolean);
|
|
221
|
+
setSelectOptions(valid.filter(option => option.type === 'single').map(({
|
|
222
|
+
property,
|
|
223
|
+
label,
|
|
224
|
+
options,
|
|
225
|
+
selected
|
|
226
|
+
}) => ({
|
|
227
|
+
id: property,
|
|
228
|
+
label,
|
|
229
|
+
options,
|
|
230
|
+
selected
|
|
231
|
+
})));
|
|
232
|
+
setMultiSelectOptions(valid.filter(option => option.type === 'multi').map(({
|
|
233
|
+
property,
|
|
234
|
+
label,
|
|
235
|
+
options,
|
|
236
|
+
selected
|
|
237
|
+
}) => ({
|
|
238
|
+
id: property,
|
|
239
|
+
label,
|
|
240
|
+
items: options.map(([id, name]) => ({
|
|
241
|
+
id,
|
|
242
|
+
name
|
|
243
|
+
})),
|
|
244
|
+
selected
|
|
245
|
+
})));
|
|
246
|
+
})();
|
|
247
|
+
}, [client, aggregationsData, findFilterConfig, multiSelectPropertySet, values]);
|
|
248
|
+
const updateFilters = (0, _react.useCallback)((term, filters) => (0, _helpers.updateListFilters)(term, filters, setListFilters, keywordSearchProperties), [setListFilters, keywordSearchProperties]);
|
|
249
|
+
const debouncedUpdateFilters = (0, _react.useMemo)(() => (0, _lodash.default)((term, filters) => updateFilters(term, filters), 300), [updateFilters]);
|
|
250
|
+
(0, _react.useEffect)(() => () => debouncedUpdateFilters.cancel(), [debouncedUpdateFilters]);
|
|
251
|
+
const handleSearch = (0, _react.useCallback)(() => updateFilters(searchTerm, selectedFilters), [searchTerm, selectedFilters, updateFilters]);
|
|
252
|
+
const handleSearchChange = (0, _react.useCallback)(({
|
|
253
|
+
target: {
|
|
254
|
+
value
|
|
255
|
+
}
|
|
256
|
+
}) => setSearchTerm(value), []);
|
|
257
|
+
const handleEnterKey = (0, _react.useCallback)(({
|
|
258
|
+
key
|
|
259
|
+
}) => {
|
|
260
|
+
if (key === _constants.ENTER_KEY) handleSearch();
|
|
247
261
|
}, [handleSearch]);
|
|
248
|
-
|
|
262
|
+
const handleReset = (0, _react.useCallback)(() => {
|
|
249
263
|
setSearchTerm('');
|
|
250
|
-
|
|
251
|
-
|
|
264
|
+
debouncedUpdateFilters.cancel();
|
|
265
|
+
setSelectedFilters(prev => Object.keys(prev).reduce((acc, key) => {
|
|
266
|
+
acc[key] = multiSelectPropertySet.has(key) ? [] : _constants.DEFAULT_FILTER_OPTION_LABEL;
|
|
267
|
+
return acc;
|
|
252
268
|
}, {}));
|
|
253
269
|
updateFilters('', {});
|
|
254
|
-
}, [
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
270
|
+
}, [multiSelectPropertySet, updateFilters, debouncedUpdateFilters]);
|
|
271
|
+
const handleSelect = (0, _react.useCallback)((property, {
|
|
272
|
+
value
|
|
273
|
+
}) => {
|
|
274
|
+
const next = _objectSpread(_objectSpread({}, selectedFilters), {}, {
|
|
275
|
+
[property]: value
|
|
276
|
+
});
|
|
258
277
|
setSelectedFilters(next);
|
|
259
|
-
|
|
260
|
-
}, [searchTerm, selectedFilters,
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
278
|
+
debouncedUpdateFilters(searchTerm, next);
|
|
279
|
+
}, [searchTerm, selectedFilters, debouncedUpdateFilters]);
|
|
280
|
+
const handleMultiSelect = (0, _react.useCallback)((property, ids) => {
|
|
281
|
+
const next = _objectSpread(_objectSpread({}, selectedFilters), {}, {
|
|
282
|
+
[property]: ids
|
|
283
|
+
});
|
|
284
|
+
setSelectedFilters(next);
|
|
285
|
+
debouncedUpdateFilters(searchTerm, next);
|
|
286
|
+
}, [searchTerm, selectedFilters, debouncedUpdateFilters]);
|
|
287
|
+
const findRelationByLocalField = (0, _react.useCallback)(localField => relationsIndex.find(relation => relation.localField === localField), [relationsIndex]);
|
|
288
|
+
const resolveAggProp = (0, _react.useCallback)((property, config) => {
|
|
289
|
+
if (!config.relation) return property;
|
|
290
|
+
if (property.includes('.')) return property;
|
|
291
|
+
const localField = config.relation.localField || property;
|
|
292
|
+
return `${localField}.name`;
|
|
293
|
+
}, []);
|
|
294
|
+
const resolveEntityIdentifier = (0, _react.useCallback)((property, config) => {
|
|
295
|
+
if (!config.relation) return undefined;
|
|
296
|
+
if (config.relation.entityIdentifier) return config.relation.entityIdentifier;
|
|
297
|
+
const localField = property.includes('.') ? property.split('.')[0] : config.relation.localField || property;
|
|
298
|
+
return findRelationByLocalField(localField).entityIdentifier;
|
|
299
|
+
}, [findRelationByLocalField]);
|
|
300
|
+
const addEntitySuffixIfNeeded = (0, _react.useCallback)((aggProp, entityIdentifier, config) => {
|
|
301
|
+
if (!config.relation || !entityIdentifier) return aggProp;
|
|
302
|
+
return `${aggProp}/${entityIdentifier}`;
|
|
303
|
+
}, []);
|
|
304
|
+
const makeOnSearchChange = (0, _react.useCallback)(property => async ({
|
|
305
|
+
event: {
|
|
306
|
+
value
|
|
307
|
+
},
|
|
308
|
+
currentOffset
|
|
309
|
+
}) => {
|
|
310
|
+
try {
|
|
311
|
+
var _config$relation, _aggregations$key, _multiSelectOptions$f;
|
|
312
|
+
if (!value || currentOffset) return [];
|
|
313
|
+
const config = findFilterConfig(property);
|
|
314
|
+
if (!config) return [];
|
|
315
|
+
let aggProp = resolveAggProp(property, config);
|
|
316
|
+
if (config.relation && !config.relation.localField && !property.includes('.')) {
|
|
317
|
+
const matchingRelation = findRelationByLocalField(property);
|
|
318
|
+
if (matchingRelation.localField) aggProp = `${matchingRelation.localField}.name`;
|
|
319
|
+
}
|
|
320
|
+
const entityIdentifier = resolveEntityIdentifier(property, config) || ((_config$relation = config.relation) === null || _config$relation === void 0 ? void 0 : _config$relation.entityIdentifier);
|
|
321
|
+
const filterByEntry = addEntitySuffixIfNeeded(aggProp, entityIdentifier, config);
|
|
322
|
+
const currentValues = {
|
|
323
|
+
entity: schema.id,
|
|
324
|
+
filterByProperty: [filterByEntry]
|
|
325
|
+
};
|
|
326
|
+
const aggregations = await (0, _adminUiUtils.fetchFilterByDataFromElastic)(client, currentValues, relationsIndex, stringTypeProps, value);
|
|
327
|
+
const key = aggProp;
|
|
328
|
+
const buckets = (aggregations === null || aggregations === void 0 ? void 0 : (_aggregations$key = aggregations[key]) === null || _aggregations$key === void 0 ? void 0 : _aggregations$key.buckets) || [];
|
|
329
|
+
let items = [];
|
|
330
|
+
if (config.relation) {
|
|
331
|
+
const names = buckets.map(bucket => bucket.key).filter(Boolean);
|
|
332
|
+
if (names.length) {
|
|
333
|
+
const schemaQuery = (0, _adminUiUtils.getQuery)('GET_ENTITY_SCHEMA');
|
|
334
|
+
const {
|
|
335
|
+
data: {
|
|
336
|
+
getEntitySchemas: [relationSchema]
|
|
337
|
+
}
|
|
338
|
+
} = await client.query({
|
|
339
|
+
query: schemaQuery,
|
|
340
|
+
variables: {
|
|
341
|
+
identifier: entityIdentifier
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
const {
|
|
345
|
+
data: {
|
|
346
|
+
result: selected = []
|
|
347
|
+
}
|
|
348
|
+
} = await client.query({
|
|
349
|
+
query: (0, _adminUiUtils.getDynamicQuery)('GET_ALL_ENTITIES')(relationSchema),
|
|
350
|
+
variables: {
|
|
351
|
+
where: {
|
|
352
|
+
name: {
|
|
353
|
+
_in: names
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
sort: [{
|
|
357
|
+
property: 'name',
|
|
358
|
+
direction: 'asc'
|
|
359
|
+
}]
|
|
360
|
+
}
|
|
361
|
+
})
|
|
362
|
+
// eslint-disable-next-line no-console
|
|
363
|
+
.catch(error => console.error(error));
|
|
364
|
+
items = selected.map(item => ({
|
|
365
|
+
id: item.id,
|
|
366
|
+
name: item.name
|
|
367
|
+
}));
|
|
368
|
+
}
|
|
369
|
+
} else {
|
|
370
|
+
items = buckets.map(bucket => ({
|
|
371
|
+
id: bucket.key,
|
|
372
|
+
name: bucket.key
|
|
373
|
+
})).filter(option => option.id != null);
|
|
374
|
+
}
|
|
375
|
+
const existingItems = ((_multiSelectOptions$f = multiSelectOptions.find(opt => opt.id === property)) === null || _multiSelectOptions$f === void 0 ? void 0 : _multiSelectOptions$f.items) || [];
|
|
376
|
+
return (0, _lodash2.default)(items, existingItems, 'id');
|
|
377
|
+
} catch (error) {
|
|
378
|
+
return [];
|
|
379
|
+
}
|
|
380
|
+
}, [client, schema.id, relationsIndex, stringTypeProps, multiSelectOptions, findFilterConfig, resolveAggProp, resolveEntityIdentifier, addEntitySuffixIfNeeded, findRelationByLocalField]);
|
|
381
|
+
const placeholderText = `Search ${keywordSearchLabels.join(', ')}`;
|
|
382
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
383
|
+
className: "search-container ms-filter"
|
|
384
|
+
}, displaySearchFilter && /*#__PURE__*/_react.default.createElement("div", {
|
|
265
385
|
className: "search-container__search-input-container"
|
|
266
|
-
}, /*#__PURE__*/_react
|
|
386
|
+
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
267
387
|
type: "search",
|
|
268
388
|
className: "search-container__search-input-container__search-input",
|
|
269
389
|
placeholder: placeholderText,
|
|
270
390
|
value: searchTerm,
|
|
271
391
|
onChange: handleSearchChange,
|
|
272
392
|
onKeyDown: handleEnterKey
|
|
273
|
-
}), /*#__PURE__*/_react
|
|
393
|
+
}), /*#__PURE__*/_react.default.createElement("i", {
|
|
274
394
|
role: "button",
|
|
275
395
|
onClick: handleSearch
|
|
276
|
-
}, /*#__PURE__*/_react
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
396
|
+
}, /*#__PURE__*/_react.default.createElement(_bs.BsSearch, null))), displaySelectFilters && selectOptions.map(({
|
|
397
|
+
id,
|
|
398
|
+
options,
|
|
399
|
+
label,
|
|
400
|
+
selected
|
|
401
|
+
}) => options && options.length ? /*#__PURE__*/_react.default.createElement("div", {
|
|
402
|
+
className: "search-container__select-wrapper",
|
|
403
|
+
key: `select-${id}`
|
|
404
|
+
}, /*#__PURE__*/_react.default.createElement(_select.default, {
|
|
405
|
+
label: label,
|
|
406
|
+
id: id,
|
|
407
|
+
name: id,
|
|
408
|
+
onChange: ({
|
|
409
|
+
value
|
|
410
|
+
}) => handleSelect(id, {
|
|
411
|
+
value
|
|
412
|
+
}),
|
|
413
|
+
options: options,
|
|
414
|
+
value: selectedFilters[id] !== undefined ? selectedFilters[id] : selected,
|
|
415
|
+
defaultTextValue: _constants.DEFAULT_FILTER_OPTION_LABEL
|
|
416
|
+
})) : null), displayMultiSelectFilters && multiSelectOptions.map(({
|
|
417
|
+
id,
|
|
418
|
+
label,
|
|
419
|
+
items
|
|
420
|
+
}) => {
|
|
421
|
+
const selectedIds = selectedFilters[id] ? selectedFilters[id] : [];
|
|
422
|
+
const multiSelectData = {
|
|
423
|
+
filterBy: ['name'],
|
|
424
|
+
identification: 'id',
|
|
425
|
+
keyValue: 'name',
|
|
426
|
+
data: items.map(({
|
|
427
|
+
id: itemId,
|
|
428
|
+
name
|
|
429
|
+
}) => ({
|
|
430
|
+
id: itemId,
|
|
431
|
+
name,
|
|
432
|
+
description: '',
|
|
433
|
+
checked: selectedIds.includes(itemId),
|
|
434
|
+
show: true
|
|
435
|
+
}))
|
|
436
|
+
};
|
|
437
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
438
|
+
className: "search-container__select-wrapper",
|
|
439
|
+
key: `multiselect-${id}`
|
|
440
|
+
}, /*#__PURE__*/_react.default.createElement(_multiselect.default, {
|
|
441
|
+
onChange: ({
|
|
442
|
+
value,
|
|
443
|
+
currentOffset
|
|
444
|
+
}) => makeOnSearchChange(id)({
|
|
445
|
+
event: {
|
|
446
|
+
value
|
|
447
|
+
},
|
|
448
|
+
currentOffset
|
|
449
|
+
}),
|
|
285
450
|
name: id,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
451
|
+
label: label,
|
|
452
|
+
data: multiSelectData,
|
|
453
|
+
limit: 10,
|
|
454
|
+
getSelected: ({
|
|
455
|
+
event: {
|
|
456
|
+
target: {
|
|
457
|
+
value
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}) => handleMultiSelect(id, value),
|
|
461
|
+
required: false,
|
|
462
|
+
checkedPreviewCount: 1,
|
|
463
|
+
formatMoreLabel: n => `${n} more`
|
|
464
|
+
}));
|
|
465
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
294
466
|
className: "search-container__reset-button"
|
|
295
|
-
}, /*#__PURE__*/_react
|
|
467
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
296
468
|
role: "button",
|
|
297
469
|
onClick: handleReset
|
|
298
|
-
}, /*#__PURE__*/_react
|
|
470
|
+
}, /*#__PURE__*/_react.default.createElement(_bs.BsArrowCounterclockwise, null))));
|
|
299
471
|
};
|
|
300
472
|
SearchContainer.propTypes = {
|
|
301
|
-
setListFilters: _propTypes
|
|
302
|
-
keywordFiltersToUse: _propTypes
|
|
303
|
-
selectFiltersToDisplay: _propTypes
|
|
304
|
-
|
|
305
|
-
|
|
473
|
+
setListFilters: _propTypes.default.func.isRequired,
|
|
474
|
+
keywordFiltersToUse: _propTypes.default.array,
|
|
475
|
+
selectFiltersToDisplay: _propTypes.default.array,
|
|
476
|
+
multiSelectFiltersToDisplay: _propTypes.default.array,
|
|
477
|
+
schema: _propTypes.default.object.isRequired,
|
|
478
|
+
index: _propTypes.default.string
|
|
306
479
|
};
|
|
307
480
|
SearchContainer.defaultProps = {
|
|
308
481
|
keywordFiltersToUse: [],
|
|
309
482
|
selectFiltersToDisplay: [],
|
|
483
|
+
multiSelectFiltersToDisplay: [],
|
|
310
484
|
index: 'admin'
|
|
311
485
|
};
|
|
312
|
-
var _default = exports
|
|
486
|
+
var _default = exports.default = SearchContainer;
|
|
313
487
|
//# sourceMappingURL=SearchContainer.js.map
|