@wolkabout/commons 0.3.3 → 0.3.5

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.
@@ -5621,13 +5621,20 @@ class NestedListViewComponent {
5621
5621
  this.children.update(children => [...children, newChild].sort(dataSource.sortingFunction));
5622
5622
  this.selectChild(newChild);
5623
5623
  });
5624
- dataControl.itemRemoved$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((id) => {
5624
+ dataControl.itemRemoved$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((ids) => {
5625
5625
  const breadcrumbs = this.breadcrumbs();
5626
- const index = breadcrumbs.findIndex(breadcrumb => breadcrumb.id === id);
5627
- this.breadcrumbs.update(breadcrumbs => breadcrumbs.slice(0, index));
5628
- const lastItem = this.breadcrumbs()[this.breadcrumbs().length - 1];
5629
- this.selectedItem.set(lastItem);
5630
- this.itemSelected.emit(lastItem.data);
5626
+ const breadcrumbIndex = breadcrumbs.findIndex(breadcrumb => ids.includes(breadcrumb.id));
5627
+ if (breadcrumbIndex !== -1) {
5628
+ this.breadcrumbs.update(breadcrumbs => breadcrumbs.slice(0, breadcrumbIndex));
5629
+ const lastItem = this.breadcrumbs()[this.breadcrumbs().length - 1];
5630
+ this.selectedItem.set(lastItem);
5631
+ this.itemSelected.emit(lastItem.data);
5632
+ }
5633
+ else {
5634
+ this.children.set(this.children().filter(child => !ids.includes(child.id)));
5635
+ }
5636
+ this.selectedItems.set([]);
5637
+ this.itemsSelected.emit([]);
5631
5638
  });
5632
5639
  dataControl.itemUpdated$.pipe(map((item) => dataSource.prepareItem(item, false, this.countsMap())), takeUntilDestroyed(this.destroyRef)).subscribe((updatedItem) => {
5633
5640
  this.breadcrumbs.update(breadcrumbs => breadcrumbs.map(breadcrumb => breadcrumb.id === updatedItem.id ? updatedItem : breadcrumb));
@@ -5857,7 +5864,7 @@ class NestedListDataControl {
5857
5864
  deselectItem = () => this._changeSelection$.next(null);
5858
5865
  updateItem = (item) => this._itemUpdated$.next(item);
5859
5866
  addItem = (item) => this._childAdded.next(item);
5860
- removeItem = (id) => this._itemRemoved$.next(id);
5867
+ removeItem = (id) => this._itemRemoved$.next(Array.isArray(id) ? id : [id]);
5861
5868
  associatedItemAdded = (scopeGuid) => this._associatedItemAdded$.next(scopeGuid);
5862
5869
  associatedItemRemoved = (scopeGuid) => this._associatedItemRemoved$.next(scopeGuid);
5863
5870
  associatedItemScopeChanged = (fromGuid, toGuid) => this._associatedItemScopeChanged$.next({ from: fromGuid, to: toGuid });
@@ -6121,7 +6128,13 @@ class StandardListViewComponent {
6121
6128
  return [...previous, item].sort(this.dataSource().sortingFunction);
6122
6129
  }
6123
6130
  });
6124
- this.itemsSelected.emit(this.selectedItems().map((item) => item.data));
6131
+ if (this.selectedItems().length === 1) {
6132
+ this.itemSelected.emit(this.selectedItems()[0].data);
6133
+ this.itemsSelected.emit([]);
6134
+ }
6135
+ else {
6136
+ this.itemsSelected.emit(this.selectedItems().map((item) => item.data));
6137
+ }
6125
6138
  }
6126
6139
  else if (this.shiftPressed()) {
6127
6140
  window.getSelection()?.removeAllRanges();
@@ -6140,7 +6153,13 @@ class StandardListViewComponent {
6140
6153
  const startIndex = currentSelectionIndex < firstSelectedItemIndex ? currentSelectionIndex : firstSelectedItemIndex;
6141
6154
  const endIndex = currentSelectionIndex < lastSelectedItemIndex ? lastSelectedItemIndex : currentSelectionIndex;
6142
6155
  this.selectedItems.set(this.allSelectableItems().slice(startIndex, endIndex + 1).sort(this.dataSource().sortingFunction));
6143
- this.itemsSelected.emit(this.selectedItems().map((item) => item.data));
6156
+ if (this.selectedItems().length === 1) {
6157
+ this.itemSelected.emit(this.selectedItems()[0].data);
6158
+ this.itemsSelected.emit([]);
6159
+ }
6160
+ else {
6161
+ this.itemsSelected.emit(this.selectedItems().map((item) => item.data));
6162
+ }
6144
6163
  }
6145
6164
  else {
6146
6165
  if (isSelected && this.selectedItems().length === 1) {