cats-ui-lib 2.2.15 → 2.2.16
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/fesm2022/cats-ui-lib.mjs +32 -20
- package/fesm2022/cats-ui-lib.mjs.map +1 -1
- package/package.json +1 -1
package/fesm2022/cats-ui-lib.mjs
CHANGED
|
@@ -1697,42 +1697,55 @@ class CheckboxButtonComponent {
|
|
|
1697
1697
|
onCheckboxChange(event, parentIndex, subIndex) {
|
|
1698
1698
|
const checked = event.target.checked;
|
|
1699
1699
|
this.optionList = this.optionList.map((task, i) => {
|
|
1700
|
+
const hasSubtasks = Object.prototype.hasOwnProperty.call(task, 'subtasks');
|
|
1701
|
+
const subtasks = hasSubtasks
|
|
1702
|
+
? (task.subtasks ?? []).map((sub) => ({
|
|
1703
|
+
...sub,
|
|
1704
|
+
checked: sub.checked === true,
|
|
1705
|
+
}))
|
|
1706
|
+
: undefined;
|
|
1700
1707
|
const safeTask = {
|
|
1701
1708
|
...task,
|
|
1702
|
-
checked: task.checked
|
|
1703
|
-
|
|
1709
|
+
checked: task.checked === true,
|
|
1710
|
+
...(hasSubtasks ? { subtasks } : {}),
|
|
1704
1711
|
};
|
|
1705
1712
|
if (i === parentIndex) {
|
|
1706
1713
|
if (subIndex === undefined) {
|
|
1707
1714
|
// Parent checkbox toggled
|
|
1708
1715
|
safeTask.checked = checked;
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1716
|
+
if (hasSubtasks) {
|
|
1717
|
+
safeTask.subtasks = (safeTask.subtasks ?? []).map((sub) => ({
|
|
1718
|
+
...sub,
|
|
1719
|
+
checked,
|
|
1720
|
+
}));
|
|
1721
|
+
}
|
|
1713
1722
|
}
|
|
1714
|
-
else if (safeTask.subtasks[subIndex]) {
|
|
1723
|
+
else if (hasSubtasks && safeTask.subtasks?.[subIndex]) {
|
|
1715
1724
|
// Subtask toggled
|
|
1716
|
-
safeTask.subtasks[
|
|
1725
|
+
safeTask.subtasks = (safeTask.subtasks ?? []).map((sub, index) => ({
|
|
1726
|
+
...sub,
|
|
1727
|
+
checked: index === subIndex ? checked : sub.checked === true,
|
|
1728
|
+
}));
|
|
1717
1729
|
// Parent checked only if all subtasks are checked
|
|
1718
1730
|
safeTask.checked = safeTask.subtasks.every((sub) => sub.checked);
|
|
1719
1731
|
}
|
|
1720
1732
|
}
|
|
1721
1733
|
return safeTask;
|
|
1722
1734
|
});
|
|
1723
|
-
const
|
|
1724
|
-
.filter((task) => (task.checked ?? false) ||
|
|
1725
|
-
task.subtasks?.some((s) => s.checked ?? false))
|
|
1726
|
-
.map((task) => ({
|
|
1735
|
+
const selectionState = this.optionList.map((task) => ({
|
|
1727
1736
|
...task,
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1737
|
+
checked: task.checked === true,
|
|
1738
|
+
...(Object.prototype.hasOwnProperty.call(task, 'subtasks')
|
|
1739
|
+
? {
|
|
1740
|
+
subtasks: (task.subtasks ?? []).map((sub) => ({
|
|
1741
|
+
...sub,
|
|
1742
|
+
checked: sub.checked === true,
|
|
1743
|
+
})),
|
|
1744
|
+
}
|
|
1745
|
+
: {}),
|
|
1733
1746
|
}));
|
|
1734
|
-
this.onCheckBoxSelection.emit(
|
|
1735
|
-
this.onChange(
|
|
1747
|
+
this.onCheckBoxSelection.emit(selectionState);
|
|
1748
|
+
this.onChange(selectionState);
|
|
1736
1749
|
this.onTouched();
|
|
1737
1750
|
}
|
|
1738
1751
|
/**
|
|
@@ -4459,7 +4472,6 @@ class SidebarComponent {
|
|
|
4459
4472
|
return !this.hasFeatures(module);
|
|
4460
4473
|
}
|
|
4461
4474
|
ngOnChanges(_changes) {
|
|
4462
|
-
console.log('check ssidee');
|
|
4463
4475
|
if (_changes['activeItem']?.currentValue && this.activeItem) {
|
|
4464
4476
|
const module = this.appMenus[this.activeItem.moduleIndex];
|
|
4465
4477
|
if (!module ||
|