mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 17:22:45 -05:00
Add ModelView method SetItemLayout (#10306)
* Add ModelView method SetItemLayout * Remove extra line break
This commit is contained in:
@@ -352,6 +352,24 @@ export abstract class ContainerBase<T> extends ComponentBase {
|
||||
|
||||
abstract setLayout(layout: any): void;
|
||||
|
||||
public setItemLayout(componentDescriptor: IComponentDescriptor, config: any): void {
|
||||
if (!componentDescriptor) {
|
||||
return;
|
||||
}
|
||||
const item = this.items.find(item => item.descriptor.id === componentDescriptor.id && item.descriptor.type === componentDescriptor.type);
|
||||
if (item) {
|
||||
item.config = config;
|
||||
this.onItemLayoutUpdated(item);
|
||||
this._changeRef.detectChanges();
|
||||
} else {
|
||||
throw new Error(`Unable to set item layout - unknown item ${componentDescriptor.id}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
protected onItemsUpdated(): void {
|
||||
}
|
||||
|
||||
protected onItemLayoutUpdated(item: ItemDescriptor<T>): void {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, forwardRef, Inject, Input, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { NavigationBarLayout, PanelComponent } from 'sql/base/browser/ui/panel/panel.component';
|
||||
import { TabType } from 'sql/base/browser/ui/panel/tab.component';
|
||||
import { ContainerBase } from 'sql/workbench/browser/modelComponents/componentBase';
|
||||
import { ContainerBase, ItemDescriptor } from 'sql/workbench/browser/modelComponents/componentBase';
|
||||
import { ComponentEventType, IComponent, IComponentDescriptor, IModelStore } from 'sql/platform/dashboard/browser/interfaces';
|
||||
import 'vs/css!./media/tabbedPanel';
|
||||
import { IUserFriendlyIcon, createIconCssClass } from 'sql/workbench/browser/modelComponents/iconUtils';
|
||||
@@ -121,4 +121,8 @@ export default class TabbedPanelComponent extends ContainerBase<TabConfig> imple
|
||||
this._panel.selectTab(firstTabIndex);
|
||||
}
|
||||
}
|
||||
|
||||
onItemLayoutUpdated(item: ItemDescriptor<TabConfig>): void {
|
||||
this._panel.updateTab(item.config.id, { title: item.config.title, iconClass: item.config.icon ? createIconCssClass(item.config.icon) : undefined });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +105,13 @@ export abstract class ViewBase extends AngularDisposable implements IModelView {
|
||||
this.queueAction(componentId, (component) => component.setLayout(layout));
|
||||
}
|
||||
|
||||
setItemLayout(containerId: string, itemConfig: IItemConfig): void {
|
||||
let childDescriptor = this.modelStore.getComponentDescriptor(itemConfig.componentShape.id);
|
||||
this.queueAction(containerId, (component) => {
|
||||
component.setItemLayout(childDescriptor, itemConfig.config);
|
||||
});
|
||||
}
|
||||
|
||||
setProperties(componentId: string, properties: { [key: string]: any; }): void {
|
||||
if (!properties) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user