Fixing schema compare checkbox column functions (#21025)

* Fixing select checkbox event and data state changes

* Only subscribing to event when check all is present

* converting object to map

* logic cleanup
This commit is contained in:
Aasim Khan
2022-10-28 18:15:48 -07:00
committed by GitHub
parent 0bfb220538
commit 998b528680
2 changed files with 29 additions and 9 deletions

View File

@@ -94,8 +94,10 @@ export class CheckboxSelectColumn<T extends Slick.SlickData> implements Slick.Pl
this._handler
.subscribe(this._grid.onClick, (e: Event, args: Slick.OnClickEventArgs<T>) => this.handleClick(e, args))
.subscribe(this._grid.onKeyDown, (e: DOMEvent, args: Slick.OnKeyDownEventArgs<T>) => this.handleKeyDown(e as KeyboardEvent, args))
.subscribe(this._grid.onHeaderClick, (e: Event, args: Slick.OnHeaderClickEventArgs<T>) => this.handleHeaderClick(e, args))
.subscribe(this._grid.onHeaderCellRendered, (e: Event, args: Slick.OnHeaderCellRenderedEventArgs<T>) => this.handleHeaderCellRendered(e, args));
if (this.isCheckAllHeaderCheckboxShown()) {
this._handler.subscribe(this._grid.onHeaderClick, (e: Event, args: Slick.OnHeaderClickEventArgs<T>) => this.handleHeaderClick(e, args));
}
}
private handleClick(e: DOMEvent, args: Slick.OnClickEventArgs<T>): void {
@@ -131,7 +133,7 @@ export class CheckboxSelectColumn<T extends Slick.SlickData> implements Slick.Pl
if (this._options.actionOnCheck === ActionOnCheck.selectRow) {
this.updateSelectedRows();
} else {
this._onChange.fire({ checked: false, row: row, column: this.index });
this._onChange.fire({ checked: !currentValue.checked, row: row, column: this.index });
}
}
@@ -152,6 +154,10 @@ export class CheckboxSelectColumn<T extends Slick.SlickData> implements Slick.Pl
e.stopPropagation();
}
private isCheckAllHeaderCheckboxShown(): boolean {
return !this._options.title;
}
private handleHeaderKeyDown(e: KeyboardEvent): void {
const event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Enter) || event.equals(KeyCode.Space)) {
@@ -200,6 +206,18 @@ export class CheckboxSelectColumn<T extends Slick.SlickData> implements Slick.Pl
this._handler.unsubscribeAll();
}
// This call is to handle reactive changes in check box UI
// This DOES NOT fire UI change Events
public reactiveCheckboxCheck(row: number, value: boolean) {
this.setCheckboxPropertyValue(row, value);
// update row to call formatter
this._grid.invalidateRow(row);
this._grid.render();
// ensure that grid reflects the change
this._grid.scrollRowIntoView(row);
}
private getCheckboxPropertyValue(row: number): ICheckboxColumnValue {
const dataItem = this._grid?.getDataItem(row);
const propertyValue = dataItem[this._options.title];