@bigbinary/neeto-filters-frontend 2.13.2 → 2.14.1
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/README.md +156 -83
- package/dist/index.cjs.js +24 -32
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +26 -34
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/types.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
# @bigbinary/neeto-filters-frontend
|
|
3
2
|
|
|
4
3
|
neetoFilters is the library that manages filters across neeto products.
|
|
@@ -12,49 +11,65 @@ yarn add @bigbinary/neeto-filters-frontend
|
|
|
12
11
|
**neetoFilters** has a few peer dependencies that are required for the proper
|
|
13
12
|
functioning of the package. Install all the peer dependencies using the below
|
|
14
13
|
command:
|
|
14
|
+
|
|
15
15
|
```bash
|
|
16
16
|
yarn add @bigbinary/neetoui @bigbinary/neeto-icons axios@0.27.2 classnames@2.3.1 dayjs@1.11.1 formik@2.2.0 ramda@0.28.0 react-router-dom@5.3.0 react-router-nav-prompt@0.4.1 react-toastify@9.0.1 yup@0.32.11
|
|
17
17
|
```
|
|
18
|
+
|
|
18
19
|
## Usage
|
|
19
20
|
|
|
20
|
-
neeto-filters-frontend exports 2 components (`Filters` & `Bar`) and 2 functions
|
|
21
|
+
neeto-filters-frontend exports 2 components (`Filters` & `Bar`) and 2 functions
|
|
22
|
+
(`buildFiltersFromURL()` & `buildSelectorsFromURL()`).
|
|
23
|
+
|
|
21
24
|
### 1. `Filters` component
|
|
22
25
|
|
|
23
26
|
#### Props
|
|
24
27
|
|
|
25
28
|
1. **isOpen**: To specify whether the Pane component is open or not.
|
|
26
29
|
2. **setIsOpen**: To trigger the isOpen state.
|
|
27
|
-
3. **columns**: The list of columns/fields that needs to be represented in the
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
3. **columns**: The list of columns/fields that needs to be represented in the
|
|
31
|
+
filters pane.
|
|
32
|
+
4. **onChange**: To specify the callback function that is triggered whenever a
|
|
33
|
+
filter is applied or cleared. This function will get the updated filters as
|
|
34
|
+
argument.
|
|
35
|
+
5. **onSelectorsChange**: To specify the callback function that is triggered
|
|
36
|
+
whenever a selector value is changed. This function will get the updated
|
|
37
|
+
selectors as argument.
|
|
30
38
|
6. **buttonProps**: To specify the props to be passed to the button component.
|
|
31
39
|
7. **paneProps**: To specify the props to be passed to the pane component.
|
|
32
|
-
8. **isSearchable**: To specify whether you need a search bar in filters pane
|
|
40
|
+
8. **isSearchable**: To specify whether you need a search bar in filters pane
|
|
41
|
+
to search through filter fields.
|
|
33
42
|
9. **className**: To specify classes to the Filters component.
|
|
34
43
|
10. **keyword**: To specify the props related to searching.
|
|
35
|
-
11. **childrenKeys** The list of keys which has to be cleared from url during
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
11. **childrenKeys** The list of keys which has to be cleared from url during
|
|
45
|
+
clear filters operation.
|
|
46
|
+
12. **children**: To specify the custom components specific to the host
|
|
47
|
+
application.
|
|
48
|
+
13. **size**: To specify the width of the filters pane. It accepts "xsmall"
|
|
49
|
+
(default), "small", and "large" as value.
|
|
38
50
|
|
|
39
51
|
Here is an example of `keyword` prop:
|
|
52
|
+
|
|
40
53
|
```js
|
|
41
54
|
const [searchTerm, setSearchTerm] = useState("");
|
|
42
55
|
const searchKeywordProps = {
|
|
43
56
|
key: "keyword",
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
57
|
+
node: "name",
|
|
58
|
+
value: searchTerm.trim(),
|
|
59
|
+
setValue: setSearchTerm,
|
|
60
|
+
};
|
|
48
61
|
```
|
|
62
|
+
|
|
49
63
|
This `searchKeywordProps` can be passed as the value to `keyword` prop.
|
|
50
64
|
|
|
51
|
-
> :memo: **Note:**
|
|
52
|
-
|
|
65
|
+
> :memo: **Note:** If you wish to conduct a search for the keyword among
|
|
66
|
+
> multiple columns spanning different tables in the DB, then you should pass the
|
|
67
|
+
> name of the models corresponding to the tables as value of `models` prop.
|
|
53
68
|
>
|
|
54
69
|
> Example:
|
|
55
70
|
>
|
|
56
|
-
> If you are querying the user records and searching the keyword among users'
|
|
57
|
-
node will be like:
|
|
71
|
+
> If you are querying the user records and searching the keyword among users'
|
|
72
|
+
> name and users' organization name, then node will be like:
|
|
58
73
|
>
|
|
59
74
|
> `node = "first_name,last_name,organization.name"`
|
|
60
75
|
>
|
|
@@ -63,6 +78,7 @@ node will be like:
|
|
|
63
78
|
> `model = "User,Organization"`
|
|
64
79
|
|
|
65
80
|
Here is an example for the `columns` prop:
|
|
81
|
+
|
|
66
82
|
```js
|
|
67
83
|
export const SAMPLE_FILTER_FIELDS = [
|
|
68
84
|
{
|
|
@@ -88,17 +104,25 @@ export const SAMPLE_FILTER_FIELDS = [
|
|
|
88
104
|
},
|
|
89
105
|
];
|
|
90
106
|
```
|
|
107
|
+
|
|
91
108
|
- `key` : A unique identifier provided to each columns/field.
|
|
92
109
|
- `group`: The label of the group, if the field is associated with a group.
|
|
93
110
|
- `node`: The column in DB table corresponding to the field.
|
|
94
111
|
- `label` The label to be shown just above the field in Pane.
|
|
95
|
-
- `suffixComponent` The component to be shown at the end of the respective Block
|
|
96
|
-
|
|
112
|
+
- `suffixComponent` The component to be shown at the end of the respective Block
|
|
113
|
+
in filters Bar.
|
|
114
|
+
- `preprocessor` The function to be used to preprocess the value before applying
|
|
115
|
+
the filter.
|
|
97
116
|
- `type`: The nature/type of the field needed in pane.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
117
|
+
- The supported types are `text`, `number`, `decimal`, `date`, `single_date`,
|
|
118
|
+
`time`, `single_time`, `single_option`, `multi_option` and `boolean`
|
|
119
|
+
- `model`: If the node provided is **not** directly refering to the column
|
|
120
|
+
within the table being queried for the filtered results, then we need to
|
|
121
|
+
provide the **model** corresponding to the target table. - For example: We are
|
|
122
|
+
adding a filter field for querying on `users` table to list all users with
|
|
123
|
+
address containing the a certain word. Say the addresses are stored in
|
|
124
|
+
**another table `addresses`**. Then the node will be `address.line_1,line_2`.
|
|
125
|
+
In such cases we need to pass this extra prop like `model: "Address"`.
|
|
102
126
|
- Then whole object for the field might look like this
|
|
103
127
|
```js
|
|
104
128
|
{
|
|
@@ -109,123 +133,172 @@ Then the node will be `address.line_1,line_2`. In such cases we need to pass thi
|
|
|
109
133
|
type: "text"
|
|
110
134
|
}
|
|
111
135
|
```
|
|
112
|
-
- `values`: The list of label-value pair to be shown in dropdown, if the `type`
|
|
113
|
-
|
|
114
|
-
- `
|
|
115
|
-
|
|
136
|
+
- `values`: The list of label-value pair to be shown in dropdown, if the `type`
|
|
137
|
+
provided is `single_option` or `multi_option`.
|
|
138
|
+
- `showRuleSelector` : Boolean value, which determines whether to show a rule
|
|
139
|
+
selector above the `text` , `number` and `decimal` type fields. `false` by
|
|
140
|
+
default.
|
|
141
|
+
- `hidden`: Boolean value, which determines to show or hide field from filter
|
|
142
|
+
pane. `false ` by default.
|
|
143
|
+
- `defaultValue`: The default value that should appear as chosen one in the
|
|
144
|
+
filter fields.
|
|
116
145
|
- `defaultType`: The type of the input that should be used in the Filters pane.
|
|
117
|
-
- `isClearable`: Boolean value which specifies whether the field can be cleared
|
|
146
|
+
- `isClearable`: Boolean value which specifies whether the field can be cleared
|
|
147
|
+
or not.
|
|
148
|
+
|
|
149
|
+
- By `selectors` we mean the filter fields which doesn't have any relation
|
|
150
|
+
(`node`) to a DB >table column.
|
|
151
|
+
- For example, consider a field in filter pane called `Group by`. We cannot
|
|
152
|
+
provide a `node` to associate it with a column in DB table. Still it can
|
|
153
|
+
provide an important value which can be used for the computation as if by
|
|
154
|
+
telling a means by which the records can be grouped after filtering.
|
|
155
|
+
- Fields without a `node`, among the ones passed as value to the `column` prop
|
|
156
|
+
of `Filters` are >considered as selectors.
|
|
118
157
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
value: "location"
|
|
135
|
-
}
|
|
136
|
-
],
|
|
158
|
+
```js
|
|
159
|
+
{
|
|
160
|
+
key: "groupBy",
|
|
161
|
+
label: "Group by",
|
|
162
|
+
type: "single_option",
|
|
163
|
+
values: [
|
|
164
|
+
{
|
|
165
|
+
label: "Team",
|
|
166
|
+
value: "team"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
label: "Location",
|
|
170
|
+
value: "location"
|
|
171
|
+
}
|
|
172
|
+
],
|
|
137
173
|
}
|
|
138
|
-
|
|
139
|
-
When user selects a value from this dropdown we get that value in the `selectors` state. This can be used for further computations outside the neeto-filters.
|
|
174
|
+
```
|
|
140
175
|
|
|
176
|
+
When user selects a value from this dropdown we get that value in the
|
|
177
|
+
`selectors` state. This can be used for further computations outside the
|
|
178
|
+
neeto-filters.
|
|
141
179
|
|
|
142
180
|
### 2. `Bar` component
|
|
143
181
|
|
|
144
182
|
#### Props
|
|
145
183
|
|
|
146
|
-
1. **columns**: The list of columns/fields that needs to be represented in the
|
|
147
|
-
|
|
184
|
+
1. **columns**: The list of columns/fields that needs to be represented in the
|
|
185
|
+
filters pane.
|
|
186
|
+
2. **onChange**: To specify the callback function that is triggered whenever a
|
|
187
|
+
filter is applied or cleared. This function will get the updated filters as
|
|
188
|
+
argument.
|
|
148
189
|
3. **setIsPaneOpen**: To trigger the isOpen state.
|
|
149
190
|
4. **className**: To specify classes to the Bar component.
|
|
150
|
-
5.
|
|
151
|
-
6.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
The
|
|
191
|
+
5. **keyword**: To specify the props related to searching.
|
|
192
|
+
6. **onSelectorsChange**: To specify the callback function that is triggered
|
|
193
|
+
whenever a selector value is changed. This function will get the updated
|
|
194
|
+
selectors as argument.
|
|
195
|
+
7. **childrenKeys** The list of keys which has to be cleared from url during
|
|
196
|
+
clear filters operation.
|
|
197
|
+
8. **entity**: The entity associated with the filters.
|
|
198
|
+
|
|
199
|
+
All these props must be same as that passed to the `Filters` component. The
|
|
200
|
+
option to save filters as segments will be enabled only when the entity prop is
|
|
201
|
+
passed to the component.
|
|
157
202
|
|
|
158
203
|
### 3. `Segments` component
|
|
159
204
|
|
|
160
205
|
#### Props
|
|
161
206
|
|
|
162
|
-
1. **columns**: The list of columns/fields that needs to be represented in the
|
|
207
|
+
1. **columns**: The list of columns/fields that needs to be represented in the
|
|
208
|
+
filters pane.
|
|
163
209
|
2. **entity**: The entity associated with the segments.
|
|
164
210
|
3. **setIsPaneOpen**: To trigger the isOpen state of the filters pane.
|
|
165
211
|
|
|
166
|
-
The "columns" prop must be same as that passed to the `Filters` component.
|
|
167
|
-
|
|
212
|
+
The "columns" prop must be same as that passed to the `Filters` component. To
|
|
213
|
+
set up the neeto-filters-engine with support for Segments, please follow the
|
|
214
|
+
instructions provided in the installation
|
|
215
|
+
[documentation](https://github.com/bigbinary/neeto-filters-engine#installation).
|
|
168
216
|
|
|
169
|
-
|
|
217
|
+
### 3. `buildFiltersFromURL` function
|
|
170
218
|
|
|
171
219
|
- This function takes a list as argument.
|
|
172
|
-
- This list should contains all the filter columns/fields and the value passed
|
|
173
|
-
|
|
220
|
+
- This list should contains all the filter columns/fields and the value passed
|
|
221
|
+
to `keyword` prop of `Filters` and `Bar`.
|
|
222
|
+
- It builds the filter payload from the URL search params. This function should
|
|
223
|
+
be called for initializing the `filters` state.
|
|
224
|
+
|
|
174
225
|
```js
|
|
175
|
-
const [filters, setFilters] = useState(() =>
|
|
226
|
+
const [filters, setFilters] = useState(() =>
|
|
227
|
+
buildFiltersFromURL([...SAMPLE_FILTER_COLUMNS, searchKeywordProps])
|
|
228
|
+
);
|
|
176
229
|
```
|
|
177
230
|
|
|
178
231
|
### 4. `buildSelectorsFromURL` function
|
|
179
232
|
|
|
180
|
-
- By `selectors` we mean the filter fields which doesn't have any relation
|
|
181
|
-
|
|
182
|
-
-
|
|
233
|
+
- By `selectors` we mean the filter fields which doesn't have any relation
|
|
234
|
+
(`node`) to a DB table column.
|
|
235
|
+
- For example, consider a field in filter pane called `Group by`. We cannot
|
|
236
|
+
provide a `node` to associate it with a column in DB table. Still it can
|
|
237
|
+
provide an important value which can be used for the computation as if by
|
|
238
|
+
telling a means by which the records can be grouped after filtering.
|
|
239
|
+
- Fields without a `node`, among the ones passed as value to the `column` prop
|
|
240
|
+
of `Filters` are considered as selectors.
|
|
183
241
|
- This function takes a list as argument.
|
|
184
242
|
- This list should contains all the filter columns/fields.
|
|
185
|
-
- It builds the selectors' value from the URL search params. This function
|
|
186
|
-
|
|
243
|
+
- It builds the selectors' value from the URL search params. This function
|
|
244
|
+
should be called for initializing the `selectors` state.
|
|
245
|
+
- `selectors` will be an object with keys same as provided in filter fields and
|
|
246
|
+
selected value as its value.
|
|
247
|
+
|
|
187
248
|
```js
|
|
188
|
-
const [selectors, setSelectors] = useState(() =>
|
|
249
|
+
const [selectors, setSelectors] = useState(() =>
|
|
250
|
+
buildSelectorsFromURL(FILTER_COLUMNS)
|
|
251
|
+
);
|
|
189
252
|
```
|
|
190
253
|
|
|
191
254
|
### 5. `buildFilterColumnsFromFields` function
|
|
192
255
|
|
|
193
|
-
The `buildFilterColumnsFromFields` function is used to generate an array of
|
|
256
|
+
The `buildFilterColumnsFromFields` function is used to generate an array of
|
|
257
|
+
filter columns based on the provided fields (often referred as custom fields)
|
|
258
|
+
and selected field names.
|
|
194
259
|
|
|
195
260
|
#### Parameters
|
|
196
261
|
|
|
197
262
|
- `fields` (array): An array of field objects representing the available fields.
|
|
198
|
-
- `selectedFields` (array, optional): An array of strings representing the
|
|
263
|
+
- `selectedFields` (array, optional): An array of strings representing the
|
|
264
|
+
selected field names. Defaults to an empty array.
|
|
265
|
+
- `showRuleSelector` (boolean, optional): A boolean value which specify whether
|
|
266
|
+
to show the rule selector for each filter or not. It is `false` by default.
|
|
199
267
|
|
|
200
268
|
```js
|
|
201
269
|
const fields = [
|
|
202
270
|
{
|
|
203
|
-
id:
|
|
204
|
-
name:
|
|
205
|
-
kind:
|
|
271
|
+
id: "1",
|
|
272
|
+
name: "name",
|
|
273
|
+
kind: "text",
|
|
206
274
|
},
|
|
207
275
|
{
|
|
208
|
-
id:
|
|
209
|
-
name:
|
|
210
|
-
kind:
|
|
276
|
+
id: "2",
|
|
277
|
+
name: "age",
|
|
278
|
+
kind: "number",
|
|
211
279
|
},
|
|
212
280
|
// Add more field objects as needed
|
|
213
281
|
];
|
|
214
282
|
|
|
215
|
-
const selectedFields = [
|
|
283
|
+
const selectedFields = ["name", "age"];
|
|
216
284
|
|
|
217
|
-
const filterColumns = buildFilterColumnsFromFields(fields, selectedFields);
|
|
285
|
+
const filterColumns = buildFilterColumnsFromFields({ fields, selectedFields });
|
|
218
286
|
```
|
|
219
287
|
|
|
220
288
|
## Development
|
|
221
289
|
|
|
222
290
|
Install all the dependencies by executing the following command
|
|
291
|
+
|
|
223
292
|
```bash
|
|
224
293
|
yarn install
|
|
225
294
|
```
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
295
|
+
|
|
296
|
+
Start the development server using the `yarn start` command. In order to run the
|
|
297
|
+
application you need to run the Rails server of the
|
|
298
|
+
[neeto-filters-engine](https://github.com/bigbinary/neeto-filters-engine)'s
|
|
299
|
+
dummy application as well. This is necessary to make sure that all the APIs and
|
|
300
|
+
React Query hooks are working as per the requirement.
|
|
301
|
+
|
|
229
302
|
```bash
|
|
230
303
|
git clone https://github.com/bigbinary/neeto-filters-engine.git
|
|
231
304
|
./test/dummy/bin/setup
|
package/dist/index.cjs.js
CHANGED
|
@@ -3373,8 +3373,8 @@ dayjs__default["default"].extend(timezone__default["default"]);
|
|
|
3373
3373
|
dayjs__default["default"].extend(weekday__default["default"]);
|
|
3374
3374
|
dayjs__default["default"].Ls.en.weekStart = 1;
|
|
3375
3375
|
|
|
3376
|
-
function ownKeys$
|
|
3377
|
-
function _objectSpread$
|
|
3376
|
+
function ownKeys$5(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; }
|
|
3377
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3378
3378
|
var groupByGroup = ramda.groupBy(function (_ref) {
|
|
3379
3379
|
var group = _ref.group;
|
|
3380
3380
|
return group || "individual";
|
|
@@ -3667,7 +3667,7 @@ var buildDatePayload = function buildDatePayload(value) {
|
|
|
3667
3667
|
var buildSingleDatePayload = function buildSingleDatePayload(filter) {
|
|
3668
3668
|
var value = filter.value;
|
|
3669
3669
|
var filterValue = Array.isArray(value) ? value.join(",") : value;
|
|
3670
|
-
return _objectSpread$
|
|
3670
|
+
return _objectSpread$5(_objectSpread$5({}, filter), {}, {
|
|
3671
3671
|
value: filterValue,
|
|
3672
3672
|
type: "date"
|
|
3673
3673
|
});
|
|
@@ -3675,7 +3675,7 @@ var buildSingleDatePayload = function buildSingleDatePayload(filter) {
|
|
|
3675
3675
|
var buildSingleTimePayload = function buildSingleTimePayload(filter) {
|
|
3676
3676
|
var value = filter.value;
|
|
3677
3677
|
var filterValue = Array.isArray(value) ? value.join(",") : value;
|
|
3678
|
-
return _objectSpread$
|
|
3678
|
+
return _objectSpread$5(_objectSpread$5({}, filter), {}, {
|
|
3679
3679
|
value: filterValue,
|
|
3680
3680
|
type: "time"
|
|
3681
3681
|
});
|
|
@@ -3924,8 +3924,12 @@ var buildUrlFromSegment = function buildUrlFromSegment(_ref19) {
|
|
|
3924
3924
|
var getKeywordValueFromUrl = function getKeywordValueFromUrl() {
|
|
3925
3925
|
return utils.getQueryParams()["keyword"] || "";
|
|
3926
3926
|
};
|
|
3927
|
-
var buildFilterColumnsFromFields = function buildFilterColumnsFromFields(
|
|
3928
|
-
var
|
|
3927
|
+
var buildFilterColumnsFromFields = function buildFilterColumnsFromFields(_ref21) {
|
|
3928
|
+
var fields = _ref21.fields,
|
|
3929
|
+
_ref21$selectedFields = _ref21.selectedFields,
|
|
3930
|
+
selectedFields = _ref21$selectedFields === void 0 ? [] : _ref21$selectedFields,
|
|
3931
|
+
_ref21$showRuleSelect = _ref21.showRuleSelector,
|
|
3932
|
+
showRuleSelector = _ref21$showRuleSelect === void 0 ? false : _ref21$showRuleSelect;
|
|
3929
3933
|
return fields.reduce(function (columns, field) {
|
|
3930
3934
|
if (ramda.isEmpty(selectedFields) || selectedFields.includes(field.name)) {
|
|
3931
3935
|
var id = field.id,
|
|
@@ -3935,7 +3939,8 @@ var buildFilterColumnsFromFields = function buildFilterColumnsFromFields(fields)
|
|
|
3935
3939
|
key: ramda.toLower(name),
|
|
3936
3940
|
node: "".concat(name, ":").concat(id),
|
|
3937
3941
|
label: capitalize(name),
|
|
3938
|
-
type: "custom.".concat(kind)
|
|
3942
|
+
type: "custom.".concat(kind),
|
|
3943
|
+
showRuleSelector: showRuleSelector
|
|
3939
3944
|
};
|
|
3940
3945
|
if (kind === "single_option" || kind === "multi_option") {
|
|
3941
3946
|
column.values = field.data.map(function (item) {
|
|
@@ -3952,7 +3957,7 @@ var buildFilterColumnsFromFields = function buildFilterColumnsFromFields(fields)
|
|
|
3952
3957
|
};
|
|
3953
3958
|
var getColumnsWithStandardizedType = function getColumnsWithStandardizedType(columns) {
|
|
3954
3959
|
return columns.map(function (column) {
|
|
3955
|
-
return _objectSpread$
|
|
3960
|
+
return _objectSpread$5(_objectSpread$5({}, column), {}, {
|
|
3956
3961
|
type: standardizeColumnType(column.type)
|
|
3957
3962
|
});
|
|
3958
3963
|
});
|
|
@@ -4173,6 +4178,8 @@ var QUERY_KEYS = {
|
|
|
4173
4178
|
};
|
|
4174
4179
|
var SEGMENTS_STALE_TIME = 900000; // 15 mins
|
|
4175
4180
|
|
|
4181
|
+
function ownKeys$4(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; }
|
|
4182
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4176
4183
|
var SEGMENTS_LIST = QUERY_KEYS.SEGMENTS_LIST;
|
|
4177
4184
|
var useFetchSegments = function useFetchSegments(_ref) {
|
|
4178
4185
|
var entity = _ref.entity,
|
|
@@ -4199,34 +4206,19 @@ var useShowSegment = function useShowSegment(id) {
|
|
|
4199
4206
|
}, options));
|
|
4200
4207
|
};
|
|
4201
4208
|
var useCreateSegment = function useCreateSegment(options) {
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
var _options$onSuccess;
|
|
4206
|
-
queryClient.invalidateQueries(SEGMENTS_LIST);
|
|
4207
|
-
options === null || options === void 0 ? void 0 : (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options);
|
|
4208
|
-
}
|
|
4209
|
-
});
|
|
4209
|
+
return reactUtils.useMutationWithInvalidation(segmentsApi.create, _objectSpread$4({
|
|
4210
|
+
keysToInvalidate: [SEGMENTS_LIST]
|
|
4211
|
+
}, options));
|
|
4210
4212
|
};
|
|
4211
4213
|
var useUpdateSegment = function useUpdateSegment(options) {
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
var _options$onSuccess2;
|
|
4216
|
-
queryClient.invalidateQueries(SEGMENTS_LIST);
|
|
4217
|
-
options === null || options === void 0 ? void 0 : (_options$onSuccess2 = options.onSuccess) === null || _options$onSuccess2 === void 0 ? void 0 : _options$onSuccess2.call(options);
|
|
4218
|
-
}
|
|
4219
|
-
});
|
|
4214
|
+
return reactUtils.useMutationWithInvalidation(segmentsApi.update, _objectSpread$4({
|
|
4215
|
+
keysToInvalidate: [SEGMENTS_LIST]
|
|
4216
|
+
}, options));
|
|
4220
4217
|
};
|
|
4221
4218
|
var useDestroySegment = function useDestroySegment(options) {
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
var _options$onSuccess3;
|
|
4226
|
-
queryClient.invalidateQueries(SEGMENTS_LIST);
|
|
4227
|
-
options === null || options === void 0 ? void 0 : (_options$onSuccess3 = options.onSuccess) === null || _options$onSuccess3 === void 0 ? void 0 : _options$onSuccess3.call(options);
|
|
4228
|
-
}
|
|
4229
|
-
});
|
|
4219
|
+
return reactUtils.useMutationWithInvalidation(segmentsApi.destroy, _objectSpread$4({
|
|
4220
|
+
keysToInvalidate: [SEGMENTS_LIST]
|
|
4221
|
+
}, options));
|
|
4230
4222
|
};
|
|
4231
4223
|
|
|
4232
4224
|
var Menu = neetoui.Dropdown.Menu,
|