[ADF-4795] The form is editable after completing the task in APS (#4979)

* [ADF-4795] Form should not be editable when a task is completed

* add unit test
This commit is contained in:
davidcanonieto 2019-08-07 15:08:57 +01:00 committed by Eugenio Romano
parent e8f179e84d
commit deca68e5b2
2 changed files with 20 additions and 1 deletions

View File

@ -292,6 +292,21 @@ describe('TaskHeaderComponent', () => {
});
}));
it('should set clickable to false if the task has already completed', async(() => {
component.taskDetails.endDate = new Date('05/05/2002');
component.formName = 'test form';
component.refreshData();
fixture.detectChanges();
fixture.whenStable().then(() => {
const clickableForm = fixture.debugElement.query(By.css('[data-automation-id="header-formName"] .adf-textitem-clickable-value'));
expect(clickableForm).toBeNull();
const readOnlyForm = fixture.debugElement.query(By.css('[data-automation-id="header-formName"] .adf-textitem-ellipsis'));
expect(readOnlyForm.nativeElement.innerText).toBe('test form');
});
}));
it('should display the default parent value if is undefined', async(() => {
component.taskDetails.processInstanceId = null;
component.refreshData();

View File

@ -190,7 +190,7 @@ export class TaskHeaderComponent implements OnChanges, OnInit {
value: this.formName,
key: 'formName',
default: this.translationService.instant('ADF_TASK_LIST.PROPERTIES.FORM_NAME_DEFAULT'),
clickable: !!this.formName,
clickable: this.isFormClickable(),
icon: 'create'
}
)
@ -311,6 +311,10 @@ export class TaskHeaderComponent implements OnChanges, OnInit {
return this.taskDetails && !!this.taskDetails.endDate;
}
isFormClickable(): boolean {
return !!this.formName && !this.isCompleted();
}
getTaskDuration(): string {
return this.taskDetails.duration ? `${this.taskDetails.duration} ms` : '';
}