[ADF-712] Task Attachment - Provide a way to attach a new content (#1898)

* create button, download, view functionality added in task attachment list component

* created sevice to attach document to task

* added new component to create/uplaod attachment to task

* added new component to create/uplaod attachment to task

* added test case for create task attachment component

* added test case for create task attachment component

* added input to block upload document  to ECM

* fixed create task attachment spec file issue

* changed alfresco-upload to alfresco-core upload directive

* removed attachCreate button and emitter from task-attachment-list

* removed uploadToEcm input and checkValidity method from alfresco-upload

* added documentation for task-attachment-list and create-task-attachment components
This commit is contained in:
Infad Kachancheri
2017-06-01 20:55:50 +05:30
committed by Eugenio Romano
parent c445b6a4df
commit 8afe6e2125
13 changed files with 320 additions and 9 deletions

View File

@@ -16,7 +16,7 @@
*/
import { Component, OnChanges, Input, Output, EventEmitter, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { AlfrescoTranslationService, ContentService } from 'ng2-alfresco-core';
import { ActivitiContentService } from 'ng2-activiti-form';
@Component({
@@ -35,10 +35,14 @@ export class TaskAttachmentListComponent implements OnChanges {
@Output()
success = new EventEmitter();
@Output()
error: EventEmitter<any> = new EventEmitter<any>();
attachments: any[] = [];
constructor(private translateService: AlfrescoTranslationService,
private activitiContentService: ActivitiContentService) {
private activitiContentService: ActivitiContentService,
private contentService: ContentService) {
if (translateService) {
translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src');
@@ -90,31 +94,63 @@ export class TaskAttachmentListComponent implements OnChanges {
}
onShowRowActionsMenu(event: any) {
let myAction = {
title: 'Delete',
name: 'delete'
let viewAction = {
title: 'View',
name: 'view'
};
let removeAction = {
title: 'Remove',
name: 'remove'
};
let downloadAction = {
title: 'Download',
name: 'download'
};
event.value.actions = [
myAction
viewAction,
removeAction,
downloadAction
];
}
onExecuteRowAction(event: any) {
let args = event.value;
let action = args.action;
if (action.name === 'delete') {
if (action.name === 'view') {
this.emitDocumentContent(args.row.obj);
} else if (action.name === 'remove') {
this.deleteAttachmentById(args.row.obj.id);
} else if (action.name === 'download') {
this.downloadContent(args.row.obj);
}
}
openContent(event: any): void {
let content = event.value.obj;
this.emitDocumentContent(content);
}
emitDocumentContent(content: any) {
this.activitiContentService.getFileRawContent(content.id).subscribe(
(blob: Blob) => {
content.contentBlob = blob;
this.attachmentClick.emit(content);
},
(err) => {
this.error.emit(err);
}
);
}
downloadContent(content: any): void {
this.activitiContentService.getFileRawContent(content.id).subscribe(
(blob: Blob) => this.contentService.downloadBlob(blob, content.name),
(err) => {
this.error.emit(err);
}
);
}
}