mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3571] Fix Dates on Task List Component (#3919)
* [ADF-3571] Fix Dates on Task List Component * [ADF-3571] Fix unit test * [ADF-3571] Fix unit test
This commit is contained in:
committed by
Eugenio Romano
parent
baf6050111
commit
eceec31089
@@ -122,9 +122,9 @@ describe('TaskListComponent', () => {
|
||||
expect(component.rows[0]['assignee'].firstName).toEqual('firstNameFake1');
|
||||
expect(component.rows[0]['assignee'].lastName).toEqual('lastNameFake1');
|
||||
expect(component.rows[0][('assignee')].email).toEqual('emailFake1');
|
||||
expect(component.rows[0]['created']).toEqual('2017-03-01T12:25:17.189+0000');
|
||||
expect(component.rows[0]['dueDate']).toEqual('2017-04-02T12:25:17.189+0000');
|
||||
expect(component.rows[0]['endDate']).toEqual('2017-05-03T12:25:31.129+0000');
|
||||
expect(component.rows[0]['created']).toEqual('Mar 1, 2017');
|
||||
expect(component.rows[0]['dueDate']).toEqual('Apr 2, 2017');
|
||||
expect(component.rows[0]['endDate']).toEqual('May 3, 2017');
|
||||
expect(component.rows[0]['duration']).toEqual(13940);
|
||||
expect(component.rows[0]['priority']).toEqual(50);
|
||||
expect(component.rows[0]['parentTaskId']).toEqual(1);
|
||||
|
@@ -38,6 +38,7 @@ import moment from 'moment-es6';
|
||||
export class TaskListComponent extends DataTableSchema implements OnChanges, AfterContentInit, PaginatedComponent {
|
||||
|
||||
static PRESET_KEY = 'adf-task-list.presets';
|
||||
public FORMAT_DATE: string = 'll';
|
||||
|
||||
@ContentChild(EmptyCustomContentDirective) emptyCustomContent: EmptyCustomContentDirective;
|
||||
|
||||
@@ -251,7 +252,7 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
|
||||
this.isLoading = true;
|
||||
this.loadTasksByState().subscribe(
|
||||
(tasks) => {
|
||||
this.rows = this.optimizeNames(tasks.data);
|
||||
this.rows = this.optimizeTaskDetails(tasks.data);
|
||||
this.selectTask(this.landingTaskId);
|
||||
this.success.emit(tasks);
|
||||
this.isLoading = false;
|
||||
@@ -345,12 +346,21 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
|
||||
* Optimize name field
|
||||
* @param instances
|
||||
*/
|
||||
private optimizeNames(instances: any[]): any[] {
|
||||
instances = instances.map(t => {
|
||||
if (!t.name) {
|
||||
t.name = 'No name';
|
||||
private optimizeTaskDetails(instances: any[]): any[] {
|
||||
instances = instances.map(task => {
|
||||
if (!task.name) {
|
||||
task.name = 'No name';
|
||||
}
|
||||
return t;
|
||||
if (task.created) {
|
||||
task.created = moment(task.created).format(this.FORMAT_DATE);
|
||||
}
|
||||
if (task.dueDate) {
|
||||
task.dueDate = moment(task.dueDate).format(this.FORMAT_DATE);
|
||||
}
|
||||
if (task.endDate) {
|
||||
task.endDate = moment(task.endDate).format(this.FORMAT_DATE);
|
||||
}
|
||||
return task;
|
||||
});
|
||||
return instances;
|
||||
}
|
||||
|
Reference in New Issue
Block a user