Skip to content

Commit

Permalink
Slickgrid POC: replace ContentSelector's tree list with ListBox#7068
Browse files Browse the repository at this point in the history
  • Loading branch information
ashklianko committed Dec 5, 2023
1 parent 4772c34 commit f443c1e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class FilterableListBoxWrapper<I>
const selectionChange: SelectionChange<I> = {selected: [], deselected: []};

this.selectionDelta.forEach((isSelected: boolean, id: string) => {
const item: I = this.listBox.getItem(id);
const item: I = this.getItemById(id);

if (isSelected) {
selectionChange.selected.push(item);
Expand All @@ -295,6 +295,10 @@ export class FilterableListBoxWrapper<I>
this.optionFilterInput.setValue('', true);
}

protected getItemById(id: string): I {
return this.listBox.getItem(id);
}

private focusNext(): void {
const focusedItemIndex: number = this.getFocusedItemIndex();
const arrayAfterFocusedItem: Element[] = focusedItemIndex > -1 ? this.listBox.getChildren().slice(focusedItemIndex + 1) : [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ export abstract class TreeListBox<I> extends LazyListBox<I> {
return result;
}

getItem(id: string): I {
return super.getItem(id) || this.findItem(id);
}

protected findItem(id: string): I {
let result: I = null;

this.itemViews.forEach((itemView: TreeListElement<I>) => {
const item: I = itemView.findItem(id);

if (item) {
result = item;
}
});

return result;
}

getDataView(item: I): Element {
return this.getItemView(item)?.getDataView();
}
Expand Down Expand Up @@ -149,6 +167,10 @@ export abstract class TreeListElement<I>
return this.childrenList.getItemView(item);
}

findItem(id: string): I {
return this.childrenList.getItem(id);
}

onItemsAdded(handler: (items: I[]) => void): void {
this.childrenList.onItemsAdded(handler);
}
Expand Down

0 comments on commit f443c1e

Please sign in to comment.