[AAE-13069]- Input fields label improvements (#8387)

* AAE-13069: Removing extra div inside mat label

* AAE-13069: Removing font size css rule and applying right class to the mat label

* AAE-13069: Refactoring text item component based on Angular Material

* AAE-13069: Updated unit test

* AAE-13069: Fixed lint issues

* AAE-13069: Fixed styles

* AAE-13069: Updated e2e tests

* AAE-13069: Updated e2e tests
This commit is contained in:
Ehsan Rezaei 2023-03-20 20:25:13 +01:00 committed by GitHub
parent cf52683771
commit 5ab6dc2e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 89 deletions

View File

@ -213,7 +213,7 @@ export class MetadataViewPage {
} }
async checkPropertyIsVisible(propertyName: string, type: string): Promise<void> { async checkPropertyIsVisible(propertyName: string, type: string): Promise<void> {
const property = $('div[data-automation-id="card-' + type + '-label-' + propertyName + '"]'); const property = $('[data-automation-id="card-' + type + '-label-' + propertyName + '"]');
await BrowserVisibility.waitUntilElementIsVisible(property); await BrowserVisibility.waitUntilElementIsVisible(property);
} }

View File

@ -1,10 +1,12 @@
<div [ngSwitch]="templateType"> <div [ngSwitch]="templateType">
<div *ngSwitchDefault> <div *ngSwitchDefault>
<mat-form-field class="adf-property-field adf-card-textitem-field" <mat-form-field class="adf-property-field adf-card-textitem-field"
[ngClass]="{ 'adf-property-read-only': !isEditable,'adf-property-field-has-error mat-form-field-invalid': isEditable && hasErrors }" [ngClass]="{ 'adf-property-read-only': !isEditable, 'adf-property-field-has-error mat-form-field-invalid': isEditable && hasErrors }"
[floatLabel]="'never'"> [floatLabel]="'never'"
<ng-container *ngTemplateOutlet="label"></ng-container> appearance="standard">
<div class="adf-property-field-content"> <mat-label *ngIf="showProperty || isEditable" [attr.data-automation-id]="'card-textitem-label-' + property.key" class="adf-property-label">
{{ property.label | translate }}
</mat-label>
<input matInput <input matInput
*ngIf="!property.multiline" *ngIf="!property.multiline"
class="adf-property-value" class="adf-property-value"
@ -30,24 +32,21 @@
[attr.data-automation-id]="'card-textitem-value-' + property.key"> [attr.data-automation-id]="'card-textitem-value-' + property.key">
</textarea> </textarea>
<button mat-button <button
matSuffix
class="adf-property-clear-value"
*ngIf="isEditable" *ngIf="isEditable"
mat-icon-button matSuffix
class="adf-textitem-clear-icon"
[attr.aria-label]="'CORE.METADATA.ACTIONS.CLEAR' | translate" [attr.aria-label]="'CORE.METADATA.ACTIONS.CLEAR' | translate"
(click)="clearValue()"> (click)="clearValue()">
<mat-icon>cancel</mat-icon> <mat-icon>cancel</mat-icon>
</button> </button>
<div matSuffix *ngIf="isEditable" class="adf-textitem-edit-value"> <button
<mat-icon *ngIf="isEditable"
*ngIf="isEditable" matSuffix
mat-icon-button class="adf-textitem-edit-icon"
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate" [attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate">
class="adf-textitem-edit-icon" <mat-icon>mode_edit</mat-icon>
>mode_edit</mat-icon> </button>
</div>
</div>
</mat-form-field> </mat-form-field>
</div> </div>
@ -65,7 +64,7 @@
</mat-chip> </mat-chip>
</mat-chip-list> </mat-chip-list>
<mat-form-field *ngIf="isEditable" <mat-form-field *ngIf="isEditable" appearance="standard"
class="adf-property-field adf-textitem-chip-list-input" class="adf-property-field adf-textitem-chip-list-input"
[ngClass]="{ 'adf-property-read-only': !isEditable }" [ngClass]="{ 'adf-property-read-only': !isEditable }"
[floatLabel]="'never'"> [floatLabel]="'never'">
@ -91,9 +90,11 @@
(click)="clicked()" (click)="clicked()"
fxLayout="row" fxLayout="row"
fxLayoutAlign="space-between center"> fxLayoutAlign="space-between center">
<mat-form-field class="adf-property-field adf-card-textitem-field" <mat-form-field class="adf-property-field adf-card-textitem-field" appearance="standard"
[floatLabel]="'never'"> [floatLabel]="'never'">
<ng-container *ngTemplateOutlet="label"></ng-container> <mat-label *ngIf="showProperty || isEditable" [attr.data-automation-id]="'card-textitem-label-' + property.key" class="adf-property-label">
{{ property.label | translate }}
</mat-label>
<input matInput <input matInput
[type]=property.inputType [type]=property.inputType
class="adf-property-value" class="adf-property-value"
@ -120,7 +121,6 @@
</div> </div>
<div *ngSwitchCase="'emptyTemplate'"> <div *ngSwitchCase="'emptyTemplate'">
<ng-container *ngTemplateOutlet="label"></ng-container>
<span class="adf-textitem-default-value">{{ property.default | translate }}</span> <span class="adf-textitem-default-value">{{ property.default | translate }}</span>
</div> </div>
@ -132,14 +132,3 @@
</ul> </ul>
</mat-error> </mat-error>
</div> </div>
<ng-template #label>
<mat-label>
<div class="adf-property-label"
[attr.data-automation-id]="'card-textitem-label-' + property.key"
*ngIf="showProperty || isEditable"
>
{{ property.label | translate }}
</div>
</mat-label>
</ng-template>

View File

@ -161,42 +161,41 @@
&-textitem-multiline { &-textitem-multiline {
display: block; display: block;
} }
}
&-property-field .adf-property-clear-value { .mat-form-field {
display: none; .mat-form-field-suffix {
} .mat-icon {
&-property-field {
.adf-property-clear-value,
.adf-textitem-edit-value {
justify-content: center;
align-items: center;
width: 30px; width: 30px;
height: 30px; height: 30px;
} }
.adf-textitem-edit-value {
display: flex;
}
.adf-property-field-content {
display: flex;
}
}
&-property-field.adf-card-textitem-field:hover {
.adf-textitem-edit-value,
.adf-textitem-edit-icon { .adf-textitem-edit-icon {
display: block;
}
.adf-textitem-clear-icon {
display: none; display: none;
} }
.adf-property-clear-value { .adf-textitem-edit-icon,
color: var(--adf-theme-foreground-text-color-025); .adf-textitem-clear-icon {
display: flex; background: transparent;
border: none;
&:hover {
cursor: pointer;
}
} }
.adf-property-clear-value:hover { &:hover {
color: var(--adf-theme-foreground-text-color); .adf-textitem-edit-icon {
display: none;
}
.adf-textitem-clear-icon {
display: block;
}
} }
} }
} }

View File

@ -460,7 +460,7 @@ describe('CardViewTextItemComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
fixture.detectChanges(); fixture.detectChanges();
const clickEl = fixture.debugElement.query(By.css(`.adf-property-clear-value`)); const clickEl = fixture.debugElement.query(By.css(`.adf-textitem-clear-icon`));
clickEl.triggerEventHandler('click', new MouseEvent('click')); clickEl.triggerEventHandler('click', new MouseEvent('click'));
fixture.detectChanges(); fixture.detectChanges();

View File

@ -7,12 +7,6 @@
margin-top: 6px; margin-top: 6px;
} }
.adf-property-read-only {
.mat-form-field-underline {
display: none;
}
}
.adf-property-field { .adf-property-field {
width: 100%; width: 100%;
margin-bottom: -25px; margin-bottom: -25px;
@ -24,24 +18,6 @@
.mat-form-field-label { .mat-form-field-label {
margin-top: 6px; margin-top: 6px;
} }
.adf-property-read-only {
.mat-form-field-underline {
display: none;
}
}
}
.adf-property-label {
font-size: var(--theme-caption-font-size);
color: var(--adf-theme-foreground-text-color-054);
word-wrap: break-word;
}
.adf-property-value,
.mat-form-field-label {
font-size: var(--theme-body-1-font-size);
color: var(--adf-theme-foreground-text-color-087);
} }
} }
} }

View File

@ -5,10 +5,6 @@ ul > li > form-field > .adf-focus {
} }
} }
.mat-form-field-label {
color: var(--adf-theme-mat-grey-color-a200-dark) !important;
}
.adf { .adf {
&-error-container { &-error-container {
height: 20px; height: 20px;

View File

@ -24,13 +24,13 @@ export class CardTextItemPage {
saveButton = 'button[data-automation-id*="card-textitem-update"]'; saveButton = 'button[data-automation-id*="card-textitem-update"]';
clearButton = 'button[data-automation-id*="card-textitem-reset"]'; clearButton = 'button[data-automation-id*="card-textitem-reset"]';
field = '[data-automation-id*="card-textitem-value"]'; field = '[data-automation-id*="card-textitem-value"]';
labelLocator = 'div[data-automation-id*="card-textitem-label"]'; labelLocator = '[data-automation-id*="card-textitem-label"]';
errorMessage = '.adf-textitem-editable-error'; errorMessage = '.adf-textitem-editable-error';
clickableElement = '.adf-textitem-clickable'; clickableElement = '.adf-textitem-clickable';
readOnlyField = '.adf-property-read-only'; readOnlyField = '.adf-property-read-only';
constructor(label: string = 'assignee') { constructor(label: string = 'assignee') {
this.rootElement = element(by.xpath(`//div[contains(@data-automation-id, "card-textitem-label-${label}")]//ancestor::adf-card-view-textitem`)); this.rootElement = element(by.xpath(`//mat-label[contains(@data-automation-id, "card-textitem-label-${label}")]//ancestor::adf-card-view-textitem`));
} }
async getFieldValue(): Promise<string> { async getFieldValue(): Promise<string> {