@controleonline/ui-default 1.0.280 → 1.0.282
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/package.json +2 -2
- package/src/react/components/cards/DefaultEntityCard.js +13 -0
- package/src/react/components/files/DefaultFile.js +11 -24
- package/src/react/components/inputs/DefaultInput.js +417 -414
- package/src/react/components/table/DefaultColumnMenu.js +1 -1
- package/src/react/components/table/DefaultSearchModal.js +14 -5
- package/src/react/components/table/DefaultTable.js +32 -21
- package/src/react/components/table/DefaultTable.layoutUtils.js +1 -0
- package/src/react/components/table/DefaultTableCards.js +5 -2
- package/src/react/components/table/DefaultTableCompactToolbar.js +2 -2
- package/src/react/components/table/DefaultTableControls.js +2 -2
- package/src/react/components/table/DefaultTableInput.js +1 -1
- package/src/react/components/table/DefaultTableRows.js +1 -1
- package/src/react/components/table/DefaultTableToolbar.js +1 -1
- package/src/react/components/table/useDefaultTablePagination.js +48 -6
- package/src/react/components/table/useDefaultTableStoreSync.js +18 -6
- package/src/store/default/actions.js +117 -116
- package/src/tests/react/components/table/defaultTableTestSetup.cjs +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {api} from '@controleonline/ui-common/src/api';
|
|
2
|
-
import localDB from '@controleonline/ui-common/src/api/localDB';
|
|
1
|
+
import {api} from '@controleonline/ui-common/src/api';
|
|
2
|
+
import localDB from '@controleonline/ui-common/src/api/localDB';
|
|
3
3
|
import {queue} from '@controleonline/ui-common/src/api/queue';
|
|
4
4
|
import * as types from '@controleonline/ui-default/src/store/default/mutation_types';
|
|
5
5
|
|
|
@@ -150,23 +150,23 @@ const commitStoreError = (commit, error, storeMeta) => {
|
|
|
150
150
|
buildStoreErrorCommitOptions(storeMeta),
|
|
151
151
|
)
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
export const executeQueue = ({commit, getters}, func, callback) => {
|
|
155
|
-
queue.executeQueue(func, callback);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export const addToQueue = ({commit, getters}, func) => {
|
|
159
|
-
queue.addToQueue(func);
|
|
160
|
-
};
|
|
161
|
-
export const initQueue = ({commit, getters}, func) => {
|
|
162
|
-
queue.initQueue(func);
|
|
163
|
-
return queue;
|
|
164
|
-
};
|
|
165
|
-
|
|
153
|
+
|
|
154
|
+
export const executeQueue = ({commit, getters}, func, callback) => {
|
|
155
|
+
queue.executeQueue(func, callback);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const addToQueue = ({commit, getters}, func) => {
|
|
159
|
+
queue.addToQueue(func);
|
|
160
|
+
};
|
|
161
|
+
export const initQueue = ({commit, getters}, func) => {
|
|
162
|
+
queue.initQueue(func);
|
|
163
|
+
return queue;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
166
|
export const saveOffline = ({commit, getters}, data) => {
|
|
167
167
|
return;
|
|
168
168
|
};
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
export const getOfflineItems = ({commit, getters}, params = {}) => {
|
|
171
171
|
const {storeMeta} = splitStoreActionPayload(params)
|
|
172
172
|
commit(types.SET_ISLOADING, true);
|
|
@@ -175,26 +175,26 @@ export const getOfflineItems = ({commit, getters}, params = {}) => {
|
|
|
175
175
|
commit(types.SET_DEBUG, {});
|
|
176
176
|
|
|
177
177
|
db = new localDB(getters);
|
|
178
|
-
|
|
179
|
-
return db
|
|
180
|
-
.getItemsByFilters()
|
|
181
|
-
.then(async data => {
|
|
182
|
-
if (!data || (Array.isArray(data) && data.length === 0))
|
|
183
|
-
return getOnlineItems({commit, getters}, params).then(data => {
|
|
184
|
-
commit(types.SET_ITEM, data);
|
|
185
|
-
if (getters.offline) saveOffline({commit, getters}, data);
|
|
186
|
-
return data;
|
|
187
|
-
});
|
|
188
|
-
})
|
|
178
|
+
|
|
179
|
+
return db
|
|
180
|
+
.getItemsByFilters()
|
|
181
|
+
.then(async data => {
|
|
182
|
+
if (!data || (Array.isArray(data) && data.length === 0))
|
|
183
|
+
return getOnlineItems({commit, getters}, params).then(data => {
|
|
184
|
+
commit(types.SET_ITEM, data);
|
|
185
|
+
if (getters.offline) saveOffline({commit, getters}, data);
|
|
186
|
+
return data;
|
|
187
|
+
});
|
|
188
|
+
})
|
|
189
189
|
.catch(e => {
|
|
190
190
|
commitStoreError(commit, e, storeMeta)
|
|
191
191
|
throw e;
|
|
192
192
|
})
|
|
193
|
-
.finally(() => {
|
|
194
|
-
commit(types.SET_ISLOADING, false);
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
|
-
|
|
193
|
+
.finally(() => {
|
|
194
|
+
commit(types.SET_ISLOADING, false);
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
|
|
198
198
|
export const getOnlineItems = ({commit, getters}, params = {}) => {
|
|
199
199
|
const {payload: requestParams, storeMeta} = splitStoreActionPayload(params)
|
|
200
200
|
const {append: shouldAppend = false, ...queryParams} = isPlainObject(requestParams)
|
|
@@ -206,11 +206,12 @@ export const getOnlineItems = ({commit, getters}, params = {}) => {
|
|
|
206
206
|
params: queryParams,
|
|
207
207
|
})
|
|
208
208
|
|
|
209
|
+
const preserveQuery = storeMeta.preserveItems === true && getters.lastCompletedRequest?.requestKey === requestKey
|
|
209
210
|
commit(types.SET_ACTIVE_REQUEST_KEY, requestKey)
|
|
210
|
-
commit(types.SET_ISLOADING,
|
|
211
|
-
commit(types.SET_ISLOADINGLIST,
|
|
211
|
+
commit(types.SET_ISLOADING, !preserveQuery);
|
|
212
|
+
commit(types.SET_ISLOADINGLIST, !preserveQuery)
|
|
212
213
|
commit(types.SET_ERROR, null);
|
|
213
|
-
if (!shouldAppend) {
|
|
214
|
+
if (!shouldAppend && !preserveQuery) {
|
|
214
215
|
if (getters.items != null) commit(types.SET_ITEMS, []);
|
|
215
216
|
commit(types.SET_TOTALITEMS, 0);
|
|
216
217
|
commit(types.SET_SUMMARY, {});
|
|
@@ -262,12 +263,12 @@ export const getOnlineItems = ({commit, getters}, params = {}) => {
|
|
|
262
263
|
}
|
|
263
264
|
});
|
|
264
265
|
};
|
|
265
|
-
|
|
266
|
-
export const getItems = ({commit, getters}, params = {}) => {
|
|
267
|
-
//if (getters.offline) return getOfflineItems({commit, getters}, params); else
|
|
268
|
-
return getOnlineItems({commit, getters}, params);
|
|
269
|
-
};
|
|
270
|
-
|
|
266
|
+
|
|
267
|
+
export const getItems = ({commit, getters}, params = {}) => {
|
|
268
|
+
//if (getters.offline) return getOfflineItems({commit, getters}, params); else
|
|
269
|
+
return getOnlineItems({commit, getters}, params);
|
|
270
|
+
};
|
|
271
|
+
|
|
271
272
|
export const get = ({commit, getters}, id) => {
|
|
272
273
|
const {payload: requestId, storeMeta} = splitStoreActionPayload(id)
|
|
273
274
|
const normalizedId = String(requestId?.id ?? requestId ?? '').replace(/\D/g, '')
|
|
@@ -359,15 +360,15 @@ export const remove = ({commit, getters}, id) => {
|
|
|
359
360
|
.then(() => {
|
|
360
361
|
commit(types.SET_ERROR, null);
|
|
361
362
|
let items = getters.items ? [...getters.items] : [];
|
|
362
|
-
const index = items.findIndex(i => {
|
|
363
|
-
if (i && i['@id']) return i['@id'].toString().replace(/\D/g, '') === id;
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
if (index >= 0) items.splice(index, 1);
|
|
367
|
-
else items = [];
|
|
368
|
-
commit(types.SET_ITEMS, items);
|
|
369
|
-
return;
|
|
370
|
-
})
|
|
363
|
+
const index = items.findIndex(i => {
|
|
364
|
+
if (i && i['@id']) return i['@id'].toString().replace(/\D/g, '') === id;
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
if (index >= 0) items.splice(index, 1);
|
|
368
|
+
else items = [];
|
|
369
|
+
commit(types.SET_ITEMS, items);
|
|
370
|
+
return;
|
|
371
|
+
})
|
|
371
372
|
.catch(e => {
|
|
372
373
|
commitStoreError(commit, e, storeMeta)
|
|
373
374
|
throw e;
|
|
@@ -375,39 +376,39 @@ export const remove = ({commit, getters}, id) => {
|
|
|
375
376
|
.finally(() => {
|
|
376
377
|
commit(types.SET_ISSAVING, false);
|
|
377
378
|
});
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
export const setFilters = ({commit, getters}, params) => {
|
|
381
|
-
commit(types.SET_FILTERS, params);
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
export const setItem = ({commit, getters}, params) => {
|
|
385
|
-
commit(types.SET_ITEM, params);
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
export const setItems = ({commit, getters}, params) => {
|
|
389
|
-
commit(types.SET_ITEMS, params);
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
export const setPrint = ({commit, getters}, params) => {
|
|
393
|
-
commit(types.SET_PRINT, params);
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
export const setReload = ({commit, getters}, reload) => {
|
|
397
|
-
commit(types.SET_RELOAD, reload);
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
export const setError = ({commit, getters}, error) => {
|
|
401
|
-
commit(types.SET_ERROR, error);
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
export const setIsSaving = ({commit, getters}, IsSaving) => {
|
|
405
|
-
commit(types.SET_ISSAVING, IsSaving);
|
|
406
|
-
};
|
|
407
|
-
export const setIsLoading = ({commit, getters}, IsLoading) => {
|
|
408
|
-
commit(types.SET_ISLOADING, IsLoading);
|
|
409
|
-
};
|
|
410
|
-
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
export const setFilters = ({commit, getters}, params) => {
|
|
382
|
+
commit(types.SET_FILTERS, params);
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
export const setItem = ({commit, getters}, params) => {
|
|
386
|
+
commit(types.SET_ITEM, params);
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
export const setItems = ({commit, getters}, params) => {
|
|
390
|
+
commit(types.SET_ITEMS, params);
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
export const setPrint = ({commit, getters}, params) => {
|
|
394
|
+
commit(types.SET_PRINT, params);
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
export const setReload = ({commit, getters}, reload) => {
|
|
398
|
+
commit(types.SET_RELOAD, reload);
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
export const setError = ({commit, getters}, error) => {
|
|
402
|
+
commit(types.SET_ERROR, error);
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
export const setIsSaving = ({commit, getters}, IsSaving) => {
|
|
406
|
+
commit(types.SET_ISSAVING, IsSaving);
|
|
407
|
+
};
|
|
408
|
+
export const setIsLoading = ({commit, getters}, IsLoading) => {
|
|
409
|
+
commit(types.SET_ISLOADING, IsLoading);
|
|
410
|
+
};
|
|
411
|
+
|
|
411
412
|
export const setTotalItems = ({commit, getters}, totalItems) => {
|
|
412
413
|
commit(types.SET_TOTALITEMS, totalItems);
|
|
413
414
|
};
|
|
@@ -425,20 +426,20 @@ export const setConfigs = ({commit, getters}, configs) => {
|
|
|
425
426
|
};
|
|
426
427
|
|
|
427
428
|
export const setResourceEndpoint = (
|
|
428
|
-
{commit, getters},
|
|
429
|
-
resourceEndpoint = null,
|
|
430
|
-
) => {
|
|
431
|
-
commit(types.SET_RESOURCE_ENDPOINT, resourceEndpoint);
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
export const setSelected = ({commit, getters}, selected) => {
|
|
435
|
-
commit(types.SET_SELECTED, selected);
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
export const setMessage = ({commit, getters}, message) => {
|
|
439
|
-
commit(types.SET_MESSAGE, message);
|
|
440
|
-
};
|
|
441
|
-
|
|
429
|
+
{commit, getters},
|
|
430
|
+
resourceEndpoint = null,
|
|
431
|
+
) => {
|
|
432
|
+
commit(types.SET_RESOURCE_ENDPOINT, resourceEndpoint);
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
export const setSelected = ({commit, getters}, selected) => {
|
|
436
|
+
commit(types.SET_SELECTED, selected);
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
export const setMessage = ({commit, getters}, message) => {
|
|
440
|
+
commit(types.SET_MESSAGE, message);
|
|
441
|
+
};
|
|
442
|
+
|
|
442
443
|
export const setMessages = ({commit, getters}, messages) => {
|
|
443
444
|
commit(types.SET_MESSAGES, messages);
|
|
444
445
|
};
|
|
@@ -461,22 +462,22 @@ export const setLastCompletedRequest = (
|
|
|
461
462
|
) => {
|
|
462
463
|
commit(types.SET_LAST_COMPLETED_REQUEST, lastCompletedRequest);
|
|
463
464
|
};
|
|
464
|
-
|
|
465
|
-
export const setVisibleColumns = ({commit, getters}, visibleColumns) => {
|
|
466
|
-
commit(types.SET_VISIBLECOLUMNS, visibleColumns);
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
export const setIsLoadingList = ({commit, getters}, isLoadingList) => {
|
|
470
|
-
commit(types.SET_ISLOADINGLIST, isLoadingList);
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
export const setStore = ({commit, getters}, store) => {
|
|
474
|
-
commit(types.SET_STORE, store);
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
export const setOffline = ({commit, getters}, offline) => {
|
|
478
|
-
commit(types.SET_OFFLINE, offline);
|
|
479
|
-
};
|
|
480
|
-
export const setPayable = ({commit, getters}, payable) => {
|
|
481
|
-
commit(types.SET_PAYABLE, payable);
|
|
482
|
-
};
|
|
465
|
+
|
|
466
|
+
export const setVisibleColumns = ({commit, getters}, visibleColumns) => {
|
|
467
|
+
commit(types.SET_VISIBLECOLUMNS, visibleColumns);
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
export const setIsLoadingList = ({commit, getters}, isLoadingList) => {
|
|
471
|
+
commit(types.SET_ISLOADINGLIST, isLoadingList);
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
export const setStore = ({commit, getters}, store) => {
|
|
475
|
+
commit(types.SET_STORE, store);
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
export const setOffline = ({commit, getters}, offline) => {
|
|
479
|
+
commit(types.SET_OFFLINE, offline);
|
|
480
|
+
};
|
|
481
|
+
export const setPayable = ({commit, getters}, payable) => {
|
|
482
|
+
commit(types.SET_PAYABLE, payable);
|
|
483
|
+
};
|