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

@@ -31,6 +31,7 @@ declare module 'sqlops' {
export interface ComponentBuilder<T extends Component> {
component(): T;
withProperties<U>(properties: U): ComponentBuilder<T>;
withValidation(validation: (component: T) => boolean): ComponentBuilder<T>;
}
export interface ContainerBuilder<T extends Component, TLayout, TItemLayout> extends ComponentBuilder<T> {
withLayout(layout: TLayout): ContainerBuilder<T, TLayout, TItemLayout>;
@@ -56,6 +57,21 @@ declare module 'sqlops' {
* @memberof Component
*/
updateProperties(properties: { [key: string]: any }): Thenable<boolean>;
/**
* Event fired to notify that the component's validity has changed
*/
readonly onValidityChanged: vscode.Event<boolean>;
/**
* Whether the component is valid or not
*/
readonly valid: boolean;
/**
* Run the component's validations
*/
validate(): void;
}
export interface FormComponent {
@@ -264,6 +280,21 @@ declare module 'sqlops' {
*/
readonly modelBuilder: ModelBuilder;
/**
* Whether or not the model view's root component is valid
*/
readonly valid: boolean;
/**
* Raised when the model view's valid property changes
*/
readonly onValidityChanged: vscode.Event<boolean>;
/**
* Run the model view root component's validations
*/
validate(): void;
/**
* Initializes the model with a root component definition.
* Once this has been done, the components will be laid out in the UI and
@@ -336,6 +367,16 @@ declare module 'sqlops' {
* Any additional buttons that should be displayed
*/
customButtons: Button[];
/**
* Whether the dialog's content is valid
*/
readonly valid: boolean;
/**
* Fired whenever the dialog's valid property changes
*/
readonly onValidityChanged: vscode.Event<boolean>;
}
export interface DialogTab {