mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 17:23:21 -05:00
Fix the select box issue (#9508)
* Fix the select box issue * map => forEach * Fix tests and a product issue * Maybe another potential fix * Fix a few more issues * Change backendValue to value * localization * Use Array.isArray
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as DialogHelper from './dialogHelper';
|
||||
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
||||
import { SelectBox, SelectOptionItemSQL } from 'sql/base/browser/ui/selectBox/selectBox';
|
||||
import { MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox';
|
||||
@@ -22,7 +22,7 @@ export interface IOptionElement {
|
||||
|
||||
export function createOptionElement(option: azdata.ServiceOption, rowContainer: HTMLElement, options: { [name: string]: any },
|
||||
optionsMap: { [optionName: string]: IOptionElement }, contextViewService: IContextViewService, onFocus: (name) => void): IOptionElement {
|
||||
let possibleInputs: string[] = [];
|
||||
let possibleInputs: SelectOptionItemSQL[] = [];
|
||||
let optionValue = getOptionValueAndCategoryValues(option, options, possibleInputs);
|
||||
let optionWidget: any;
|
||||
let inputElement: HTMLElement;
|
||||
@@ -69,7 +69,7 @@ export function createOptionElement(option: azdata.ServiceOption, rowContainer:
|
||||
return optionElement;
|
||||
}
|
||||
|
||||
export function getOptionValueAndCategoryValues(option: azdata.ServiceOption, options: { [optionName: string]: any }, possibleInputs: string[]): any {
|
||||
export function getOptionValueAndCategoryValues(option: azdata.ServiceOption, options: { [optionName: string]: any }, possibleInputs: SelectOptionItemSQL[]): any {
|
||||
let optionValue = option.defaultValue;
|
||||
if (options[option.name] !== undefined) {
|
||||
// if the value type is boolean, the option value can be either boolean or string
|
||||
@@ -87,18 +87,18 @@ export function getOptionValueAndCategoryValues(option: azdata.ServiceOption, op
|
||||
if (option.valueType === ServiceOptionType.boolean || option.valueType === ServiceOptionType.category) {
|
||||
// If the option is not required, the empty string should be add at the top of possible choices
|
||||
if (!option.isRequired) {
|
||||
possibleInputs.push('');
|
||||
possibleInputs.push({ text: '', value: '' });
|
||||
}
|
||||
|
||||
if (option.valueType === ServiceOptionType.boolean) {
|
||||
possibleInputs.push(trueInputValue, falseInputValue);
|
||||
possibleInputs.push({ text: trueInputValue, value: trueInputValue }, { text: falseInputValue, value: falseInputValue });
|
||||
} else {
|
||||
option.categoryValues.map(c => possibleInputs.push(c.name));
|
||||
option.categoryValues.forEach(c => possibleInputs.push({ text: c.displayName, value: c.name }));
|
||||
}
|
||||
|
||||
// If the option value is not set and default value is null, the option value should be set to the first possible input.
|
||||
if (optionValue === null || optionValue === undefined) {
|
||||
optionValue = possibleInputs[0];
|
||||
optionValue = possibleInputs[0].text;
|
||||
}
|
||||
}
|
||||
return optionValue;
|
||||
|
||||
Reference in New Issue
Block a user