mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-463] - change dueDate render component (#5200)
* change dueDate render component * fix tests * fix lint * rebase and add test * split code into 2 declarations
This commit is contained in:
committed by
Eugenio Romano
parent
f20b78a2c5
commit
b41514cad7
@@ -26,19 +26,22 @@ import { TasksCloudDemoPage } from '../pages/adf/demo-shell/process-services/tas
|
|||||||
describe('Task Header cloud component', () => {
|
describe('Task Header cloud component', () => {
|
||||||
const basicCreatedTaskName = StringUtil.generateRandomString();
|
const basicCreatedTaskName = StringUtil.generateRandomString();
|
||||||
const completedTaskName = StringUtil.generateRandomString();
|
const completedTaskName = StringUtil.generateRandomString();
|
||||||
let basicCreatedTask;
|
let basicCreatedTask: any;
|
||||||
let basicCreatedDate;
|
let basicCreatedDate: any;
|
||||||
let completedTask;
|
let completedTask: any;
|
||||||
let completedCreatedDate;
|
let completedCreatedDate: string;
|
||||||
let subTask;
|
let dueDate: string;
|
||||||
let subTaskCreatedDate;
|
let subTask: any;
|
||||||
let completedEndDate;
|
let subTaskCreatedDate: string;
|
||||||
let defaultDate;
|
let completedEndDate: string;
|
||||||
let groupInfo, testUser;
|
let defaultDate: string;
|
||||||
|
let groupInfo: any;
|
||||||
|
let testUser: any;
|
||||||
const simpleApp = browser.params.resources.ACTIVITI_CLOUD_APPS.SIMPLE_APP.name;
|
const simpleApp = browser.params.resources.ACTIVITI_CLOUD_APPS.SIMPLE_APP.name;
|
||||||
const priority = 30;
|
const priority = 30;
|
||||||
const description = 'descriptionTask';
|
const description = 'descriptionTask';
|
||||||
const formatDate = 'MMM D, YYYY';
|
const formatDate = 'MMM D, YYYY';
|
||||||
|
const dateTimeFormat = 'MMM D, Y, H:mm';
|
||||||
const defaultFormat = 'M/D/YY';
|
const defaultFormat = 'M/D/YY';
|
||||||
|
|
||||||
const taskHeaderCloudPage = new TaskHeaderCloudPage();
|
const taskHeaderCloudPage = new TaskHeaderCloudPage();
|
||||||
@@ -75,6 +78,7 @@ describe('Task Header cloud component', () => {
|
|||||||
await tasksService.completeTask(completedTaskId.entry.id, simpleApp);
|
await tasksService.completeTask(completedTaskId.entry.id, simpleApp);
|
||||||
completedTask = await tasksService.getTask(completedTaskId.entry.id, simpleApp);
|
completedTask = await tasksService.getTask(completedTaskId.entry.id, simpleApp);
|
||||||
completedCreatedDate = moment(completedTask.entry.createdDate).format(formatDate);
|
completedCreatedDate = moment(completedTask.entry.createdDate).format(formatDate);
|
||||||
|
dueDate = moment(completedTask.entry.createdDate).format(dateTimeFormat);
|
||||||
completedEndDate = moment(completedTask.entry.endDate).format(formatDate);
|
completedEndDate = moment(completedTask.entry.endDate).format(formatDate);
|
||||||
defaultDate = moment(completedTask.entry.createdDate).format(defaultFormat);
|
defaultDate = moment(completedTask.entry.createdDate).format(defaultFormat);
|
||||||
|
|
||||||
@@ -130,7 +134,7 @@ describe('Task Header cloud component', () => {
|
|||||||
await expect(await taskHeaderCloudPage.getCategory()).toEqual(!completedTask.entry.category ?
|
await expect(await taskHeaderCloudPage.getCategory()).toEqual(!completedTask.entry.category ?
|
||||||
CONSTANTS.TASK_DETAILS.NO_CATEGORY : completedTask.entry.category);
|
CONSTANTS.TASK_DETAILS.NO_CATEGORY : completedTask.entry.category);
|
||||||
await expect(await taskHeaderCloudPage.getDueDate()).toEqual(completedTask.entry.dueDate === null ?
|
await expect(await taskHeaderCloudPage.getDueDate()).toEqual(completedTask.entry.dueDate === null ?
|
||||||
CONSTANTS.TASK_DETAILS.NO_DATE : completedCreatedDate);
|
CONSTANTS.TASK_DETAILS.NO_DATE : dueDate);
|
||||||
await expect(await taskHeaderCloudPage.getEndDate()).toEqual(completedEndDate);
|
await expect(await taskHeaderCloudPage.getEndDate()).toEqual(completedEndDate);
|
||||||
await expect(await taskHeaderCloudPage.getCreated()).toEqual(completedCreatedDate);
|
await expect(await taskHeaderCloudPage.getCreated()).toEqual(completedCreatedDate);
|
||||||
await expect(await taskHeaderCloudPage.getAssignee()).toEqual(completedTask.entry.assignee === null ? '' : completedTask.entry.assignee);
|
await expect(await taskHeaderCloudPage.getAssignee()).toEqual(completedTask.entry.assignee === null ? '' : completedTask.entry.assignee);
|
||||||
|
@@ -25,6 +25,7 @@ import { of, throwError } from 'rxjs';
|
|||||||
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { TaskCloudService } from '../../services/task-cloud.service';
|
import { TaskCloudService } from '../../services/task-cloud.service';
|
||||||
|
import moment = require('moment');
|
||||||
|
|
||||||
describe('TaskHeaderCloudComponent', () => {
|
describe('TaskHeaderCloudComponent', () => {
|
||||||
let component: TaskHeaderCloudComponent;
|
let component: TaskHeaderCloudComponent;
|
||||||
@@ -138,7 +139,7 @@ describe('TaskHeaderCloudComponent', () => {
|
|||||||
|
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
const valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-dueDate"] .adf-property-value'));
|
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(moment(assignedTaskDetailsCloudMock.dueDate, 'x').format('MMM D, Y, H:mm'));
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@@ -25,7 +25,8 @@ import {
|
|||||||
TranslationService,
|
TranslationService,
|
||||||
AppConfigService,
|
AppConfigService,
|
||||||
UpdateNotification,
|
UpdateNotification,
|
||||||
CardViewUpdateService
|
CardViewUpdateService,
|
||||||
|
CardViewDatetimeItemModel
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { TaskDetailsCloudModel, TaskStatusEnum } from '../../start-task/models/task-details-cloud.model';
|
import { TaskDetailsCloudModel, TaskStatusEnum } from '../../start-task/models/task-details-cloud.model';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
@@ -66,6 +67,7 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
inEdit: boolean = false;
|
inEdit: boolean = false;
|
||||||
parentTaskName: string;
|
parentTaskName: string;
|
||||||
dateFormat: string;
|
dateFormat: string;
|
||||||
|
dateTimeFormat: string;
|
||||||
dateLocale: string;
|
dateLocale: string;
|
||||||
displayDateClearAction = false;
|
displayDateClearAction = false;
|
||||||
|
|
||||||
@@ -80,6 +82,7 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
) {
|
) {
|
||||||
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
|
this.dateFormat = this.appConfig.get('dateValues.defaultDateFormat');
|
||||||
this.dateLocale = this.appConfig.get('dateValues.defaultDateLocale');
|
this.dateLocale = this.appConfig.get('dateValues.defaultDateLocale');
|
||||||
|
this.dateTimeFormat = this.appConfig.get('dateValue.defaultDateTimeFormat');
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -145,14 +148,14 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges {
|
|||||||
validators: [new NumericFieldValidator()]
|
validators: [new NumericFieldValidator()]
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
new CardViewDateItemModel(
|
new CardViewDatetimeItemModel(
|
||||||
{
|
{
|
||||||
label: 'ADF_CLOUD_TASK_HEADER.PROPERTIES.DUE_DATE',
|
label: 'ADF_CLOUD_TASK_HEADER.PROPERTIES.DUE_DATE',
|
||||||
value: this.taskDetails.dueDate,
|
value: this.taskDetails.dueDate,
|
||||||
key: 'dueDate',
|
key: 'dueDate',
|
||||||
default: this.translationService.instant('ADF_CLOUD_TASK_HEADER.PROPERTIES.DUE_DATE_DEFAULT'),
|
default: this.translationService.instant('ADF_CLOUD_TASK_HEADER.PROPERTIES.DUE_DATE_DEFAULT'),
|
||||||
editable: true,
|
editable: true,
|
||||||
format: this.dateFormat,
|
format: this.dateTimeFormat,
|
||||||
locale: this.dateLocale
|
locale: this.dateLocale
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
@@ -26,7 +26,7 @@ export const assignedTaskDetailsCloudMock = new TaskDetailsCloudModel(
|
|||||||
'name': 'This is a new task ',
|
'name': 'This is a new task ',
|
||||||
'description': 'This is the description ',
|
'description': 'This is the description ',
|
||||||
'createdDate': 1545048055900,
|
'createdDate': 1545048055900,
|
||||||
'dueDate': 1545091200000,
|
'dueDate': Date.now(),
|
||||||
'claimedDate': null,
|
'claimedDate': null,
|
||||||
'priority': 5,
|
'priority': 5,
|
||||||
'category': null,
|
'category': null,
|
||||||
|
Reference in New Issue
Block a user