Add validation to model view components (#1356)

This commit is contained in:
Matt Irvine
2018-05-08 14:15:26 -07:00
committed by GitHub
parent c2b32fd64a
commit f10e281ffc
18 changed files with 459 additions and 35 deletions

View File

@@ -11,9 +11,11 @@ import { ModelViewContent } from 'sql/parts/modelComponents/modelViewContent.com
import { BootstrapParams } from 'sql/services/bootstrap/bootstrapParams';
import { BOOTSTRAP_SERVICE_ID, IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import Event, { Emitter } from 'vs/base/common/event';
import { ComponentEventType } from '../../parts/modelComponents/interfaces';
export interface DialogComponentParams extends BootstrapParams {
modelViewId: string;
validityChangedCallback: (valid: boolean) => void;
}
@Component({
@@ -27,16 +29,23 @@ export interface DialogComponentParams extends BootstrapParams {
export class DialogContainer implements AfterContentInit {
private _onResize = new Emitter<void>();
public readonly onResize: Event<void> = this._onResize.event;
private _params: DialogComponentParams;
public modelViewId: string;
@ViewChild(ModelViewContent) private _modelViewContent: ModelViewContent;
constructor(
@Inject(forwardRef(() => ElementRef)) el: ElementRef,
@Inject(BOOTSTRAP_SERVICE_ID) bootstrapService: IBootstrapService) {
this.modelViewId = (bootstrapService.getBootstrapParams(el.nativeElement.tagName) as DialogComponentParams).modelViewId;
this._params = bootstrapService.getBootstrapParams(el.nativeElement.tagName) as DialogComponentParams;
this.modelViewId = this._params.modelViewId;
}
ngAfterContentInit(): void {
this._modelViewContent.onEvent(event => {
if (event.eventType === ComponentEventType.validityChanged) {
this._params.validityChangedCallback(event.args);
}
});
}
public layout(): void {