mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -05:00
Add setFilter to DeclarativeTableComponent (#14143)
* Add setFilter to DeclarativeTableComponent * fix tests * Update param name
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
<tbody role="rowgroup">
|
||||
<ng-container *ngIf="data.length > 0">
|
||||
<ng-container *ngFor="let row of data;let r = index;">
|
||||
<tr class="declarative-table-row" [class.selected]="isRowSelected(r)" role="row">
|
||||
<tr [style.display]="isFiltered(r) ? 'none' : ''" class="declarative-table-row" [class.selected]="isRowSelected(r)" role="row">
|
||||
<ng-container *ngFor="let cellData of row;let c = index;trackBy:trackByFnCols">
|
||||
<td class="declarative-table-cell" [style.width]="getColumnWidth(c)"
|
||||
[attr.aria-label]="getAriaLabel(r, c)"
|
||||
|
||||
@@ -15,7 +15,7 @@ import { ContainerBase } from 'sql/workbench/browser/modelComponents/componentBa
|
||||
import { ISelectData } from 'vs/base/browser/ui/selectBox/selectBox';
|
||||
import { equals as arrayEquals } from 'vs/base/common/arrays';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/platform/dashboard/browser/interfaces';
|
||||
import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType, ModelViewAction } from 'sql/platform/dashboard/browser/interfaces';
|
||||
import { convertSize } from 'sql/base/browser/dom';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
|
||||
@@ -36,6 +36,7 @@ export default class DeclarativeTableComponent extends ContainerBase<any, azdata
|
||||
@Input() modelStore: IModelStore;
|
||||
|
||||
private _data: azdata.DeclarativeTableCellValue[][] = [];
|
||||
private _filteredRowIndexes: number[] | undefined = undefined;
|
||||
private columns: azdata.DeclarativeTableColumn[] = [];
|
||||
private _selectedRow: number;
|
||||
|
||||
@@ -311,10 +312,29 @@ export default class DeclarativeTableComponent extends ContainerBase<any, azdata
|
||||
}
|
||||
}
|
||||
|
||||
public doAction(action: string, ...args: any[]): void {
|
||||
if (action === ModelViewAction.Filter) {
|
||||
this._filteredRowIndexes = args[0];
|
||||
}
|
||||
this._changeRef.detectChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given row is filtered (not visible)
|
||||
* @param rowIndex The row to check
|
||||
*/
|
||||
public isFiltered(rowIndex: number): boolean {
|
||||
if (this._filteredRowIndexes === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this._filteredRowIndexes.includes(rowIndex) ? false : true;
|
||||
}
|
||||
|
||||
public get CSSStyles(): azdata.CssStyles {
|
||||
return this.mergeCss(super.CSSStyles, {
|
||||
'width': this.getWidth(),
|
||||
'height': this.getHeight()
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user