@blaze-cms/plugin-data-ui 0.146.0-node18-core-styles-tooltips.56 → 0.146.0-node18-tooltips.44
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 +42 -164
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +0 -1
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -1
- package/lib/components/EntityManager/Entity/Entity.js +5 -5
- package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +0 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js +5 -5
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -1
- package/lib/components/EntityManager/EntityManager.js +3 -3
- package/lib/components/EntityManager/EntityManager.js.map +1 -1
- package/lib/components/EntityManager/utils/entity.js +1 -1
- package/lib/components/EntityManager/utils/entity.js.map +1 -1
- package/lib/components/EntityManager/utils/entityAvailableActions.js +2 -2
- package/lib/components/EntityManager/utils/entityAvailableActions.js.map +1 -1
- package/lib/components/InfoBoxes/InfoBoxes.js +0 -1
- package/lib/components/InfoBoxes/InfoBoxes.js.map +1 -1
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js +1 -1
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +0 -1
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
- package/lib/components/ListingTable/ListingTable.js +7 -7
- package/lib/components/ListingTable/ListingTable.js.map +1 -1
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +1 -1
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js +496 -121
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js +12 -6
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/helpers.js +48 -12
- package/lib/components/ListingTable/SearchFilter/helpers.js.map +1 -1
- package/lib/components/ListingTable/TableActions/TableActions.js.map +1 -1
- package/lib/components/ListingTable/service/index.js +1 -2
- package/lib/components/ListingTable/service/index.js.map +1 -1
- package/lib/components/Tabs/index.js +4 -5
- package/lib/components/Tabs/index.js.map +1 -1
- package/lib/index.js +12 -5
- package/lib/index.js.map +1 -1
- package/lib/utils/add-content-menu-items.js +1 -1
- package/lib/utils/add-content-menu-items.js.map +1 -1
- package/lib/utils/hoc/withContext.js.map +1 -1
- 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/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/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.map +1 -1
- 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 +3 -5
- package/lib-es/components/Tabs/index.js.map +1 -1
- package/lib-es/index.js +3 -2
- 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 +11 -11
- package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +3 -3
- 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/Tabs/index.js +2 -6
- package/src/index.js +2 -0
- package/src/utils/hoc/withContext.js +5 -4
|
@@ -13,36 +13,47 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
13
13
|
});
|
|
14
14
|
exports["default"] = void 0;
|
|
15
15
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
18
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
19
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
20
|
+
require("core-js/modules/es.array.concat.js");
|
|
16
21
|
require("core-js/modules/es.array.filter.js");
|
|
17
22
|
require("core-js/modules/es.array.find.js");
|
|
18
23
|
require("core-js/modules/es.array.for-each.js");
|
|
24
|
+
require("core-js/modules/es.array.from.js");
|
|
25
|
+
require("core-js/modules/es.array.includes.js");
|
|
19
26
|
require("core-js/modules/es.array.is-array.js");
|
|
20
27
|
require("core-js/modules/es.array.iterator.js");
|
|
21
28
|
require("core-js/modules/es.array.join.js");
|
|
22
29
|
require("core-js/modules/es.array.map.js");
|
|
23
30
|
require("core-js/modules/es.array.reduce.js");
|
|
24
31
|
require("core-js/modules/es.function.name.js");
|
|
32
|
+
require("core-js/modules/es.map.js");
|
|
25
33
|
require("core-js/modules/es.object.entries.js");
|
|
26
34
|
require("core-js/modules/es.object.keys.js");
|
|
27
35
|
require("core-js/modules/es.object.to-string.js");
|
|
28
36
|
require("core-js/modules/es.promise.js");
|
|
37
|
+
require("core-js/modules/es.set.js");
|
|
38
|
+
require("core-js/modules/es.string.includes.js");
|
|
29
39
|
require("core-js/modules/es.string.iterator.js");
|
|
30
40
|
require("core-js/modules/web.dom-collections.for-each.js");
|
|
31
41
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
32
|
-
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
42
|
var _react = _interopRequireWildcard(require("react"));
|
|
36
43
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
37
44
|
var _select = _interopRequireDefault(require("@blaze-react/select"));
|
|
45
|
+
var _multiselect = _interopRequireDefault(require("@blaze-react/multiselect"));
|
|
46
|
+
var _lodash = _interopRequireDefault(require("lodash.debounce"));
|
|
47
|
+
var _lodash2 = _interopRequireDefault(require("lodash.unionby"));
|
|
38
48
|
var _client = require("@apollo/client");
|
|
39
49
|
var _adminUiUtils = require("@blaze-cms/admin-ui-utils");
|
|
50
|
+
var _utils = require("@blaze-cms/utils");
|
|
40
51
|
var _bs = require("react-icons/bs");
|
|
41
52
|
var _helpers = require("./helpers");
|
|
42
53
|
var _querys = require("./querys");
|
|
43
54
|
var _constants = require("../../../constants");
|
|
44
55
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
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 &&
|
|
56
|
+
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; }
|
|
46
57
|
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
58
|
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; }
|
|
48
59
|
var SearchContainer = function SearchContainer(_ref) {
|
|
@@ -51,9 +62,12 @@ var SearchContainer = function SearchContainer(_ref) {
|
|
|
51
62
|
keywordFiltersToUse = _ref$keywordFiltersTo === void 0 ? [] : _ref$keywordFiltersTo,
|
|
52
63
|
_ref$selectFiltersToD = _ref.selectFiltersToDisplay,
|
|
53
64
|
selectFiltersToDisplay = _ref$selectFiltersToD === void 0 ? [] : _ref$selectFiltersToD,
|
|
65
|
+
_ref$multiSelectFilte = _ref.multiSelectFiltersToDisplay,
|
|
66
|
+
multiSelectFiltersToDisplay = _ref$multiSelectFilte === void 0 ? [] : _ref$multiSelectFilte,
|
|
54
67
|
schema = _ref.schema,
|
|
55
|
-
index = _ref.index
|
|
56
|
-
|
|
68
|
+
index = _ref.index,
|
|
69
|
+
values = _ref.values;
|
|
70
|
+
var client = (0, _client.useApolloClient)();
|
|
57
71
|
var _useState = (0, _react.useState)(''),
|
|
58
72
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
59
73
|
searchTerm = _useState2[0],
|
|
@@ -66,15 +80,59 @@ var SearchContainer = function SearchContainer(_ref) {
|
|
|
66
80
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
67
81
|
selectOptions = _useState6[0],
|
|
68
82
|
setSelectOptions = _useState6[1];
|
|
83
|
+
var _useState7 = (0, _react.useState)([]),
|
|
84
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
85
|
+
multiSelectOptions = _useState8[0],
|
|
86
|
+
setMultiSelectOptions = _useState8[1];
|
|
87
|
+
var _useState9 = (0, _react.useState)([]),
|
|
88
|
+
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
89
|
+
allEntitySchemas = _useState10[0],
|
|
90
|
+
setAllEntitySchemas = _useState10[1];
|
|
69
91
|
var displaySearchFilter = keywordFiltersToUse.length > 0;
|
|
70
92
|
var displaySelectFilters = selectFiltersToDisplay.length > 0;
|
|
93
|
+
var displayMultiSelectFilters = multiSelectFiltersToDisplay.length > 0;
|
|
94
|
+
var displayAggregations = displaySelectFilters || displayMultiSelectFilters;
|
|
95
|
+
(0, _react.useEffect)(function () {
|
|
96
|
+
(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
97
|
+
var all;
|
|
98
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
99
|
+
while (1) switch (_context.prev = _context.next) {
|
|
100
|
+
case 0:
|
|
101
|
+
_context.prev = 0;
|
|
102
|
+
_context.next = 3;
|
|
103
|
+
return (0, _adminUiUtils.fetchAllEntities)({
|
|
104
|
+
client: client
|
|
105
|
+
});
|
|
106
|
+
case 3:
|
|
107
|
+
all = _context.sent;
|
|
108
|
+
setAllEntitySchemas(all || []);
|
|
109
|
+
_context.next = 10;
|
|
110
|
+
break;
|
|
111
|
+
case 7:
|
|
112
|
+
_context.prev = 7;
|
|
113
|
+
_context.t0 = _context["catch"](0);
|
|
114
|
+
setAllEntitySchemas([]);
|
|
115
|
+
case 10:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context.stop();
|
|
118
|
+
}
|
|
119
|
+
}, _callee, null, [[0, 7]]);
|
|
120
|
+
}))();
|
|
121
|
+
}, [client]);
|
|
122
|
+
var multiSelectPropertySet = (0, _react.useMemo)(function () {
|
|
123
|
+
return new Set(multiSelectFiltersToDisplay.map(function (_ref3) {
|
|
124
|
+
var _ref4 = (0, _slicedToArray2["default"])(_ref3, 1),
|
|
125
|
+
property = _ref4[0];
|
|
126
|
+
return property;
|
|
127
|
+
}));
|
|
128
|
+
}, [multiSelectFiltersToDisplay]);
|
|
71
129
|
var _useMemo = (0, _react.useMemo)(function () {
|
|
72
130
|
var labels = [];
|
|
73
131
|
var properties = [];
|
|
74
|
-
keywordFiltersToUse.forEach(function (
|
|
75
|
-
var
|
|
76
|
-
property =
|
|
77
|
-
label =
|
|
132
|
+
keywordFiltersToUse.forEach(function (_ref5) {
|
|
133
|
+
var _ref6 = (0, _slicedToArray2["default"])(_ref5, 2),
|
|
134
|
+
property = _ref6[0],
|
|
135
|
+
label = _ref6[1].label;
|
|
78
136
|
if (label) labels.push(label);
|
|
79
137
|
properties.push(property);
|
|
80
138
|
});
|
|
@@ -86,13 +144,13 @@ var SearchContainer = function SearchContainer(_ref) {
|
|
|
86
144
|
keywordSearchProperties = _useMemo.keywordSearchProperties,
|
|
87
145
|
keywordSearchLabels = _useMemo.keywordSearchLabels;
|
|
88
146
|
var _useMemo2 = (0, _react.useMemo)(function () {
|
|
89
|
-
return (0, _helpers.buildQueryFields)(selectFiltersToDisplay, schema.id);
|
|
90
|
-
}, [selectFiltersToDisplay, schema.id]),
|
|
147
|
+
return (0, _helpers.buildQueryFields)([].concat((0, _toConsumableArray2["default"])(selectFiltersToDisplay), (0, _toConsumableArray2["default"])(multiSelectFiltersToDisplay)), schema.id);
|
|
148
|
+
}, [selectFiltersToDisplay, multiSelectFiltersToDisplay, schema.id]),
|
|
91
149
|
gqlFields = _useMemo2.gqlFields,
|
|
92
150
|
rawQuery = _useMemo2.rawQuery;
|
|
93
|
-
var action =
|
|
151
|
+
var action = displayAggregations ? (0, _adminUiUtils.getDynamicQuery)('ADMIN_SEARCH')([schema], gqlFields, false, index) : _querys.NOOP_QUERY;
|
|
94
152
|
var _useQuery = (0, _client.useQuery)(action, {
|
|
95
|
-
skip: !
|
|
153
|
+
skip: !displayAggregations,
|
|
96
154
|
variables: {
|
|
97
155
|
where: rawQuery,
|
|
98
156
|
limit: 0
|
|
@@ -100,87 +158,143 @@ var SearchContainer = function SearchContainer(_ref) {
|
|
|
100
158
|
fetchPolicy: 'cache-and-network'
|
|
101
159
|
}),
|
|
102
160
|
data = _useQuery.data;
|
|
103
|
-
var
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
161
|
+
var buildRelationsIndex = (0, _react.useCallback)(function (schemaObj) {
|
|
162
|
+
var items = [];
|
|
163
|
+
if (schemaObj.properties) {
|
|
164
|
+
Object.entries(schemaObj.properties).forEach(function (_ref7) {
|
|
165
|
+
var _ref8 = (0, _slicedToArray2["default"])(_ref7, 2),
|
|
166
|
+
propName = _ref8[0],
|
|
167
|
+
definition = _ref8[1];
|
|
168
|
+
var _ref9 = definition || {},
|
|
169
|
+
relation = _ref9.relation;
|
|
170
|
+
if (!relation) return;
|
|
171
|
+
var relationLocalField = relation.localField,
|
|
172
|
+
entityIdentifier = relation.entityIdentifier;
|
|
173
|
+
var localField = relationLocalField || propName;
|
|
174
|
+
if (localField) items.push({
|
|
175
|
+
localField: localField,
|
|
176
|
+
entityIdentifier: entityIdentifier
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
if (Array.isArray(schemaObj.relations)) {
|
|
181
|
+
schemaObj.relations.forEach(function (relation) {
|
|
182
|
+
if (!relation.localField) return;
|
|
183
|
+
var localField = relation.localField,
|
|
184
|
+
entityIdentifier = relation.entityIdentifier;
|
|
185
|
+
items.push({
|
|
186
|
+
localField: localField,
|
|
187
|
+
entityIdentifier: entityIdentifier
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
var byKey = new Map();
|
|
192
|
+
items.forEach(function (item) {
|
|
193
|
+
var key = "".concat(item.localField, "|").concat(item.entityIdentifier || '');
|
|
194
|
+
if (!byKey.has(key)) byKey.set(key, item);
|
|
195
|
+
});
|
|
196
|
+
return Array.from(byKey.values());
|
|
197
|
+
}, []);
|
|
198
|
+
var relationsIndex = (0, _react.useMemo)(function () {
|
|
199
|
+
return buildRelationsIndex(schema);
|
|
200
|
+
}, [schema, buildRelationsIndex]);
|
|
201
|
+
var stringTypeProps = (0, _react.useMemo)(function () {
|
|
202
|
+
return (0, _utils.getStringTypeProps)(schema.id, relationsIndex, allEntitySchemas);
|
|
203
|
+
}, [schema.id, relationsIndex, allEntitySchemas]);
|
|
204
|
+
var aggregationsData = (0, _react.useMemo)(function () {
|
|
205
|
+
var _ref10 = data || {},
|
|
206
|
+
_ref10$searchResults = _ref10.searchResults,
|
|
207
|
+
_ref10$searchResults2 = _ref10$searchResults === void 0 ? {} : _ref10$searchResults,
|
|
208
|
+
_ref10$searchResults3 = _ref10$searchResults2.rawResults,
|
|
209
|
+
_ref10$searchResults4 = _ref10$searchResults3 === void 0 ? {} : _ref10$searchResults3,
|
|
210
|
+
_ref10$searchResults5 = _ref10$searchResults4.aggregations,
|
|
211
|
+
aggregations = _ref10$searchResults5 === void 0 ? {} : _ref10$searchResults5;
|
|
212
|
+
var processed = [];
|
|
213
|
+
Object.entries(aggregations).forEach(function (_ref11) {
|
|
214
|
+
var _ref12 = (0, _slicedToArray2["default"])(_ref11, 2),
|
|
215
|
+
key = _ref12[0],
|
|
216
|
+
buckets = _ref12[1].buckets;
|
|
217
|
+
processed.push(Array.isArray(buckets) ? [key, buckets.map(function (bucket) {
|
|
218
|
+
return bucket.key;
|
|
118
219
|
}).filter(Boolean)] : []);
|
|
119
220
|
});
|
|
120
|
-
return
|
|
221
|
+
return processed;
|
|
121
222
|
}, [data]);
|
|
223
|
+
var findFilterConfig = (0, _react.useCallback)(function (property) {
|
|
224
|
+
var _selectFiltersToDispl, _multiSelectFiltersTo;
|
|
225
|
+
return ((_selectFiltersToDispl = selectFiltersToDisplay.find(function (_ref13) {
|
|
226
|
+
var _ref14 = (0, _slicedToArray2["default"])(_ref13, 1),
|
|
227
|
+
prop = _ref14[0];
|
|
228
|
+
return prop === property;
|
|
229
|
+
})) === null || _selectFiltersToDispl === void 0 ? void 0 : _selectFiltersToDispl[1]) || ((_multiSelectFiltersTo = multiSelectFiltersToDisplay.find(function (_ref15) {
|
|
230
|
+
var _ref16 = (0, _slicedToArray2["default"])(_ref15, 1),
|
|
231
|
+
prop = _ref16[0];
|
|
232
|
+
return prop === property;
|
|
233
|
+
})) === null || _multiSelectFiltersTo === void 0 ? void 0 : _multiSelectFiltersTo[1]);
|
|
234
|
+
}, [selectFiltersToDisplay, multiSelectFiltersToDisplay]);
|
|
122
235
|
(0, _react.useEffect)(function () {
|
|
123
|
-
if (!
|
|
236
|
+
if (!aggregationsData.length) {
|
|
124
237
|
setSelectOptions([]);
|
|
238
|
+
setMultiSelectOptions([]);
|
|
125
239
|
return;
|
|
126
240
|
}
|
|
127
|
-
(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function
|
|
128
|
-
var results;
|
|
129
|
-
return _regenerator["default"].wrap(function
|
|
130
|
-
while (1) switch (
|
|
241
|
+
(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
242
|
+
var results, valid;
|
|
243
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
244
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
131
245
|
case 0:
|
|
132
|
-
|
|
133
|
-
return Promise.all(
|
|
134
|
-
var
|
|
135
|
-
var
|
|
136
|
-
return _regenerator["default"].wrap(function
|
|
137
|
-
while (1) switch (
|
|
246
|
+
_context3.next = 2;
|
|
247
|
+
return Promise.all(aggregationsData.map( /*#__PURE__*/function () {
|
|
248
|
+
var _ref19 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_ref18) {
|
|
249
|
+
var _ref20, property, ids, config, _config$adminListingO, _config$adminListingO2, tidyLabel, _baseOptions, schemaQuery, _yield$client$query, _yield$client$query$d, relationSchema, _yield$client$query$c, _yield$client$query$c2, selected, baseOptions;
|
|
250
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
251
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
138
252
|
case 0:
|
|
139
|
-
|
|
140
|
-
|
|
253
|
+
_ref20 = (0, _slicedToArray2["default"])(_ref18, 2), property = _ref20[0], ids = _ref20[1];
|
|
254
|
+
_context2.prev = 1;
|
|
141
255
|
if (!(!ids || !ids.length)) {
|
|
142
|
-
|
|
256
|
+
_context2.next = 4;
|
|
143
257
|
break;
|
|
144
258
|
}
|
|
145
|
-
return
|
|
259
|
+
return _context2.abrupt("return", null);
|
|
146
260
|
case 4:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return selectProperty === property;
|
|
151
|
-
}) || [], _ref12 = (0, _slicedToArray2["default"])(_ref11, 2), selectionDetails = _ref12[1];
|
|
152
|
-
if (selectionDetails) {
|
|
153
|
-
_context.next = 7;
|
|
261
|
+
config = findFilterConfig(property);
|
|
262
|
+
if (config) {
|
|
263
|
+
_context2.next = 7;
|
|
154
264
|
break;
|
|
155
265
|
}
|
|
156
|
-
return
|
|
266
|
+
return _context2.abrupt("return", null);
|
|
157
267
|
case 7:
|
|
158
|
-
|
|
159
|
-
|
|
268
|
+
_config$adminListingO = config.adminListingOptions, _config$adminListingO2 = _config$adminListingO === void 0 ? {} : _config$adminListingO, tidyLabel = _config$adminListingO2.tidyLabel;
|
|
269
|
+
if (config.relation) {
|
|
270
|
+
_context2.next = 11;
|
|
160
271
|
break;
|
|
161
272
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
label: selectionDetails.label,
|
|
165
|
-
options: ids.map(function (value) {
|
|
166
|
-
return [value, value];
|
|
167
|
-
})
|
|
273
|
+
_baseOptions = ids.map(function (value) {
|
|
274
|
+
return [value, (0, _helpers.getTidyLabel)(value, tidyLabel)];
|
|
168
275
|
});
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
276
|
+
return _context2.abrupt("return", {
|
|
277
|
+
property: property,
|
|
278
|
+
label: config.label,
|
|
279
|
+
type: multiSelectPropertySet.has(property) ? 'multi' : 'single',
|
|
280
|
+
options: _baseOptions,
|
|
281
|
+
selected: values && values[property]
|
|
282
|
+
});
|
|
283
|
+
case 11:
|
|
284
|
+
schemaQuery = (0, _adminUiUtils.getQuery)('GET_ENTITY_SCHEMA');
|
|
285
|
+
_context2.next = 14;
|
|
286
|
+
return client.query({
|
|
287
|
+
query: schemaQuery,
|
|
174
288
|
variables: {
|
|
175
|
-
identifier:
|
|
289
|
+
identifier: config.relation.entityIdentifier
|
|
176
290
|
}
|
|
177
291
|
});
|
|
178
|
-
case
|
|
179
|
-
_yield$
|
|
180
|
-
_yield$
|
|
181
|
-
relationSchema = _yield$
|
|
182
|
-
|
|
183
|
-
return
|
|
292
|
+
case 14:
|
|
293
|
+
_yield$client$query = _context2.sent;
|
|
294
|
+
_yield$client$query$d = (0, _slicedToArray2["default"])(_yield$client$query.data.getEntitySchemas, 1);
|
|
295
|
+
relationSchema = _yield$client$query$d[0];
|
|
296
|
+
_context2.next = 19;
|
|
297
|
+
return client.query({
|
|
184
298
|
query: (0, _adminUiUtils.getDynamicQuery)('GET_ALL_ENTITIES')(relationSchema),
|
|
185
299
|
variables: {
|
|
186
300
|
where: {
|
|
@@ -195,72 +309,277 @@ var SearchContainer = function SearchContainer(_ref) {
|
|
|
195
309
|
}
|
|
196
310
|
})
|
|
197
311
|
// eslint-disable-next-line no-console
|
|
198
|
-
["catch"](function (
|
|
199
|
-
return console.error(
|
|
312
|
+
["catch"](function (error) {
|
|
313
|
+
return console.error(error);
|
|
314
|
+
});
|
|
315
|
+
case 19:
|
|
316
|
+
_yield$client$query$c = _context2.sent;
|
|
317
|
+
_yield$client$query$c2 = _yield$client$query$c.data.result;
|
|
318
|
+
selected = _yield$client$query$c2 === void 0 ? [] : _yield$client$query$c2;
|
|
319
|
+
baseOptions = selected.map(function (item) {
|
|
320
|
+
return [item.id, (0, _helpers.getTidyLabel)(item.name, tidyLabel)];
|
|
200
321
|
});
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
label: selectionDetails.label,
|
|
208
|
-
options: selected.map(function (item) {
|
|
209
|
-
return [item.id, item.name];
|
|
210
|
-
})
|
|
322
|
+
return _context2.abrupt("return", {
|
|
323
|
+
property: property,
|
|
324
|
+
label: config.label || config.relation.label,
|
|
325
|
+
type: multiSelectPropertySet.has(property) ? 'multi' : 'single',
|
|
326
|
+
options: baseOptions,
|
|
327
|
+
selected: values && values[property]
|
|
211
328
|
});
|
|
212
|
-
case 23:
|
|
213
|
-
_context.prev = 23;
|
|
214
|
-
_context.t0 = _context["catch"](1);
|
|
215
|
-
return _context.abrupt("return", null);
|
|
216
329
|
case 26:
|
|
330
|
+
_context2.prev = 26;
|
|
331
|
+
_context2.t0 = _context2["catch"](1);
|
|
332
|
+
return _context2.abrupt("return", null);
|
|
333
|
+
case 29:
|
|
217
334
|
case "end":
|
|
218
|
-
return
|
|
335
|
+
return _context2.stop();
|
|
219
336
|
}
|
|
220
|
-
},
|
|
337
|
+
}, _callee2, null, [[1, 26]]);
|
|
221
338
|
}));
|
|
222
339
|
return function (_x) {
|
|
223
|
-
return
|
|
340
|
+
return _ref19.apply(this, arguments);
|
|
224
341
|
};
|
|
225
342
|
}()));
|
|
226
343
|
case 2:
|
|
227
|
-
results =
|
|
228
|
-
|
|
229
|
-
|
|
344
|
+
results = _context3.sent;
|
|
345
|
+
valid = results.filter(Boolean);
|
|
346
|
+
setSelectOptions(valid.filter(function (option) {
|
|
347
|
+
return option.type === 'single';
|
|
348
|
+
}).map(function (_ref21) {
|
|
349
|
+
var property = _ref21.property,
|
|
350
|
+
label = _ref21.label,
|
|
351
|
+
options = _ref21.options,
|
|
352
|
+
selected = _ref21.selected;
|
|
353
|
+
return {
|
|
354
|
+
id: property,
|
|
355
|
+
label: label,
|
|
356
|
+
options: options,
|
|
357
|
+
selected: selected
|
|
358
|
+
};
|
|
359
|
+
}));
|
|
360
|
+
setMultiSelectOptions(valid.filter(function (option) {
|
|
361
|
+
return option.type === 'multi';
|
|
362
|
+
}).map(function (_ref22) {
|
|
363
|
+
var property = _ref22.property,
|
|
364
|
+
label = _ref22.label,
|
|
365
|
+
options = _ref22.options,
|
|
366
|
+
selected = _ref22.selected;
|
|
367
|
+
return {
|
|
368
|
+
id: property,
|
|
369
|
+
label: label,
|
|
370
|
+
items: options.map(function (_ref23) {
|
|
371
|
+
var _ref24 = (0, _slicedToArray2["default"])(_ref23, 2),
|
|
372
|
+
id = _ref24[0],
|
|
373
|
+
name = _ref24[1];
|
|
374
|
+
return {
|
|
375
|
+
id: id,
|
|
376
|
+
name: name
|
|
377
|
+
};
|
|
378
|
+
}),
|
|
379
|
+
selected: selected
|
|
380
|
+
};
|
|
381
|
+
}));
|
|
382
|
+
case 6:
|
|
230
383
|
case "end":
|
|
231
|
-
return
|
|
384
|
+
return _context3.stop();
|
|
232
385
|
}
|
|
233
|
-
},
|
|
386
|
+
}, _callee3);
|
|
234
387
|
}))();
|
|
235
|
-
}, [
|
|
388
|
+
}, [client, aggregationsData, findFilterConfig, multiSelectPropertySet, values]);
|
|
236
389
|
var updateFilters = (0, _react.useCallback)(function (term, filters) {
|
|
237
390
|
return (0, _helpers.updateListFilters)(term, filters, setListFilters, keywordSearchProperties);
|
|
238
391
|
}, [setListFilters, keywordSearchProperties]);
|
|
392
|
+
var debouncedUpdateFilters = (0, _react.useMemo)(function () {
|
|
393
|
+
return (0, _lodash["default"])(function (term, filters) {
|
|
394
|
+
return updateFilters(term, filters);
|
|
395
|
+
}, 300);
|
|
396
|
+
}, [updateFilters]);
|
|
397
|
+
(0, _react.useEffect)(function () {
|
|
398
|
+
return function () {
|
|
399
|
+
return debouncedUpdateFilters.cancel();
|
|
400
|
+
};
|
|
401
|
+
}, [debouncedUpdateFilters]);
|
|
239
402
|
var handleSearch = (0, _react.useCallback)(function () {
|
|
240
403
|
return updateFilters(searchTerm, selectedFilters);
|
|
241
404
|
}, [searchTerm, selectedFilters, updateFilters]);
|
|
242
|
-
var handleSearchChange = (0, _react.useCallback)(function (
|
|
243
|
-
|
|
405
|
+
var handleSearchChange = (0, _react.useCallback)(function (_ref25) {
|
|
406
|
+
var value = _ref25.target.value;
|
|
407
|
+
return setSearchTerm(value);
|
|
244
408
|
}, []);
|
|
245
|
-
var handleEnterKey = (0, _react.useCallback)(function (
|
|
246
|
-
|
|
409
|
+
var handleEnterKey = (0, _react.useCallback)(function (_ref26) {
|
|
410
|
+
var key = _ref26.key;
|
|
411
|
+
if (key === _constants.ENTER_KEY) handleSearch();
|
|
247
412
|
}, [handleSearch]);
|
|
248
413
|
var handleReset = (0, _react.useCallback)(function () {
|
|
249
414
|
setSearchTerm('');
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
415
|
+
debouncedUpdateFilters.cancel();
|
|
416
|
+
setSelectedFilters(function (prev) {
|
|
417
|
+
return Object.keys(prev).reduce(function (acc, key) {
|
|
418
|
+
acc[key] = multiSelectPropertySet.has(key) ? [] : _constants.DEFAULT_FILTER_OPTION_LABEL;
|
|
419
|
+
return acc;
|
|
420
|
+
}, {});
|
|
421
|
+
});
|
|
253
422
|
updateFilters('', {});
|
|
254
|
-
}, [
|
|
255
|
-
var handleSelect = (0, _react.useCallback)(function (property,
|
|
256
|
-
var value =
|
|
423
|
+
}, [multiSelectPropertySet, updateFilters, debouncedUpdateFilters]);
|
|
424
|
+
var handleSelect = (0, _react.useCallback)(function (property, _ref27) {
|
|
425
|
+
var value = _ref27.value;
|
|
257
426
|
var next = _objectSpread(_objectSpread({}, selectedFilters), {}, (0, _defineProperty2["default"])({}, property, value));
|
|
258
427
|
setSelectedFilters(next);
|
|
259
|
-
|
|
260
|
-
}, [searchTerm, selectedFilters,
|
|
428
|
+
debouncedUpdateFilters(searchTerm, next);
|
|
429
|
+
}, [searchTerm, selectedFilters, debouncedUpdateFilters]);
|
|
430
|
+
var handleMultiSelect = (0, _react.useCallback)(function (property, ids) {
|
|
431
|
+
var next = _objectSpread(_objectSpread({}, selectedFilters), {}, (0, _defineProperty2["default"])({}, property, ids));
|
|
432
|
+
setSelectedFilters(next);
|
|
433
|
+
debouncedUpdateFilters(searchTerm, next);
|
|
434
|
+
}, [searchTerm, selectedFilters, debouncedUpdateFilters]);
|
|
435
|
+
var findRelationByLocalField = (0, _react.useCallback)(function (localField) {
|
|
436
|
+
return relationsIndex.find(function (relation) {
|
|
437
|
+
return relation.localField === localField;
|
|
438
|
+
});
|
|
439
|
+
}, [relationsIndex]);
|
|
440
|
+
var resolveAggProp = (0, _react.useCallback)(function (property, config) {
|
|
441
|
+
if (!config.relation) return property;
|
|
442
|
+
if (property.includes('.')) return property;
|
|
443
|
+
var localField = config.relation.localField || property;
|
|
444
|
+
return "".concat(localField, ".name");
|
|
445
|
+
}, []);
|
|
446
|
+
var resolveEntityIdentifier = (0, _react.useCallback)(function (property, config) {
|
|
447
|
+
if (!config.relation) return undefined;
|
|
448
|
+
if (config.relation.entityIdentifier) return config.relation.entityIdentifier;
|
|
449
|
+
var localField = property.includes('.') ? property.split('.')[0] : config.relation.localField || property;
|
|
450
|
+
return findRelationByLocalField(localField).entityIdentifier;
|
|
451
|
+
}, [findRelationByLocalField]);
|
|
452
|
+
var addEntitySuffixIfNeeded = (0, _react.useCallback)(function (aggProp, entityIdentifier, config) {
|
|
453
|
+
if (!config.relation || !entityIdentifier) return aggProp;
|
|
454
|
+
return "".concat(aggProp, "/").concat(entityIdentifier);
|
|
455
|
+
}, []);
|
|
456
|
+
var makeOnSearchChange = (0, _react.useCallback)(function (property) {
|
|
457
|
+
return /*#__PURE__*/function () {
|
|
458
|
+
var _ref29 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(_ref28) {
|
|
459
|
+
var value, currentOffset, _config$relation, _aggregations$key, _multiSelectOptions$f, config, aggProp, matchingRelation, entityIdentifier, filterByEntry, currentValues, aggregations, key, buckets, items, names, schemaQuery, _yield$client$query2, _yield$client$query2$, relationSchema, _yield$client$query$c3, _yield$client$query$c4, selected, existingItems;
|
|
460
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
461
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
462
|
+
case 0:
|
|
463
|
+
value = _ref28.event.value, currentOffset = _ref28.currentOffset;
|
|
464
|
+
_context4.prev = 1;
|
|
465
|
+
if (!(!value || currentOffset)) {
|
|
466
|
+
_context4.next = 4;
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
return _context4.abrupt("return", []);
|
|
470
|
+
case 4:
|
|
471
|
+
config = findFilterConfig(property);
|
|
472
|
+
if (config) {
|
|
473
|
+
_context4.next = 7;
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
return _context4.abrupt("return", []);
|
|
477
|
+
case 7:
|
|
478
|
+
aggProp = resolveAggProp(property, config);
|
|
479
|
+
if (config.relation && !config.relation.localField && !property.includes('.')) {
|
|
480
|
+
matchingRelation = findRelationByLocalField(property);
|
|
481
|
+
if (matchingRelation.localField) aggProp = "".concat(matchingRelation.localField, ".name");
|
|
482
|
+
}
|
|
483
|
+
entityIdentifier = resolveEntityIdentifier(property, config) || ((_config$relation = config.relation) === null || _config$relation === void 0 ? void 0 : _config$relation.entityIdentifier);
|
|
484
|
+
filterByEntry = addEntitySuffixIfNeeded(aggProp, entityIdentifier, config);
|
|
485
|
+
currentValues = {
|
|
486
|
+
entity: schema.id,
|
|
487
|
+
filterByProperty: [filterByEntry]
|
|
488
|
+
};
|
|
489
|
+
_context4.next = 14;
|
|
490
|
+
return (0, _adminUiUtils.fetchFilterByDataFromElastic)(client, currentValues, relationsIndex, stringTypeProps, value);
|
|
491
|
+
case 14:
|
|
492
|
+
aggregations = _context4.sent;
|
|
493
|
+
key = aggProp;
|
|
494
|
+
buckets = (aggregations === null || aggregations === void 0 ? void 0 : (_aggregations$key = aggregations[key]) === null || _aggregations$key === void 0 ? void 0 : _aggregations$key.buckets) || [];
|
|
495
|
+
items = [];
|
|
496
|
+
if (!config.relation) {
|
|
497
|
+
_context4.next = 35;
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
names = buckets.map(function (bucket) {
|
|
501
|
+
return bucket.key;
|
|
502
|
+
}).filter(Boolean);
|
|
503
|
+
if (!names.length) {
|
|
504
|
+
_context4.next = 33;
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
schemaQuery = (0, _adminUiUtils.getQuery)('GET_ENTITY_SCHEMA');
|
|
508
|
+
_context4.next = 24;
|
|
509
|
+
return client.query({
|
|
510
|
+
query: schemaQuery,
|
|
511
|
+
variables: {
|
|
512
|
+
identifier: entityIdentifier
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
case 24:
|
|
516
|
+
_yield$client$query2 = _context4.sent;
|
|
517
|
+
_yield$client$query2$ = (0, _slicedToArray2["default"])(_yield$client$query2.data.getEntitySchemas, 1);
|
|
518
|
+
relationSchema = _yield$client$query2$[0];
|
|
519
|
+
_context4.next = 29;
|
|
520
|
+
return client.query({
|
|
521
|
+
query: (0, _adminUiUtils.getDynamicQuery)('GET_ALL_ENTITIES')(relationSchema),
|
|
522
|
+
variables: {
|
|
523
|
+
where: {
|
|
524
|
+
name: {
|
|
525
|
+
_in: names
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
sort: [{
|
|
529
|
+
property: 'name',
|
|
530
|
+
direction: 'asc'
|
|
531
|
+
}]
|
|
532
|
+
}
|
|
533
|
+
})
|
|
534
|
+
// eslint-disable-next-line no-console
|
|
535
|
+
["catch"](function (error) {
|
|
536
|
+
return console.error(error);
|
|
537
|
+
});
|
|
538
|
+
case 29:
|
|
539
|
+
_yield$client$query$c3 = _context4.sent;
|
|
540
|
+
_yield$client$query$c4 = _yield$client$query$c3.data.result;
|
|
541
|
+
selected = _yield$client$query$c4 === void 0 ? [] : _yield$client$query$c4;
|
|
542
|
+
items = selected.map(function (item) {
|
|
543
|
+
return {
|
|
544
|
+
id: item.id,
|
|
545
|
+
name: item.name
|
|
546
|
+
};
|
|
547
|
+
});
|
|
548
|
+
case 33:
|
|
549
|
+
_context4.next = 36;
|
|
550
|
+
break;
|
|
551
|
+
case 35:
|
|
552
|
+
items = buckets.map(function (bucket) {
|
|
553
|
+
return {
|
|
554
|
+
id: bucket.key,
|
|
555
|
+
name: bucket.key
|
|
556
|
+
};
|
|
557
|
+
}).filter(function (option) {
|
|
558
|
+
return option.id != null;
|
|
559
|
+
});
|
|
560
|
+
case 36:
|
|
561
|
+
existingItems = ((_multiSelectOptions$f = multiSelectOptions.find(function (opt) {
|
|
562
|
+
return opt.id === property;
|
|
563
|
+
})) === null || _multiSelectOptions$f === void 0 ? void 0 : _multiSelectOptions$f.items) || [];
|
|
564
|
+
return _context4.abrupt("return", (0, _lodash2["default"])(items, existingItems, 'id'));
|
|
565
|
+
case 40:
|
|
566
|
+
_context4.prev = 40;
|
|
567
|
+
_context4.t0 = _context4["catch"](1);
|
|
568
|
+
return _context4.abrupt("return", []);
|
|
569
|
+
case 43:
|
|
570
|
+
case "end":
|
|
571
|
+
return _context4.stop();
|
|
572
|
+
}
|
|
573
|
+
}, _callee4, null, [[1, 40]]);
|
|
574
|
+
}));
|
|
575
|
+
return function (_x2) {
|
|
576
|
+
return _ref29.apply(this, arguments);
|
|
577
|
+
};
|
|
578
|
+
}();
|
|
579
|
+
}, [client, schema.id, relationsIndex, stringTypeProps, multiSelectOptions, findFilterConfig, resolveAggProp, resolveEntityIdentifier, addEntitySuffixIfNeeded, findRelationByLocalField]);
|
|
261
580
|
var placeholderText = "Search ".concat(keywordSearchLabels.join(', '));
|
|
262
581
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
263
|
-
className: "search-container"
|
|
582
|
+
className: "search-container ms-filter"
|
|
264
583
|
}, displaySearchFilter && /*#__PURE__*/_react["default"].createElement("div", {
|
|
265
584
|
className: "search-container__search-input-container"
|
|
266
585
|
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
@@ -273,23 +592,77 @@ var SearchContainer = function SearchContainer(_ref) {
|
|
|
273
592
|
}), /*#__PURE__*/_react["default"].createElement("i", {
|
|
274
593
|
role: "button",
|
|
275
594
|
onClick: handleSearch
|
|
276
|
-
}, /*#__PURE__*/_react["default"].createElement(_bs.BsSearch, null))), displaySelectFilters && selectOptions.map(function (
|
|
277
|
-
var id =
|
|
278
|
-
options =
|
|
279
|
-
label =
|
|
280
|
-
|
|
281
|
-
|
|
595
|
+
}, /*#__PURE__*/_react["default"].createElement(_bs.BsSearch, null))), displaySelectFilters && selectOptions.map(function (_ref30) {
|
|
596
|
+
var id = _ref30.id,
|
|
597
|
+
options = _ref30.options,
|
|
598
|
+
label = _ref30.label,
|
|
599
|
+
selected = _ref30.selected;
|
|
600
|
+
return options && options.length ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
601
|
+
className: "search-container__select-wrapper",
|
|
602
|
+
key: "select-".concat(id)
|
|
282
603
|
}, /*#__PURE__*/_react["default"].createElement(_select["default"], {
|
|
283
604
|
label: label,
|
|
284
605
|
id: id,
|
|
285
606
|
name: id,
|
|
286
|
-
onChange: function onChange(
|
|
287
|
-
|
|
607
|
+
onChange: function onChange(_ref31) {
|
|
608
|
+
var value = _ref31.value;
|
|
609
|
+
return handleSelect(id, {
|
|
610
|
+
value: value
|
|
611
|
+
});
|
|
288
612
|
},
|
|
289
613
|
options: options,
|
|
290
|
-
value: selectedFilters[id],
|
|
614
|
+
value: selectedFilters[id] !== undefined ? selectedFilters[id] : selected,
|
|
291
615
|
defaultTextValue: _constants.DEFAULT_FILTER_OPTION_LABEL
|
|
292
|
-
}))
|
|
616
|
+
})) : null;
|
|
617
|
+
}), displayMultiSelectFilters && multiSelectOptions.map(function (_ref32) {
|
|
618
|
+
var id = _ref32.id,
|
|
619
|
+
label = _ref32.label,
|
|
620
|
+
items = _ref32.items;
|
|
621
|
+
var selectedIds = selectedFilters[id] ? selectedFilters[id] : [];
|
|
622
|
+
var multiSelectData = {
|
|
623
|
+
filterBy: ['name'],
|
|
624
|
+
identification: 'id',
|
|
625
|
+
keyValue: 'name',
|
|
626
|
+
data: items.map(function (_ref33) {
|
|
627
|
+
var itemId = _ref33.id,
|
|
628
|
+
name = _ref33.name;
|
|
629
|
+
return {
|
|
630
|
+
id: itemId,
|
|
631
|
+
name: name,
|
|
632
|
+
description: '',
|
|
633
|
+
checked: selectedIds.includes(itemId),
|
|
634
|
+
show: true
|
|
635
|
+
};
|
|
636
|
+
})
|
|
637
|
+
};
|
|
638
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
639
|
+
className: "search-container__select-wrapper",
|
|
640
|
+
key: "multiselect-".concat(id)
|
|
641
|
+
}, /*#__PURE__*/_react["default"].createElement(_multiselect["default"], {
|
|
642
|
+
onChange: function onChange(_ref34) {
|
|
643
|
+
var value = _ref34.value,
|
|
644
|
+
currentOffset = _ref34.currentOffset;
|
|
645
|
+
return makeOnSearchChange(id)({
|
|
646
|
+
event: {
|
|
647
|
+
value: value
|
|
648
|
+
},
|
|
649
|
+
currentOffset: currentOffset
|
|
650
|
+
});
|
|
651
|
+
},
|
|
652
|
+
name: id,
|
|
653
|
+
label: label,
|
|
654
|
+
data: multiSelectData,
|
|
655
|
+
limit: 10,
|
|
656
|
+
getSelected: function getSelected(_ref35) {
|
|
657
|
+
var value = _ref35.event.target.value;
|
|
658
|
+
return handleMultiSelect(id, value);
|
|
659
|
+
},
|
|
660
|
+
required: false,
|
|
661
|
+
checkedPreviewCount: 1,
|
|
662
|
+
formatMoreLabel: function formatMoreLabel(n) {
|
|
663
|
+
return "".concat(n, " more");
|
|
664
|
+
}
|
|
665
|
+
}));
|
|
293
666
|
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
294
667
|
className: "search-container__reset-button"
|
|
295
668
|
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
@@ -301,12 +674,14 @@ SearchContainer.propTypes = {
|
|
|
301
674
|
setListFilters: _propTypes["default"].func.isRequired,
|
|
302
675
|
keywordFiltersToUse: _propTypes["default"].array,
|
|
303
676
|
selectFiltersToDisplay: _propTypes["default"].array,
|
|
677
|
+
multiSelectFiltersToDisplay: _propTypes["default"].array,
|
|
304
678
|
schema: _propTypes["default"].object.isRequired,
|
|
305
679
|
index: _propTypes["default"].string
|
|
306
680
|
};
|
|
307
681
|
SearchContainer.defaultProps = {
|
|
308
682
|
keywordFiltersToUse: [],
|
|
309
683
|
selectFiltersToDisplay: [],
|
|
684
|
+
multiSelectFiltersToDisplay: [],
|
|
310
685
|
index: 'admin'
|
|
311
686
|
};
|
|
312
687
|
var _default = exports["default"] = SearchContainer;
|