diff --git a/demo-shell-ng2/app/components/activiti/activiti-process-attachments.component.html b/demo-shell-ng2/app/components/activiti/activiti-process-attachments.component.html
index 4b039bff2d..e786152649 100644
--- a/demo-shell-ng2/app/components/activiti/activiti-process-attachments.component.html
+++ b/demo-shell-ng2/app/components/activiti/activiti-process-attachments.component.html
@@ -6,13 +6,14 @@
[showNotificationBar]="false">
diff --git a/demo-shell-ng2/app/components/activiti/activiti-process-attachments.component.ts b/demo-shell-ng2/app/components/activiti/activiti-process-attachments.component.ts
index d6e31cab33..487faefa46 100644
--- a/demo-shell-ng2/app/components/activiti/activiti-process-attachments.component.ts
+++ b/demo-shell-ng2/app/components/activiti/activiti-process-attachments.component.ts
@@ -67,8 +67,8 @@ export class ActivitiProcessAttachmentsComponent implements OnInit, OnChanges {
this.contentName = content.name;
}
- isRunning(): boolean {
- return this.processInstance && !this.processInstance.ended;
+ isCompletedProcess(): boolean {
+ return this.processInstance && this.processInstance.ended !== undefined && this.processInstance.ended !== null;
}
}
diff --git a/demo-shell-ng2/app/components/activiti/activiti-task-attachments.component.html b/demo-shell-ng2/app/components/activiti/activiti-task-attachments.component.html
index 6cafcae6eb..c100f7f588 100644
--- a/demo-shell-ng2/app/components/activiti/activiti-task-attachments.component.html
+++ b/demo-shell-ng2/app/components/activiti/activiti-task-attachments.component.html
@@ -7,11 +7,13 @@
diff --git a/demo-shell-ng2/app/components/activiti/activiti-task-attachments.component.ts b/demo-shell-ng2/app/components/activiti/activiti-task-attachments.component.ts
index 4d5cda2132..e10f87513c 100644
--- a/demo-shell-ng2/app/components/activiti/activiti-task-attachments.component.ts
+++ b/demo-shell-ng2/app/components/activiti/activiti-task-attachments.component.ts
@@ -15,8 +15,9 @@
* 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 { ActivitiTaskListService } from 'ng2-activiti-tasklist';
import { UploadService } from 'ng2-alfresco-core';
@Component({
@@ -28,7 +29,7 @@ import { UploadService } from 'ng2-alfresco-core';
]
})
-export class ActivitiTaskAttachmentsComponent implements OnInit {
+export class ActivitiTaskAttachmentsComponent implements OnInit, OnChanges {
@Input()
taskId: string;
@@ -40,7 +41,10 @@ export class ActivitiTaskAttachmentsComponent implements OnInit {
content: Blob;
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));
}
+ ngOnChanges() {
+ if (this.taskId) {
+ this.activitiTaskList.getTaskDetails(this.taskId).map((res) => res).subscribe(
+ (res: any) => {
+ this.taskDetails = res;
+ });
+ }
+ }
+
onFileUploadComplete(content: any) {
this.taskAttachList.add(content);
}
@@ -58,4 +71,7 @@ export class ActivitiTaskAttachmentsComponent implements OnInit {
this.contentName = content.name;
}
+ isCompletedTask(): boolean {
+ return this.taskDetails && this.taskDetails.endDate !== undefined && this.taskDetails.endDate !== null;
+ }
}
diff --git a/ng2-components/ng2-activiti-processlist/src/components/process-attachment-list.component.spec.ts b/ng2-components/ng2-activiti-processlist/src/components/process-attachment-list.component.spec.ts
index bbde7d3718..96b3b9dd94 100644
--- a/ng2-components/ng2-activiti-processlist/src/components/process-attachment-list.component.spec.ts
+++ b/ng2-components/ng2-activiti-processlist/src/components/process-attachment-list.component.spec.ts
@@ -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(() => {
getProcessRelatedContentSpy.and.returnValue(Observable.of({
'size': 0,
diff --git a/ng2-components/ng2-activiti-tasklist/src/components/task-attachment-list.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/task-attachment-list.component.spec.ts
index 230fa4344d..529d200c4c 100644
--- a/ng2-components/ng2-activiti-tasklist/src/components/task-attachment-list.component.spec.ts
+++ b/ng2-components/ng2-activiti-tasklist/src/components/task-attachment-list.component.spec.ts
@@ -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(() => {
getTaskRelatedContentSpy.and.returnValue(Observable.of({
'size': 0,