mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
add required indicator (#22971)
This commit is contained in:
8
src/sql/base/browser/ui/label/label.ts
Normal file
8
src/sql/base/browser/ui/label/label.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import 'vs/css!./media/label';
|
||||||
|
|
||||||
|
export const RequiredIndicatorClassName = 'required-indicator';
|
||||||
10
src/sql/base/browser/ui/label/media/label.css
Normal file
10
src/sql/base/browser/ui/label/media/label.css
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
.required-indicator:after {
|
||||||
|
content: '*';
|
||||||
|
color: red;
|
||||||
|
margin-left: 2px;
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ import { IColorTheme, ICssStyleCollector, registerThemingParticipant } from 'vs/
|
|||||||
import { errorForeground } from 'vs/platform/theme/common/colorRegistry';
|
import { errorForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||||
|
import { RequiredIndicatorClassName } from 'sql/base/browser/ui/label/label';
|
||||||
|
|
||||||
export enum TextType {
|
export enum TextType {
|
||||||
Normal = 'Normal',
|
Normal = 'Normal',
|
||||||
@@ -50,7 +51,6 @@ const errorTextClass = 'error-text';
|
|||||||
<div *ngIf="showDiv;else noDiv" style="display:flex;flex-flow:row;align-items:center;" [style.width]="getWidth()" [style.height]="getHeight()">
|
<div *ngIf="showDiv;else noDiv" style="display:flex;flex-flow:row;align-items:center;" [style.width]="getWidth()" [style.height]="getHeight()">
|
||||||
<p [title]="title" [ngStyle]="this.CSSStyles" [attr.role]="ariaRole" [attr.aria-hidden]="ariaHidden" [attr.aria-live]="ariaLive"></p>
|
<p [title]="title" [ngStyle]="this.CSSStyles" [attr.role]="ariaRole" [attr.aria-hidden]="ariaHidden" [attr.aria-live]="ariaLive"></p>
|
||||||
<div #textContainer id="textContainer"></div>
|
<div #textContainer id="textContainer"></div>
|
||||||
<span *ngIf="requiredIndicator" style="color:red;margin-left:5px;">*</span>
|
|
||||||
<div *ngIf="description" tabindex="0" class="modelview-text-tooltip" [attr.aria-label]="description" role="img" (mouseenter)="showTooltip($event)" (focus)="showTooltip($event)" (keydown)="onDescriptionKeyDown($event)">
|
<div *ngIf="description" tabindex="0" class="modelview-text-tooltip" [attr.aria-label]="description" role="img" (mouseenter)="showTooltip($event)" (focus)="showTooltip($event)" (keydown)="onDescriptionKeyDown($event)">
|
||||||
<div class="modelview-text-tooltip-content" [innerHTML]="description"></div>
|
<div class="modelview-text-tooltip-content" [innerHTML]="description"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -160,7 +160,13 @@ export default class TextComponent extends TitledComponent<azdata.TextComponentP
|
|||||||
if (typeof this.value !== 'string') {
|
if (typeof this.value !== 'string') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DOM.clearNode((<HTMLElement>this.textContainer.nativeElement));
|
const textContainerElement = <HTMLElement>this.textContainer.nativeElement;
|
||||||
|
DOM.clearNode((textContainerElement));
|
||||||
|
if (this.requiredIndicator) {
|
||||||
|
textContainerElement.classList.add(RequiredIndicatorClassName);
|
||||||
|
} else {
|
||||||
|
textContainerElement.classList.remove(RequiredIndicatorClassName);
|
||||||
|
}
|
||||||
const links = this.getPropertyOrDefault<azdata.LinkArea[]>((props) => props.links, []);
|
const links = this.getPropertyOrDefault<azdata.LinkArea[]>((props) => props.links, []);
|
||||||
// The text may contain link placeholders so go through and create those and insert them as needed now
|
// The text may contain link placeholders so go through and create those and insert them as needed now
|
||||||
let text = this.value;
|
let text = this.value;
|
||||||
@@ -177,13 +183,13 @@ export default class TextComponent extends TitledComponent<azdata.TextComponentP
|
|||||||
if (curText && typeof text === 'string') {
|
if (curText && typeof text === 'string') {
|
||||||
const textElement = this.createTextElement();
|
const textElement = this.createTextElement();
|
||||||
textElement.innerText = text.slice(0, placeholderIndex);
|
textElement.innerText = text.slice(0, placeholderIndex);
|
||||||
(<HTMLElement>this.textContainer.nativeElement).appendChild(textElement);
|
textContainerElement.appendChild(textElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now insert the link element
|
// Now insert the link element
|
||||||
const link = links[i];
|
const link = links[i];
|
||||||
const linkElement = this._register(this.instantiationService.createInstance(Link,
|
const linkElement = this._register(this.instantiationService.createInstance(Link,
|
||||||
(<HTMLElement>this.textContainer.nativeElement), {
|
textContainerElement, {
|
||||||
label: link.text,
|
label: link.text,
|
||||||
href: link.url
|
href: link.url
|
||||||
}, undefined));
|
}, undefined));
|
||||||
@@ -195,7 +201,7 @@ export default class TextComponent extends TitledComponent<azdata.TextComponentP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(<HTMLElement>this.textContainer.nativeElement).appendChild(linkElement.el);
|
textContainerElement.appendChild(linkElement.el);
|
||||||
|
|
||||||
// And finally update the text to remove the text up through the placeholder we just added
|
// And finally update the text to remove the text up through the placeholder we just added
|
||||||
text = text.slice(placeholderIndex + 3);
|
text = text.slice(placeholderIndex + 3);
|
||||||
@@ -205,7 +211,7 @@ export default class TextComponent extends TitledComponent<azdata.TextComponentP
|
|||||||
if (text && typeof text === 'string') {
|
if (text && typeof text === 'string') {
|
||||||
const textElement = this.createTextElement();
|
const textElement = this.createTextElement();
|
||||||
textElement.innerText = text;
|
textElement.innerText = text;
|
||||||
(<HTMLElement>this.textContainer.nativeElement).appendChild(textElement);
|
textContainerElement.appendChild(textElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import { attachModalDialogStyler } from 'sql/workbench/common/styler';
|
|||||||
import { assertIsDefined, isUndefinedOrNull } from 'vs/base/common/types';
|
import { assertIsDefined, isUndefinedOrNull } from 'vs/base/common/types';
|
||||||
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfiguration';
|
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfiguration';
|
||||||
|
import { RequiredIndicatorClassName } from 'sql/base/browser/ui/label/label';
|
||||||
|
|
||||||
interface IRenderedServerGroupDialog {
|
interface IRenderedServerGroupDialog {
|
||||||
groupNameInputBox: InputBox;
|
groupNameInputBox: InputBox;
|
||||||
@@ -96,13 +97,14 @@ export class ServerGroupDialog extends Modal {
|
|||||||
// Connection Group Name
|
// Connection Group Name
|
||||||
const serverGroupNameLabel = localize('connectionGroupName', "Server group name");
|
const serverGroupNameLabel = localize('connectionGroupName', "Server group name");
|
||||||
|
|
||||||
DOM.append(body, DOM.$('.dialog-label')).innerText = serverGroupNameLabel;
|
DOM.append(body, DOM.$(`.dialog-label.${RequiredIndicatorClassName}`)).innerText = serverGroupNameLabel;
|
||||||
|
|
||||||
this._groupNameInputBox = new InputBox(DOM.append(body, DOM.$('.input-divider')), this._contextViewService, {
|
this._groupNameInputBox = new InputBox(DOM.append(body, DOM.$('.input-divider')), this._contextViewService, {
|
||||||
validationOptions: {
|
validationOptions: {
|
||||||
validation: (value: string) => !value && !this._skipGroupNameValidation ? ({ type: MessageType.ERROR, content: localize('MissingGroupNameError', "Group name is required.") }) : null
|
validation: (value: string) => !value && !this._skipGroupNameValidation ? ({ type: MessageType.ERROR, content: localize('MissingGroupNameError', "Group name is required.") }) : null
|
||||||
},
|
},
|
||||||
ariaLabel: serverGroupNameLabel
|
ariaLabel: serverGroupNameLabel,
|
||||||
|
required: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// Connection Group Description
|
// Connection Group Description
|
||||||
|
|||||||
Reference in New Issue
Block a user