fix object filtering regression (#10609)

* fix object filtering regression

* add comments
This commit is contained in:
Alan Ren
2020-05-29 10:19:44 -07:00
committed by GitHub
parent 7e49eb85fb
commit 1305743479
2 changed files with 19 additions and 6 deletions

View File

@@ -46,7 +46,7 @@ export class ExplorerTable extends Disposable {
private _actionsColumn: ButtonColumn<Slick.SlickData>;
private _filterStr: string;
private _explorerView: ExplorerView;
private _displayProperties: ObjectListViewProperty[];
private _propertiesToDisplay: ObjectListViewProperty[];
constructor(private parentElement: HTMLElement,
private readonly router: Router,
@@ -61,8 +61,8 @@ export class ExplorerTable extends Disposable {
super();
this._explorerView = new ExplorerView(this.context);
const connectionInfo = this.bootStrapService.connectionManagementService.connectionInfo;
this._displayProperties = this._explorerView.getPropertyList(getFlavor(connectionInfo.serverInfo, this.logService, connectionInfo.providerId));
const explorerFilter = new ExplorerFilter(this.context, this._displayProperties.map(p => p.value));
this._propertiesToDisplay = this._explorerView.getPropertyList(getFlavor(connectionInfo.serverInfo, this.logService, connectionInfo.providerId));
const explorerFilter = new ExplorerFilter(this.context, this.propertiesToFilter);
this._view = new TableDataView<Slick.SlickData>(undefined, undefined, undefined, (data: Slick.SlickData[]): Slick.SlickData[] => {
return explorerFilter.filter(this._filterStr, data);
});
@@ -180,13 +180,13 @@ export class ExplorerTable extends Disposable {
private get columnDefinitions(): Slick.Column<Slick.SlickData>[] {
const totalWidth = DOM.getContentWidth(this.parentElement);
let totalColumnWidthWeight: number = 0;
this._displayProperties.forEach(p => {
this._propertiesToDisplay.forEach(p => {
if (p.widthWeight) {
totalColumnWidthWeight += p.widthWeight;
}
});
const columns: Slick.Column<Slick.SlickData>[] = this._displayProperties.map(property => {
const columns: Slick.Column<Slick.SlickData>[] = this._propertiesToDisplay.map(property => {
const columnWidth = property.widthWeight ? totalWidth * (property.widthWeight / totalColumnWidthWeight) : undefined;
if (property.value === NameProperty) {
const nameColumn = new TextWithIconColumn({
@@ -209,5 +209,14 @@ export class ExplorerTable extends Disposable {
columns.push(this._actionsColumn.definition);
return columns;
}
private get propertiesToFilter(): string[] {
const properties = this._propertiesToDisplay.map(p => p.value);
if (this.context === 'database') {
// for objects in databases, we also support filter by full name: schema.objectName even though the full name is not being displayed.
properties.push('fullName');
}
return properties;
}
}

View File

@@ -13,6 +13,10 @@ export class ObjectMetadataWrapper implements ObjectMetadata {
public name: string;
public schema: string;
public get fullName(): string {
return `${this.schema}.${this.name}`;
}
constructor(from?: ObjectMetadata) {
if (from) {
this.metadataType = from.metadataType;
@@ -65,4 +69,4 @@ export class ObjectMetadataWrapper implements ObjectMetadata {
}
}
}
}
}