Add focus function for modelview components (#8348)

* Add focus method for modelview components

* Remove focus properties from table and radiobutton

* Fix break
This commit is contained in:
Charles Gagnon
2019-11-15 17:36:55 -08:00
committed by GitHub
parent d6ef42c8b0
commit ae8304fc33
17 changed files with 62 additions and 48 deletions

View File

@@ -180,6 +180,7 @@ export class AddControllerDialog {
}]).withLayout({ width: '100%' }).component();
this.onAuthChanged();
await view.initializeModel(formModel);
this.urlInputBox.focus();
});
this.dialog.registerCloseValidator(async () => await this.validate());

View File

@@ -38,10 +38,6 @@ export class SelectOperationPage extends BasePage {
let importComponent = await this.createImportRadioButton();
let exportComponent = await this.createExportRadioButton();
// default have the first radio button checked
this.deployRadioButton.checked = true;
this.deployRadioButton.focused = true;
this.form = this.view.modelBuilder.formContainer()
.withFormItems(
[
@@ -54,6 +50,7 @@ export class SelectOperationPage extends BasePage {
}).component();
await this.view.initializeModel(this.form);
this.deployRadioButton.focus();
this.instance.setDoneButton(Operation.deploy);
return true;
}
@@ -67,6 +64,7 @@ export class SelectOperationPage extends BasePage {
.withProperties({
name: 'selectedOperation',
label: localize('dacFx.deployRadioButtonLabel', "Deploy a data-tier application .dacpac file to an instance of SQL Server [Deploy Dacpac]"),
checked: true // Default to first radio button being selected
}).component();
this.deployRadioButton.onDidClick(() => {

View File

@@ -2,12 +2,10 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as nls from 'vscode-nls';
import * as azdata from 'azdata';
import * as vscode from 'vscode';
import * as os from 'os';
import { SchemaCompareMainWindow } from '../schemaCompareMainWindow';
import { promises as fs } from 'fs';
import { Telemetry } from '../telemetry';
@@ -46,6 +44,8 @@ async function exists(path: string): Promise<boolean> {
export class SchemaCompareDialog {
public dialog: azdata.window.Dialog;
public dialogName: string;
private sourceDacpacRadioButton: azdata.RadioButtonComponent;
private sourceDatabaseRadioButton: azdata.RadioButtonComponent;
private schemaCompareTab: azdata.window.DialogTab;
private sourceDacpacComponent: azdata.FormComponent;
private sourceTextBox: azdata.InputBoxComponent;
@@ -291,6 +291,11 @@ export class SchemaCompareDialog {
let formModel = this.formBuilder.component();
await view.initializeModel(formModel);
if (this.sourceIsDacpac) {
this.sourceDacpacRadioButton.focus();
} else {
this.sourceDatabaseRadioButton.focus();
}
});
}
@@ -346,20 +351,20 @@ export class SchemaCompareDialog {
}
private async createSourceRadiobuttons(view: azdata.ModelView): Promise<azdata.FormComponent> {
let dacpacRadioButton = view.modelBuilder.radioButton()
this.sourceDacpacRadioButton = view.modelBuilder.radioButton()
.withProperties({
name: 'source',
label: DacpacRadioButtonLabel
}).component();
let databaseRadioButton = view.modelBuilder.radioButton()
this.sourceDatabaseRadioButton = view.modelBuilder.radioButton()
.withProperties({
name: 'source',
label: DatabaseRadioButtonLabel
}).component();
// show dacpac file browser
dacpacRadioButton.onDidClick(async () => {
this.sourceDacpacRadioButton.onDidClick(async () => {
this.sourceIsDacpac = true;
this.formBuilder.removeFormItem(this.sourceNoActiveConnectionsText);
this.formBuilder.removeFormItem(this.sourceServerComponent);
@@ -369,7 +374,7 @@ export class SchemaCompareDialog {
});
// show server and db dropdowns or 'No active connections' text
databaseRadioButton.onDidClick(async () => {
this.sourceDatabaseRadioButton.onDidClick(async () => {
this.sourceIsDacpac = false;
if ((this.sourceServerDropdown.value as ConnectionDropdownValue)) {
this.formBuilder.insertFormItem(this.sourceServerComponent, 2, { horizontal: true, titleFontSize: titleFontSize });
@@ -383,17 +388,15 @@ export class SchemaCompareDialog {
// if source is currently a db, show it in the server and db dropdowns
if (this.schemaCompareResult.sourceEndpointInfo && this.schemaCompareResult.sourceEndpointInfo.endpointType === mssql.SchemaCompareEndpointType.Database) {
databaseRadioButton.checked = true;
databaseRadioButton.focused = true;
this.sourceDatabaseRadioButton.checked = true;
this.sourceIsDacpac = false;
} else {
dacpacRadioButton.checked = true;
dacpacRadioButton.focused = true;
this.sourceDacpacRadioButton.checked = true;
this.sourceIsDacpac = true;
}
let flexRadioButtonsModel = view.modelBuilder.flexContainer()
.withLayout({ flexFlow: 'column' })
.withItems([dacpacRadioButton, databaseRadioButton]
.withItems([this.sourceDacpacRadioButton, this.sourceDatabaseRadioButton]
).component();
return {