mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
fix dropdown component issue (#1709)
* fix dropdown component issue * handle enable property default
This commit is contained in:
@@ -98,10 +98,6 @@ export abstract class ComponentBase extends Disposable implements IComponent, On
|
|||||||
if (enabled === undefined) {
|
if (enabled === undefined) {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
properties['enabled'] = enabled;
|
properties['enabled'] = enabled;
|
||||||
this.fireEvent({
|
|
||||||
eventType: ComponentEventType.PropertiesChanged,
|
|
||||||
args: this.getProperties()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return <boolean>enabled;
|
return <boolean>enabled;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,15 +145,11 @@ export default class DropDownComponent extends ComponentBase implements ICompone
|
|||||||
private getSelectedValue(): string {
|
private getSelectedValue(): string {
|
||||||
if (this.values && this.values.length > 0 && this.valuesHaveDisplayName()) {
|
if (this.values && this.values.length > 0 && this.valuesHaveDisplayName()) {
|
||||||
let selectedValue = <sqlops.CategoryValue>this.value || <sqlops.CategoryValue>this.values[0];
|
let selectedValue = <sqlops.CategoryValue>this.value || <sqlops.CategoryValue>this.values[0];
|
||||||
if (!this.value) {
|
|
||||||
this.value = selectedValue;
|
|
||||||
}
|
|
||||||
let valueCategory = (<sqlops.CategoryValue[]>this.values).find(v => v.name === selectedValue.name);
|
let valueCategory = (<sqlops.CategoryValue[]>this.values).find(v => v.name === selectedValue.name);
|
||||||
|
|
||||||
return valueCategory && valueCategory.displayName;
|
return valueCategory && valueCategory.displayName;
|
||||||
} else {
|
} else {
|
||||||
if (!this.value && this.values && this.values.length > 0) {
|
if (!this.value && this.values && this.values.length > 0) {
|
||||||
this.value = <string>this.values[0];
|
return <string>this.values[0];
|
||||||
}
|
}
|
||||||
return <string>this.value;
|
return <string>this.value;
|
||||||
}
|
}
|
||||||
@@ -198,11 +194,11 @@ export default class DropDownComponent extends ComponentBase implements ICompone
|
|||||||
this.setPropertyFromUI<sqlops.DropDownProperties, string[] | sqlops.CategoryValue[]>(this.setValuesProperties, newValue);
|
this.setPropertyFromUI<sqlops.DropDownProperties, string[] | sqlops.CategoryValue[]>(this.setValuesProperties, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private setValueProperties(properties: sqlops.DropDownProperties, value: string): void {
|
private setValueProperties(properties: sqlops.DropDownProperties, value: string | sqlops.CategoryValue): void {
|
||||||
properties.value = value;
|
properties.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private setValuesProperties(properties: sqlops.DropDownProperties, values: string[]): void {
|
private setValuesProperties(properties: sqlops.DropDownProperties, values: string[] | sqlops.CategoryValue[]): void {
|
||||||
properties.values = values;
|
properties.values = values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -380,7 +380,8 @@ class ComponentWrapper implements sqlops.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get enabled(): boolean {
|
public get enabled(): boolean {
|
||||||
return this.properties['enabled'];
|
let isEnabled = this.properties['enabled'];
|
||||||
|
return (isEnabled === undefined) ? true : isEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public set enabled(value: boolean) {
|
public set enabled(value: boolean) {
|
||||||
@@ -782,7 +783,11 @@ class DropDownWrapper extends ComponentWrapper implements sqlops.DropDownCompone
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get value(): string | sqlops.CategoryValue {
|
public get value(): string | sqlops.CategoryValue {
|
||||||
return this.properties['value'];
|
let val = this.properties['value'];
|
||||||
|
if (!val && this.values && this.values.length > 0) {
|
||||||
|
val = this.values[0];
|
||||||
|
}
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
public set value(v: string | sqlops.CategoryValue) {
|
public set value(v: string | sqlops.CategoryValue) {
|
||||||
this.setProperty('value', v);
|
this.setProperty('value', v);
|
||||||
|
|||||||
Reference in New Issue
Block a user