mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-6722] aca custom aspect property of d date type breaks application (#9331)
* [ACS-6722] fix custom date property parsing, delete reduntant function calls in templates * [ACS-6722] add unit test
This commit is contained in:
committed by
GitHub
parent
8d5f3c9884
commit
a8d547c7b4
@@ -2,19 +2,19 @@
|
|||||||
<div class="adf-property-value adf-card-view-array-item-container">
|
<div class="adf-property-value adf-card-view-array-item-container">
|
||||||
<ng-container *ngIf="(property.displayValue | async) as items; else elseEmptyValueBlock">
|
<ng-container *ngIf="(property.displayValue | async) as items; else elseEmptyValueBlock">
|
||||||
<mat-chip-list *ngIf="items.length > 0; else elseEmptyValueBlock" data-automation-id="card-arrayitem-chip-list-container">
|
<mat-chip-list *ngIf="items.length > 0; else elseEmptyValueBlock" data-automation-id="card-arrayitem-chip-list-container">
|
||||||
<ng-container *ngIf="displayCount() > 0; else withOutDisplayCount" >
|
<ng-container *ngIf="displayCount > 0; else withOutDisplayCount" >
|
||||||
<mat-chip
|
<mat-chip
|
||||||
*ngFor="let item of items.slice(0, displayCount())"
|
*ngFor="let item of items.slice(0, displayCount)"
|
||||||
(click)="clicked()"
|
(click)="clicked()"
|
||||||
[attr.data-automation-id]="'card-arrayitem-chip-' + item.value">
|
[attr.data-automation-id]="'card-arrayitem-chip-' + item.value">
|
||||||
<mat-icon *ngIf="item?.icon" class="adf-array-item-icon">{{item.icon}}</mat-icon>
|
<mat-icon *ngIf="item?.icon" class="adf-array-item-icon">{{item.icon}}</mat-icon>
|
||||||
<span>{{item?.value}}</span>
|
<span>{{item?.value}}</span>
|
||||||
</mat-chip>
|
</mat-chip>
|
||||||
<mat-chip
|
<mat-chip
|
||||||
*ngIf="items.length > displayCount()"
|
*ngIf="items.length > displayCount"
|
||||||
data-automation-id="card-arrayitem-more-chip"
|
data-automation-id="card-arrayitem-more-chip"
|
||||||
[matMenuTriggerFor]="menu">
|
[matMenuTriggerFor]="menu">
|
||||||
<span>{{items.length - displayCount()}} {{'CORE.CARDVIEW.MORE' | translate}}</span>
|
<span>{{items.length - displayCount}} {{'CORE.CARDVIEW.MORE' | translate}}</span>
|
||||||
</mat-chip>
|
</mat-chip>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-template #withOutDisplayCount>
|
<ng-template #withOutDisplayCount>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<mat-chip-list>
|
<mat-chip-list>
|
||||||
<mat-chip (click)="clicked()"
|
<mat-chip (click)="clicked()"
|
||||||
*ngFor="let item of items.slice(displayCount(), items.length)"
|
*ngFor="let item of items.slice(displayCount, items.length)"
|
||||||
[attr.data-automation-id]="'card-arrayitem-chip-' + item.value">
|
[attr.data-automation-id]="'card-arrayitem-chip-' + item.value">
|
||||||
<mat-icon *ngIf="item?.icon" class="adf-array-item-icon">{{item.icon}}</mat-icon>
|
<mat-icon *ngIf="item?.icon" class="adf-array-item-icon">{{item.icon}}</mat-icon>
|
||||||
<span>{{item?.value}}</span>
|
<span>{{item?.value}}</span>
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
<ng-template #elseEmptyValueBlock>
|
<ng-template #elseEmptyValueBlock>
|
||||||
<span class="adf-card-array-item-default" data-automation-id="card-arrayitem-default">{{ property?.default | translate }}</span>
|
<span class="adf-card-array-item-default" data-automation-id="card-arrayitem-default">{{ property?.default | translate }}</span>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<button mat-icon-button *ngIf="showClickableIcon()"
|
<button mat-icon-button *ngIf="showClickableIcon"
|
||||||
(click)="clicked()"
|
(click)="clicked()"
|
||||||
class="adf-array-item-action"
|
class="adf-array-item-action"
|
||||||
[attr.aria-label]="'CORE.METADATA.ACTIONS.EDIT' | translate"
|
[attr.aria-label]="'CORE.METADATA.ACTIONS.EDIT' | translate"
|
||||||
|
@@ -27,20 +27,20 @@ import { BaseCardView } from '../base-card-view';
|
|||||||
})
|
})
|
||||||
export class CardViewArrayItemComponent extends BaseCardView<CardViewArrayItemModel> {
|
export class CardViewArrayItemComponent extends BaseCardView<CardViewArrayItemModel> {
|
||||||
clicked(): void {
|
clicked(): void {
|
||||||
if (this.isClickable()) {
|
if (this.isClickable) {
|
||||||
this.cardViewUpdateService.clicked(this.property);
|
this.cardViewUpdateService.clicked(this.property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showClickableIcon(): boolean {
|
get showClickableIcon(): boolean {
|
||||||
return this.hasIcon && this.isClickable();
|
return this.hasIcon && this.isClickable;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayCount(): number {
|
get displayCount(): number {
|
||||||
return this.property.noOfItemsToDisplay ? this.property.noOfItemsToDisplay : 0;
|
return this.property.noOfItemsToDisplay ? this.property.noOfItemsToDisplay : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
isClickable(): boolean {
|
get isClickable(): boolean {
|
||||||
return !!this.property.clickable;
|
return !!this.property.clickable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<label class="adf-property-label"
|
<label class="adf-property-label"
|
||||||
[attr.data-automation-id]="'card-dateitem-label-' + property.key"
|
[attr.data-automation-id]="'card-dateitem-label-' + property.key"
|
||||||
*ngIf="showProperty() || isEditable"
|
*ngIf="showProperty || isEditable"
|
||||||
[attr.for]="'card-view-dateitem-' + property.key"
|
[attr.for]="'card-view-dateitem-' + property.key"
|
||||||
[ngClass]="{'adf-property-readonly-value': isReadonlyProperty, 'adf-property-value-editable': editable}">
|
[ngClass]="{'adf-property-readonly-value': isReadonlyProperty, 'adf-property-value-editable': editable}">
|
||||||
{{ property.label | translate }}
|
{{ property.label | translate }}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
<div class="adf-property-value" [ngClass]="{'adf-property-value-editable': editable, 'adf-property-readonly-value': isReadonlyProperty}">
|
<div class="adf-property-value" [ngClass]="{'adf-property-value-editable': editable, 'adf-property-readonly-value': isReadonlyProperty}">
|
||||||
<span *ngIf="!isEditable && !property.multivalued"
|
<span *ngIf="!isEditable && !property.multivalued"
|
||||||
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
|
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
|
||||||
<span *ngIf="showProperty()"
|
<span *ngIf="showProperty"
|
||||||
[attr.data-automation-id]="'card-dateitem-' + property.key"
|
[attr.data-automation-id]="'card-dateitem-' + property.key"
|
||||||
(dblclick)="copyToClipboard(property.displayValue)"
|
(dblclick)="copyToClipboard(property.displayValue)"
|
||||||
matTooltipShowDelay="1000"
|
matTooltipShowDelay="1000"
|
||||||
@@ -19,13 +19,13 @@
|
|||||||
<span class="adf-datepicker-toggle"
|
<span class="adf-datepicker-toggle"
|
||||||
[attr.data-automation-id]="'datepicker-label-toggle-' + property.key"
|
[attr.data-automation-id]="'datepicker-label-toggle-' + property.key"
|
||||||
(click)="showDatePicker()">
|
(click)="showDatePicker()">
|
||||||
<span *ngIf="showProperty(); else elseEmptyValueBlock"
|
<span *ngIf="showProperty; else elseEmptyValueBlock"
|
||||||
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
|
[attr.data-automation-id]="'card-' + property.type + '-value-' + property.key">
|
||||||
{{ property.displayValue }}</span>
|
{{ property.displayValue }}</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<mat-icon
|
<mat-icon
|
||||||
*ngIf="showClearAction()"
|
*ngIf="showClearAction"
|
||||||
class="adf-date-reset-icon"
|
class="adf-date-reset-icon"
|
||||||
(click)="onDateClear()"
|
(click)="onDateClear()"
|
||||||
[attr.title]="'CORE.METADATA.ACTIONS.CLEAR' | translate"
|
[attr.title]="'CORE.METADATA.ACTIONS.CLEAR' | translate"
|
||||||
|
@@ -84,15 +84,15 @@ export class CardViewDateItemComponent extends BaseCardView<CardViewDateItemMode
|
|||||||
super.ngOnDestroy();
|
super.ngOnDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
showProperty(): boolean {
|
get showProperty(): boolean {
|
||||||
return this.displayEmpty || !this.property.isEmpty();
|
return this.displayEmpty || !this.property.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
showClearAction(): boolean {
|
get showClearAction(): boolean {
|
||||||
return this.displayClearAction && (!this.property.isEmpty() || !!this.property.default);
|
return this.displayClearAction && (!this.property.isEmpty() || !!this.property.default);
|
||||||
}
|
}
|
||||||
|
|
||||||
showDatePicker() {
|
showDatePicker(): void {
|
||||||
this.datepicker.open();
|
this.datepicker.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,18 +1,18 @@
|
|||||||
<div [attr.data-automation-id]="'card-mapitem-label-' + property.key"
|
<div [attr.data-automation-id]="'card-mapitem-label-' + property.key"
|
||||||
class="adf-property-label"
|
class="adf-property-label"
|
||||||
*ngIf="showProperty()">{{ property.label | translate }}</div>
|
*ngIf="showProperty">{{ property.label | translate }}</div>
|
||||||
<div class="adf-property-value adf-map-item-padding">
|
<div class="adf-property-value adf-map-item-padding">
|
||||||
<div>
|
<div>
|
||||||
<span *ngIf="!isClickable(); else clickableTemplate"
|
<span *ngIf="!isClickable; else clickableTemplate"
|
||||||
[attr.data-automation-id]="'card-mapitem-value-' + property.key">
|
[attr.data-automation-id]="'card-mapitem-value-' + property.key">
|
||||||
<span *ngIf="showProperty();">{{ property.displayValue }}</span>
|
<span *ngIf="showProperty;">{{ property.displayValue }}</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<ng-template #clickableTemplate>
|
<ng-template #clickableTemplate>
|
||||||
<span class="adf-mapitem-clickable-value"
|
<span class="adf-mapitem-clickable-value"
|
||||||
(click)="clicked()"
|
(click)="clicked()"
|
||||||
[attr.data-automation-id]="'card-mapitem-value-' + property.key">
|
[attr.data-automation-id]="'card-mapitem-value-' + property.key">
|
||||||
<span *ngIf="showProperty(); else emptyValueTemplate">{{ property.displayValue }}</span>
|
<span *ngIf="showProperty; else emptyValueTemplate">{{ property.displayValue }}</span>
|
||||||
</span>
|
</span>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template #emptyValueTemplate>
|
<ng-template #emptyValueTemplate>
|
||||||
|
@@ -29,11 +29,11 @@ export class CardViewMapItemComponent extends BaseCardView<CardViewMapItemModel>
|
|||||||
@Input()
|
@Input()
|
||||||
displayEmpty: boolean = true;
|
displayEmpty: boolean = true;
|
||||||
|
|
||||||
showProperty() {
|
get showProperty(): boolean {
|
||||||
return this.displayEmpty || !this.property.isEmpty();
|
return this.displayEmpty || !this.property.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
isClickable() {
|
get isClickable(): boolean {
|
||||||
return this.property.clickable;
|
return this.property.clickable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -125,4 +125,11 @@ describe('DateFnsUtils', () => {
|
|||||||
const result = DateFnsUtils.isValidDate('2021-06-09 14:10', 'D-M-YYYY hh:mm A');
|
const result = DateFnsUtils.isValidDate('2021-06-09 14:10', 'D-M-YYYY hh:mm A');
|
||||||
expect(result).toBeFalse();
|
expect(result).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return Date when forcing locale or UTC with string date argument', () => {
|
||||||
|
const resultLocal = DateFnsUtils.forceLocal('2014-02-11T11:30:30');
|
||||||
|
const resultUtc = DateFnsUtils.forceUtc('2014-02-11T11:30:30');
|
||||||
|
expect(resultLocal).toBeInstanceOf(Date);
|
||||||
|
expect(resultUtc).toBeInstanceOf(Date);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -203,11 +203,17 @@ export class DateFnsUtils {
|
|||||||
return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
|
return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
static forceLocal(date: Date): Date {
|
static forceLocal(date: string | Date): Date {
|
||||||
|
if (typeof date === 'string'){
|
||||||
|
date = parseISO(date);
|
||||||
|
}
|
||||||
return new Date(lightFormat(date, 'yyyy-MM-dd'));
|
return new Date(lightFormat(date, 'yyyy-MM-dd'));
|
||||||
}
|
}
|
||||||
|
|
||||||
static forceUtc(date: Date): Date {
|
static forceUtc(date: string | Date): Date {
|
||||||
|
if (typeof date === 'string'){
|
||||||
|
date = parseISO(date);
|
||||||
|
}
|
||||||
return new Date(lightFormat(date, 'yyyy-MM-dd').concat('T00:00:00.000Z'));
|
return new Date(lightFormat(date, 'yyyy-MM-dd').concat('T00:00:00.000Z'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user