mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Disable the attachment component when the task/process is completed (#2351)
This commit is contained in:
committed by
Eugenio Romano
parent
d7bd9aa50b
commit
7a31a16178
@@ -6,13 +6,14 @@
|
|||||||
[showNotificationBar]="false">
|
[showNotificationBar]="false">
|
||||||
<adf-process-attachment-list #processAttachList
|
<adf-process-attachment-list #processAttachList
|
||||||
*ngIf="processId"
|
*ngIf="processId"
|
||||||
|
[disabled]="isCompletedProcess()"
|
||||||
[processInstanceId]="processId"
|
[processInstanceId]="processId"
|
||||||
(attachmentClick)="onAttachmentClick($event)">
|
(attachmentClick)="onAttachmentClick($event)">
|
||||||
</adf-process-attachment-list>
|
</adf-process-attachment-list>
|
||||||
</adf-upload-drag-area>
|
</adf-upload-drag-area>
|
||||||
|
|
||||||
<adf-create-process-attachment
|
<adf-create-process-attachment
|
||||||
*ngIf="isRunning()"
|
*ngIf="!isCompletedProcess()"
|
||||||
[processInstanceId]="processId"
|
[processInstanceId]="processId"
|
||||||
(success)="onFileUploadComplete($event)">
|
(success)="onFileUploadComplete($event)">
|
||||||
</adf-create-process-attachment>
|
</adf-create-process-attachment>
|
||||||
|
@@ -67,8 +67,8 @@ export class ActivitiProcessAttachmentsComponent implements OnInit, OnChanges {
|
|||||||
this.contentName = content.name;
|
this.contentName = content.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
isRunning(): boolean {
|
isCompletedProcess(): boolean {
|
||||||
return this.processInstance && !this.processInstance.ended;
|
return this.processInstance && this.processInstance.ended !== undefined && this.processInstance.ended !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -7,11 +7,13 @@
|
|||||||
<adf-task-attachment-list #taskAttachList
|
<adf-task-attachment-list #taskAttachList
|
||||||
*ngIf="taskId"
|
*ngIf="taskId"
|
||||||
[taskId]="taskId"
|
[taskId]="taskId"
|
||||||
|
[disabled]="isCompletedTask()"
|
||||||
(attachmentClick)="onAttachmentClick($event)">
|
(attachmentClick)="onAttachmentClick($event)">
|
||||||
</adf-task-attachment-list>
|
</adf-task-attachment-list>
|
||||||
</adf-upload-drag-area>
|
</adf-upload-drag-area>
|
||||||
|
|
||||||
<adf-create-task-attachment
|
<adf-create-task-attachment
|
||||||
|
*ngIf="!isCompletedTask()"
|
||||||
[taskId]="taskId"
|
[taskId]="taskId"
|
||||||
(success)="onFileUploadComplete($event)">
|
(success)="onFileUploadComplete($event)">
|
||||||
</adf-create-task-attachment>
|
</adf-create-task-attachment>
|
||||||
|
@@ -15,8 +15,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
import { Component, Input, OnChanges, OnInit, ViewChild } from '@angular/core';
|
||||||
import { ProcessUploadService, TaskAttachmentListComponent } from 'ng2-activiti-tasklist';
|
import { ProcessUploadService, TaskAttachmentListComponent } from 'ng2-activiti-tasklist';
|
||||||
|
import { ActivitiTaskListService } from 'ng2-activiti-tasklist';
|
||||||
import { UploadService } from 'ng2-alfresco-core';
|
import { UploadService } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -28,7 +29,7 @@ import { UploadService } from 'ng2-alfresco-core';
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class ActivitiTaskAttachmentsComponent implements OnInit {
|
export class ActivitiTaskAttachmentsComponent implements OnInit, OnChanges {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
taskId: string;
|
taskId: string;
|
||||||
@@ -40,7 +41,10 @@ export class ActivitiTaskAttachmentsComponent implements OnInit {
|
|||||||
content: Blob;
|
content: Blob;
|
||||||
contentName: string;
|
contentName: string;
|
||||||
|
|
||||||
constructor(private uploadService: UploadService) {
|
taskDetails: any;
|
||||||
|
|
||||||
|
constructor(private uploadService: UploadService,
|
||||||
|
private activitiTaskList: ActivitiTaskListService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +52,15 @@ export class ActivitiTaskAttachmentsComponent implements OnInit {
|
|||||||
this.uploadService.fileUploadComplete.subscribe(value => this.onFileUploadComplete(value.data));
|
this.uploadService.fileUploadComplete.subscribe(value => this.onFileUploadComplete(value.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnChanges() {
|
||||||
|
if (this.taskId) {
|
||||||
|
this.activitiTaskList.getTaskDetails(this.taskId).map((res) => res).subscribe(
|
||||||
|
(res: any) => {
|
||||||
|
this.taskDetails = res;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onFileUploadComplete(content: any) {
|
onFileUploadComplete(content: any) {
|
||||||
this.taskAttachList.add(content);
|
this.taskAttachList.add(content);
|
||||||
}
|
}
|
||||||
@@ -58,4 +71,7 @@ export class ActivitiTaskAttachmentsComponent implements OnInit {
|
|||||||
this.contentName = content.name;
|
this.contentName = content.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isCompletedTask(): boolean {
|
||||||
|
return this.taskDetails && this.taskDetails.endDate !== undefined && this.taskDetails.endDate !== null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -231,6 +231,24 @@ describe('ProcessAttachmentListComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should not show the empty list drag and drop component when is disabled', async(() => {
|
||||||
|
getProcessRelatedContentSpy.and.returnValue(Observable.of({
|
||||||
|
'size': 0,
|
||||||
|
'total': 0,
|
||||||
|
'start': 0,
|
||||||
|
'data': []
|
||||||
|
}));
|
||||||
|
let change = new SimpleChange(null, '123', true);
|
||||||
|
component.ngOnChanges({'processInstanceId': change});
|
||||||
|
component.disabled = true;
|
||||||
|
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(fixture.nativeElement.querySelector('adf-empty-list .adf-empty-list-drag_drop')).toBeNull();
|
||||||
|
expect(fixture.nativeElement.querySelector('div[adf-empty-list-header]').innerText.trim()).toEqual('PROCESS-ATTACHMENT.EMPTY.HEADER');
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should show the empty list component when the attachments list is empty for completed process', async(() => {
|
it('should show the empty list component when the attachments list is empty for completed process', async(() => {
|
||||||
getProcessRelatedContentSpy.and.returnValue(Observable.of({
|
getProcessRelatedContentSpy.and.returnValue(Observable.of({
|
||||||
'size': 0,
|
'size': 0,
|
||||||
|
@@ -222,6 +222,24 @@ describe('TaskAttachmentList', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should not show the empty list drag and drop component when is disabled', async(() => {
|
||||||
|
getTaskRelatedContentSpy.and.returnValue(Observable.of({
|
||||||
|
'size': 0,
|
||||||
|
'total': 0,
|
||||||
|
'start': 0,
|
||||||
|
'data': []
|
||||||
|
}));
|
||||||
|
let change = new SimpleChange(null, '123', true);
|
||||||
|
component.ngOnChanges({'taskId': change});
|
||||||
|
component.disabled = true;
|
||||||
|
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(fixture.nativeElement.querySelector('adf-empty-list .adf-empty-list-drag_drop')).toBeNull();
|
||||||
|
expect(fixture.nativeElement.querySelector('div[adf-empty-list-header]').innerText.trim()).toEqual('TASK-ATTACHMENT.EMPTY.HEADER');
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should show the empty list component when the attachments list is empty for completed task', async(() => {
|
it('should show the empty list component when the attachments list is empty for completed task', async(() => {
|
||||||
getTaskRelatedContentSpy.and.returnValue(Observable.of({
|
getTaskRelatedContentSpy.and.returnValue(Observable.of({
|
||||||
'size': 0,
|
'size': 0,
|
||||||
|
Reference in New Issue
Block a user