mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Make dropdown editable but not allow okay till a valid value is selected (#5991)
Make dropdown editable but not allow OK till a valid value is selected
This commit is contained in:
@@ -53,6 +53,8 @@ export class SchemaCompareDialog {
|
|||||||
private targetIsDacpac: boolean;
|
private targetIsDacpac: boolean;
|
||||||
private database: string;
|
private database: string;
|
||||||
private connectionId: string;
|
private connectionId: string;
|
||||||
|
private sourceDbEditable: string;
|
||||||
|
private taregtDbEditable: string;
|
||||||
|
|
||||||
protected initializeDialog(): void {
|
protected initializeDialog(): void {
|
||||||
this.schemaCompareTab = azdata.window.createTab(SchemaCompareLabel);
|
this.schemaCompareTab = azdata.window.createTab(SchemaCompareLabel);
|
||||||
@@ -396,8 +398,11 @@ export class SchemaCompareDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private shouldEnableOkayButton(): boolean {
|
private shouldEnableOkayButton(): boolean {
|
||||||
let sourcefilled = (this.sourceIsDacpac && this.existsDacpac(this.sourceTextBox.value)) || (!this.sourceIsDacpac && !isNullOrUndefined(this.sourceDatabaseDropdown.value));
|
|
||||||
let targetfilled = (this.targetIsDacpac && this.existsDacpac(this.targetTextBox.value)) || (!this.targetIsDacpac && !isNullOrUndefined(this.targetDatabaseDropdown.value));
|
let sourcefilled = (this.sourceIsDacpac && this.existsDacpac(this.sourceTextBox.value))
|
||||||
|
|| (!this.sourceIsDacpac && !isNullOrUndefined(this.sourceDatabaseDropdown.value) && this.sourceDatabaseDropdown.values.findIndex(x => this.matchesValue(x, this.sourceDbEditable)) !== -1);
|
||||||
|
let targetfilled = (this.targetIsDacpac && this.existsDacpac(this.targetTextBox.value))
|
||||||
|
|| (!this.targetIsDacpac && !isNullOrUndefined(this.targetDatabaseDropdown.value) && this.targetDatabaseDropdown.values.findIndex(x => this.matchesValue(x, this.taregtDbEditable)) !== -1);
|
||||||
|
|
||||||
return sourcefilled && targetfilled;
|
return sourcefilled && targetfilled;
|
||||||
}
|
}
|
||||||
@@ -407,9 +412,21 @@ export class SchemaCompareDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async createSourceServerDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
|
protected async createSourceServerDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
|
||||||
this.sourceServerDropdown = view.modelBuilder.dropDown().component();
|
this.sourceServerDropdown = view.modelBuilder.dropDown().withProperties(
|
||||||
this.sourceServerDropdown.onValueChanged(async () => {
|
{
|
||||||
|
editable: true,
|
||||||
|
fireOnTextChange: true
|
||||||
|
}
|
||||||
|
).component();
|
||||||
|
this.sourceServerDropdown.onValueChanged(async (value) => {
|
||||||
|
if (this.sourceServerDropdown.values.findIndex(x => this.matchesValue(x, value)) === -1) {
|
||||||
|
this.sourceDatabaseDropdown.updateProperties({
|
||||||
|
values: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
await this.populateDatabaseDropdown((this.sourceServerDropdown.value as ConnectionDropdownValue).connection.connectionId, false);
|
await this.populateDatabaseDropdown((this.sourceServerDropdown.value as ConnectionDropdownValue).connection.connectionId, false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -419,9 +436,21 @@ export class SchemaCompareDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async createTargetServerDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
|
protected async createTargetServerDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
|
||||||
this.targetServerDropdown = view.modelBuilder.dropDown().component();
|
this.targetServerDropdown = view.modelBuilder.dropDown().withProperties(
|
||||||
this.targetServerDropdown.onValueChanged(async () => {
|
{
|
||||||
|
editable: true,
|
||||||
|
fireOnTextChange: true
|
||||||
|
}
|
||||||
|
).component();
|
||||||
|
this.targetServerDropdown.onValueChanged(async (value) => {
|
||||||
|
if (this.targetServerDropdown.values.findIndex(x => this.matchesValue(x, value)) === -1) {
|
||||||
|
this.targetDatabaseDropdown.updateProperties({
|
||||||
|
values: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
await this.populateDatabaseDropdown((this.targetServerDropdown.value as ConnectionDropdownValue).connection.connectionId, true);
|
await this.populateDatabaseDropdown((this.targetServerDropdown.value as ConnectionDropdownValue).connection.connectionId, true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -492,8 +521,14 @@ export class SchemaCompareDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async createSourceDatabaseDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
|
protected async createSourceDatabaseDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
|
||||||
this.sourceDatabaseDropdown = view.modelBuilder.dropDown().component();
|
this.sourceDatabaseDropdown = view.modelBuilder.dropDown().withProperties(
|
||||||
this.sourceDatabaseDropdown.onValueChanged(() => {
|
{
|
||||||
|
editable: true,
|
||||||
|
fireOnTextChange: true
|
||||||
|
}
|
||||||
|
).component();
|
||||||
|
this.sourceDatabaseDropdown.onValueChanged((value) => {
|
||||||
|
this.sourceDbEditable = value;
|
||||||
this.dialog.okButton.enabled = this.shouldEnableOkayButton();
|
this.dialog.okButton.enabled = this.shouldEnableOkayButton();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -504,8 +539,14 @@ export class SchemaCompareDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async createTargetDatabaseDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
|
protected async createTargetDatabaseDropdown(view: azdata.ModelView): Promise<azdata.FormComponent> {
|
||||||
this.targetDatabaseDropdown = view.modelBuilder.dropDown().component();
|
this.targetDatabaseDropdown = view.modelBuilder.dropDown().withProperties(
|
||||||
this.targetDatabaseDropdown.onValueChanged(() => {
|
{
|
||||||
|
editable: true,
|
||||||
|
fireOnTextChange: true,
|
||||||
|
}
|
||||||
|
).component();
|
||||||
|
this.targetDatabaseDropdown.onValueChanged((value) => {
|
||||||
|
this.taregtDbEditable = value;
|
||||||
this.dialog.okButton.enabled = this.shouldEnableOkayButton();
|
this.dialog.okButton.enabled = this.shouldEnableOkayButton();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -515,6 +556,10 @@ export class SchemaCompareDialog {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private matchesValue(listValue: any, value: string): boolean {
|
||||||
|
return listValue.displayName === value || listValue === value;
|
||||||
|
}
|
||||||
|
|
||||||
protected async populateDatabaseDropdown(connectionId: string, isTarget: boolean): Promise<void> {
|
protected async populateDatabaseDropdown(connectionId: string, isTarget: boolean): Promise<void> {
|
||||||
let currentDropdown = isTarget ? this.targetDatabaseDropdown : this.sourceDatabaseDropdown;
|
let currentDropdown = isTarget ? this.targetDatabaseDropdown : this.sourceDatabaseDropdown;
|
||||||
currentDropdown.updateProperties({ values: [] });
|
currentDropdown.updateProperties({ values: [] });
|
||||||
|
|||||||
Reference in New Issue
Block a user