Add default model view input types and validation (#1397)

This commit is contained in:
Matt Irvine
2018-05-14 16:20:19 -07:00
committed by GitHub
parent 89c48bbe75
commit 9bd45cf66a
14 changed files with 363 additions and 118 deletions

View File

@@ -46,7 +46,7 @@ export class MainThreadModelView extends Disposable implements MainThreadModelVi
$initializeModel(handle: number, rootComponent: IComponentShape): Thenable<void> {
return this.execModelViewAction(handle, (modelView) => {
modelView.initializeModel(rootComponent);
modelView.initializeModel(rootComponent, (componentId) => this.runCustomValidations(handle, componentId));
});
}
@@ -82,8 +82,12 @@ export class MainThreadModelView extends Disposable implements MainThreadModelVi
return this.execModelViewAction(handle, (modelView) => modelView.setProperties(componentId, properties));
}
$notifyValidation(handle: number, componentId: string, valid: boolean): Thenable<void> {
return this.execModelViewAction(handle, (modelView) => modelView.setValid(componentId, valid));
$validate(handle: number, componentId: string): Thenable<boolean> {
return new Promise(resolve => this.execModelViewAction(handle, (modelView) => resolve(modelView.validate(componentId))));
}
private runCustomValidations(handle: number, componentId: string): Thenable<boolean> {
return this._proxy.$runCustomValidations(handle, componentId);
}
private execModelViewAction<T>(handle: number, action: (m: IModelView) => T): Thenable<T> {