Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update required indicators in Add Database Reference Dialog #24346

Merged
merged 2 commits into from
Sep 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export class AddDatabaseReferenceDialog {
private systemDbRefRadioButtonsComponent: azdataType.FormComponent | undefined;
private systemDbRefType: SystemDbReferenceType = SystemDbReferenceType.ArtifactReference;
public currentReferencedDatabaseType: ReferencedDatabaseType | undefined;
private databaseNameTextboxLabel: azdataType.TextComponent | undefined;
private serverNameTextboxLabel: azdataType.TextComponent | undefined;
private serverVariableTextboxLabel: azdataType.TextComponent | undefined;

private toDispose: vscode.Disposable[] = [];
private initDialogComplete: Deferred = new Deferred();
Expand Down Expand Up @@ -413,7 +416,8 @@ export class AddDatabaseReferenceDialog {

private async createProjectDropdown(): Promise<azdataType.FormComponent> {
this.projectDropdown = this.view!.modelBuilder.dropDown().withProps({
ariaLabel: constants.databaseProject
ariaLabel: constants.databaseProject,
required: true
}).component();

this.projectDropdown.onValueChanged(() => {
Expand All @@ -436,7 +440,8 @@ export class AddDatabaseReferenceDialog {
private createSystemDatabaseDropdown(): azdataType.FormComponent {
this.systemDatabaseDropdown = this.view!.modelBuilder.dropDown().withProps({
values: getSystemDbOptions(this.project),
ariaLabel: constants.databaseNameLabel
ariaLabel: constants.databaseNameLabel,
required: true
}).component();

this.systemDatabaseDropdown.onValueChanged(() => {
Expand All @@ -453,7 +458,8 @@ export class AddDatabaseReferenceDialog {
this.dacpacTextbox = this.view!.modelBuilder.inputBox().withProps({
ariaLabel: constants.dacpacText,
placeHolder: constants.selectDacpac,
width: '400px'
width: '400px',
required: true
}).component();

this.dacpacTextbox.onTextChanged(() => {
Expand Down Expand Up @@ -553,6 +559,11 @@ export class AddDatabaseReferenceDialog {
this.serverNameTextbox!.enabled = false;
this.serverVariableTextbox!.enabled = false;

// update required indicator
this.databaseNameTextboxLabel!.requiredIndicator = false;
this.serverNameTextboxLabel!.requiredIndicator = false;
this.serverVariableTextboxLabel!.requiredIndicator = false;

// clear values in disabled fields
this.databaseNameTextbox!.value = '';
this.databaseVariableTextbox!.value = '';
Expand All @@ -564,6 +575,11 @@ export class AddDatabaseReferenceDialog {
this.serverNameTextbox!.enabled = false;
this.serverVariableTextbox!.enabled = false;

// update required indicator
this.databaseNameTextboxLabel!.requiredIndicator = true;
this.serverNameTextboxLabel!.requiredIndicator = false;
this.serverVariableTextboxLabel!.requiredIndicator = false;

// clear values in disabled fields
this.databaseVariableTextbox!.value = isSystemDb ? '' : this.databaseVariableTextbox!.value;
this.serverNameTextbox!.value = '';
Expand All @@ -577,6 +593,11 @@ export class AddDatabaseReferenceDialog {
this.serverNameTextbox!.enabled = true;
this.serverVariableTextbox!.enabled = true;

// update required indicator
this.databaseNameTextboxLabel!.requiredIndicator = true;
this.serverNameTextboxLabel!.requiredIndicator = true;
this.serverVariableTextboxLabel!.requiredIndicator = true;

// add default values in enabled fields
this.setDefaultDatabaseValues();
this.serverNameTextbox!.value = constants.otherServer;
Expand Down Expand Up @@ -617,20 +638,23 @@ export class AddDatabaseReferenceDialog {

private createVariableSection(): azdataType.FormComponent {
// database name row
this.databaseNameTextbox = this.createInputBox(constants.databaseName, true, true);
const databaseNameRow = this.view!.modelBuilder.flexContainer().withItems([this.createLabel(constants.databaseName, true), this.databaseNameTextbox], { flex: '0 0 auto' }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
this.databaseNameTextboxLabel = this.createLabel(constants.databaseName, true);
this.databaseNameTextbox = this.createInputBox(constants.databaseName, true);
const databaseNameRow = this.view!.modelBuilder.flexContainer().withItems([this.databaseNameTextboxLabel, this.databaseNameTextbox], { flex: '0 0 auto' }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();

// database variable row
this.databaseVariableTextbox = this.createInputBox(constants.databaseVariable, false, false);
this.databaseVariableTextbox = this.createInputBox(constants.databaseVariable, false);
const databaseVariableRow = this.view!.modelBuilder.flexContainer().withItems([this.createLabel(constants.databaseVariable), this.databaseVariableTextbox], { flex: '0 0 auto' }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();

// server name row
this.serverNameTextbox = this.createInputBox(constants.serverName, false, true);
const serverNameRow = this.view!.modelBuilder.flexContainer().withItems([this.createLabel(constants.serverName, true), this.serverNameTextbox], { flex: '0 0 auto' }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
this.serverNameTextboxLabel = this.createLabel(constants.serverName, false);
this.serverNameTextbox = this.createInputBox(constants.serverName, false);
const serverNameRow = this.view!.modelBuilder.flexContainer().withItems([this.serverNameTextboxLabel, this.serverNameTextbox], { flex: '0 0 auto' }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();

// server variable row
this.serverVariableTextbox = this.createInputBox(constants.serverVariable, false, true);
const serverVariableRow = this.view!.modelBuilder.flexContainer().withItems([this.createLabel(constants.serverVariable, true), this.serverVariableTextbox], { flex: '0 0 auto' }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
this.serverVariableTextboxLabel = this.createLabel(constants.serverVariable, false);
this.serverVariableTextbox = this.createInputBox(constants.serverVariable, false);
const serverVariableRow = this.view!.modelBuilder.flexContainer().withItems([this.serverVariableTextboxLabel, this.serverVariableTextbox], { flex: '0 0 auto' }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();

const variableSection = this.view!.modelBuilder.flexContainer().withItems([databaseNameRow, databaseVariableRow, serverNameRow, serverVariableRow]).withLayout({ flexFlow: 'column' }).withProps({ CSSStyles: { 'margin-bottom': '25px' } }).component();
this.setDefaultDatabaseValues();
Expand All @@ -651,12 +675,11 @@ export class AddDatabaseReferenceDialog {
return label;
}

private createInputBox(ariaLabel: string, enabled: boolean, required: boolean): azdataType.InputBoxComponent {
private createInputBox(ariaLabel: string, enabled: boolean): azdataType.InputBoxComponent {
const inputBox = this.view!.modelBuilder.inputBox().withProps({
ariaLabel: ariaLabel,
enabled: enabled,
width: cssStyles.addDatabaseReferenceInputboxWidth,
required: required
SakshiS-harma marked this conversation as resolved.
Show resolved Hide resolved
width: cssStyles.addDatabaseReferenceInputboxWidth
}).component();

inputBox.onTextChanged(() => {
Expand Down