[ADF-4338] Add locale to CardViewDateItemModel and improve logic of LocalizedDat… (#4845)

* Add locale to CardViewDateItemModel and improve logic of LocalizedDatePipe

* Fix e2e tests

* Fix e2e tests

* Fix C305010 test
This commit is contained in:
davidcanonieto
2019-06-14 18:26:08 +02:00
committed by Eugenio Romano
parent e03290d26c
commit 334ebd1256
25 changed files with 110 additions and 58 deletions

View File

@@ -128,7 +128,7 @@ describe('ProcessHeaderCloudComponent', () => {
fixture.whenStable().then(() => {
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-startDate"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toBe('Mar 09 2019');
expect(valueEl.nativeElement.innerText.trim()).toBe('Mar 9, 2019');
});
}));
@@ -138,7 +138,7 @@ describe('ProcessHeaderCloudComponent', () => {
fixture.whenStable().then(() => {
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-lastModified"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toBe('Mar 09 2019');
expect(valueEl.nativeElement.innerText.trim()).toBe('Mar 9, 2019');
});
}));

View File

@@ -37,13 +37,16 @@ export class ProcessHeaderCloudComponent implements OnChanges {
processInstanceId: string;
processInstanceDetails: ProcessInstanceCloud = new ProcessInstanceCloud();
properties: CardViewItem[];
dateFormat: string;
dateLocale: string;
constructor(
private processHeaderCloudService: ProcessHeaderCloudService,
private translationService: TranslationService,
private appConfig: AppConfigService) {
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
this.dateLocale = this.appConfig.get('dateValues.defaultDateLocale');
}
ngOnChanges() {
@@ -102,13 +105,17 @@ export class ProcessHeaderCloudComponent implements OnChanges {
{
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.START_DATE',
value: this.processInstanceDetails.startDate,
key: 'startDate'
key: 'startDate',
format: this.dateFormat,
locale: this.dateLocale
}),
new CardViewDateItemModel(
{
label: 'ADF_CLOUD_PROCESS_HEADER.PROPERTIES.LAST_MODIFIED',
value: this.processInstanceDetails.lastModified,
key: 'lastModified'
key: 'lastModified',
format: this.dateFormat,
locale: this.dateLocale
}),
new CardViewTextItemModel(
{

View File

@@ -118,7 +118,7 @@ describe('TaskHeaderCloudComponent', () => {
fixture.whenStable().then(() => {
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toBe('Dec 18 2018');
expect(valueEl.nativeElement.innerText.trim()).toBe('Dec 18, 2018');
});
}));

View File

@@ -60,6 +60,7 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy {
inEdit: boolean = false;
parentTaskName: string;
dateFormat: string;
dateLocale: string;
private subscriptions: Subscription[] = [];
@@ -71,6 +72,7 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy {
private cardViewUpdateService: CardViewUpdateService
) {
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
this.dateLocale = this.appConfig.get('dateValues.defaultDateLocale');
}
ngOnInit() {
@@ -126,7 +128,9 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy {
value: this.taskDetails.dueDate,
key: 'dueDate',
default: this.translationService.instant('ADF_CLOUD_TASK_HEADER.PROPERTIES.DUE_DATE_DEFAULT'),
editable: true
editable: true,
format: this.dateFormat,
locale: this.dateLocale
}
),
new CardViewTextItemModel(
@@ -141,7 +145,9 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy {
{
label: 'ADF_CLOUD_TASK_HEADER.PROPERTIES.CREATED',
value: this.taskDetails.createdDate,
key: 'created'
key: 'created',
format: this.dateFormat,
locale: this.dateLocale
}
),
new CardViewTextItemModel(
@@ -163,7 +169,9 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy {
{
label: 'ADF_CLOUD_TASK_HEADER.PROPERTIES.END_DATE',
value: this.taskDetails.completedDate,
key: 'endDate'
key: 'endDate',
format: this.dateFormat,
locale: this.dateLocale
}
),
new CardViewTextItemModel(