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.
@@ -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 ?? false,
1703
- subtasks: task.subtasks ?? [],
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
- safeTask.subtasks = safeTask.subtasks.map((sub) => ({
1710
- ...sub,
1711
- checked,
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[subIndex].checked = checked;
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 checkedTasks = this.optionList
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
- subtasks: task.subtasks?.filter((s) => s.checked ?? false) || [],
1729
- }));
1730
- const selectedObjects = checkedTasks.map((task) => ({
1731
- ...task,
1732
- subtasks: task.subtasks.filter((s) => s.checked),
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(selectedObjects);
1735
- this.onChange(this.optionList);
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 ||