mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-9200] - Be able to customise task/process list and header date f… (#7711)
* [AAE-9200] - Be able to customise task/process list and header date formats * Update json schema * Revert schema changes * Update task and process name translation values * move task/process header date formats inside header config * Add documentation * Update documentation * Use a fixed timezone for unit tests of core and cloud * Fix e2e due to column rename * More e2e fixes due to column rename, remove test covered by unit test
This commit is contained in:
@@ -84,4 +84,5 @@ module.exports = function (config) {
|
||||
browsers: ['Chrome'],
|
||||
singleRun: false
|
||||
});
|
||||
process.env.TZ = 'UTC';
|
||||
};
|
||||
|
@@ -6,7 +6,7 @@
|
||||
"NONE": "No process instance filter selected."
|
||||
},
|
||||
"PROPERTIES": {
|
||||
"NAME": "Name",
|
||||
"NAME": "Process Name",
|
||||
"CREATED": "Created",
|
||||
"STATUS": "Status",
|
||||
"START_DATE": "Start Date",
|
||||
@@ -83,7 +83,7 @@
|
||||
}
|
||||
},
|
||||
"PROPERTIES": {
|
||||
"NAME": "Name",
|
||||
"NAME": "Task Name",
|
||||
"ASSIGNEE": "Assignee",
|
||||
"ID": "Id",
|
||||
"STATUS": "Status",
|
||||
|
@@ -34,7 +34,7 @@ export const processInstancePlaceholdersCloudMock: ProcessInstanceCloud = {
|
||||
businessKey: '',
|
||||
id: '00fcc4ab-4290-11e9-b133-0a586460016a',
|
||||
initiator: 'devopsuser',
|
||||
lastModified: new Date(1552152187081),
|
||||
lastModified: new Date(2022, 1, 1, 1, 30, 40),
|
||||
name: '',
|
||||
parentId: '',
|
||||
startDate: new Date(1552152187080),
|
||||
|
@@ -206,4 +206,28 @@ describe('ProcessHeaderCloudComponent', () => {
|
||||
expect(propertyList[1].nativeElement.textContent).toContain('ADF_CLOUD_PROCESS_HEADER.PROPERTIES.NAME');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Date values format', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
appConfigService.config = {
|
||||
'adf-cloud-process-header': {
|
||||
defaultDateFormat: 'full'
|
||||
}
|
||||
};
|
||||
component.ngOnInit();
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('should format the dates based on app config format configuration', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
const startedDateElement = fixture.debugElement.query(By.css('[data-automation-id="header-startDate"] .adf-property-value'));
|
||||
const lastModifiedElement = fixture.debugElement.query(By.css('[data-automation-id="header-lastModified"] .adf-property-value'));
|
||||
|
||||
expect(component.dateFormat).toEqual('full');
|
||||
expect(startedDateElement.nativeElement.innerText.trim()).toBe('Saturday, March 9, 2019 at 5:23:07 PM GMT+00:00');
|
||||
expect(lastModifiedElement.nativeElement.innerText.trim()).toBe('Saturday, March 9, 2019 at 5:23:07 PM GMT+00:00');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -55,7 +55,7 @@ export class ProcessHeaderCloudComponent implements OnChanges, OnInit, OnDestroy
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
|
||||
this.dateFormat = this.appConfig.get('adf-cloud-process-header.defaultDateFormat');
|
||||
this.dateLocale = this.appConfig.get('dateValues.defaultDateLocale');
|
||||
|
||||
this.processCloudService.dataChangesDetected
|
||||
|
@@ -31,7 +31,6 @@ import {
|
||||
taskDetailsWithParentTaskIdMock,
|
||||
createdTaskDetailsCloudMock
|
||||
} from '../mocks/task-details-cloud.mock';
|
||||
import moment from 'moment-es6';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
|
||||
@@ -67,9 +66,14 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
appConfigService = TestBed.inject(AppConfigService);
|
||||
appConfigService.config = {
|
||||
'adf-cloud-task-header': {
|
||||
defaultDateFormat: 'full'
|
||||
}
|
||||
};
|
||||
fixture = TestBed.createComponent(TaskHeaderCloudComponent);
|
||||
component = fixture.componentInstance;
|
||||
appConfigService = TestBed.inject(AppConfigService);
|
||||
taskCloudService = TestBed.inject(TaskCloudService);
|
||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||
component.appName = 'mock-app-name';
|
||||
@@ -103,7 +107,7 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
expect(taskTitle).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should fectch task details when appName and taskId defined', async () => {
|
||||
it('should fetch task details when appName and taskId defined', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(getTaskByIdSpy).toHaveBeenCalled();
|
||||
@@ -149,7 +153,7 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));
|
||||
expect(valueEl.nativeElement.innerText.trim()).toBe(moment(assignedTaskDetailsCloudMock.dueDate, 'x').format('MMM D, Y, H:mm'));
|
||||
expect(valueEl.nativeElement.innerText.trim()).toBe('Monday, December 17, 2018 at 12:00:55 PM GMT+00:00');
|
||||
});
|
||||
|
||||
it('should display process instance id', async () => {
|
||||
@@ -501,7 +505,13 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
describe('Config properties', () => {
|
||||
|
||||
it('should show only the properties from the configuration file', async () => {
|
||||
spyOn(appConfigService, 'get').and.returnValue(['assignee', 'status']);
|
||||
appConfigService.config = {
|
||||
'adf-cloud-task-header': {
|
||||
presets: {
|
||||
properties: ['assignee', 'status']
|
||||
}
|
||||
}
|
||||
};
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
const propertyList = fixture.debugElement.queryAll(By.css('.adf-property-list .adf-property'));
|
||||
@@ -527,6 +537,18 @@ describe('TaskHeaderCloudComponent', () => {
|
||||
expect(propertyList[0].nativeElement.textContent).toContain('ADF_CLOUD_TASK_HEADER.PROPERTIES.ASSIGNEE');
|
||||
expect(propertyList[1].nativeElement.textContent).toContain('ADF_CLOUD_TASK_HEADER.PROPERTIES.STATUS');
|
||||
});
|
||||
|
||||
it('should format the dates based on app config format configuration', async () => {
|
||||
component.ngOnInit();
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
const createdDateElement = fixture.debugElement.query(By.css('[data-automation-id="header-created"] .adf-property-value'));
|
||||
|
||||
expect(component.dateFormat).toEqual('full');
|
||||
expect(createdDateElement.nativeElement.innerText.trim()).toBe('Monday, December 17, 2018 at 12:00:55 PM GMT+00:00');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Task errors', () => {
|
||||
|
@@ -74,7 +74,6 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges {
|
||||
inEdit: boolean = false;
|
||||
parentTaskName: string;
|
||||
dateFormat: string;
|
||||
dateTimeFormat: string;
|
||||
dateLocale: string;
|
||||
displayDateClearAction = false;
|
||||
isLoading = true;
|
||||
@@ -88,9 +87,8 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges {
|
||||
private appConfig: AppConfigService,
|
||||
private cardViewUpdateService: CardViewUpdateService
|
||||
) {
|
||||
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
|
||||
this.dateFormat = this.appConfig.get('adf-cloud-task-header.defaultDateFormat');
|
||||
this.dateLocale = this.appConfig.get('dateValues.defaultDateLocale');
|
||||
this.dateTimeFormat = this.appConfig.get('dateValue.defaultDateTimeFormat');
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -178,7 +176,7 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges {
|
||||
key: 'dueDate',
|
||||
default: this.translationService.instant('ADF_CLOUD_TASK_HEADER.PROPERTIES.DUE_DATE_DEFAULT'),
|
||||
editable: true,
|
||||
format: this.dateTimeFormat,
|
||||
format: this.dateFormat,
|
||||
locale: this.dateLocale
|
||||
}
|
||||
),
|
||||
|
@@ -49,7 +49,7 @@ export const assignedTaskDetailsCloudMock: TaskDetailsCloudModel = {
|
||||
name: 'This is a new task',
|
||||
description: 'This is the description ',
|
||||
createdDate: new Date(1545048055900),
|
||||
dueDate: new Date(),
|
||||
dueDate: new Date(1545048055900),
|
||||
claimedDate: null,
|
||||
priority: 1,
|
||||
category: null,
|
||||
|
Reference in New Issue
Block a user