[AAE-8856] Enable left label for form widgets in several widgets (#7640)

This commit is contained in:
Rubén Barroso 2022-05-18 18:43:59 +02:00 committed by GitHub
parent d4779360d8
commit b13a5cc282
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 482 additions and 109 deletions

View File

@ -1,26 +1,21 @@
<div class="adf-amount-widget__container adf-amount-widget {{field.className}}" <div class="adf-amount-widget__container adf-amount-widget {{field.className}}"
[class.adf-invalid]="!field.isValid && isTouched()" [class.adf-invalid]="!field.isValid && isTouched()" [class.adf-readonly]="field.readOnly"
[class.adf-readonly]="field.readOnly"> [class.adf-left-label-input-container]="field.leftLabels">
<label class="adf-label" <div>
[attr.for]="field.id">{{field.name | translate }}<span class="adf-asterisk" *ngIf="isRequired()">*</span></label> <label class="adf-label"
<mat-form-field class="adf-amount-widget__input" [hideRequiredMarker]="true"> [class.adf-left-label]="field.leftLabels" [attr.for]="field.id">{{field.name | translate }}<span class="adf-asterisk" *ngIf="isRequired()">*</span></label>
<span matPrefix class="adf-amount-widget__prefix-spacing">{{ currency }} &nbsp;</span> </div>
<input matInput <div>
[matTooltip]="field.tooltip" <mat-form-field class="adf-amount-widget__input" [hideRequiredMarker]="true">
matTooltipPosition="above" <span matPrefix class="adf-amount-widget__prefix-spacing">{{ currency }} &nbsp;</span>
matTooltipShowDelay="1000" <input matInput [matTooltip]="field.tooltip" matTooltipPosition="above" matTooltipShowDelay="1000"
class="adf-input" class="adf-input" type="text" [id]="field.id" [required]="isRequired()"
type="text" [placeholder]="placeholder" [value]="field.value" [(ngModel)]="field.value"
[id]="field.id" (ngModelChange)="onFieldChanged(field)" [disabled]="field.readOnly"
[required]="isRequired()" (blur)="markAsTouched()">
[placeholder]="placeholder" </mat-form-field>
[value]="field.value" <error-widget [error]="field.validationSummary"></error-widget>
[(ngModel)]="field.value" <error-widget *ngIf="isInvalidFieldRequired() && isTouched()"
(ngModelChange)="onFieldChanged(field)" required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget>
[disabled]="field.readOnly" </div>
(blur)="markAsTouched()"> </div>
</mat-form-field>
<error-widget [error]="field.validationSummary"></error-widget>
<error-widget *ngIf="isInvalidFieldRequired() && isTouched()"
required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget>
</div>

View File

@ -2,6 +2,10 @@
&-amount-widget { &-amount-widget {
width: 100%; width: 100%;
margin-top: 15px; margin-top: 15px;
.adf-left-label {
line-height: 36px;
}
} }
&-amount-widget__input { &-amount-widget__input {

View File

@ -118,6 +118,7 @@ describe('AmountWidgetComponent - rendering', () => {
let widget: AmountWidgetComponent; let widget: AmountWidgetComponent;
let fixture: ComponentFixture<AmountWidgetComponent>; let fixture: ComponentFixture<AmountWidgetComponent>;
let element: HTMLElement;
setupTestBed({ setupTestBed({
imports: [ imports: [
@ -130,6 +131,7 @@ describe('AmountWidgetComponent - rendering', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(AmountWidgetComponent); fixture = TestBed.createComponent(AmountWidgetComponent);
widget = fixture.componentInstance; widget = fixture.componentInstance;
element = fixture.nativeElement;
}); });
it('[C309692] - Should be possible to set the General Properties for Amount Widget', async () => { it('[C309692] - Should be possible to set the General Properties for Amount Widget', async () => {
@ -207,6 +209,69 @@ describe('AmountWidgetComponent - rendering', () => {
expect(tooltip).toEqual(widget.field.tooltip); expect(tooltip).toEqual(widget.field.tooltip);
}); });
describe('when form model has left labels', () => {
it('should have left labels classes on leftLabels true', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: true }), {
id: 'amount-id',
name: 'amount-name',
value: '',
type: FormFieldTypes.AMOUNT,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).not.toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).not.toBeNull();
});
it('should not have left labels classes on leftLabels false', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: false }), {
id: 'amount-id',
name: 'amount-name',
value: '',
type: FormFieldTypes.AMOUNT,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull();
});
it('should not have left labels classes on leftLabels not present', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
id: 'amount-id',
name: 'amount-name',
value: '',
type: FormFieldTypes.AMOUNT,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull();
});
});
}); });
describe('AmountWidgetComponent settings', () => { describe('AmountWidgetComponent settings', () => {

View File

@ -1,23 +1,27 @@
<div class="{{field.className}}" id="data-time-widget" [class.adf-invalid]="!field.isValid && isTouched()"> <div class="{{field.className}}" id="data-time-widget" [class.adf-invalid]="!field.isValid && isTouched()" [class.adf-left-label-input-container]="field.leftLabels">
<mat-form-field class="adf-date-time-widget" [hideRequiredMarker]="true"> <div *ngIf="field.leftLabels">
<label class="adf-label" [attr.for]="field.id">{{field.name | translate }} ({{field.dateDisplayFormat}})<span class="adf-asterisk" *ngIf="isRequired()">*</span></label> <label class="adf-label adf-left-label" [attr.for]="field.id">{{field.name | translate }} ({{field.dateDisplayFormat}})<span class="adf-asterisk" *ngIf="isRequired()">*</span></label>
<input matInput </div>
[id]="field.id" <div>
[value]="field.value" <mat-form-field class="adf-date-time-widget" [class.adf-left-label-input-datepicker]="field.leftLabels" [hideRequiredMarker]="true">
[required]="isRequired()" <label class="adf-label" *ngIf="!field.leftLabels" [attr.for]="field.id">{{field.name | translate }} ({{field.dateDisplayFormat}})<span class="adf-asterisk" *ngIf="isRequired()">*</span></label>
[disabled]="field.readOnly" <input matInput
(change)="onDateChanged($any($event).srcElement.value)" [id]="field.id"
[placeholder]="field.placeholder" [value]="field.value"
[matTooltip]="field.tooltip" [required]="isRequired()"
(blur)="markAsTouched()" [disabled]="field.readOnly"
matTooltipPosition="above" (change)="onDateChanged($any($event).srcElement.value)"
matTooltipShowDelay="1000" [placeholder]="field.placeholder"
(focus)="datetimePicker.open()"> [matTooltip]="field.tooltip"
<mat-datetimepicker-toggle matSuffix [for]="datetimePicker" [disabled]="field.readOnly"></mat-datetimepicker-toggle> (blur)="markAsTouched()"
</mat-form-field> matTooltipPosition="above"
<error-widget [error]="field.validationSummary"></error-widget> matTooltipShowDelay="1000"
<error-widget *ngIf="isInvalidFieldRequired() && isTouched()" required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget> (focus)="datetimePicker.open()">
<mat-datetimepicker #datetimePicker type="datetime" [touchUi]="true" [timeInterval]="5" [disabled]="field.readOnly"></mat-datetimepicker> <mat-datetimepicker-toggle matSuffix [for]="datetimePicker" [disabled]="field.readOnly"></mat-datetimepicker-toggle>
</mat-form-field>
<error-widget [error]="field.validationSummary"></error-widget>
<error-widget *ngIf="isInvalidFieldRequired() && isTouched()" required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget>
<mat-datetimepicker #datetimePicker type="datetime" [touchUi]="true" [timeInterval]="5" [disabled]="field.readOnly"></mat-datetimepicker>
<input <input
type="hidden" type="hidden"
[matDatetimepicker]="datetimePicker" [matDatetimepicker]="datetimePicker"
@ -26,4 +30,5 @@
[max]="maxDate" [max]="maxDate"
[disabled]="field.readOnly" [disabled]="field.readOnly"
(dateInput)="onDateChanged($any($event).targetElement.value)"> (dateInput)="onDateChanged($any($event).targetElement.value)">
</div>
</div> </div>

View File

@ -8,6 +8,16 @@
top: 20px; top: 20px;
} }
} }
&-left-label-input-datepicker {
.mat-form-field-suffix {
top: 0;
}
.mat-form-field-infix {
width: 100%;
}
}
} }
.mat-datetimepicker-toggle { .mat-datetimepicker-toggle {

View File

@ -250,4 +250,76 @@ describe('DateTimeWidgetComponent', () => {
}); });
}); });
}); });
describe('when form model has left labels', () => {
it('should have left labels classes on leftLabels true', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: true }), {
id: 'datetime-id',
name: 'datetime-name',
value: '',
type: FormFieldTypes.DATETIME,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).not.toBeNull();
const leftDatePicker = element.querySelector('.adf-left-label-input-datepicker');
expect(leftDatePicker).not.toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).not.toBeNull();
});
it('should not have left labels classes on leftLabels false', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: false }), {
id: 'datetime-id',
name: 'datetime-name',
value: '',
type: FormFieldTypes.DATETIME,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).toBeNull();
const leftDatePicker = element.querySelector('.adf-left-label-input-datepicker');
expect(leftDatePicker).toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull();
});
it('should not have left labels classes on leftLabels not present', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
id: 'datetime-id',
name: 'datetime-name',
value: '',
type: FormFieldTypes.DATETIME,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).toBeNull();
const leftDatePicker = element.querySelector('.adf-left-label-input-datepicker');
expect(leftDatePicker).toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull();
});
});
}); });

View File

@ -1,29 +1,35 @@
<div class="{{field.className}}" id="data-widget" [class.adf-invalid]="!field.isValid && isTouched()"> <div class="{{field.className}}" id="data-widget" [class.adf-invalid]="!field.isValid && isTouched()" [class.adf-left-label-input-container]="field.leftLabels">
<mat-form-field class="adf-date-widget" [hideRequiredMarker]="true"> <div *ngIf="field.leftLabels">
<label class="adf-label" [attr.for]="field.id">{{field.name | translate }} ({{field.dateDisplayFormat}})<span class="adf-asterisk" <label class="adf-label adf-left-label" [attr.for]="field.id">{{field.name | translate }} ({{field.dateDisplayFormat}})<span class="adf-asterisk"
*ngIf="isRequired()">*</span></label> *ngIf="isRequired()">*</span></label>
<input matInput </div>
[id]="field.id" <div>
[value]="field.value" <mat-form-field class="adf-date-widget" [class.adf-left-label-input-datepicker]="field.leftLabels" [hideRequiredMarker]="true">
[required]="isRequired()" <label class="adf-label" *ngIf="!field.leftLabels" [attr.for]="field.id">{{field.name | translate }} ({{field.dateDisplayFormat}})<span class="adf-asterisk"
[disabled]="field.readOnly" *ngIf="isRequired()">*</span></label>
(change)="onDateChanged($any($event).srcElement.value)" <input matInput
[placeholder]="field.placeholder" [id]="field.id"
[matTooltip]="field.tooltip" [value]="field.value"
(blur)="markAsTouched()" [required]="isRequired()"
matTooltipPosition="above" [disabled]="field.readOnly"
matTooltipShowDelay="1000"> (change)="onDateChanged($any($event).srcElement.value)"
<mat-datepicker-toggle matSuffix [for]="datePicker" [disabled]="field.readOnly" ></mat-datepicker-toggle> [placeholder]="field.placeholder"
</mat-form-field> [matTooltip]="field.tooltip"
<error-widget [error]="field.validationSummary"></error-widget> (blur)="markAsTouched()"
<error-widget *ngIf="isInvalidFieldRequired() && isTouched()" required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget> matTooltipPosition="above"
<mat-datepicker #datePicker [touchUi]="true" [startAt]="field.value | adfMomentDate: field.dateDisplayFormat" [disabled]="field.readOnly"></mat-datepicker> matTooltipShowDelay="1000">
<input <mat-datepicker-toggle matSuffix [for]="datePicker" [disabled]="field.readOnly" ></mat-datepicker-toggle>
type="hidden" </mat-form-field>
[matDatepicker]="datePicker" <error-widget [error]="field.validationSummary"></error-widget>
[value]="field.value | adfMomentDate: field.dateDisplayFormat" <error-widget *ngIf="isInvalidFieldRequired() && isTouched()" required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget>
[min]="minDate" <mat-datepicker #datePicker [touchUi]="true" [startAt]="field.value | adfMomentDate: field.dateDisplayFormat" [disabled]="field.readOnly"></mat-datepicker>
[max]="maxDate" <input
[disabled]="field.readOnly" type="hidden"
(dateInput)="onDateChanged($any($event).targetElement.value)"> [matDatepicker]="datePicker"
[value]="field.value | adfMomentDate: field.dateDisplayFormat"
[min]="minDate"
[max]="maxDate"
[disabled]="field.readOnly"
(dateInput)="onDateChanged($any($event).targetElement.value)">
</div>
</div> </div>

View File

@ -8,4 +8,14 @@
top: 20px; top: 20px;
} }
} }
&-left-label-input-datepicker {
.mat-form-field-suffix {
top: 0;
}
.mat-form-field-infix {
width: 100%;
}
}
} }

View File

@ -17,7 +17,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DateCloudWidgetComponent, DATE_FORMAT_CLOUD } from './date-cloud.widget'; import { DateCloudWidgetComponent, DATE_FORMAT_CLOUD } from './date-cloud.widget';
import { setupTestBed, FormFieldModel, FormModel } from '@alfresco/adf-core'; import { setupTestBed, FormFieldModel, FormModel, FormFieldTypes } from '@alfresco/adf-core';
import moment from 'moment-es6'; import moment from 'moment-es6';
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module'; import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@ -230,4 +230,76 @@ describe('DateWidgetComponent', () => {
}); });
}); });
describe('when form model has left labels', () => {
it('should have left labels classes on leftLabels true', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: true }), {
id: 'date-id',
name: 'date-name',
value: '',
type: FormFieldTypes.DATE,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).not.toBeNull();
const leftDatePicker = element.querySelector('.adf-left-label-input-datepicker');
expect(leftDatePicker).not.toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).not.toBeNull();
});
it('should not have left labels classes on leftLabels false', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: false }), {
id: 'date-id',
name: 'date-name',
value: '',
type: FormFieldTypes.DATE,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).toBeNull();
const leftDatePicker = element.querySelector('.adf-left-label-input-datepicker');
expect(leftDatePicker).toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull();
});
it('should not have left labels classes on leftLabels not present', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
id: 'date-id',
name: 'date-name',
value: '',
type: FormFieldTypes.DATE,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).toBeNull();
const leftDatePicker = element.querySelector('.adf-left-label-input-datepicker');
expect(leftDatePicker).toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull();
});
});
}); });

View File

@ -1,22 +1,26 @@
<div class="adf-dropdown-widget {{field.className}}" <div class="adf-dropdown-widget {{field.className}}"
[class.adf-invalid]="!field.isValid && isTouched()" [class.adf-readonly]="field.readOnly"> [class.adf-invalid]="!field.isValid && isTouched()" [class.adf-readonly]="field.readOnly" [class.adf-left-label-input-container]="field.leftLabels">
<label class="adf-label" [attr.for]="field.id">{{field.name | translate }}<span class="adf-asterisk" <div>
*ngIf="isRequired()">*</span></label> <label class="adf-label" [class.adf-left-label]="field.leftLabels" [attr.for]="field.id">{{field.name | translate }}<span class="adf-asterisk"
*ngIf="isRequired()">*</span></label>
</div>
<div>
<adf-cloud-group [mode]="mode" <adf-cloud-group [mode]="mode"
[title]="title" [title]="title"
[readOnly]="field.readOnly" [readOnly]="field.readOnly"
[roles]="roles" [roles]="roles"
[searchGroupsControl]="search" [searchGroupsControl]="search"
[required]="isRequired()" [required]="isRequired()"
(changedGroups)="onChangedGroup($event)" (changedGroups)="onChangedGroup($event)"
[preSelectGroups]="preSelectGroup" [preSelectGroups]="preSelectGroup"
(blur)="markAsTouched()" (blur)="markAsTouched()"
[matTooltip]="field.tooltip" [matTooltip]="field.tooltip"
[matTooltipPosition]="'above'" [matTooltipPosition]="'above'"
[matTooltipShowDelay]="1000"> [matTooltipShowDelay]="1000">
</adf-cloud-group> </adf-cloud-group>
<error-widget [error]="field.validationSummary"></error-widget> <error-widget [error]="field.validationSummary"></error-widget>
<error-widget class="adf-dropdown-required-message" *ngIf="isInvalidFieldRequired() && isTouched()" <error-widget class="adf-dropdown-required-message" *ngIf="isInvalidFieldRequired() && isTouched()"
required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget> required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget>
</div>
</div> </div>

View File

@ -80,4 +80,67 @@ describe('GroupCloudWidgetComponent', () => {
expect(element.querySelector('.adf-invalid')).toBeTruthy(); expect(element.querySelector('.adf-invalid')).toBeTruthy();
}); });
}); });
describe('when form model has left labels', () => {
it('should have left labels classes on leftLabels true', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: true }), {
id: 'group-id',
name: 'group-name',
value: '',
type: FormFieldTypes.GROUP,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).not.toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).not.toBeNull();
});
it('should not have left labels classes on leftLabels false', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: false }), {
id: 'group-id',
name: 'group-name',
value: '',
type: FormFieldTypes.GROUP,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull();
});
it('should not have left labels classes on leftLabels not present', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
id: 'group-id',
name: 'group-name',
value: '',
type: FormFieldTypes.GROUP,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull();
});
});
}); });

View File

@ -1,25 +1,29 @@
<div class="adf-dropdown-widget {{field.className}}" <div class="adf-dropdown-widget {{field.className}}"
[class.adf-invalid]="!field.isValid && isTouched()" [class.adf-readonly]="field.readOnly"> [class.adf-invalid]="!field.isValid && isTouched()" [class.adf-readonly]="field.readOnly" [class.adf-left-label-input-container]="field.leftLabels">
<label class="adf-label" [attr.for]="field.id">{{field.name | translate }}<span class="adf-asterisk" *ngIf="isRequired()">*</span></label> <div>
<label class="adf-label" [class.adf-left-label]="field.leftLabels" [attr.for]="field.id">{{field.name | translate }}<span class="adf-asterisk" *ngIf="isRequired()">*</span></label>
</div>
<div>
<adf-cloud-people <adf-cloud-people
[preSelectUsers]="preSelectUsers" [preSelectUsers]="preSelectUsers"
[validate]="true" [validate]="true"
[appName]="appName" [appName]="appName"
[title]="title" [title]="title"
[readOnly]="field.readOnly" [readOnly]="field.readOnly"
[searchUserCtrl]="search" [searchUserCtrl]="search"
[required]="isRequired()" [required]="isRequired()"
(changedUsers)="onChangedUser($event)" (changedUsers)="onChangedUser($event)"
[roles]="roles" [roles]="roles"
[mode]="mode" [mode]="mode"
[groupsRestriction]="groupsRestriction" [groupsRestriction]="groupsRestriction"
(blur)="markAsTouched()" (blur)="markAsTouched()"
[matTooltip]="field.tooltip" [matTooltip]="field.tooltip"
matTooltipPosition="above" matTooltipPosition="above"
matTooltipShowDelay="1000"> matTooltipShowDelay="1000">
</adf-cloud-people> </adf-cloud-people>
<error-widget [error]="field.validationSummary"></error-widget> <error-widget [error]="field.validationSummary"></error-widget>
<error-widget class="adf-dropdown-required-message" *ngIf="isInvalidFieldRequired() && isTouched()" <error-widget class="adf-dropdown-required-message" *ngIf="isInvalidFieldRequired() && isTouched()"
required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget> required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget>
</div>
</div> </div>

View File

@ -99,4 +99,67 @@ describe('PeopleCloudWidgetComponent', () => {
expect(element.querySelector('.adf-invalid')).toBeTruthy(); expect(element.querySelector('.adf-invalid')).toBeTruthy();
}); });
}); });
describe('when form model has left labels', () => {
it('should have left labels classes on leftLabels true', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: true }), {
id: 'people-id',
name: 'people-name',
value: '',
type: FormFieldTypes.PEOPLE,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).not.toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).not.toBeNull();
});
it('should not have left labels classes on leftLabels false', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id', leftLabels: false }), {
id: 'people-id',
name: 'people-name',
value: '',
type: FormFieldTypes.PEOPLE,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull();
});
it('should not have left labels classes on leftLabels not present', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
id: 'people-id',
name: 'people-name',
value: '',
type: FormFieldTypes.PEOPLE,
readOnly: false,
required: true
});
fixture.detectChanges();
await fixture.whenStable();
const widgetContainer = element.querySelector('.adf-left-label-input-container');
expect(widgetContainer).toBeNull();
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull();
});
});
}); });