@civicactions/cmsds-open-data-components 2.0.0-alpha.9 → 2.0.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/dist/CMSGovLogo-O.3fac6f9b.png +0 -0
- package/dist/CMSgov@2x-white-O.a5f4312c.png +0 -0
- package/dist/main.css +28 -39
- package/dist/main.css.map +1 -1
- package/dist/main.js +2966 -1311
- package/dist/main.js.map +1 -1
- package/dist/scss/components/additional-information-table.scss +9 -0
- package/dist/scss/components/breadcrumb.scss +32 -0
- package/dist/scss/components/dataset-downloads.scss +0 -0
- package/dist/scss/components/dataset-search-facets.scss +10 -0
- package/dist/scss/components/dataset-search-list-item.scss +20 -0
- package/dist/scss/components/dataset-tags.scss +4 -0
- package/dist/scss/components/datatable.scss +24 -0
- package/dist/scss/components/index.scss +9 -0
- package/dist/scss/components/pagination.scss +59 -0
- package/dist/scss/components/resource-information-table.scss +5 -0
- package/dist/scss/index.scss +24 -0
- package/dist/scss/templates/dataset-search.scss +38 -0
- package/dist/scss/templates/dataset.scss +44 -0
- package/dist/scss/templates/filtered-resource.scss +19 -0
- package/dist/scss/templates/footer.scss +83 -0
- package/dist/scss/templates/header.scss +402 -0
- package/dist/scss/templates/index.scss +7 -0
- package/dist/scss/templates/query-builder.scss +22 -0
- package/dist/scss/templates/swagger.scss +21 -0
- package/dist/types.d.ts +26 -3
- package/dist/types.d.ts.map +1 -1
- package/lib/assets/frequencyMap.js +22 -0
- package/lib/assets/icons/close.js +33 -0
- package/lib/assets/icons/close.jsx +24 -0
- package/lib/assets/icons/copy.js +33 -0
- package/lib/assets/icons/copy.jsx +23 -0
- package/lib/assets/icons/download.js +33 -0
- package/lib/assets/icons/download.jsx +23 -0
- package/lib/assets/icons/settings.js +34 -0
- package/lib/assets/icons/settings.jsx +24 -0
- package/lib/assets/images/CMSGovLogo-O.png +0 -0
- package/lib/assets/images/CMSgov@2x-white-O.png +0 -0
- package/lib/assets/metadataMapping.js +161 -0
- package/lib/assets/metadataMapping.jsx +110 -0
- package/lib/commands/index.js +7 -0
- package/lib/commands/templates/footer.js +61 -0
- package/lib/commands/templates/header.js +84 -0
- package/lib/commands/templates/page_not_found.js +14 -0
- package/lib/components/ApiDocumentation/index.js +24 -0
- package/lib/components/Breadcrumb/index.js +47 -0
- package/lib/components/DataTableDensity/datatabledensity.test.js +30 -0
- package/lib/components/DataTableDensity/index.js +47 -0
- package/lib/components/DataTableRowChanger/datatablerowchanger.test.js +49 -0
- package/lib/components/DataTableRowChanger/index.js +46 -0
- package/lib/components/DatasetAdditionalInformation/index.js +59 -0
- package/lib/components/DatasetDownloads/datasetdownloads.test.js +30 -0
- package/lib/components/DatasetDownloads/index.js +34 -0
- package/lib/components/DatasetSearchFacets/dataset_search_facets.test.js +103 -0
- package/lib/components/DatasetSearchFacets/index.js +104 -0
- package/lib/components/DatasetSearchListItem/datasetsearchlistitem.test.js +44 -0
- package/lib/components/DatasetSearchListItem/index.js +86 -0
- package/lib/components/DatasetTags/datasettags.test.js +40 -0
- package/lib/components/DatasetTags/index.js +38 -0
- package/lib/components/Hero/index.js +92 -0
- package/lib/components/ManageColumns/index.js +36 -0
- package/lib/components/NavBar/index.js +55 -0
- package/lib/components/NavLink/index.js +60 -0
- package/lib/components/NavLink/navlink.test.js +35 -0
- package/lib/components/Pagination/index.js +263 -0
- package/lib/components/Pagination/pagination.test.js +541 -0
- package/lib/components/ResourceConditionField/ResourceConditionalField.test.js +20 -0
- package/lib/components/ResourceConditionField/index.js +246 -0
- package/lib/components/ResourceFilter/index.js +174 -0
- package/lib/components/ResourceFilter/resourcefilter.test.js +440 -0
- package/lib/components/ResourceFooter/index.js +34 -0
- package/lib/components/ResourceHeader/index.js +149 -0
- package/lib/components/ResourceInformation/index.js +37 -0
- package/lib/components/ResourcePreview/index.js +139 -0
- package/lib/components/SearchModal/index.js +116 -0
- package/lib/components/SubMenu/index.js +86 -0
- package/lib/components/TransformedDate/index.js +34 -0
- package/lib/components/useAddLoginLink/index.js +44 -0
- package/lib/components/useScrollToTop/index.js +22 -0
- package/lib/index.js +247 -0
- package/lib/templates/APIPage/index.js +30 -0
- package/lib/templates/Dataset/DatasetBody.js +189 -0
- package/lib/templates/Dataset/index.js +83 -0
- package/lib/templates/DatasetSearch/datasetsearch.test.js +122 -0
- package/lib/templates/DatasetSearch/index.js +356 -0
- package/lib/templates/DrupalPage/index.js +37 -0
- package/lib/templates/FilteredResource/FilteredResourceBody.js +160 -0
- package/lib/templates/FilteredResource/QueryBuilder.js +235 -0
- package/lib/templates/FilteredResource/QueryRow.js +175 -0
- package/lib/templates/FilteredResource/QueryTitle.js +89 -0
- package/lib/templates/FilteredResource/functions.js +142 -0
- package/lib/templates/FilteredResource/index.js +95 -0
- package/lib/templates/Footer/footer.test.js +48 -0
- package/lib/templates/Footer/index.js +366 -0
- package/lib/templates/PageNotFound/index.js +25 -0
- package/lib/templates/header/index.js +112 -0
- package/lib/templates/mobile_header/index.js +199 -0
- package/package.json +11 -7
- /package/dist/{CMSGovLogo-O.90ce815c.png → CMSGovLogo-O.3e657bfb.png} +0 -0
- /package/dist/{CMSgov@2x-white-O.78cd05d3.png → CMSgov@2x-white-O.5655e842.png} +0 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
16
|
+
var _designSystem = require("@cmsgov/design-system");
|
|
17
|
+
|
|
18
|
+
var _reactDatepicker = _interopRequireDefault(require("react-datepicker"));
|
|
19
|
+
|
|
20
|
+
var _close = _interopRequireDefault(require("../../assets/icons/close"));
|
|
21
|
+
|
|
22
|
+
require("react-datepicker/dist/react-datepicker.css");
|
|
23
|
+
|
|
24
|
+
function convertUTCToLocalDate(date) {
|
|
25
|
+
if (!date) {
|
|
26
|
+
return date;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
date = new Date(date);
|
|
30
|
+
date = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
31
|
+
return date;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function buildOperatorOptions(type) {
|
|
35
|
+
switch (type) {
|
|
36
|
+
case 'text': // Will change from text to string in future update
|
|
37
|
+
|
|
38
|
+
case 'string':
|
|
39
|
+
return [{
|
|
40
|
+
label: 'Is',
|
|
41
|
+
value: '='
|
|
42
|
+
}, {
|
|
43
|
+
label: 'Contains',
|
|
44
|
+
value: 'like'
|
|
45
|
+
}, {
|
|
46
|
+
label: 'Is Not',
|
|
47
|
+
value: '<>'
|
|
48
|
+
}, {
|
|
49
|
+
label: 'Or',
|
|
50
|
+
value: 'in'
|
|
51
|
+
}];
|
|
52
|
+
|
|
53
|
+
case 'date':
|
|
54
|
+
return [{
|
|
55
|
+
label: 'Is',
|
|
56
|
+
value: '='
|
|
57
|
+
}, {
|
|
58
|
+
label: 'Is Not',
|
|
59
|
+
value: '<>'
|
|
60
|
+
}, {
|
|
61
|
+
label: 'Greater Than',
|
|
62
|
+
value: '>'
|
|
63
|
+
}, {
|
|
64
|
+
label: 'Less Than',
|
|
65
|
+
value: '<'
|
|
66
|
+
}];
|
|
67
|
+
|
|
68
|
+
default:
|
|
69
|
+
// These 2 should be safe for all data types
|
|
70
|
+
return [{
|
|
71
|
+
label: 'Is',
|
|
72
|
+
value: '='
|
|
73
|
+
}, {
|
|
74
|
+
label: 'Is Not',
|
|
75
|
+
value: '<>'
|
|
76
|
+
}];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function cleanText(value, operator) {
|
|
81
|
+
var newValue = value;
|
|
82
|
+
|
|
83
|
+
if (Array.isArray(newValue)) {
|
|
84
|
+
newValue = newValue.join(',');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return newValue.replace(/(^\%+|\%+$)/gm, '');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var ResourceConditionField = function ResourceConditionField(_ref) {
|
|
91
|
+
var data = _ref.data,
|
|
92
|
+
index = _ref.index,
|
|
93
|
+
remove = _ref.remove,
|
|
94
|
+
schema = _ref.schema,
|
|
95
|
+
update = _ref.update;
|
|
96
|
+
var fields = schema.fields;
|
|
97
|
+
|
|
98
|
+
var _React$useState = _react["default"].useState(data.value ? new Date(data.value) : new Date()),
|
|
99
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
100
|
+
startDate = _React$useState2[0],
|
|
101
|
+
setStartDate = _React$useState2[1];
|
|
102
|
+
|
|
103
|
+
var _React$useState3 = _react["default"].useState(Object.keys(fields).map(function (key) {
|
|
104
|
+
return {
|
|
105
|
+
label: fields[key].description ? fields[key].description : key,
|
|
106
|
+
value: key
|
|
107
|
+
};
|
|
108
|
+
})),
|
|
109
|
+
_React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2),
|
|
110
|
+
propertyOptions = _React$useState4[0],
|
|
111
|
+
setPropertyOptions = _React$useState4[1];
|
|
112
|
+
|
|
113
|
+
var _React$useState5 = _react["default"].useState(data.property),
|
|
114
|
+
_React$useState6 = (0, _slicedToArray2["default"])(_React$useState5, 2),
|
|
115
|
+
property = _React$useState6[0],
|
|
116
|
+
setProperty = _React$useState6[1];
|
|
117
|
+
|
|
118
|
+
var _React$useState7 = _react["default"].useState(data.operator),
|
|
119
|
+
_React$useState8 = (0, _slicedToArray2["default"])(_React$useState7, 2),
|
|
120
|
+
operator = _React$useState8[0],
|
|
121
|
+
setOperator = _React$useState8[1];
|
|
122
|
+
|
|
123
|
+
var _React$useState9 = _react["default"].useState([{
|
|
124
|
+
label: '--',
|
|
125
|
+
value: ''
|
|
126
|
+
}]),
|
|
127
|
+
_React$useState10 = (0, _slicedToArray2["default"])(_React$useState9, 2),
|
|
128
|
+
operatorOptions = _React$useState10[0],
|
|
129
|
+
setOperatorOptions = _React$useState10[1];
|
|
130
|
+
|
|
131
|
+
var _React$useState11 = _react["default"].useState(data.value),
|
|
132
|
+
_React$useState12 = (0, _slicedToArray2["default"])(_React$useState11, 2),
|
|
133
|
+
value = _React$useState12[0],
|
|
134
|
+
setValue = _React$useState12[1];
|
|
135
|
+
|
|
136
|
+
_react["default"].useEffect(function () {
|
|
137
|
+
if (property) {
|
|
138
|
+
var opOptions = buildOperatorOptions(fields[property].mysql_type ? fields[property].mysql_type : fields[property].type).map(function (opt) {
|
|
139
|
+
return {
|
|
140
|
+
label: opt.label,
|
|
141
|
+
value: opt.value
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
update(index, 'property', property);
|
|
145
|
+
|
|
146
|
+
if (!operator) {
|
|
147
|
+
setOperator(opOptions[0].value);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
setOperatorOptions(opOptions);
|
|
151
|
+
|
|
152
|
+
if (fields[property].mysql_type && fields[property].mysql_type === 'date' || fields[property].type === 'date') {
|
|
153
|
+
setValue(startDate.toJSON().slice(0, 10));
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
update(index, 'property', property);
|
|
157
|
+
setOperator('');
|
|
158
|
+
setValue('');
|
|
159
|
+
setOperatorOptions([{
|
|
160
|
+
label: '--',
|
|
161
|
+
value: ''
|
|
162
|
+
}]);
|
|
163
|
+
}
|
|
164
|
+
}, [property, operator]);
|
|
165
|
+
|
|
166
|
+
_react["default"].useEffect(function () {
|
|
167
|
+
if (operator) {
|
|
168
|
+
update(index, 'operator', operator);
|
|
169
|
+
} else {
|
|
170
|
+
update(index, 'operator', '');
|
|
171
|
+
}
|
|
172
|
+
}, [operator]);
|
|
173
|
+
|
|
174
|
+
_react["default"].useEffect(function () {
|
|
175
|
+
if (value) {
|
|
176
|
+
update(index, 'value', value);
|
|
177
|
+
} else {
|
|
178
|
+
update(index, 'value', '');
|
|
179
|
+
}
|
|
180
|
+
}, [value]);
|
|
181
|
+
|
|
182
|
+
return /*#__PURE__*/_react["default"].createElement("fieldset", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
183
|
+
className: "ds-l-form-row"
|
|
184
|
+
}, /*#__PURE__*/_react["default"].createElement(_designSystem.Dropdown, {
|
|
185
|
+
options: [{
|
|
186
|
+
label: 'Select column',
|
|
187
|
+
value: ''
|
|
188
|
+
}].concat((0, _toConsumableArray2["default"])(propertyOptions)),
|
|
189
|
+
value: property,
|
|
190
|
+
onChange: function onChange(e) {
|
|
191
|
+
return setProperty(e.target.value);
|
|
192
|
+
},
|
|
193
|
+
label: "Filter column",
|
|
194
|
+
labelClassName: "ds-u-margin-top--0 ds-u-visibility--screen-reader",
|
|
195
|
+
name: "column_name_".concat(index),
|
|
196
|
+
className: "ds-l-col--6"
|
|
197
|
+
}), /*#__PURE__*/_react["default"].createElement(_designSystem.Dropdown, {
|
|
198
|
+
options: (0, _toConsumableArray2["default"])(operatorOptions),
|
|
199
|
+
value: operator,
|
|
200
|
+
disabled: !property ? true : false,
|
|
201
|
+
onChange: function onChange(e) {
|
|
202
|
+
return setOperator(e.target.value);
|
|
203
|
+
},
|
|
204
|
+
labelClassName: "ds-u-margin-top--0 ds-u-visibility--screen-reader",
|
|
205
|
+
size: "small",
|
|
206
|
+
label: "Filter operator",
|
|
207
|
+
name: "filter_operator_".concat(index),
|
|
208
|
+
className: "ds-l-col--3"
|
|
209
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
210
|
+
className: "ds-l-form-row"
|
|
211
|
+
}, property && (fields[property].mysql_type === 'date' || fields[property].type === 'date') ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
212
|
+
className: "ds-u-clearfix ds-l-col--11"
|
|
213
|
+
}, /*#__PURE__*/_react["default"].createElement(_reactDatepicker["default"], {
|
|
214
|
+
selected: convertUTCToLocalDate(startDate),
|
|
215
|
+
onChange: function onChange(date) {
|
|
216
|
+
setStartDate(date);
|
|
217
|
+
setValue(date.toJSON().slice(0, 10));
|
|
218
|
+
},
|
|
219
|
+
showMonthDropdown: true,
|
|
220
|
+
showYearDropdown: true,
|
|
221
|
+
dropdownMode: "select",
|
|
222
|
+
className: "ds-c-field"
|
|
223
|
+
})) : /*#__PURE__*/_react["default"].createElement(_designSystem.TextField, {
|
|
224
|
+
hint: operator.toLowerCase() === 'in' ? "Separate values with a comma." : '',
|
|
225
|
+
value: cleanText(value, operator),
|
|
226
|
+
disabled: !property ? true : false,
|
|
227
|
+
onChange: function onChange(e) {
|
|
228
|
+
return setValue(e.target.value);
|
|
229
|
+
},
|
|
230
|
+
label: "Filter value",
|
|
231
|
+
labelClassName: "ds-u-margin-top--0",
|
|
232
|
+
name: "filter_value_".concat(index),
|
|
233
|
+
className: "ds-l-col--11"
|
|
234
|
+
}), /*#__PURE__*/_react["default"].createElement(_designSystem.Button, {
|
|
235
|
+
className: "ds-l-col--1",
|
|
236
|
+
variation: "transparent",
|
|
237
|
+
"aria-label": "Remove filter",
|
|
238
|
+
onClick: function onClick(e) {
|
|
239
|
+
e.preventDefault();
|
|
240
|
+
remove(index);
|
|
241
|
+
}
|
|
242
|
+
}, /*#__PURE__*/_react["default"].createElement(_close["default"], null))));
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
var _default = ResourceConditionField;
|
|
246
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
|
|
18
|
+
var _qs = _interopRequireDefault(require("qs"));
|
|
19
|
+
|
|
20
|
+
var _designSystem = require("@cmsgov/design-system");
|
|
21
|
+
|
|
22
|
+
var _ResourceConditionField = _interopRequireDefault(require("../ResourceConditionField"));
|
|
23
|
+
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
+
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
|
|
28
|
+
var ResourceFilter = function ResourceFilter(_ref) {
|
|
29
|
+
var id = _ref.id,
|
|
30
|
+
filterOpen = _ref.filterOpen,
|
|
31
|
+
setFilterOpen = _ref.setFilterOpen,
|
|
32
|
+
defaultCondition = _ref.defaultCondition,
|
|
33
|
+
resource = _ref.resource,
|
|
34
|
+
includeSearchParams = _ref.includeSearchParams;
|
|
35
|
+
var setConditions = resource.setConditions,
|
|
36
|
+
schema = resource.schema,
|
|
37
|
+
conditions = resource.conditions;
|
|
38
|
+
|
|
39
|
+
var _React$useState = _react["default"].useState(conditions && conditions.length ? conditions : [_objectSpread({}, defaultCondition)]),
|
|
40
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
41
|
+
formConditions = _React$useState2[0],
|
|
42
|
+
setFormConditions = _React$useState2[1];
|
|
43
|
+
|
|
44
|
+
_react["default"].useEffect(function () {
|
|
45
|
+
if (includeSearchParams) {
|
|
46
|
+
var url = new URL(window.location);
|
|
47
|
+
|
|
48
|
+
var urlString = _qs["default"].stringify({
|
|
49
|
+
conditions: conditions
|
|
50
|
+
}, {
|
|
51
|
+
encodeValuesOnly: true,
|
|
52
|
+
addQueryPrefix: true
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
window.history.pushState({}, '', "".concat(url.origin).concat(url.pathname).concat(urlString));
|
|
56
|
+
}
|
|
57
|
+
}, [conditions]);
|
|
58
|
+
|
|
59
|
+
function removeByIndex(index) {
|
|
60
|
+
var newConditions = (0, _toConsumableArray2["default"])(formConditions);
|
|
61
|
+
newConditions.splice(index, 1);
|
|
62
|
+
setFormConditions(newConditions);
|
|
63
|
+
setConditions(newConditions);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function updateByIndex(index, key, value) {
|
|
67
|
+
var newConditions = (0, _toConsumableArray2["default"])(formConditions);
|
|
68
|
+
newConditions[index][key] = value;
|
|
69
|
+
setFormConditions(newConditions);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function removeAll() {
|
|
73
|
+
setFormConditions([]);
|
|
74
|
+
setConditions([]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function submitFilters(e) {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
|
|
80
|
+
if (formConditions.length) {
|
|
81
|
+
var updatedConditions = formConditions.filter(function (cond) {
|
|
82
|
+
if (cond.property) {
|
|
83
|
+
return cond;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return false;
|
|
87
|
+
}).map(function (cond) {
|
|
88
|
+
if (cond.operator === '=' || cond.operator === '<>') {
|
|
89
|
+
if (Array.isArray(cond.value)) {
|
|
90
|
+
cond.value = cond.value.join();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
cond.value = cond.value.replace(/(^\%+|\%+$)/gm, '');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (cond.operator.toLowerCase() === 'like') {
|
|
97
|
+
if (Array.isArray(cond.value)) {
|
|
98
|
+
cond.value = cond.value.join();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
var cleanedValue = cond.value.replace(/(^\%+|\%+$)/gm, '');
|
|
102
|
+
cond.value = "%".concat(cleanedValue, "%");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (cond.operator.toLowerCase() === 'in') {
|
|
106
|
+
if (!Array.isArray(cond.value)) {
|
|
107
|
+
cond.value = cond.value.split(',');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (Array.isArray(cond.value)) {
|
|
112
|
+
cond.value = cond.value.map(function (v) {
|
|
113
|
+
return v.trim().replace(/(^\%+|\%+$)/gm, '');
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return cond;
|
|
118
|
+
});
|
|
119
|
+
setConditions(updatedConditions);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return /*#__PURE__*/_react["default"].createElement(_designSystem.HelpDrawer, {
|
|
124
|
+
footerTitle: "Update actions",
|
|
125
|
+
footerBody: /*#__PURE__*/_react["default"].createElement(_designSystem.Button, {
|
|
126
|
+
className: "ds-u-margin-right--1",
|
|
127
|
+
onClick: function onClick(e) {
|
|
128
|
+
return submitFilters(e, formConditions);
|
|
129
|
+
}
|
|
130
|
+
}, "Update table"),
|
|
131
|
+
heading: "Add filters",
|
|
132
|
+
className: "dc-c-filterd-resouce-drawer",
|
|
133
|
+
onCloseClick: function onCloseClick() {
|
|
134
|
+
setFilterOpen(!filterOpen);
|
|
135
|
+
}
|
|
136
|
+
}, /*#__PURE__*/_react["default"].createElement("form", {
|
|
137
|
+
onSubmit: function onSubmit(e) {
|
|
138
|
+
return submitFilters(e, formConditions);
|
|
139
|
+
}
|
|
140
|
+
}, Object.keys(schema).length && formConditions.map(function (f, index) {
|
|
141
|
+
return /*#__PURE__*/_react["default"].createElement(_ResourceConditionField["default"], {
|
|
142
|
+
key: index,
|
|
143
|
+
data: f,
|
|
144
|
+
index: index,
|
|
145
|
+
remove: removeByIndex,
|
|
146
|
+
schema: schema[id],
|
|
147
|
+
update: updateByIndex
|
|
148
|
+
});
|
|
149
|
+
}), /*#__PURE__*/_react["default"].createElement(_designSystem.Button, {
|
|
150
|
+
className: "ds-u-margin-right--1",
|
|
151
|
+
variation: "transparent",
|
|
152
|
+
onClick: function onClick(e) {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
setFormConditions([].concat((0, _toConsumableArray2["default"])(formConditions), [_objectSpread({}, defaultCondition)]));
|
|
155
|
+
}
|
|
156
|
+
}, "+ Add another filter")), formConditions.length > 1 ? /*#__PURE__*/_react["default"].createElement(_designSystem.Button, {
|
|
157
|
+
variation: "transparent",
|
|
158
|
+
onClick: function onClick(e) {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
removeAll();
|
|
161
|
+
}
|
|
162
|
+
}, "Remove all filters") : '');
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
ResourceFilter.defaultProps = {
|
|
166
|
+
defaultCondition: {
|
|
167
|
+
property: '',
|
|
168
|
+
value: '',
|
|
169
|
+
operator: ''
|
|
170
|
+
},
|
|
171
|
+
includeSearchParams: true
|
|
172
|
+
};
|
|
173
|
+
var _default = ResourceFilter;
|
|
174
|
+
exports["default"] = _default;
|