Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Show only selected items goes to first page #5

Merged
merged 1 commit into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
ListState,
ListStateDispatcher,
ListViewsLoadAction,
ListViewModel
ListViewModel,
ListPagingSetPageNumberAction
} from '@skyux/list-builder/modules/list/state';

import {
Expand Down Expand Up @@ -348,6 +349,23 @@ describe('List View Checklist Component', () => {
expect(visibleCheckboxesLength).toEqual(fixture.componentInstance.selectedItems.size);
}));

it('should go to the first page when \'showOnlySelected\' is selected', fakeAsync(() => {
const dispatcherSpy = spyOn(dispatcher, 'next').and.callThrough();

tick();
fixture.detectChanges();
let checkboxes = document.querySelectorAll('.sky-list-view-checklist sky-checkbox input');
(checkboxes.item(0) as HTMLElement).click();
tick();
fixture.detectChanges();

component.showOnlySelected = true;
tick();
fixture.detectChanges();

expect(dispatcherSpy).toHaveBeenCalledWith(new ListPagingSetPageNumberAction(Number(1)));
}));

it('should hide the item if \'showOnlySelected\' property is set & user uncheck the checkbox', fakeAsync(() => {
tick();
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
ListSelectedModel,
ListFilterModel,
ListItemModel,
ListPagingSetPageNumberAction,
ListSelectedSetItemSelectedAction,
ListSelectedSetItemsSelectedAction,
ListToolbarItemModel,
Expand Down Expand Up @@ -352,6 +353,9 @@ export class SkyListViewChecklistComponent extends ListViewComponent implements
this.dispatcher.filtersUpdate(filters);
});

this.dispatcher.next(
new ListPagingSetPageNumberAction(Number(1))
);
this.disableToolbar(isSelected);
}
}