From a90423aa2131e97b874244f2d6fb9493dc0af4b2 Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Thu, 18 May 2017 16:52:39 +0200 Subject: [PATCH] [ADF-491] Task Attachment List Component (#1877) * Create a new component Task Attachment List Improve the datatable to get the rows to show * The component name should follow the guide style Move the Content calls in a different service file Show the attach file inside the viewer * Change method name * Datatable should get the path and show the icon * Improve attachment component * Improve datatable documentation * Remove console.log --- .../activiti/activiti-demo.component.html | 6 + .../activiti/activiti-demo.component.ts | 6 + ng2-components/ng2-activiti-form/index.ts | 3 + .../src/services/activiti-content-service.ts | 126 +++++++++++ .../services/activiti-content.service.spec.ts | 99 +++++++++ ng2-components/ng2-activiti-tasklist/index.ts | 6 +- .../adf-task-attachment-list.component.css | 8 + .../adf-task-attachment-list.component.html | 12 + ...adf-task-attachment-list.component.spec.ts | 130 +++++++++++ .../adf-task-attachment-list.component.ts | 120 ++++++++++ .../src/components/index.ts | 1 + .../ng2-alfresco-datatable/README.md | 1 + .../src/assets/images/empty_doc_lib.svg | 208 ++++++++++++++++++ .../src/assets/images/ft_ic_archive.svg | 144 ++++++++++++ .../src/assets/images/ft_ic_audio.svg | 143 ++++++++++++ .../src/assets/images/ft_ic_database.svg | 142 ++++++++++++ .../src/assets/images/ft_ic_document.svg | 143 ++++++++++++ .../src/assets/images/ft_ic_ebook.svg | 143 ++++++++++++ .../src/assets/images/ft_ic_folder.svg | 142 ++++++++++++ .../src/assets/images/ft_ic_folder_empty.svg | 143 ++++++++++++ .../src/assets/images/ft_ic_form.svg | 143 ++++++++++++ .../src/assets/images/ft_ic_google_docs.svg | 147 +++++++++++++ .../assets/images/ft_ic_google_drawings.svg | 147 +++++++++++++ .../src/assets/images/ft_ic_google_forms.svg | 147 +++++++++++++ .../src/assets/images/ft_ic_google_sheets.svg | 148 +++++++++++++ .../src/assets/images/ft_ic_google_slides.svg | 146 ++++++++++++ .../src/assets/images/ft_ic_miscellaneous.svg | 142 ++++++++++++ .../src/assets/images/ft_ic_ms_excel.svg | 157 +++++++++++++ .../src/assets/images/ft_ic_ms_powerpoint.svg | 152 +++++++++++++ .../src/assets/images/ft_ic_ms_word.svg | 151 +++++++++++++ .../src/assets/images/ft_ic_pdf.svg | 144 ++++++++++++ .../src/assets/images/ft_ic_presentation.svg | 142 ++++++++++++ .../src/assets/images/ft_ic_raster_image.svg | 143 ++++++++++++ .../src/assets/images/ft_ic_spreadsheet.svg | 151 +++++++++++++ .../src/assets/images/ft_ic_vector_image.svg | 144 ++++++++++++ .../src/assets/images/ft_ic_video.svg | 144 ++++++++++++ .../src/assets/images/ft_ic_website.svg | 142 ++++++++++++ .../datatable/datatable.component.ts | 25 ++- .../src/data/object-datatable-adapter.ts | 16 ++ 39 files changed, 4252 insertions(+), 5 deletions(-) create mode 100644 ng2-components/ng2-activiti-form/src/services/activiti-content-service.ts create mode 100644 ng2-components/ng2-activiti-form/src/services/activiti-content.service.spec.ts create mode 100644 ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.css create mode 100644 ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.html create mode 100644 ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.spec.ts create mode 100644 ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.ts create mode 100644 ng2-components/ng2-alfresco-datatable/src/assets/images/empty_doc_lib.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_archive.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_audio.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_database.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_document.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ebook.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_folder.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_folder_empty.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_form.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_docs.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_drawings.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_forms.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_sheets.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_slides.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_miscellaneous.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_excel.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_powerpoint.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_word.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_pdf.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_presentation.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_raster_image.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_spreadsheet.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_vector_image.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_video.svg create mode 100755 ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_website.svg diff --git a/demo-shell-ng2/app/components/activiti/activiti-demo.component.html b/demo-shell-ng2/app/components/activiti/activiti-demo.component.html index 1280bc92eb..943a2cacdc 100644 --- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.html +++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.html @@ -70,6 +70,12 @@ (taskCreated)="onTaskCreated($event)" (taskDeleted)="onTaskDeleted($event)"> +
+
Attachments
+ + diff --git a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts index ff2b792bc2..982905e7e3 100644 --- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts +++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts @@ -254,6 +254,12 @@ export class ActivitiDemoComponent implements AfterViewInit { this.contentName = content.name; } + onAttachmentClick(content: any) { + this.fileShowed = true; + this.content = content.contentBlob; + this.contentName = content.name; + } + onTaskCreated(data: any) { this.currentTaskId = data.parentTaskId; this.taskList.reload(); diff --git a/ng2-components/ng2-activiti-form/index.ts b/ng2-components/ng2-activiti-form/index.ts index 8c680e935b..b20bf4efb1 100644 --- a/ng2-components/ng2-activiti-form/index.ts +++ b/ng2-components/ng2-activiti-form/index.ts @@ -23,6 +23,7 @@ import { ActivitiContent } from './src/components/activiti-content.component'; import { FormFieldComponent } from './src/components/form-field/form-field.component'; import { ActivitiStartForm } from './src/components/activiti-start-form.component'; import { FormService } from './src/services/form.service'; +import { ActivitiContentService } from './src/services/activiti-content-service'; import { EcmModelService } from './src/services/ecm-model.service'; import { NodeService } from './src/services/node.service'; import { WidgetVisibilityService } from './src/services/widget-visibility.service'; @@ -35,6 +36,7 @@ export * from './src/components/activiti-form.component'; export * from './src/components/activiti-content.component'; export * from './src/components/activiti-start-form.component'; export * from './src/services/form.service'; +export * from './src/services/activiti-content-service'; export * from './src/components/widgets/index'; export * from './src/services/ecm-model.service'; export * from './src/services/node.service'; @@ -51,6 +53,7 @@ export const ACTIVITI_FORM_DIRECTIVES: any[] = [ export const ACTIVITI_FORM_PROVIDERS: any[] = [ FormService, + ActivitiContentService, EcmModelService, NodeService, WidgetVisibilityService, diff --git a/ng2-components/ng2-activiti-form/src/services/activiti-content-service.ts b/ng2-components/ng2-activiti-form/src/services/activiti-content-service.ts new file mode 100644 index 0000000000..194c510cb2 --- /dev/null +++ b/ng2-components/ng2-activiti-form/src/services/activiti-content-service.ts @@ -0,0 +1,126 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Rx'; +import { AlfrescoApiService, LogService } from 'ng2-alfresco-core'; + +@Injectable() +export class ActivitiContentService { + + static UNKNOWN_ERROR_MESSAGE: string = 'Unknown error'; + static GENERIC_ERROR_MESSAGE: string = 'Server error'; + static DEFAULT_MIME_TYPE_ICON: string = 'ft_ic_miscellaneous.svg'; + + mimeTypeIcons: any = { + 'image/png': 'ft_ic_raster_image.svg', + 'image/jpeg': 'ft_ic_raster_image.svg', + 'image/gif': 'ft_ic_raster_image.svg', + 'application/pdf': 'ft_ic_pdf.svg', + 'application/vnd.ms-excel': 'ft_ic_ms_excel.svg', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'ft_ic_ms_excel.svg', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.template': 'ft_ic_ms_excel.svg', + 'application/msword': 'ft_ic_ms_word.svg', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'ft_ic_ms_word.svg', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.template': 'ft_ic_ms_word.svg', + 'application/vnd.ms-powerpoint': 'ft_ic_ms_powerpoint.svg', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'ft_ic_ms_powerpoint.svg', + 'application/vnd.openxmlformats-officedocument.presentationml.template': 'ft_ic_ms_powerpoint.svg', + 'application/vnd.openxmlformats-officedocument.presentationml.slideshow': 'ft_ic_ms_powerpoint.svg', + 'video/mp4': 'ft_ic_video.svg', + 'text/plain': 'ft_ic_document.svg', + 'application/x-javascript': 'ft_ic_document.svg', + 'application/json': 'ft_ic_document.svg', + 'image/svg+xml': 'ft_ic_vector_image.svg', + 'text/html': 'ft_ic_website.svg', + 'application/x-compressed': 'ft_ic_archive.svg', + 'application/x-zip-compressed': 'ft_ic_archive.svg', + 'application/zip': 'ft_ic_archive.svg', + 'application/vnd.apple.keynote': 'ft_ic_presentation.svg', + 'application/vnd.apple.pages': 'ft_ic_document.svg', + 'application/vnd.apple.numbers': 'ft_ic_spreadsheet.svg' + }; + + constructor(private apiService: AlfrescoApiService, + private logService: LogService) { + } + + getFileRawContent(contentId: number): Observable { + let alfrescoApi = this.apiService.getInstance(); + return Observable.fromPromise(alfrescoApi.activiti.contentApi.getRawContent(contentId)) + .catch(err => this.handleError(err)); + } + + /** + * Return all the related content of the task + * @param taskId + * @returns {any} + */ + getTaskRelatedContent(taskId: string): Observable { + return Observable.fromPromise(this.apiService.getInstance().activiti.contentApi.getRelatedContentForTask(taskId)) + .catch(err => this.handleError(err)); + } + + /** + * Return all the related content of the process + * @param processId + * @returns {any} + */ + getProcessRelatedContent(processId: string): Observable { + return Observable.fromPromise(this.apiService.getInstance().activiti.contentApi.getRelatedContentForProcessInstance(processId)) + .catch(err => this.handleError(err)); + } + + /** + * Delete a content by Id + * @param contentId + * @returns {any} + */ + deleteRelatedContent(contentId: string): Observable { + return Observable.fromPromise(this.apiService.getInstance().activiti.contentApi.deleteContent(contentId)) + .catch(err => this.handleError(err)); + } + + toJson(res: any) { + if (res) { + return res || {}; + } + return {}; + } + + toJsonArray(res: any) { + if (res) { + return res.data || []; + } + return []; + } + + handleError(error: any): Observable { + let errMsg = ActivitiContentService.UNKNOWN_ERROR_MESSAGE; + if (error) { + errMsg = (error.message) ? error.message : + error.status ? `${error.status} - ${error.statusText}` : ActivitiContentService.GENERIC_ERROR_MESSAGE; + } + this.logService.error(errMsg); + return Observable.throw(errMsg); + } + + getMimeTypeIcon(mimeType: string): string { + let icon = this.mimeTypeIcons[mimeType]; + return icon || ActivitiContentService.DEFAULT_MIME_TYPE_ICON; + } +} diff --git a/ng2-components/ng2-activiti-form/src/services/activiti-content.service.spec.ts b/ng2-components/ng2-activiti-form/src/services/activiti-content.service.spec.ts new file mode 100644 index 0000000000..d6b14c365f --- /dev/null +++ b/ng2-components/ng2-activiti-form/src/services/activiti-content.service.spec.ts @@ -0,0 +1,99 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { TestBed } from '@angular/core/testing'; +import { CoreModule } from 'ng2-alfresco-core'; +import { ActivitiContentService } from './activiti-content-service'; + +declare let jasmine: any; + +describe('ActivitiContentService', () => { + + let service: ActivitiContentService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ + CoreModule.forRoot() + ], + providers: [ + ActivitiContentService + ] + }); + service = TestBed.get(ActivitiContentService); + }); + + beforeEach(() => { + jasmine.Ajax.install(); + }); + + afterEach(() => { + jasmine.Ajax.uninstall(); + }); + + it('Should fetch the attachements', (done) => { + service.getTaskRelatedContent('1234').subscribe((res) => { + expect(res.data).toBeDefined(); + expect(res.data.length).toBe(2); + expect(res.data[0].name).toBe('fake.zip'); + expect(res.data[0].mimeType).toBe('application/zip'); + expect(res.data[0].relatedContent).toBeTruthy(); + expect(res.data[1].name).toBe('fake.jpg'); + expect(res.data[1].mimeType).toBe('image/jpeg'); + expect(res.data[1].relatedContent).toBeTruthy(); + done(); + }); + + jasmine.Ajax.requests.mostRecent().respondWith({ + 'status': 200, + contentType: 'application/json', + responseText: JSON.stringify({ + size: 2, + total: 2, + start: 0, + data: [ + { + id: 8, + name: 'fake.zip', + created: 1494595697381, + createdBy: {id: 2, firstName: 'user', lastName: 'user', email: 'user@user.com'}, + relatedContent: true, + contentAvailable: true, + link: false, + mimeType: 'application/zip', + simpleType: 'content', + previewStatus: 'unsupported', + thumbnailStatus: 'unsupported' + }, + { + id: 9, + name: 'fake.jpg', + created: 1494595655381, + createdBy: {id: 2, firstName: 'user', lastName: 'user', email: 'user@user.com'}, + relatedContent: true, + contentAvailable: true, + link: false, + mimeType: 'image/jpeg', + simpleType: 'image', + previewStatus: 'unsupported', + thumbnailStatus: 'unsupported' + } + ] + }) + }); + }); +}); diff --git a/ng2-components/ng2-activiti-tasklist/index.ts b/ng2-components/ng2-activiti-tasklist/index.ts index 0d30f02947..e1716b5fb3 100644 --- a/ng2-components/ng2-activiti-tasklist/index.ts +++ b/ng2-components/ng2-activiti-tasklist/index.ts @@ -34,7 +34,8 @@ import { ActivitiPeople, ActivitiTaskHeader, ActivitiStartTaskButton, - ActivitiPeopleSearch + ActivitiPeopleSearch, + TaskAttachmentListComponent } from './src/components/index'; export * from './src/components/index'; @@ -52,7 +53,8 @@ export const ACTIVITI_TASKLIST_DIRECTIVES: any[] = [ ActivitiPeople, ActivitiTaskHeader, ActivitiStartTaskButton, - ActivitiPeopleSearch + ActivitiPeopleSearch, + TaskAttachmentListComponent ]; export const ACTIVITI_TASKLIST_PROVIDERS: any[] = [ diff --git a/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.css b/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.css new file mode 100644 index 0000000000..67458ff066 --- /dev/null +++ b/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.css @@ -0,0 +1,8 @@ +alfresco-datatable >>> .column-header { + color: #232323; + font-size: 15px; +} + +alfresco-datatable >>> .data-cell { + cursor: pointer !important; +} diff --git a/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.html b/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.html new file mode 100644 index 0000000000..74208ad2f7 --- /dev/null +++ b/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.html @@ -0,0 +1,12 @@ + + + + + + + diff --git a/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.spec.ts new file mode 100644 index 0000000000..be73ab280a --- /dev/null +++ b/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.spec.ts @@ -0,0 +1,130 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { SimpleChange } from '@angular/core'; +import { ComponentFixture, TestBed, async } from '@angular/core/testing'; +import { CoreModule, AlfrescoTranslationService } from 'ng2-alfresco-core'; +import { DataTableModule } from 'ng2-alfresco-datatable'; +import { ActivitiContentService } from 'ng2-activiti-form'; +import { TaskAttachmentListComponent } from './adf-task-attachment-list.component'; +import { Observable } from 'rxjs/Rx'; + +declare let jasmine: any; + +describe('TaskAttachmentList', () => { + + let componentHandler: any; + let component: TaskAttachmentListComponent; + let fixture: ComponentFixture; + let service: ActivitiContentService; + + beforeEach(() => { + jasmine.Ajax.install(); + }); + + afterEach(() => { + jasmine.Ajax.uninstall(); + }); + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ + CoreModule.forRoot(), + DataTableModule + ], + declarations: [ + TaskAttachmentListComponent + ], + providers: [ + ActivitiContentService + ] + }).compileComponents(); + + let translateService = TestBed.get(AlfrescoTranslationService); + spyOn(translateService, 'addTranslationFolder').and.stub(); + spyOn(translateService, 'get').and.callFake((key) => { return Observable.of(key); }); + })); + + beforeEach(() => { + + fixture = TestBed.createComponent(TaskAttachmentListComponent); + component = fixture.componentInstance; + + service = TestBed.get(ActivitiContentService); + + componentHandler = jasmine.createSpyObj('componentHandler', [ + 'upgradeAllRegistered', + 'upgradeElement' + ]); + window['componentHandler'] = componentHandler; + }); + + it('should fetch all the attachments of a taskId', (done) => { + + component.success.subscribe((res) => { + expect(res).toBeDefined(); + expect(res.length).toBe(2); + expect(res[0].name).toBe('fake.zip'); + expect(res[0].icon).toBe('ft_ic_archive.svg'); + expect(res[1].name).toBe('fake.jpg'); + expect(res[1].icon).toBe('ft_ic_raster_image.svg'); + done(); + }); + + let taskId = '1'; + let change = new SimpleChange(null, taskId, true); + component.ngOnChanges({ 'taskId': change }); + + jasmine.Ajax.requests.mostRecent().respondWith({ + 'status': 200, + contentType: 'application/json', + responseText: JSON.stringify({ + size: 2, + total: 2, + start: 0, + data: [ + { + id: 8, + name: 'fake.zip', + created: 1494595697381, + createdBy: {id: 2, firstName: 'user', lastName: 'user', email: 'user@user.com'}, + relatedContent: true, + contentAvailable: true, + link: false, + mimeType: 'application/zip', + simpleType: 'content', + previewStatus: 'unsupported', + thumbnailStatus: 'unsupported' + }, + { + id: 9, + name: 'fake.jpg', + created: 1494595655381, + createdBy: {id: 2, firstName: 'user', lastName: 'user', email: 'user@user.com'}, + relatedContent: true, + contentAvailable: true, + link: false, + mimeType: 'image/jpeg', + simpleType: 'image', + previewStatus: 'unsupported', + thumbnailStatus: 'unsupported' + } + ] + }) + }); + }); +}); diff --git a/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.ts new file mode 100644 index 0000000000..40bc9712dd --- /dev/null +++ b/ng2-components/ng2-activiti-tasklist/src/components/adf-task-attachment-list.component.ts @@ -0,0 +1,120 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Component, OnChanges, Input, Output, EventEmitter, SimpleChanges } from '@angular/core'; +import { AlfrescoTranslationService } from 'ng2-alfresco-core'; +import { ActivitiContentService } from 'ng2-activiti-form'; + +@Component({ + selector: 'adf-task-attachment-list', + styleUrls: ['./adf-task-attachment-list.component.css'], + templateUrl: './adf-task-attachment-list.component.html' +}) +export class TaskAttachmentListComponent implements OnChanges { + + @Input() + taskId: string; + + @Output() + attachmentClick = new EventEmitter(); + + @Output() + success = new EventEmitter(); + + attachments: any[] = []; + + constructor(private translateService: AlfrescoTranslationService, + private activitiContentService: ActivitiContentService) { + + if (translateService) { + translateService.addTranslationFolder('ng2-activiti-tasklist', 'node_modules/ng2-activiti-tasklist/src'); + } + } + + ngOnChanges(changes: SimpleChanges) { + if (changes['taskId'] && changes['taskId'].currentValue) { + this.loadAttachmentsByTaskId(changes['taskId'].currentValue); + } + } + + reset () { + this.attachments = []; + } + + private loadAttachmentsByTaskId(taskId: string) { + if (taskId) { + this.reset(); + this.activitiContentService.getTaskRelatedContent(taskId).subscribe( + (res: any) => { + res.data.forEach(content => { + this.attachments.push({ + id: content.id, + name: content.name, + created: content.created, + createdBy: content.createdBy.firstName + ' ' + content.createdBy.lastName, + icon: this.activitiContentService.getMimeTypeIcon(content.mimeType) + }); + }); + this.success.emit(this.attachments); + }); + } + } + + private deleteAttachmentById(contentId: string) { + if (contentId) { + this.activitiContentService.deleteRelatedContent(contentId).subscribe( + (res: any) => { + this.attachments = this.attachments.filter(content => { + return content.id !== contentId; + }); + }); + } + } + + isEmpty(): boolean { + return this.attachments && this.attachments.length === 0; + } + + onShowRowActionsMenu(event: any) { + let myAction = { + title: 'Delete', + name: 'delete' + }; + event.value.actions = [ + myAction + ]; + } + + onExecuteRowAction(event: any) { + let args = event.value; + let action = args.action; + if (action.name === 'delete') { + this.deleteAttachmentById(args.row.obj.id); + } + } + + openContent(event: any): void { + let content = event.value.obj; + this.activitiContentService.getFileRawContent(content.id).subscribe( + (blob: Blob) => { + content.contentBlob = blob; + this.attachmentClick.emit(content); + } + ); + } + +} diff --git a/ng2-components/ng2-activiti-tasklist/src/components/index.ts b/ng2-components/ng2-activiti-tasklist/src/components/index.ts index cef995cbf1..2f7a94872f 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/index.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/index.ts @@ -19,6 +19,7 @@ export * from './activiti-apps.component'; export * from './activiti-tasklist.component'; export * from './activiti-checklist.component'; export * from './activiti-comments.component'; +export * from './adf-task-attachment-list.component'; export * from './activiti-people.component'; export * from './activiti-task-header.component'; export * from './no-task-detail-template.component'; diff --git a/ng2-components/ng2-alfresco-datatable/README.md b/ng2-components/ng2-alfresco-datatable/README.md index cc01ffef56..5694d07293 100644 --- a/ng2-components/ng2-alfresco-datatable/README.md +++ b/ng2-components/ng2-alfresco-datatable/README.md @@ -228,6 +228,7 @@ platformBrowserDynamic().bootstrapModule(AppModule); | Name | Type | Default | Description | | --- | --- | --- | --- | | `data` | DataTableAdapter | instance of **ObjectDataTableAdapter** | data source | +| `rows` | Object[] | [] | The rows that the datatable should show | | `multiselect` | boolean | false | Toggles multiple row selection, renders checkboxes at the beginning of each row | | `actions` | boolean | false | Toggles data actions column | | `actionsPosition` | string (left\|right) | right | Position of the actions dropdown menu. | diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/empty_doc_lib.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/empty_doc_lib.svg new file mode 100644 index 0000000000..866acd527b --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/empty_doc_lib.svg @@ -0,0 +1,208 @@ + + + + empty_doc_lib + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_archive.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_archive.svg new file mode 100755 index 0000000000..b010f8065d --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_archive.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_audio.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_audio.svg new file mode 100755 index 0000000000..f3836172dd --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_audio.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_database.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_database.svg new file mode 100755 index 0000000000..6f7cbdb5dd --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_database.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_document.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_document.svg new file mode 100755 index 0000000000..62e011d124 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_document.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ebook.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ebook.svg new file mode 100755 index 0000000000..c26452389f --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ebook.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_folder.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_folder.svg new file mode 100755 index 0000000000..aff7d2871d --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_folder.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_folder_empty.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_folder_empty.svg new file mode 100755 index 0000000000..54d0b9003a --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_folder_empty.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_form.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_form.svg new file mode 100755 index 0000000000..d46e889326 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_form.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_docs.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_docs.svg new file mode 100755 index 0000000000..1d9a03515b --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_docs.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_drawings.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_drawings.svg new file mode 100755 index 0000000000..a1eae45e65 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_drawings.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_forms.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_forms.svg new file mode 100755 index 0000000000..d8946f40f9 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_forms.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_sheets.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_sheets.svg new file mode 100755 index 0000000000..d6a96c144a --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_sheets.svg @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_slides.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_slides.svg new file mode 100755 index 0000000000..61fab21ab7 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_google_slides.svg @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_miscellaneous.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_miscellaneous.svg new file mode 100755 index 0000000000..a6bd024609 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_miscellaneous.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_excel.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_excel.svg new file mode 100755 index 0000000000..b98380dd76 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_excel.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_powerpoint.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_powerpoint.svg new file mode 100755 index 0000000000..a6166744c7 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_powerpoint.svg @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_word.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_word.svg new file mode 100755 index 0000000000..046efc4f83 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_ms_word.svg @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_pdf.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_pdf.svg new file mode 100755 index 0000000000..4d6d4b388d --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_pdf.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_presentation.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_presentation.svg new file mode 100755 index 0000000000..7dce6d633c --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_presentation.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_raster_image.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_raster_image.svg new file mode 100755 index 0000000000..d48242ce6d --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_raster_image.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_spreadsheet.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_spreadsheet.svg new file mode 100755 index 0000000000..9de2326880 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_spreadsheet.svg @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_vector_image.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_vector_image.svg new file mode 100755 index 0000000000..cfa5dbe4bd --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_vector_image.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_video.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_video.svg new file mode 100755 index 0000000000..b93d993619 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_video.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_website.svg b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_website.svg new file mode 100755 index 0000000000..220bab2a91 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/assets/images/ft_ic_website.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.ts b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.ts index e7c0cddbd9..b88c61eddf 100644 --- a/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.ts +++ b/ng2-components/ng2-alfresco-datatable/src/components/datatable/datatable.component.ts @@ -18,6 +18,7 @@ import { Component, OnChanges, + SimpleChange, SimpleChanges, Input, Output, @@ -28,7 +29,7 @@ import { ContentChild, Optional } from '@angular/core'; -import { DataTableAdapter, DataRow, DataColumn, DataSorting, DataRowEvent, ObjectDataTableAdapter } from '../../data/index'; +import { DataTableAdapter, DataRow, DataColumn, DataSorting, DataRowEvent, ObjectDataTableAdapter, ObjectDataRow } from '../../data/index'; import { DataCellEvent } from './data-cell.event'; import { DataRowActionEvent } from './data-row-action.event'; import { DataColumnListComponent } from 'ng2-alfresco-core'; @@ -48,6 +49,9 @@ export class DataTableComponent implements AfterContentInit, OnChanges { @Input() data: DataTableAdapter; + @Input() + rows: any[] = []; + @Input() multiselect: boolean = false; @@ -96,10 +100,25 @@ export class DataTableComponent implements AfterContentInit, OnChanges { } ngOnChanges(changes: SimpleChanges) { - if (changes['data'] && changes['data'].currentValue) { + if (this.isPropertyChanged(changes['data'])) { this.loadTable(); return; } + + if (this.isPropertyChanged(changes['rows'])) { + if (this.data) { + this.data.setRows(this.convertToRowsData(changes['rows'].currentValue)); + } + return; + } + } + + isPropertyChanged(property: SimpleChange): boolean { + return property && property.currentValue ? true : false; + } + + convertToRowsData(rows: any []): ObjectDataRow[] { + return rows.map(row => new ObjectDataRow(row)); } loadTable() { @@ -110,7 +129,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges { } if (!this.data) { - this.data = new ObjectDataTableAdapter([], schema); + this.data = new ObjectDataTableAdapter(this.rows, schema); } else { this.setHtmlColumnConfigurationOnObjectAdapter(schema); } diff --git a/ng2-components/ng2-alfresco-datatable/src/data/object-datatable-adapter.ts b/ng2-components/ng2-alfresco-datatable/src/data/object-datatable-adapter.ts index d1eb3cd771..cab70d8f9c 100644 --- a/ng2-components/ng2-alfresco-datatable/src/data/object-datatable-adapter.ts +++ b/ng2-components/ng2-alfresco-datatable/src/data/object-datatable-adapter.ts @@ -111,9 +111,25 @@ export class ObjectDataTableAdapter implements DataTableAdapter { } } + if (col.type === 'image') { + + if (col.key === 'icon') { + + let icon = this.getImagePath(row.getValue('icon')); + if (icon) { + return icon; + } + return this.getImagePath('ft_ic_miscellaneous.svg'); + } + } + return value; } + getImagePath(id: string): any { + return require('./../assets/images/' + id); + } + getSorting(): DataSorting { return this._sorting; }