Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Sep 29, 2024
2 parents 1caf1e8 + 4ecb439 commit 84ba58d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const gridStub = {
registerPlugin: jest.fn(),
setSelectionModel: jest.fn(),
sanitizeHtmlString: (s: string) => s,
onColumnsReordered: new SlickEvent(),
onRendered: new SlickEvent(),
onSelectedRowsChanged: new SlickEvent(),
onSort: new SlickEvent(),
} as unknown as SlickGrid;
Expand Down Expand Up @@ -177,7 +177,7 @@ describe('SlickRowDetailView', () => {
columnsMock = [{ id: 'field1', field: 'field1', width: 100, cssClass: 'red' }];
jest.spyOn(gridStub, 'getOptions').mockReturnValue(gridOptionsMock);
jest.clearAllMocks();
gridStub.onColumnsReordered = new SlickEvent();
gridStub.onRendered = new SlickEvent();
gridStub.onSort = new SlickEvent();
});

Expand Down Expand Up @@ -392,7 +392,7 @@ describe('SlickRowDetailView', () => {
});
});

it('should call Aurelia Util "createAureliaViewModelAddToSlot" when grid "onColumnsReordered" is triggered', (done) => {
it('should call Aurelia Util "createAureliaViewModelAddToSlot" when grid "onRendered" is triggered', (done) => {
const mockColumn = { id: 'field1', field: 'field1', width: 100, cssClass: 'red', __collapsed: true };
const handlerSpy = jest.spyOn(plugin.eventHandler, 'subscribe');
// @ts-ignore:2345
Expand All @@ -402,7 +402,7 @@ describe('SlickRowDetailView', () => {
plugin.onBeforeRowDetailToggle = new SlickEvent();
plugin.register();
plugin.eventHandler.subscribe(plugin.onBeforeRowDetailToggle, () => {
gridStub.onColumnsReordered.notify({ impactedColumns: [mockColumn] } as any, new SlickEventData(), gridStub);
gridStub.onRendered.notify({ impactedColumns: [mockColumn] } as any, new SlickEventData(), gridStub);
expect(appendSpy).toHaveBeenCalledWith(
ExampleLoader,
expect.objectContaining({ model: mockColumn, addon: expect.anything(), grid: gridStub }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
// --
// hook some events needed by the Plugin itself

// we need to redraw the open detail views if we change column position (column reorder)
this._eventHandler.subscribe(this._grid.onColumnsReordered, this.redrawAllViewSlots.bind(this));
// redraw anytime the grid is re-rendered
this.eventHandler.subscribe(this._grid.onRendered, this.redrawAllViewSlots.bind(this));

// on row selection changed, we also need to redraw
if (this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector) {
Expand All @@ -208,8 +208,7 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
// on filter changed, we need to re-render all Views
this._subscriptions.push(
this.eventPubSubService?.subscribe('onFilterChanged', this.redrawAllViewSlots.bind(this)),
this.eventPubSubService?.subscribe('onGridMenuClearAllFilters', () => window.setTimeout(() => this.redrawAllViewSlots())),
this.eventPubSubService?.subscribe('onGridMenuClearAllSorting', () => window.setTimeout(() => this.redrawAllViewSlots())),
this.eventPubSubService?.subscribe(['onGridMenuClearAllFilters', 'onGridMenuClearAllSorting'], () => window.setTimeout(() => this.redrawAllViewSlots())),
);
}
}
Expand Down

0 comments on commit 84ba58d

Please sign in to comment.