diff --git a/demo-shell/src/app/components/process-service/process-attachments.component.html b/demo-shell/src/app/components/process-service/process-attachments.component.html index 484772dd41..c9abd272ea 100644 --- a/demo-shell/src/app/components/process-service/process-attachments.component.html +++ b/demo-shell/src/app/components/process-service/process-attachments.component.html @@ -3,8 +3,7 @@
+ [disabled]="isCompletedProcess()"> this.onTaskFileUploadComplete(value.data)); - } ngOnDestroy() { @@ -378,10 +371,6 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit this.processList.reload(); } - onSuccessNewProcess(data: any): void { - this.processList.reload(); - } - onFormCompleted(form): void { this.currentTaskId = null; this.taskPagination.totalItems--; @@ -482,16 +471,9 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit this.logService.log(event); } - isTaskCompleted(): boolean { - return this.activitidetails.isCompletedTask(); - } - onAssignTask() { this.taskList.reload(); this.currentTaskId = null; } - onTaskFileUploadComplete(content: any) { - this.taskAttachList.add(content); - } } diff --git a/demo-shell/src/app/components/process-service/task-attachments.component.html b/demo-shell/src/app/components/process-service/task-attachments.component.html index f77be75d7b..56d89adb0e 100644 --- a/demo-shell/src/app/components/process-service/task-attachments.component.html +++ b/demo-shell/src/app/components/process-service/task-attachments.component.html @@ -1,13 +1,12 @@
+ [parentId]="taskId"> + [taskId]="taskId">
{{'ADF_TASK_LIST.ATTACHMENT.EMPTY.HEADER' | translate}}
diff --git a/demo-shell/src/app/components/process-service/task-attachments.component.ts b/demo-shell/src/app/components/process-service/task-attachments.component.ts index 6e3694b7b9..9065b062a3 100644 --- a/demo-shell/src/app/components/process-service/task-attachments.component.ts +++ b/demo-shell/src/app/components/process-service/task-attachments.component.ts @@ -16,26 +16,23 @@ */ import { Component, Input, OnChanges, OnInit, ViewChild } from '@angular/core'; -import { ProcessUploadService, TaskListService, TaskAttachmentListComponent } from '@alfresco/adf-process-services'; +import { TaskListService, TaskAttachmentListComponent } from '@alfresco/adf-process-services'; import { UploadService } from '@alfresco/adf-core'; @Component({ selector: 'app-task-attachments', templateUrl: './task-attachments.component.html', - styleUrls: ['./task-attachments.component.css'], - providers: [ - { provide: UploadService, useClass: ProcessUploadService } - ] + styleUrls: ['./task-attachments.component.css'] }) export class TaskAttachmentsComponent implements OnInit, OnChanges { - @Input() - taskId: string; - @ViewChild(TaskAttachmentListComponent) taskAttachList: TaskAttachmentListComponent; + @Input() + taskId: string; + fileShowed: boolean = false; content: Blob; contentName: string; @@ -73,4 +70,5 @@ export class TaskAttachmentsComponent implements OnInit, OnChanges { isCompletedTask(): boolean { return this.taskDetails && this.taskDetails.endDate !== undefined && this.taskDetails.endDate !== null; } + } diff --git a/docs/upload-drag-area.component.md b/docs/upload-drag-area.component.md index f6e8264706..d71f339a30 100644 --- a/docs/upload-drag-area.component.md +++ b/docs/upload-drag-area.component.md @@ -40,10 +40,7 @@ export class AppComponent { | Name | Type | Default | Description | | --- | --- | --- | --- | | disabled | boolean | false | Toggle component disabled state | -| **(deprecated)** enabled | boolean | true | Toggle component enabled state | -| **(deprecated)** showNotificationBar | boolean | true | Hide/show notification bar. **Deprecated in 1.6.0: use UploadService events and NotificationService api instead.** | | rootFolderId | string | '-root-' | The ID of the root folder node. | -| **(deprecated)** currentFolderPath | string | '/' | define the path where the files are uploaded. **Deprecated in 1.6.0: use rootFolderId instead.** | | versioning | boolean | false | Versioning false is the default uploader behaviour and it renames the file using an integer suffix if there is a name clash. Versioning true to indicate that a major version should be created | ### Events diff --git a/lib/content-services/upload/components/upload-drag-area.component.spec.ts b/lib/content-services/upload/components/upload-drag-area.component.spec.ts index d3d3a82e8f..89010427ff 100644 --- a/lib/content-services/upload/components/upload-drag-area.component.spec.ts +++ b/lib/content-services/upload/components/upload-drag-area.component.spec.ts @@ -90,7 +90,7 @@ describe('UploadDragAreaComponent', () => { describe('When disabled', () => { it('should NOT upload the list of files dropped', () => { - component.enabled = false; + component.disabled = true; spyOn(uploadService, 'addToQueue'); spyOn(uploadService, 'uploadFilesInTheQueue'); fixture.detectChanges(); @@ -104,7 +104,7 @@ describe('UploadDragAreaComponent', () => { }); it('should NOT upload the file dropped', () => { - component.enabled = false; + component.disabled = true; spyOn(uploadService, 'addToQueue'); spyOn(uploadService, 'uploadFilesInTheQueue'); fixture.detectChanges(); @@ -126,7 +126,7 @@ describe('UploadDragAreaComponent', () => { }); it('should NOT upload the folder dropped', (done) => { - component.enabled = false; + component.disabled = true; spyOn(uploadService, 'addToQueue'); spyOn(uploadService, 'uploadFilesInTheQueue'); fixture.detectChanges(); @@ -151,7 +151,7 @@ describe('UploadDragAreaComponent', () => { }); it('should NOT upload the files', () => { - component.enabled = false; + component.disabled = true; spyOn(uploadService, 'addToQueue'); spyOn(uploadService, 'uploadFilesInTheQueue'); @@ -178,9 +178,7 @@ describe('UploadDragAreaComponent', () => { }); it('should upload the list of files dropped', (done) => { - component.currentFolderPath = '/root-fake-/sites-fake/folder-fake'; component.success = null; - component.showNotificationBar = false; uploadService.uploadFilesInTheQueue = jasmine.createSpy('uploadFilesInTheQueue'); fixture.detectChanges(); @@ -195,24 +193,7 @@ describe('UploadDragAreaComponent', () => { component.onFilesDropped(filesList); }); - it('should show the loading messages in the notification bar when the files are dropped', () => { - component.currentFolderPath = '/root-fake-/sites-fake/folder-fake'; - component.success = null; - component.showNotificationBar = true; - uploadService.uploadFilesInTheQueue = jasmine.createSpy('uploadFilesInTheQueue'); - component.showUndoNotificationBar = jasmine.createSpy('_showUndoNotificationBar'); - - fixture.detectChanges(); - let fileFake = {name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json'}; - let filesList = [fileFake]; - - component.onFilesDropped(filesList); - expect(uploadService.uploadFilesInTheQueue).toHaveBeenCalledWith(null); - expect(component.showUndoNotificationBar).toHaveBeenCalled(); - }); - it('should upload a file when dropped', () => { - component.currentFolderPath = '/root-fake-/sites-fake/document-library-fake'; component.success = null; fixture.detectChanges(); @@ -234,8 +215,6 @@ describe('UploadDragAreaComponent', () => { }); it('should upload a file with a custom root folder ID when dropped', () => { - component.currentFolderPath = '/root-fake-/sites-fake/document-library-fake'; - component.rootFolderId = '-my-'; component.success = null; fixture.detectChanges(); @@ -257,10 +236,6 @@ describe('UploadDragAreaComponent', () => { }); it('should upload a file when user has create permission on target folder', async(() => { - component.currentFolderPath = '/root-fake-/sites-fake/document-library-fake'; - component.rootFolderId = '-my-'; - component.enabled = false; - let fakeItem = { fullPath: '/folder-fake/file-fake.png', isDirectory: false, @@ -287,29 +262,4 @@ describe('UploadDragAreaComponent', () => { component.onUploadFiles(fakeCustomEvent); })); - - it('should show notification bar when a file is dropped', () => { - component.currentFolderPath = '/root-fake-/sites-fake/document-library-fake'; - component.rootFolderId = '-my-'; - component.success = null; - - fixture.detectChanges(); - spyOn(uploadService, 'uploadFilesInTheQueue'); - - let itemEntity = { - fullPath: '/folder-fake/file-fake.png', - isDirectory: false, - isFile: true, - name: 'file-fake.png', - file: (callbackFile) => { - let fileFake = new File(['fakefake'], 'file-fake.png', {type: 'image/png'}); - callbackFile(fileFake); - } - }; - - component.onFilesEntityDropped(itemEntity); - fixture.detectChanges(); - expect(document.querySelector('snack-bar-container > simple-snack-bar')).not.toBeNull(); - }); - }); diff --git a/lib/content-services/upload/components/upload-drag-area.component.ts b/lib/content-services/upload/components/upload-drag-area.component.ts index b8a66a7567..3b93276e8b 100644 --- a/lib/content-services/upload/components/upload-drag-area.component.ts +++ b/lib/content-services/upload/components/upload-drag-area.component.ts @@ -38,31 +38,6 @@ import { Component, EventEmitter, forwardRef, Input, Output, ViewEncapsulation } }) export class UploadDragAreaComponent implements NodePermissionSubject { - /** @deprecated Deprecated in favor of disabled input property */ - @Input() - set enabled(enabled: boolean) { - console.warn('Deprecated: enabled input property should not be used for UploadDragAreaComponent. Please use disabled instead.'); - this.disabled = !enabled; - } - - /** @deprecated Deprecated in favor of disabled input property */ - get enabled(): boolean { - console.warn('Deprecated: enabled input property should not be used for UploadDragAreaComponent. Please use disabled instead.'); - return !this.disabled; - } - - /** @deprecated Deprecated in 1.6.0, you can use UploadService events and NotificationService api instead. */ - @Input() - showNotificationBar: boolean = true; - - /** @deprecated Deprecated in 1.6.0, this property is not used for couple of releases already. Use rootFolderId instead. */ - @Input() - currentFolderPath: string = '/'; - - /** @deprecated Deprecated in 1.6.2, this property is not used for couple of releases already. Use parentId instead. */ - @Input() - rootFolderId: string = '-root-'; - @Input() disabled: boolean = false; @@ -90,14 +65,10 @@ export class UploadDragAreaComponent implements NodePermissionSubject { const fileModels = files.map(file => new FileModel(file, { newVersion: this.versioning, path: '/', - parentId: this.parentId || this.rootFolderId + parentId: this.parentId })); this.uploadService.addToQueue(...fileModels); this.uploadService.uploadFilesInTheQueue(this.success); - let latestFilesAdded = this.uploadService.getQueue(); - if (this.showNotificationBar) { - this.showUndoNotificationBar(latestFilesAdded); - } } } @@ -111,15 +82,12 @@ export class UploadDragAreaComponent implements NodePermissionSubject { item.file((file: File) => { const fileModel = new FileModel(file, { newVersion: this.versioning, - parentId: this.parentId || this.rootFolderId, + parentId: this.parentId, path: item.fullPath.replace(item.name, '') }); this.uploadService.addToQueue(fileModel); this.uploadService.uploadFilesInTheQueue(this.success); }); - if (this.showNotificationBar) { - this.showUndoNotificationBar(item); - } } } @@ -134,16 +102,11 @@ export class UploadDragAreaComponent implements NodePermissionSubject { let files = entries.map(entry => { return new FileModel(entry.file, { newVersion: this.versioning, - parentId: this.parentId || this.rootFolderId, + parentId: this.parentId, path: entry.relativeFolder }); }); this.uploadService.addToQueue(...files); - /* @deprecated in 1.6.0 */ - if (this.showNotificationBar) { - let latestFilesAdded = this.uploadService.getQueue(); - this.showUndoNotificationBar(latestFilesAdded); - } this.uploadService.uploadFilesInTheQueue(this.success); }); } @@ -191,9 +154,9 @@ export class UploadDragAreaComponent implements NodePermissionSubject { if (isAllowed) { let files: FileInfo[] = event.detail.files; if (files && files.length > 0) { - let parentId = this.parentId || this.rootFolderId; + let parentId = this.parentId; if (event.detail.data && event.detail.data.obj.entry.isFolder) { - parentId = event.detail.data.obj.entry.id || this.parentId || this.rootFolderId; + parentId = event.detail.data.obj.entry.id || this.parentId; } const fileModels = files.map(fileInfo => new FileModel(fileInfo.file, { newVersion: this.versioning, @@ -214,10 +177,6 @@ export class UploadDragAreaComponent implements NodePermissionSubject { if (files.length) { this.uploadService.addToQueue(...files); this.uploadService.uploadFilesInTheQueue(this.success); - let latestFilesAdded = this.uploadService.getQueue(); - if (this.showNotificationBar) { - this.showUndoNotificationBar(latestFilesAdded); - } } } diff --git a/lib/process-services/attachment/process-attachment-list.component.ts b/lib/process-services/attachment/process-attachment-list.component.ts index da1c40e4a4..fca04bd57b 100644 --- a/lib/process-services/attachment/process-attachment-list.component.ts +++ b/lib/process-services/attachment/process-attachment-list.component.ts @@ -17,12 +17,16 @@ import { ContentService, ThumbnailService } from '@alfresco/adf-core'; import { Component, EventEmitter, Input, NgZone, OnChanges, Output, SimpleChanges } from '@angular/core'; -import { ProcessContentService } from '@alfresco/adf-core'; +import { ProcessContentService, UploadService } from '@alfresco/adf-core'; +import { ProcessUploadService } from '../task-list/services/process-upload.service'; @Component({ selector: 'adf-process-attachment-list', styleUrls: ['./process-attachment-list.component.scss'], - templateUrl: './process-attachment-list.component.html' + templateUrl: './process-attachment-list.component.html', + providers: [ + { provide: UploadService, useClass: ProcessUploadService } + ] }) export class ProcessAttachmentListComponent implements OnChanges { diff --git a/lib/process-services/attachment/task-attachment-list.component.ts b/lib/process-services/attachment/task-attachment-list.component.ts index 738dc79d5d..750dc8e9fb 100644 --- a/lib/process-services/attachment/task-attachment-list.component.ts +++ b/lib/process-services/attachment/task-attachment-list.component.ts @@ -17,13 +17,17 @@ import { ContentService, ThumbnailService } from '@alfresco/adf-core'; import { AfterViewInit, Component, ElementRef, EventEmitter, Input, NgZone, OnChanges, Output, SimpleChanges, ViewChild, ViewEncapsulation } from '@angular/core'; -import { ProcessContentService } from '@alfresco/adf-core'; +import { ProcessContentService, UploadService } from '@alfresco/adf-core'; +import { ProcessUploadService } from '../task-list/services/process-upload.service'; @Component({ selector: 'adf-task-attachment-list', styleUrls: ['./task-attachment-list.component.scss'], templateUrl: './task-attachment-list.component.html', - encapsulation: ViewEncapsulation.None + encapsulation: ViewEncapsulation.None, + providers: [ + { provide: UploadService, useClass: ProcessUploadService } + ] }) export class TaskAttachmentListComponent implements OnChanges, AfterViewInit { diff --git a/lib/process-services/task-list/services/process-upload.service.ts b/lib/process-services/task-list/services/process-upload.service.ts index 4471913175..7ba13184eb 100644 --- a/lib/process-services/task-list/services/process-upload.service.ts +++ b/lib/process-services/task-list/services/process-upload.service.ts @@ -35,7 +35,11 @@ export class ProcessUploadService extends UploadService { isRelatedContent: true }; let taskId = file.options.parentId; - return this.instanceApi.getInstance().activiti.contentApi.createRelatedContentOnTask(taskId, file.file, opts).catch(err => this.handleError(err)); + let promise = this.instanceApi.getInstance().activiti.contentApi.createRelatedContentOnTask(taskId, file.file, opts); + + promise.catch(err => this.handleError(err)); + + return promise; } private handleError(error: any) {