Skip to content

Commit

Permalink
Add autoload on search option to growing list
Browse files Browse the repository at this point in the history
Auto load more items if after applying the search filter
only <= autoloadOnSearch items are visible.
Use false or -1 to disable (true is counted as 0).
  • Loading branch information
buehlefs committed Sep 26, 2023
1 parent 062cb05 commit 366b70f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/app/components/growing-list/growing-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class GrowingListComponent implements OnInit, OnDestroy {
@Input() set search(value: string | null) {
this.normalizedSearch = value?.toLowerCase()?.trim() ?? null;
}
@Input() autoloadOnSearch: boolean | number = false;

normalizedSearch: string | null = null;

Expand Down Expand Up @@ -362,6 +363,13 @@ export class GrowingListComponent implements OnInit, OnDestroy {
this.visibleItems.emit(itemsInSearch);
this.visibleCollectionSize.emit(itemsInSearchCount);
});
if (this.autoloadOnSearch !== false) {
const minItems = this.autoloadOnSearch === true ? 0 : this.autoloadOnSearch;
const underMinItems = itemsInSearchCount <= minItems;
if (underMinItems && this.loadMoreApiLink != null) {
this.loadMore();
}
}
}

onItemClick(link: ApiLink) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ <h3 class="plugin-group-header">
<mat-divider></mat-divider>
</summary>
<qhana-growing-list [apiLink]="group.link" [query]="group?.query ?? null" [search]="searchInput.value"
[highlighted]="highlightedPlugins" [highlightByKey]="'pluginId'" (clickItem)="selectPlugin($event)"
#pluginList></qhana-growing-list>
[autoloadOnSearch]="true" [highlighted]="highlightedPlugins" [highlightByKey]="'pluginId'"
(clickItem)="selectPlugin($event)" #pluginList></qhana-growing-list>
<mat-divider></mat-divider>
</details>
</div>
Expand Down

0 comments on commit 366b70f

Please sign in to comment.