asab_webui_components 27.3.7 → 27.3.9
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.
|
@@ -366,7 +366,8 @@ function DataTable2(_ref5) {
|
|
|
366
366
|
id: "datatable-column-".concat(idx)
|
|
367
367
|
}, column !== null && column !== void 0 && column.sort ? /*#__PURE__*/_react.default.createElement(DataTableSort2, {
|
|
368
368
|
title: column === null || column === void 0 ? void 0 : column.title,
|
|
369
|
-
field: column.sort
|
|
369
|
+
field: column.sort,
|
|
370
|
+
sortDirection: column === null || column === void 0 ? void 0 : column.sortDirection
|
|
370
371
|
}) : column === null || column === void 0 ? void 0 : column.title)))), /*#__PURE__*/_react.default.createElement("tbody", null, rows.map((row, ridx) => /*#__PURE__*/_react.default.createElement("tr", {
|
|
371
372
|
key: ridx,
|
|
372
373
|
style: _objectSpread(_objectSpread({}, rowStyle ? rowStyle(row) : {}), {}, {
|
|
@@ -489,7 +490,8 @@ function DataTableBadge(_ref7) {
|
|
|
489
490
|
function DataTableSort2(_ref8) {
|
|
490
491
|
var {
|
|
491
492
|
title,
|
|
492
|
-
field
|
|
493
|
+
field,
|
|
494
|
+
sortDirection
|
|
493
495
|
} = _ref8;
|
|
494
496
|
var {
|
|
495
497
|
onTriggerSort,
|
|
@@ -498,21 +500,35 @@ function DataTableSort2(_ref8) {
|
|
|
498
500
|
var {
|
|
499
501
|
t
|
|
500
502
|
} = (0, _reactI18next.useTranslation)();
|
|
501
|
-
|
|
503
|
+
|
|
504
|
+
// Get the current sorting direction for this field from URL/search params (e.g. 'a' or 'd')
|
|
505
|
+
var currentSort = getParam("s".concat(field));
|
|
506
|
+
|
|
507
|
+
// Determine what the start sorting direction should be after click
|
|
508
|
+
var getInitialSortDirection = () => {
|
|
509
|
+
if (sortDirection && !currentSort) {
|
|
510
|
+
// If there is a SortDirection and the field is not sorted yet, we use SortDirection
|
|
511
|
+
return sortDirection;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// Otherwise standard behavior (sorted in ascending order)
|
|
515
|
+
return 'a';
|
|
516
|
+
};
|
|
517
|
+
return currentSort ? currentSort === 'd' ? /*#__PURE__*/_react.default.createElement("span", {
|
|
502
518
|
className: "sort-span-wrapper",
|
|
503
|
-
onClick: e => onTriggerSort(e, field,
|
|
519
|
+
onClick: e => onTriggerSort(e, field, 'a')
|
|
504
520
|
}, title, /*#__PURE__*/_react.default.createElement("i", {
|
|
505
521
|
title: "".concat(t('General|Sort ascend'), ". ").concat(t('General|Shift + left mouse click to remove from sorting')),
|
|
506
522
|
className: "bi bi-sort-up sort-icon-active ms-2"
|
|
507
523
|
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
508
524
|
className: "sort-span-wrapper",
|
|
509
|
-
onClick: e => onTriggerSort(e, field,
|
|
525
|
+
onClick: e => onTriggerSort(e, field, 'd')
|
|
510
526
|
}, title, /*#__PURE__*/_react.default.createElement("i", {
|
|
511
527
|
title: "".concat(t('General|Sort descend'), ". ").concat(t('General|Shift + left mouse click to remove from sorting')),
|
|
512
528
|
className: "bi bi-sort-down-alt sort-icon-active ms-2"
|
|
513
529
|
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
514
530
|
className: "sort-span-wrapper",
|
|
515
|
-
onClick: e => onTriggerSort(e, field,
|
|
531
|
+
onClick: e => onTriggerSort(e, field, getInitialSortDirection())
|
|
516
532
|
}, title, /*#__PURE__*/_react.default.createElement("i", {
|
|
517
533
|
title: t('General|Shift + left mouse click for advanced sorting'),
|
|
518
534
|
className: "bi bi-arrow-down-up ms-2"
|
|
@@ -307,6 +307,7 @@ export function DataTable2({columns, rows, limit, loading, rowHeight, rowStyle})
|
|
|
307
307
|
<DataTableSort2
|
|
308
308
|
title={column?.title}
|
|
309
309
|
field={column.sort}
|
|
310
|
+
sortDirection={column?.sortDirection}
|
|
310
311
|
/>
|
|
311
312
|
: column?.title}
|
|
312
313
|
</th>
|
|
@@ -431,35 +432,49 @@ function DataTableBadge({ item, value, isLoading, onRemove }) {
|
|
|
431
432
|
}
|
|
432
433
|
|
|
433
434
|
// Inner sorting function
|
|
434
|
-
function DataTableSort2({title, field}) {
|
|
435
|
+
function DataTableSort2({title, field, sortDirection}) {
|
|
435
436
|
const { onTriggerSort, getParam } = useDataTableContext();
|
|
436
437
|
const { t } = useTranslation();
|
|
437
438
|
|
|
439
|
+
// Get the current sorting direction for this field from URL/search params (e.g. 'a' or 'd')
|
|
440
|
+
const currentSort = getParam(`s${field}`);
|
|
441
|
+
|
|
442
|
+
// Determine what the start sorting direction should be after click
|
|
443
|
+
const getInitialSortDirection = () => {
|
|
444
|
+
if (sortDirection && !currentSort) {
|
|
445
|
+
// If there is a SortDirection and the field is not sorted yet, we use SortDirection
|
|
446
|
+
return sortDirection;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// Otherwise standard behavior (sorted in ascending order)
|
|
450
|
+
return 'a';
|
|
451
|
+
};
|
|
452
|
+
|
|
438
453
|
return (
|
|
439
|
-
|
|
440
|
-
(
|
|
441
|
-
<span className=
|
|
454
|
+
currentSort ?
|
|
455
|
+
(currentSort === 'd') ?
|
|
456
|
+
<span className='sort-span-wrapper' onClick={(e) => onTriggerSort(e, field, 'a')}>
|
|
442
457
|
{title}
|
|
443
458
|
<i
|
|
444
459
|
title={`${t('General|Sort ascend')}. ${t('General|Shift + left mouse click to remove from sorting')}`}
|
|
445
|
-
className=
|
|
446
|
-
|
|
447
|
-
</span>
|
|
448
|
-
:
|
|
449
|
-
<span className="sort-span-wrapper" onClick={(e) => onTriggerSort(e, field, "d")}>
|
|
450
|
-
{title}
|
|
451
|
-
<i
|
|
452
|
-
title={`${t('General|Sort descend')}. ${t('General|Shift + left mouse click to remove from sorting')}`}
|
|
453
|
-
className="bi bi-sort-down-alt sort-icon-active ms-2"
|
|
454
|
-
></i>
|
|
460
|
+
className='bi bi-sort-up sort-icon-active ms-2'
|
|
461
|
+
/>
|
|
455
462
|
</span>
|
|
456
463
|
:
|
|
457
|
-
<span className=
|
|
464
|
+
<span className='sort-span-wrapper' onClick={(e) => onTriggerSort(e, field, 'd')}>
|
|
458
465
|
{title}
|
|
459
466
|
<i
|
|
460
|
-
title={t('General|Shift + left mouse click
|
|
461
|
-
className=
|
|
462
|
-
|
|
467
|
+
title={`${t('General|Sort descend')}. ${t('General|Shift + left mouse click to remove from sorting')}`}
|
|
468
|
+
className='bi bi-sort-down-alt sort-icon-active ms-2'
|
|
469
|
+
/>
|
|
463
470
|
</span>
|
|
464
|
-
|
|
471
|
+
:
|
|
472
|
+
<span className='sort-span-wrapper' onClick={(e) => onTriggerSort(e, field, getInitialSortDirection())}>
|
|
473
|
+
{title}
|
|
474
|
+
<i
|
|
475
|
+
title={t('General|Shift + left mouse click for advanced sorting')}
|
|
476
|
+
className='bi bi-arrow-down-up ms-2'
|
|
477
|
+
/>
|
|
478
|
+
</span>
|
|
479
|
+
);
|
|
465
480
|
}
|
|
@@ -116,7 +116,17 @@ var DataTableContextProvider = _ref => {
|
|
|
116
116
|
updatedSearchParams.append(key, value);
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
|
-
|
|
119
|
+
/* Only decrease limit when adding the very first filtering.
|
|
120
|
+
Check original params (including the field being replaced) so that
|
|
121
|
+
replacing an existing filter does not decrease the limit a second time
|
|
122
|
+
*/
|
|
123
|
+
var isFirstFilter = ![...searchParams.entries()].some(_ref2 => {
|
|
124
|
+
var [key] = _ref2;
|
|
125
|
+
return key.startsWith('a');
|
|
126
|
+
});
|
|
127
|
+
if (isFirstFilter) {
|
|
128
|
+
(0, _updateTableLimit.updateLimit)("decrease", updatedSearchParams);
|
|
129
|
+
}
|
|
120
130
|
updatedSearchParams.set("p", 1);
|
|
121
131
|
updatedSearchParams.append("a".concat(field), value);
|
|
122
132
|
setSearchParams(updatedSearchParams);
|
|
@@ -129,7 +139,11 @@ var DataTableContextProvider = _ref => {
|
|
|
129
139
|
updatedState[key] = prevState[key];
|
|
130
140
|
}
|
|
131
141
|
});
|
|
132
|
-
|
|
142
|
+
// Same check against the original prevState (before stripping the field)
|
|
143
|
+
var isFirstFilter = !Object.keys(prevState).some(key => key.startsWith('a'));
|
|
144
|
+
if (isFirstFilter) {
|
|
145
|
+
(0, _updateTableLimit.updateStateLimit)("decrease", updatedState);
|
|
146
|
+
}
|
|
133
147
|
updatedState['p'] = 1;
|
|
134
148
|
updatedState["a".concat(field)] = [value];
|
|
135
149
|
return updatedState;
|
|
@@ -359,8 +373,8 @@ var DataTableContextProvider = _ref => {
|
|
|
359
373
|
|
|
360
374
|
// Inner method to update search params
|
|
361
375
|
var _updateSearchParams = (searchParams, params) => {
|
|
362
|
-
Object.entries(params).forEach(
|
|
363
|
-
var [key, value] =
|
|
376
|
+
Object.entries(params).forEach(_ref3 => {
|
|
377
|
+
var [key, value] = _ref3;
|
|
364
378
|
searchParams.set(key, value);
|
|
365
379
|
});
|
|
366
380
|
return searchParams;
|
|
@@ -89,7 +89,14 @@ const DataTableContextProvider = ({ children, disableParams, initialLimit }) =>
|
|
|
89
89
|
updatedSearchParams.append(key, value);
|
|
90
90
|
}
|
|
91
91
|
})
|
|
92
|
-
|
|
92
|
+
/* Only decrease limit when adding the very first filtering.
|
|
93
|
+
Check original params (including the field being replaced) so that
|
|
94
|
+
replacing an existing filter does not decrease the limit a second time
|
|
95
|
+
*/
|
|
96
|
+
const isFirstFilter = ![...searchParams.entries()].some(([key]) => key.startsWith('a'));
|
|
97
|
+
if (isFirstFilter) {
|
|
98
|
+
updateLimit("decrease", updatedSearchParams);
|
|
99
|
+
}
|
|
93
100
|
updatedSearchParams.set("p", 1);
|
|
94
101
|
updatedSearchParams.append(`a${field}`, value);
|
|
95
102
|
setSearchParams(updatedSearchParams);
|
|
@@ -102,7 +109,11 @@ const DataTableContextProvider = ({ children, disableParams, initialLimit }) =>
|
|
|
102
109
|
updatedState[key] = prevState[key];
|
|
103
110
|
}
|
|
104
111
|
});
|
|
105
|
-
|
|
112
|
+
// Same check against the original prevState (before stripping the field)
|
|
113
|
+
const isFirstFilter = !Object.keys(prevState).some(key => key.startsWith('a'));
|
|
114
|
+
if (isFirstFilter) {
|
|
115
|
+
updateStateLimit("decrease", updatedState);
|
|
116
|
+
}
|
|
106
117
|
updatedState['p'] = 1;
|
|
107
118
|
updatedState[`a${field}`] = [value];
|
|
108
119
|
return updatedState;
|