Add required value validations for checkbox and dropdown (#9770)

This commit is contained in:
Charles Gagnon
2020-03-30 12:44:56 -07:00
committed by GitHub
parent 90277d627c
commit 9b641490ea
3 changed files with 16 additions and 6 deletions

View File

@@ -105,9 +105,10 @@ export function createNumberInput(view: azdata.ModelView, info: { defaultValue?:
}).component();
}
export function createCheckbox(view: azdata.ModelView, info: { initialValue: boolean, label: string }): azdata.CheckBoxComponent {
export function createCheckbox(view: azdata.ModelView, info: { initialValue: boolean, label: string, required?: boolean }): azdata.CheckBoxComponent {
return view.modelBuilder.checkBox().withProperties<azdata.CheckBoxProperties>({
checked: info.initialValue,
required: info.required,
label: info.label
}).component();
}
@@ -119,6 +120,7 @@ export function createDropdown(view: azdata.ModelView, info: { defaultValue?: st
width: info.width,
editable: info.editable,
fireOnTextChange: true,
required: info.required,
ariaLabel: info.label
}).component();
}
@@ -420,7 +422,7 @@ function processReadonlyTextField(context: FieldContext): void {
}
function processCheckboxField(context: FieldContext): void {
const checkbox = createCheckbox(context.view, { initialValue: context.fieldInfo.defaultValue! === 'true', label: context.fieldInfo.label });
const checkbox = createCheckbox(context.view, { initialValue: context.fieldInfo.defaultValue! === 'true', label: context.fieldInfo.label, required: context.fieldInfo.required });
context.components.push(checkbox);
context.onNewInputComponentCreated(context.fieldInfo.variableName!, checkbox);
}