mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 01:25:36 -05:00
Add required value validations for checkbox and dropdown (#9770)
This commit is contained in:
@@ -74,30 +74,34 @@ export default class DropDownComponent extends ComponentBase implements ICompone
|
||||
|
||||
this._register(this._editableDropdown);
|
||||
this._register(attachEditableDropdownStyler(this._editableDropdown, this.themeService));
|
||||
this._register(this._editableDropdown.onValueChange(e => {
|
||||
this._register(this._editableDropdown.onValueChange(async e => {
|
||||
if (this.editable) {
|
||||
this.setSelectedValue(this._editableDropdown.value);
|
||||
await this.validate();
|
||||
this.fireEvent({
|
||||
eventType: ComponentEventType.onDidChange,
|
||||
args: e
|
||||
});
|
||||
}
|
||||
}));
|
||||
this._validations.push(() => !this.required || !this.editable || !!this._editableDropdown.value);
|
||||
}
|
||||
if (this._dropDownContainer) {
|
||||
this._selectBox = new SelectBox(this.getValues(), this.getSelectedValue(), this.contextViewService, this._dropDownContainer.nativeElement);
|
||||
this._selectBox.render(this._dropDownContainer.nativeElement);
|
||||
this._register(this._selectBox);
|
||||
this._register(attachSelectBoxStyler(this._selectBox, this.themeService));
|
||||
this._register(this._selectBox.onDidSelect(e => {
|
||||
this._register(this._selectBox.onDidSelect(async e => {
|
||||
if (!this.editable) {
|
||||
this.setSelectedValue(this._selectBox.value);
|
||||
await this.validate();
|
||||
this.fireEvent({
|
||||
eventType: ComponentEventType.onDidChange,
|
||||
args: e
|
||||
});
|
||||
}
|
||||
}));
|
||||
this._validations.push(() => !this.required || this.editable || !!this._selectBox.value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +143,7 @@ export default class DropDownComponent extends ComponentBase implements ICompone
|
||||
|
||||
this._selectBox.selectElem.required = this.required;
|
||||
this._editableDropdown.inputElement.required = this.required;
|
||||
this.validate();
|
||||
}
|
||||
|
||||
private getValues(): string[] {
|
||||
|
||||
Reference in New Issue
Block a user