Feature/input box component (#1190)

* Adding new view component for input box
This commit is contained in:
Leila Lali
2018-04-20 16:26:58 -07:00
committed by GitHub
parent 93aa052856
commit a7c4686980
11 changed files with 289 additions and 18 deletions

View File

@@ -16,6 +16,7 @@ import { IModelView } from 'sql/services/model/modelViewService';
import { Extensions, IComponentRegistry } from 'sql/platform/dashboard/common/modelComponentRegistry';
import { AngularDisposable } from 'sql/base/common/lifecycle';
import { ModelStore } from 'sql/parts/modelComponents/modelStore';
import Event, { Emitter } from 'vs/base/common/event';
const componentRegistry = <IComponentRegistry> Registry.as(Extensions.ComponentContribution);
@@ -35,6 +36,8 @@ export abstract class ViewBase extends AngularDisposable implements IModelView {
abstract id: string;
abstract connection: sqlops.connection.Connection;
abstract serverInfo: sqlops.ServerInfo;
private _onEventEmitter = new Emitter<any>();
initializeModel(rootComponent: IComponentShape): void {
let descriptor = this.defineComponent(rootComponent);
@@ -52,11 +55,13 @@ export abstract class ViewBase extends AngularDisposable implements IModelView {
let descriptor = this.modelStore.createComponentDescriptor(typeId, component.id);
this.setProperties(component.id, component.properties);
this.setLayout(component.id, component.layout);
this.registerEvent(component.id);
if (component.itemConfigs) {
for(let item of component.itemConfigs) {
this.addToContainer(component.id, item);
}
}
return descriptor;
}
@@ -91,4 +96,18 @@ export abstract class ViewBase extends AngularDisposable implements IModelView {
// TODO add error handling
});
}
registerEvent(componentId: string) {
this.queueAction(componentId, (component) => {
if (component.onEvent) {
this._register(component.onEvent(e => {
this._onEventEmitter.fire(e);
}));
}
});
}
public get onEvent(): Event<any> {
return this._onEventEmitter.event;
}
}