AAE-48227 replacing custom labels with mat-labels

This commit is contained in:
Isoumyajit
2026-08-25 12:10:44 +05:30
parent 9f37f22702
commit 93e818d5ba
30 changed files with 121 additions and 105 deletions
@@ -1,4 +1,4 @@
<div id="adf-form-renderer" class="{{ formDefinition.className }} adf-form-renderer" <div id="adf-form-renderer" data-automation-id="adf-form-renderer" class="{{ formDefinition.className }} adf-form-renderer"
[ngClass]="{ 'adf-readonly-form': formDefinition.readOnly }"> [ngClass]="{ 'adf-readonly-form': formDefinition.readOnly }">
@if (formDefinition.hasTabs()) { @if (formDefinition.hasTabs()) {
@if (hasTabs()) { @if (hasTabs()) {
@@ -11,8 +11,9 @@
</div> </div>
<div class="adf-amount-widget-container"> <div class="adf-amount-widget-container">
<mat-form-field class="adf-amount-widget__input adf-form-field-input" [floatLabel]="placeholder ? 'always' : null"> <mat-form-field class="adf-amount-widget__input adf-form-field-input" [floatLabel]="placeholder ? 'always' : null">
@if ( (field.name || field?.required) && !field.leftLabels) { <mat-label class="adf-label" [attr.for]="field.id">{{field.name | translate }}</mat-label> } @if ( (field.name || field?.required) && !field.leftLabels) {
@if(!enableDisplayBasedOnLocale) { <mat-label data-automation-id="adf-amount-widget-label">{{field.name | translate }}</mat-label>
} @if(!enableDisplayBasedOnLocale) {
<span matTextPrefix class="adf-amount-widget__prefix-spacing">{{ currency }}&nbsp;</span> <span matTextPrefix class="adf-amount-widget__prefix-spacing">{{ currency }}&nbsp;</span>
} }
<input <input
@@ -35,7 +36,9 @@
<mat-error> <mat-error>
<mat-icon class="adf-error-icon">error_outline</mat-icon> <mat-icon class="adf-error-icon">error_outline</mat-icon>
<span class="adf-error-text" <span class="adf-error-text"
>@if (field.validationSummary?.message) {{{ field.validationSummary.message | translate:translateParameters }}} @else {{{ 'FORM.FIELD.REQUIRED' | translate }}}</span> >@if (field.validationSummary?.message) {{{ field.validationSummary.message | translate:translateParameters }}} @else {{{
'FORM.FIELD.REQUIRED' | translate }}}</span
>
</mat-error> </mat-error>
} }
</mat-form-field> </mat-form-field>
@@ -325,7 +325,7 @@ describe('AmountWidgetComponent - rendering', () => {
expect(inputField).toBeTruthy(); expect(inputField).toBeTruthy();
expect(await field.getPrefixText()).toBe('$'); expect(await field.getPrefixText()).toBe('$');
const widgetLabel = testingUtils.getByCSS('.adf-label').nativeElement; const widgetLabel = testingUtils.getByDataAutomationId('adf-amount-widget-label').nativeElement;
expect(widgetLabel.textContent.trim()).toBe('Test Amount'); expect(widgetLabel.textContent.trim()).toBe('Test Amount');
expect(widget.field.isValid).toBe(false); expect(widget.field.isValid).toBe(false);
@@ -362,7 +362,7 @@ describe('AmountWidgetComponent - rendering', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const widgetLabel = testingUtils.getByCSS('.adf-label').nativeElement; const widgetLabel = testingUtils.getByDataAutomationId('adf-amount-widget-label').nativeElement;
expect(widgetLabel.textContent.trim()).toBe('Test Amount'); expect(widgetLabel.textContent.trim()).toBe('Test Amount');
const field = await testingUtils.formField.get(); const field = await testingUtils.formField.get();
@@ -13,7 +13,7 @@
[class.adf-left-label-input-datepicker]="field.leftLabels" [class.adf-left-label-input-datepicker]="field.leftLabels"
[floatLabel]="field.placeholder ? 'always' : null"> [floatLabel]="field.placeholder ? 'always' : null">
@if( (field.name || field?.required) && !field.leftLabels) { @if( (field.name || field?.required) && !field.leftLabels) {
<mat-label class="adf-label" [attr.for]="field.id"> <mat-label class="adf-label">
{{ field.name | translate }} ({{ field.dateDisplayFormat }}) {{ field.name | translate }} ({{ field.dateDisplayFormat }})
</mat-label> </mat-label>
} }
@@ -1,13 +1,13 @@
<div class="{{ field.className }} date-widget-container" id="data-widget" <div
class="{{ field.className }} date-widget-container"
id="data-widget"
[class.adf-invalid]="dateInputControl.invalid && dateInputControl.touched" [class.adf-invalid]="dateInputControl.invalid && dateInputControl.touched"
[class.adf-readonly]="field.readOnly"> [class.adf-readonly]="field.readOnly"
>
<mat-form-field class="adf-date-widget adf-form-field-input" [floatLabel]="field.placeholder ? 'always' : null"> <mat-form-field class="adf-date-widget adf-form-field-input" [floatLabel]="field.placeholder ? 'always' : null">
<mat-label class="adf-label" <mat-label data-automation-id="adf-date-widget-label"> {{ field.name | translate }} ({{ field.dateDisplayFormat }}) </mat-label>
[id]="field.id + '-label'" <input
[attr.for]="field.id"> matInput
{{ field.name | translate }} ({{ field.dateDisplayFormat }})
</mat-label>
<input matInput
[matDatepicker]="datePicker" [matDatepicker]="datePicker"
[id]="field.id" [id]="field.id"
[formControl]="dateInputControl" [formControl]="dateInputControl"
@@ -18,14 +18,18 @@
[readonly]="field.readOnly" [readonly]="field.readOnly"
/> />
<mat-datepicker-toggle matSuffix [for]="datePicker" [disabled]="field.readOnly" /> <mat-datepicker-toggle matSuffix [for]="datePicker" [disabled]="field.readOnly" />
<mat-datepicker #datePicker <mat-datepicker #datePicker [startAt]="startAt" [disabled]="field.readOnly" />
[startAt]="startAt"
[disabled]="field.readOnly" />
@if (dateInputControl.invalid && dateInputControl.touched) { @if (dateInputControl.invalid && dateInputControl.touched) {
<mat-error> <mat-error>
<mat-icon class="adf-error-icon">error_outline</mat-icon> <mat-icon class="adf-error-icon">error_outline</mat-icon>
<span class="adf-error-text" <span class="adf-error-text"
>@if (dateInputControl.hasError('required')) {{{ 'FORM.FIELD.REQUIRED' | translate }}} @else if (dateInputControl.hasError('matDatepickerParse')) {{{ 'FORM.FIELD.VALIDATOR.INVALID_DATE_FORMAT' | translate: { format: field.dateDisplayFormat || field.defaultDateTimeFormat } }}} @else if (dateInputControl.hasError('matDatepickerMin')) {{{ 'FORM.FIELD.VALIDATOR.NOT_LESS_THAN' | translate: { minValue: formattedMinDate } }}} @else if (dateInputControl.hasError('matDatepickerMax')) {{{ 'FORM.FIELD.VALIDATOR.NOT_GREATER_THAN' | translate: { maxValue: formattedMaxDate } }}}</span> >@if (dateInputControl.hasError('required')) {{{ 'FORM.FIELD.REQUIRED' | translate }}} @else if
(dateInputControl.hasError('matDatepickerParse')) {{{ 'FORM.FIELD.VALIDATOR.INVALID_DATE_FORMAT' | translate: { format:
field.dateDisplayFormat || field.defaultDateTimeFormat } }}} @else if (dateInputControl.hasError('matDatepickerMin')) {{{
'FORM.FIELD.VALIDATOR.NOT_LESS_THAN' | translate: { minValue: formattedMinDate } }}} @else if
(dateInputControl.hasError('matDatepickerMax')) {{{ 'FORM.FIELD.VALIDATOR.NOT_GREATER_THAN' | translate: { maxValue: formattedMaxDate
} }}}</span
>
</mat-error> </mat-error>
} }
</mat-form-field> </mat-form-field>
@@ -10,7 +10,7 @@
<div class="adf-decimal-widget-container"> <div class="adf-decimal-widget-container">
<mat-form-field class="adf-form-field-input" [floatLabel]="field.placeholder ? 'always' : null"> <mat-form-field class="adf-form-field-input" [floatLabel]="field.placeholder ? 'always' : null">
@if ( (field.name || field?.required) && !field.leftLabels) { <mat-label class="adf-label" [attr.for]="field.id">{{ field.name | translate }}</mat-label> } @if ( (field.name || field?.required) && !field.leftLabels) { <mat-label class="adf-label">{{ field.name | translate }}</mat-label> }
<input matInput <input matInput
class="adf-input" class="adf-input"
type="text" type="text"
@@ -11,7 +11,7 @@
[floatLabel]="field.placeholder ? 'always' : null" [floatLabel]="field.placeholder ? 'always' : null"
> >
@if(field.name || field.required) { @if(field.name || field.required) {
<mat-label class="adf-label" [attr.for]="field.id"> {{ field.name | translate }} </mat-label> <mat-label class="adf-multiline-text-widget-label" data-automation-id="adf-multiline-text-widget-label"> {{ field.name | translate }} </mat-label>
} }
<textarea <textarea
matInput matInput
@@ -35,7 +35,9 @@
@if (field.maxLength > 0) {<span class="adf-multiline-counter-block">{{ field?.value?.length || 0 }}/{{ field.maxLength }}</span>} @if (field.maxLength > 0) {<span class="adf-multiline-counter-block">{{ field?.value?.length || 0 }}/{{ field.maxLength }}</span>}
<mat-icon class="adf-error-icon">error_outline</mat-icon> <mat-icon class="adf-error-icon">error_outline</mat-icon>
<span class="adf-error-text" <span class="adf-error-text"
>@if (field.validationSummary?.message) {{{ field.validationSummary.message | translate:translateParameters }}} @else {{{ 'FORM.FIELD.REQUIRED' | translate }}}</span> >@if (field.validationSummary?.message) {{{ field.validationSummary.message | translate:translateParameters }}} @else {{{
'FORM.FIELD.REQUIRED' | translate }}}</span
>
</mat-error> </mat-error>
} @else if (field.maxLength > 0) { } @else if (field.maxLength > 0) {
<mat-hint class="adf-multiline-hint">{{ field?.value?.length || 0 }}/{{ field.maxLength }}</mat-hint> <mat-hint class="adf-multiline-hint">{{ field?.value?.length || 0 }}/{{ field.maxLength }}</mat-hint>
@@ -8,7 +8,7 @@
flex-direction: column; flex-direction: column;
position: relative; position: relative;
.adf-label { .adf-multiline-text-widget-label {
top: 20px; top: 20px;
} }
@@ -11,7 +11,7 @@
<div class="adf-number-widget-container"> <div class="adf-number-widget-container">
<mat-form-field class="adf-form-field-input" [floatLabel]="field.placeholder ? 'always' : null"> <mat-form-field class="adf-form-field-input" [floatLabel]="field.placeholder ? 'always' : null">
@if( (field.name || this.field?.required) && !field.leftLabels) { @if( (field.name || this.field?.required) && !field.leftLabels) {
<mat-label class="adf-label" [attr.for]="field.id"> <mat-label class="adf-label">
{{ field.name | translate }} {{ field.name | translate }}
</mat-label> </mat-label>
} }
@@ -9,7 +9,7 @@
</div> </div>
<div class="adf-text-widget-container"> <div class="adf-text-widget-container">
<mat-form-field class="adf-form-field-input" [floatLabel]="placeholder ? 'always' : null"> <mat-form-field class="adf-form-field-input" [floatLabel]="placeholder ? 'always' : null">
@if ( (field.name || this.field?.required) && !field.leftLabels) { <mat-label class="adf-label" [attr.for]="field.id"> @if ( (field.name || this.field?.required) && !field.leftLabels) { <mat-label data-automation-id="adf-text-widget-label">
{{ field.name | translate }} {{ field.name | translate }}
</mat-label> </mat-label>
} }
@@ -5,6 +5,7 @@
} @else { } @else {
<div <div
class="adf-cloud-form-container adf-cloud-form-{{ displayConfiguration?.options?.fullscreen ? 'fullscreen' : 'inline' }}-container" class="adf-cloud-form-container adf-cloud-form-{{ displayConfiguration?.options?.fullscreen ? 'fullscreen' : 'inline' }}-container"
data-automation-id="adf-cloud-form-container"
[style]="formStyle" [style]="formStyle"
> >
<div <div
@@ -135,7 +135,8 @@
} }
} }
.adf-label { .adf-label,
.adf-display-external-property-widget-label {
white-space: normal; white-space: normal;
} }
} }
@@ -17,7 +17,7 @@
<div class="adf-date-widget-container"> <div class="adf-date-widget-container">
<mat-form-field class="adf-date-widget adf-form-field-input" [class.adf-left-label-input-datepicker]="field.leftLabels"> <mat-form-field class="adf-date-widget adf-form-field-input" [class.adf-left-label-input-datepicker]="field.leftLabels">
@if ( (field.name || field?.required) && !field.leftLabels) { @if ( (field.name || field?.required) && !field.leftLabels) {
<mat-label class="adf-label" [attr.for]="field.id"> <mat-label class="adf-label">
{{field.name | translate }} ({{field.dateDisplayFormat}}) {{field.name | translate }} ({{field.dateDisplayFormat}})
</mat-label> </mat-label>
} }
@@ -13,7 +13,7 @@
<div> <div>
<mat-form-field class="adf-form-field-input" [floatLabel]="field.placeholder ? 'always' : null"> <mat-form-field class="adf-form-field-input" [floatLabel]="field.placeholder ? 'always' : null">
@if( (field.name || field?.required) && !field.leftLabels) { @if( (field.name || field?.required) && !field.leftLabels) {
<mat-label class="adf-label" [attr.for]="field.id"> {{ field.name | translate }} </mat-label> <mat-label class="adf-display-external-property-widget-label" data-automation-id="adf-display-external-property-widget-label"> {{ field.name | translate }} </mat-label>
} }
<input <input
matInput matInput
@@ -32,7 +32,10 @@
</span> </span>
</ng-container> </ng-container>
@if (propertyLoadFailed && !previewState) { @if (propertyLoadFailed && !previewState) {
<mat-error><mat-icon class="adf-error-icon">error_outline</mat-icon><span class="adf-error-text">{{ 'FORM.FIELD.EXTERNAL_PROPERTY_LOAD_FAILED' | translate }}</span></mat-error> <mat-error
><mat-icon class="adf-error-icon">error_outline</mat-icon
><span class="adf-error-text">{{ 'FORM.FIELD.EXTERNAL_PROPERTY_LOAD_FAILED' | translate }}</span></mat-error
>
} }
</mat-form-field> </mat-form-field>
</div> </div>
@@ -4,7 +4,7 @@
&-display-external-property-widget { &-display-external-property-widget {
width: 100%; width: 100%;
.adf-label { .adf-display-external-property-widget-label {
top: 20px; top: 20px;
} }
@@ -14,7 +14,7 @@
<div class="adf-dropdown-widget-container"> <div class="adf-dropdown-widget-container">
<mat-form-field class="adf-form-field-input"> <mat-form-field class="adf-form-field-input">
@if ( (field.name || this.field?.required) && !field.leftLabels) { @if ( (field.name || this.field?.required) && !field.leftLabels) {
<mat-label class="adf-label" [attr.for]="field.id">{{ field.name | translate }}</mat-label> <mat-label class="adf-label">{{ field.name | translate }}</mat-label>
} }
<mat-select <mat-select
class="adf-select" class="adf-select"
@@ -191,7 +191,7 @@ describe('StartFormComponent', () => {
const formFields = component.form.getFormFields(); const formFields = component.form.getFormFields();
const labelField = formFields.find((field) => field.id === 'mocktext'); const labelField = formFields.find((field) => field.id === 'mocktext');
const textWidget = fixture.debugElement.nativeElement.querySelector('text-widget'); const textWidget = fixture.debugElement.nativeElement.querySelector('text-widget');
const textWidgetLabel = fixture.debugElement.nativeElement.querySelector('.adf-label'); const textWidgetLabel = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-text-widget-label"]');
expect(labelField.type).toBe('text'); expect(labelField.type).toBe('text');
expect(textWidget).toBeTruthy(); expect(textWidget).toBeTruthy();
@@ -262,7 +262,7 @@ describe('StartFormComponent', () => {
const formFields = component.form.getFormFields(); const formFields = component.form.getFormFields();
const dropdownField = formFields.find((field) => field.id === 'mockTypeDropDown'); const dropdownField = formFields.find((field) => field.id === 'mockTypeDropDown');
const dropdownWidget = fixture.debugElement.nativeElement.querySelector('dropdown-widget'); const dropdownWidget = fixture.debugElement.nativeElement.querySelector('dropdown-widget');
const dropdownLabel = fixture.debugElement.nativeElement.querySelector('.adf-dropdown-widget .adf-label'); const dropdownLabel = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-dropdown-widget-label"]');
const selectElement = await loader.getHarness(MatSelectHarness); const selectElement = await loader.getHarness(MatSelectHarness);
await selectElement.open(); await selectElement.open();
@@ -287,7 +287,7 @@ describe('StartFormComponent', () => {
const formFields = component.form.getFormFields(); const formFields = component.form.getFormFields();
const labelField = formFields.find((field) => field.id === 'date'); const labelField = formFields.find((field) => field.id === 'date');
const dateWidget = fixture.debugElement.nativeElement.querySelector('date-widget'); const dateWidget = fixture.debugElement.nativeElement.querySelector('date-widget');
const dateLabelElement = fixture.debugElement.nativeElement.querySelector('#data-widget .adf-label'); const dateLabelElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-date-widget-label"]');
expect(dateWidget).toBeTruthy(); expect(dateWidget).toBeTruthy();
expect(labelField.type).toBe('date'); expect(labelField.type).toBe('date');
@@ -320,11 +320,11 @@ describe('StartFormComponent', () => {
const formFieldsWidget = fixture.debugElement.nativeElement.querySelector('form-field'); const formFieldsWidget = fixture.debugElement.nativeElement.querySelector('form-field');
const inputElement = fixture.debugElement.nativeElement.querySelector('.adf-input'); const inputElement = fixture.debugElement.nativeElement.querySelector('.adf-input');
const inputLabelElement = fixture.debugElement.nativeElement.querySelector('.adf-label'); const inputLabelElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-text-widget-label"]');
const dateElement = fixture.debugElement.nativeElement.querySelector('#billdate'); const dateElement = fixture.debugElement.nativeElement.querySelector('#billdate');
const dateLabelElement = fixture.debugElement.nativeElement.querySelector('#data-widget .adf-label'); const dateLabelElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-date-widget-label"]');
const selectElement = fixture.debugElement.nativeElement.querySelector('#claimtype'); const selectElement = fixture.debugElement.nativeElement.querySelector('#claimtype');
const selectLabelElement = fixture.debugElement.nativeElement.querySelector('.adf-dropdown-widget > .adf-label'); const selectLabelElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-dropdown-widget-label"]');
expect(formFieldsWidget).toBeDefined(); expect(formFieldsWidget).toBeDefined();
expect(inputElement).toBeDefined(); expect(inputElement).toBeDefined();
@@ -348,7 +348,7 @@ describe('StartFormComponent', () => {
/* cspell:disable-next-line */ /* cspell:disable-next-line */
const selectElement = fixture.debugElement.nativeElement.querySelector('#claimtype'); const selectElement = fixture.debugElement.nativeElement.querySelector('#claimtype');
const selectLabelElement = fixture.debugElement.nativeElement.querySelector('.adf-dropdown-widget > .adf-label'); const selectLabelElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-dropdown-widget-label"]');
expect(refreshElement).toBeDefined(); expect(refreshElement).toBeDefined();
expect(selectElement).toBeDefined(); expect(selectElement).toBeDefined();
expect(translate.instant(selectLabelElement.innerText)).toBe('ClaimType'); expect(translate.instant(selectLabelElement.innerText)).toBe('ClaimType');
@@ -2,12 +2,16 @@
class="adf-dropdown-widget {{field.className}}" class="adf-dropdown-widget {{field.className}}"
[class.adf-invalid]="dropdownControl.invalid && dropdownControl.touched" [class.adf-invalid]="dropdownControl.invalid && dropdownControl.touched"
[class.adf-readonly]="field.readOnly" [class.adf-readonly]="field.readOnly"
>
<label class="adf-label" [attr.for]="field.id"
>{{field.name | translate }}<span class="adf-asterisk" [style.visibility]="isRequired() ? 'visible' : 'hidden'">*</span></label
> >
<mat-form-field class="adf-form-field-input"> <mat-form-field class="adf-form-field-input">
<mat-select class="adf-select" [id]="field.id" [formControl]="dropdownControl"> <mat-label data-automation-id="adf-dropdown-widget-label">{{ field.name | translate }}</mat-label>
<mat-select
class="adf-select"
data-automation-id="adf-dropdown-widget-select"
[id]="field.id"
[formControl]="dropdownControl"
[required]="isRequired() && field.isVisible"
>
<mat-option *ngFor="let opt of field.options" [value]="opt" [id]="opt.id">{{opt.name}}</mat-option> <mat-option *ngFor="let opt of field.options" [value]="opt" [id]="opt.id">{{opt.name}}</mat-option>
<mat-option id="readonlyOption" *ngIf="dropdownControl.disabled" [value]="field.value">{{field.value}}</mat-option> <mat-option id="readonlyOption" *ngIf="dropdownControl.disabled" [value]="field.value">{{field.value}}</mat-option>
</mat-select> </mat-select>
@@ -15,7 +19,9 @@
<mat-error data-automation-id="adf-dropdown-error"> <mat-error data-automation-id="adf-dropdown-error">
<mat-icon class="adf-error-icon">error_outline</mat-icon> <mat-icon class="adf-error-icon">error_outline</mat-icon>
<span class="adf-error-text" <span class="adf-error-text"
>@if (field.validationSummary?.message) {{{ field.validationSummary.message | translate }}} @else {{{ 'FORM.FIELD.REQUIRED' | translate }}}</span> >@if (field.validationSummary?.message) {{{ field.validationSummary.message | translate }}} @else {{{ 'FORM.FIELD.REQUIRED' |
translate }}}</span
>
</mat-error> </mat-error>
} }
</mat-form-field> </mat-form-field>
@@ -161,10 +161,9 @@ describe('DropdownWidgetComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const asterisk: HTMLElement = element.querySelector('.adf-asterisk'); const dropdown = await loader.getHarness(MatSelectHarness.with({ selector: '[data-automation-id="adf-dropdown-widget-select"]' }));
expect(asterisk).toBeTruthy(); expect(await dropdown.isRequired()).toBeTrue();
expect(asterisk.textContent).toEqual('*');
}); });
it('should be invalid if no default option after interaction', async () => { it('should be invalid if no default option after interaction', async () => {
@@ -1,6 +1,6 @@
<div class="adf-amount-editor"> <div class="adf-amount-editor">
<mat-form-field> <mat-form-field>
<label [attr.for]="column.id">{{displayName}}</label> <mat-label>{{ displayName }}</mat-label>
<input matInput <input matInput
type="number" type="number"
[value]="table.getCellValue(row, column)" [value]="table.getCellValue(row, column)"
@@ -1,6 +1,6 @@
<div> <div>
<mat-form-field class="adf-date-editor"> <mat-form-field class="adf-date-editor">
<label [attr.for]="column.id">{{column.name}} ({{DATE_FORMAT}})</label> <mat-label>{{ column.name }} ({{ DATE_FORMAT }})</mat-label>
<input matInput <input matInput
id="dateInput" id="dateInput"
type="text" type="text"
@@ -1,6 +1,6 @@
<div> <div>
<mat-form-field class="adf-date-editor"> <mat-form-field class="adf-date-editor">
<label [attr.for]="column.id">{{column.name}} {{DATE_TIME_FORMAT}}</label> <mat-label>{{ column.name }} {{ DATE_TIME_FORMAT }}</mat-label>
<input matInput <input matInput
[matDatetimepicker]="datetimePicker" [matDatetimepicker]="datetimePicker"
[(ngModel)]="value" [(ngModel)]="value"
@@ -1,6 +1,6 @@
<div class="dropdown-editor"> <div class="dropdown-editor">
<label [attr.for]="column.id">{{column.name}}</label>
<mat-form-field> <mat-form-field>
<mat-label>{{column.name}}</mat-label>
<mat-select <mat-select
floatPlaceholder="never" floatPlaceholder="never"
class="adf-dropdown-editor-select" class="adf-dropdown-editor-select"
@@ -8,7 +8,8 @@
[(ngModel)]="value" [(ngModel)]="value"
[required]="column.required" [required]="column.required"
[disabled]="!column.editable" [disabled]="!column.editable"
(selectionChange)="onValueChanged(row, column, $event)"> (selectionChange)="onValueChanged(row, column, $event)"
>
<mat-option /> <mat-option />
<mat-option *ngFor="let opt of options" [value]="opt.name" [id]="opt.id">{{opt.name}}</mat-option> <mat-option *ngFor="let opt of options" [value]="opt.name" [id]="opt.id">{{opt.name}}</mat-option>
</mat-select> </mat-select>
@@ -1,6 +1,6 @@
<div class="adf-text-editor"> <div class="adf-text-editor">
<mat-form-field> <mat-form-field>
<label [attr.for]="column.id">{{displayName}}</label> <mat-label>{{ displayName }}</mat-label>
<input matInput <input matInput
type="text" type="text"
[value]="table.getCellValue(row, column)" [value]="table.getCellValue(row, column)"
@@ -4,12 +4,10 @@
[class.adf-invalid]="!field.isValid && isTouched()" [class.adf-invalid]="!field.isValid && isTouched()"
[class.adf-readonly]="field.readOnly" [class.adf-readonly]="field.readOnly"
id="functional-group-div" id="functional-group-div"
>
<label class="adf-label" [attr.for]="field.id"
>{{field.name | translate }}<span class="adf-asterisk" [style.visibility]="isRequired() ? 'visible' : 'hidden'">*</span></label
> >
<mat-form-field class="adf-group-widget-field"> <mat-form-field class="adf-group-widget-field">
<mat-chip-grid #chipGrid> <mat-label data-automation-id="adf-group-widget-label">{{ field.name | translate }}</mat-label>
<mat-chip-grid #chipGrid [required]="isRequired()">
<mat-chip-row <mat-chip-row
*ngFor="let group of selectedGroups" *ngFor="let group of selectedGroups"
(removed)="onRemove(group)" (removed)="onRemove(group)"
@@ -52,7 +50,9 @@
<mat-error> <mat-error>
<mat-icon class="adf-error-icon">error_outline</mat-icon> <mat-icon class="adf-error-icon">error_outline</mat-icon>
<span class="adf-error-text" <span class="adf-error-text"
>@if (field.validationSummary?.message) {{{ field.validationSummary.message | translate }}} @else {{{ 'FORM.FIELD.REQUIRED' | translate }}}</span> >@if (field.validationSummary?.message) {{{ field.validationSummary.message | translate }}} @else {{{ 'FORM.FIELD.REQUIRED' |
translate }}}</span
>
</mat-error> </mat-error>
} }
</mat-form-field> </mat-form-field>
@@ -22,7 +22,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PeopleProcessService } from '../../../services/people-process.service'; import { PeopleProcessService } from '../../../services/people-process.service';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { HarnessLoader } from '@angular/cdk/testing'; import { HarnessLoader } from '@angular/cdk/testing';
import { MatChipRowHarness } from '@angular/material/chips/testing'; import { MatChipGridHarness, MatChipRowHarness } from '@angular/material/chips/testing';
import { MatAutocompleteHarness } from '@angular/material/autocomplete/testing'; import { MatAutocompleteHarness } from '@angular/material/autocomplete/testing';
describe('FunctionalGroupWidgetComponent', () => { describe('FunctionalGroupWidgetComponent', () => {
@@ -30,7 +30,6 @@ describe('FunctionalGroupWidgetComponent', () => {
let component: FunctionalGroupWidgetComponent; let component: FunctionalGroupWidgetComponent;
let peopleProcessService: PeopleProcessService; let peopleProcessService: PeopleProcessService;
let getWorkflowGroupsSpy: jasmine.Spy; let getWorkflowGroupsSpy: jasmine.Spy;
let element: HTMLElement;
let loader: HarnessLoader; let loader: HarnessLoader;
let unitTestingUtils: UnitTestingUtils; let unitTestingUtils: UnitTestingUtils;
@@ -51,7 +50,6 @@ describe('FunctionalGroupWidgetComponent', () => {
unitTestingUtils = new UnitTestingUtils(fixture.debugElement); unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
loader = TestbedHarnessEnvironment.loader(fixture); loader = TestbedHarnessEnvironment.loader(fixture);
component.field = new FormFieldModel(new FormModel()); component.field = new FormFieldModel(new FormModel());
element = fixture.nativeElement;
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -176,10 +174,9 @@ describe('FunctionalGroupWidgetComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const asterisk: HTMLElement = element.querySelector('.adf-asterisk'); const chipGrid = await loader.getHarness(MatChipGridHarness);
expect(asterisk).toBeTruthy(); expect(await chipGrid.isRequired()).toBeTrue();
expect(asterisk.textContent).toEqual('*');
}); });
}); });
@@ -2,11 +2,11 @@
[class.adf-invalid]="!field.isValid && isTouched()" [class.adf-invalid]="!field.isValid && isTouched()"
[class.adf-readonly]="field.readOnly" [class.adf-readonly]="field.readOnly"
id="people-widget-content"> id="people-widget-content">
<label class="adf-label" [attr.for]="field.id">{{field.name | translate }}<span class="adf-asterisk" [style.visibility]="isRequired() ? 'visible' : 'hidden'">*</span></label>
<mat-form-field <mat-form-field
class="adf-people-widget-field"> class="adf-people-widget-field">
<mat-label class="adf-people-widget-label" data-automation-id="adf-people-widget-label">{{ field.name | translate }}</mat-label>
<mat-chip-grid #chipGrid [attr.aria-label]="'ADF_PROCESS_LIST.START_PROCESS.FORM.LABEL.SELECTED_PEOPLE' | translate" <mat-chip-grid #chipGrid [attr.aria-label]="'ADF_PROCESS_LIST.START_PROCESS.FORM.LABEL.SELECTED_PEOPLE' | translate"
[ngModel]="selectedUsers" [errorStateMatcher]="errorStateMatcher"> [required]="isRequired()" [ngModel]="selectedUsers" [errorStateMatcher]="errorStateMatcher">
<mat-chip-row <mat-chip-row
*ngFor="let user of selectedUsers" *ngFor="let user of selectedUsers"
(removed)="onRemove(user)" (removed)="onRemove(user)"
@@ -23,7 +23,7 @@ import { PeopleWidgetComponent } from './people.widget';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { PeopleProcessService } from '../../../services/people-process.service'; import { PeopleProcessService } from '../../../services/people-process.service';
import { LightUserRepresentation } from '@alfresco/js-api'; import { LightUserRepresentation } from '@alfresco/js-api';
import { MatChipHarness } from '@angular/material/chips/testing'; import { MatChipGridHarness, MatChipHarness } from '@angular/material/chips/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { HarnessLoader } from '@angular/cdk/testing'; import { HarnessLoader } from '@angular/cdk/testing';
@@ -325,10 +325,9 @@ describe('PeopleWidgetComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const asterisk: HTMLElement = element.querySelector('.adf-asterisk'); const chipGrid = await loader.getHarness(MatChipGridHarness);
expect(asterisk).toBeTruthy(); expect(await chipGrid.isRequired()).toBeTrue();
expect(asterisk.textContent).toEqual('*');
}); });
}); });
@@ -5,7 +5,7 @@
[class.adf-readonly]="field.readOnly" [class.adf-readonly]="field.readOnly"
id="typehead-div"> id="typehead-div">
<mat-form-field class="adf-form-field-input"> <mat-form-field class="adf-form-field-input">
<label class="adf-label" [attr.for]="field.id">{{field.name | translate }}</label> <mat-label>{{ field.name | translate }}</mat-label>
<input matInput class="adf-input" <input matInput class="adf-input"
type="text" type="text"
[id]="field.id" [id]="field.id"
@@ -77,7 +77,7 @@ adf-start-task {
width: 100%; width: 100%;
} }
.adf-label { .adf-people-widget-label {
line-height: 0; line-height: 0;
} }
@@ -126,7 +126,7 @@ adf-start-task {
border-color: var(--mat-sys-error); border-color: var(--mat-sys-error);
} }
.adf-label { .adf-people-widget-label {
color: var(--mat-sys-error); color: var(--mat-sys-error);
&::after { &::after {