mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-17 11:03:14 -04:00
Refactor create inputbox method (#24113)
Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
This commit is contained in:
@@ -143,10 +143,26 @@ export abstract class DialogBase<DialogResult> {
|
||||
}
|
||||
|
||||
protected createPasswordInputBox(ariaLabel: string, textChangeHandler: (newValue: string) => Promise<void>, value: string = '', enabled: boolean = true, width: number = DefaultInputWidth): azdata.InputBoxComponent {
|
||||
return this.createInputBox(ariaLabel, textChangeHandler, value, enabled, 'password', width);
|
||||
return this.createInputBox(textChangeHandler, {
|
||||
ariaLabel: ariaLabel,
|
||||
value: value,
|
||||
enabled: enabled,
|
||||
inputType: 'password',
|
||||
width: width
|
||||
});
|
||||
}
|
||||
|
||||
protected createInputBoxWithProperties(textChangeHandler: (newValue: string) => Promise<void>, properties: azdata.InputBoxProperties, customValidation?: () => Promise<boolean>): azdata.InputBoxComponent {
|
||||
/**
|
||||
* Creates an input box. If properties are not passed in, then an input box is created with the following default properties:
|
||||
* inputType - text
|
||||
* width - DefaultInputWidth
|
||||
* value - empty
|
||||
* enabled - true
|
||||
* @param textChangeHandler - Function called on text changed.
|
||||
* @param properties - Inputbox properties.
|
||||
* @param customValidation - Dynamic validation function.
|
||||
*/
|
||||
protected createInputBox(textChangeHandler: (newValue: string) => Promise<void>, properties: azdata.InputBoxProperties, customValidation?: () => Promise<boolean>): azdata.InputBoxComponent {
|
||||
properties.width = properties.width ?? DefaultInputWidth;
|
||||
properties.inputType = properties.inputType ?? 'text';
|
||||
properties.value = properties.value ?? '';
|
||||
@@ -164,16 +180,6 @@ export abstract class DialogBase<DialogResult> {
|
||||
return inputBoxComponent;
|
||||
}
|
||||
|
||||
protected createInputBox(ariaLabel: string, textChangeHandler: (newValue: string) => Promise<void>, value: string = '', enabled: boolean = true, type: azdata.InputBoxInputType = 'text', width: number = DefaultInputWidth, required?: boolean, min?: number, max?: number): azdata.InputBoxComponent {
|
||||
const inputbox = this.modelView.modelBuilder.inputBox().withProps({ inputType: type, enabled: enabled, ariaLabel: ariaLabel, value: value, width: width, required: required, min: min, max: max }).component();
|
||||
this.disposables.push(inputbox.onTextChanged(async () => {
|
||||
await textChangeHandler(inputbox.value!);
|
||||
this.onFormFieldChange();
|
||||
await this.runValidation(false);
|
||||
}));
|
||||
return inputbox;
|
||||
}
|
||||
|
||||
protected createGroup(header: string, items: azdata.Component[], collapsible: boolean = true, collapsed: boolean = false): azdata.GroupContainer {
|
||||
return this.modelView.modelBuilder.groupContainer().withLayout({
|
||||
header: header,
|
||||
|
||||
Reference in New Issue
Block a user