asab_webui_components 27.3.7 → 27.3.8
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
|
}
|