Skip to content

Commit

Permalink
fix: entry actionbar load more
Browse files Browse the repository at this point in the history
- minor fixes in actionbar ux
  • Loading branch information
felixroos committed Jul 26, 2019
1 parent fecb195 commit 19a5130
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
25 changes: 25 additions & 0 deletions packages/data/src/lib/entry-actionbar/entry-actionbar.component.ts
Expand Up @@ -87,9 +87,34 @@ export class EntryActionbarComponent extends ActionbarComponent implements OnIni
select: false,
action: () => this.loadModelActions(),
});
const nextPageAction = this.getNextPageAction(entryList);
if (nextPageAction) {
entryActions.push(nextPageAction);
}
this.loadActions(entryActions);
}

getNextPageAction(entryList) {
if (entryList.hasNextLink()) {
return {
id: 'load-next-page',
title: 'Load More...',
select: false,
action: async () => {
const nextPage = await entryList.followNextLink();
const entryActions: any[] = nextPage.getAllItems().map((entry) => this.getEntryAction(entry));
const allActions = (this.currentActions() || []).filter(a => a.id !== 'load-next-page').concat(entryActions);
const nextPageAction = this.getNextPageAction(nextPage);
if (nextPageAction) {
allActions.push(nextPageAction);
}
this.loadActions(allActions);

}
};
}
}

writeValue(value) {
if (!value) {
value = [];
Expand Down
9 changes: 6 additions & 3 deletions packages/ui/src/lib/actionbar/actionbar.component.ts
Expand Up @@ -14,7 +14,7 @@ export interface Action {
action?: ActionFunction;
}

export interface ActionbarConfig extends ListConfig<Action> {}
export interface ActionbarConfig extends ListConfig<Action> { }

@Component({
selector: 'ec-actionbar',
Expand Down Expand Up @@ -44,7 +44,7 @@ export class ActionbarComponent extends SelectComponent<Action> implements OnIni
if (item.getBody().children) {
this.loadActions(item.getBody().children);
}
this.searchbar.clear();
// this.searchbar.clear();
});
this.remove.subscribe((item) => {
this.selection.remove(item);
Expand Down Expand Up @@ -89,7 +89,10 @@ export class ActionbarComponent extends SelectComponent<Action> implements OnIni
if (addToStack) {
this.actionStack[this.currentID()] = actions;
}
this.list = new List(resolved, this.config);
this.list = new List(resolved, { size: 1000, ...this.config });
if (resolved.length > this.list.config) {
console.warn('actions exceed list size...');
}
if (!this.selection) {
this.initSelection();
}
Expand Down

0 comments on commit 19a5130

Please sign in to comment.