alfresco-ng2-components/docs/task-attachment-list.component.md
Maurizio Vitale 18dc0711f9 [ADF-1711] Task Attachment list - Fix the TaskService dependency (#2752)
* Fix the TaskService dependency

* Improve doc and remove unused dep
2017-11-29 12:06:52 +00:00

2.6 KiB

Task Attachment List Component

Displays attached documents on a specified task.

task-attachment-list-sample

Basic Usage

<adf-task-attachment-list 
    [taskId]="YOUR_TASK_ID" 
    (attachmentClick)="YOUR_HANDLER">
</adf-task-attachment-list>

If the List is empty, a default no content template is displayed.

default-no-content-template-sample

How to Add Drag and Drop Functionality

If we want user to be able to upload attachments for empty lists, We can wrap our component with upload drag area component. In that case, We should also pass a custom no content template as shown below with our component urging the user to drag files to upload whenever the list is empty.

<adf-upload-drag-area
    [parentId]="YOUR_TASK_ID"
    [showNotificationBar]="BOOLEAN">
    <adf-task-attachment-list  
        [taskId]="YOUR_TASK_ID"
        (attachmentClick)="YOUR_HANDLER">
        <adf-empty-list>
            <div adf-empty-list-header>{{This List is empty}}</div>
            <div adf-empty-list-body>{{Drag and drop to upload}}</div>
            <div adf-empty-list-footer>
                <img [src]="Your custom image URL"></div> 
        </adf-empty-list>
    </adf-task-attachment-list>
</adf-upload-drag-area>

import { UploadService } from '@alfresco/adf-core'; import { TaskUploadService } from '@alfresco/adf-process-services';

Make sure to override the UploadService with the TaskUploadService

@Component({
    selector: 'my-custom-task-attachment',
    providers: [
        { provide: UploadService, useClass: TaskUploadService }
    ]
})
export class MyCustomTaskAttachmentComponent {
    constructor() {}
}

Upload Drag Area Component

If the List is empty, the custom no-content template we passed is displayed.

custom-no-content-drag-drop-template-sample

Properties

Name Type Description
taskId string (required): The ID of the task to display
disabled boolean false

Events

Name Description
attachmentClick Raised when the attachment double clicked or selected view option from context menu by the user from within the component and return a Blob obj of the object clicker
success Raised when the attachment list fetch all the attach and return a list of attachments
error Raised when the attachment list is not able to fetch the attachments for example network error