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 c9abd272ea..5ed63d02ec 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 @@ -1,15 +1,17 @@
-
Attachments
+ + + *ngIf="processInstanceId" + [disabled]="isCompletedProcess()" + [processInstanceId]="processInstanceId" + (attachmentClick)="onAttachmentClick($event)"> + { + this.processService.getProcess(this.processInstanceId) + .subscribe((processInstance: ProcessInstance) => { this.processInstance = processInstance; }); } diff --git a/demo-shell/src/app/components/process-service/process-service.component.ts b/demo-shell/src/app/components/process-service/process-service.component.ts index fa435c38fa..8f198a322c 100644 --- a/demo-shell/src/app/components/process-service/process-service.component.ts +++ b/demo-shell/src/app/components/process-service/process-service.component.ts @@ -104,8 +104,8 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit @Input() appId: number = null; - fileShowed: boolean = false; - selectFirstReport: boolean = false; + fileShowed = false; + selectFirstReport = false; private tabs = { tasks: 0, processes: 1, reports: 2 }; @@ -122,7 +122,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit maxItems: 10, totalItems: 0 }; - taskPage: number = 0; + taskPage = 0; processSchemaColumns: any[] = []; activeTab: number = this.tabs.tasks; // tasks|processes|reports @@ -133,11 +133,11 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit sub: Subscription; blobFile: any; - flag: boolean = true; + flag = true; dataTasks: ObjectDataTableAdapter; dataProcesses: ObjectDataTableAdapter; - presetColoum: string = 'default'; + presetColoum = 'default'; fieldValidators = [ ...FORM_FIELD_VALIDATORS, @@ -170,12 +170,12 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit }); formService.validateDynamicTableRow.subscribe( - (e: ValidateDynamicTableRowEvent) => { - const row: DynamicTableRow = e.row; + (validateDynamicTableRowEvent: ValidateDynamicTableRowEvent) => { + const row: DynamicTableRow = validateDynamicTableRowEvent.row; if (row && row.value && row.value.name === 'admin') { - e.summary.isValid = false; - e.summary.message = 'Sorry, wrong value. You cannot use "admin".'; - e.preventDefault(); + validateDynamicTableRowEvent.summary.isValid = false; + validateDynamicTableRowEvent.summary.message = 'Sorry, wrong value. You cannot use "admin".'; + validateDynamicTableRowEvent.preventDefault(); } } ); @@ -240,7 +240,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit this.activeTab = this.tabs.processes; } this.sub = this.route.params.subscribe(params => { - let applicationId = params['appId']; + const applicationId = params['appId']; if (applicationId && applicationId !== '0') { this.appId = params['appId']; } @@ -417,10 +417,10 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit loadStencilScriptsInPageFromProcessService() { this.apiService.getInstance().activiti.scriptFileApi.getControllers().then(response => { if (response) { - let s = document.createElement('script'); - s.type = 'text/javascript'; - s.text = response; - this.elementRef.nativeElement.appendChild(s); + const stencilSript = document.createElement('script'); + stencilSript.type = 'text/javascript'; + stencilSript.text = response; + this.elementRef.nativeElement.appendChild(stencilSript); } }); } 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 56d89adb0e..5295cd14fc 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,17 +1,24 @@
+ + [taskId]="taskId" + (attachmentClick)="onAttachmentClick($event)">
-
{{'ADF_TASK_LIST.ATTACHMENT.EMPTY.HEADER' | translate}}
+
{{'ADF_TASK_LIST.ATTACHMENT.EMPTY.HEADER' + | translate}} +
-
{{'ADF_TASK_LIST.ATTACHMENT.EMPTY.DRAG-AND-DROP.TITLE' | translate}}
-
{{'ADF_TASK_LIST.ATTACHMENT.EMPTY.DRAG-AND-DROP.SUBTITLE' | translate}}
+
+ {{'ADF_TASK_LIST.ATTACHMENT.EMPTY.DRAG-AND-DROP.TITLE' | translate}} +
+
+ {{'ADF_TASK_LIST.ATTACHMENT.EMPTY.DRAG-AND-DROP.SUBTITLE' | 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 9065b062a3..1d9fe55fe7 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,7 +16,7 @@ */ import { Component, Input, OnChanges, OnInit, ViewChild } from '@angular/core'; -import { TaskListService, TaskAttachmentListComponent } from '@alfresco/adf-process-services'; +import { TaskListService, TaskAttachmentListComponent, TaskDetailsModel } from '@alfresco/adf-process-services'; import { UploadService } from '@alfresco/adf-core'; @Component({ @@ -33,15 +33,13 @@ export class TaskAttachmentsComponent implements OnInit, OnChanges { @Input() taskId: string; - fileShowed: boolean = false; + fileShowed = false; content: Blob; contentName: string; taskDetails: any; - constructor(private uploadService: UploadService, - private activitiTaskList: TaskListService) { - + constructor(private uploadService: UploadService, private activitiTaskList: TaskListService) { } ngOnInit() { @@ -50,9 +48,9 @@ export class TaskAttachmentsComponent implements OnInit, OnChanges { ngOnChanges() { if (this.taskId) { - this.activitiTaskList.getTaskDetails(this.taskId).map((res) => res).subscribe( - (res: any) => { - this.taskDetails = res; + this.activitiTaskList.getTaskDetails(this.taskId).map((res) => res) + .subscribe((taskDetails: TaskDetailsModel) => { + this.taskDetails = taskDetails; }); } } diff --git a/lib/process-services/attachment/task-attachment-list.component.ts b/lib/process-services/attachment/task-attachment-list.component.ts index 750dc8e9fb..8f5693ed7c 100644 --- a/lib/process-services/attachment/task-attachment-list.component.ts +++ b/lib/process-services/attachment/task-attachment-list.component.ts @@ -18,7 +18,7 @@ import { ContentService, ThumbnailService } from '@alfresco/adf-core'; import { AfterViewInit, Component, ElementRef, EventEmitter, Input, NgZone, OnChanges, Output, SimpleChanges, ViewChild, ViewEncapsulation } from '@angular/core'; import { ProcessContentService, UploadService } from '@alfresco/adf-core'; -import { ProcessUploadService } from '../task-list/services/process-upload.service'; +import { TaskUploadService } from '../task-list/services/task-upload.service'; @Component({ selector: 'adf-task-attachment-list', @@ -26,7 +26,7 @@ import { ProcessUploadService } from '../task-list/services/process-upload.servi templateUrl: './task-attachment-list.component.html', encapsulation: ViewEncapsulation.None, providers: [ - { provide: UploadService, useClass: ProcessUploadService } + { provide: UploadService, useClass: TaskUploadService } ] }) export class TaskAttachmentListComponent implements OnChanges, AfterViewInit { diff --git a/lib/process-services/process-list/components/process-filters.component.spec.ts b/lib/process-services/process-list/components/process-filters.component.spec.ts index f817fad614..5bbf9fbbe2 100644 --- a/lib/process-services/process-list/components/process-filters.component.spec.ts +++ b/lib/process-services/process-list/components/process-filters.component.spec.ts @@ -56,7 +56,7 @@ describe('ActivitiFilters', () => { }); beforeEach(() => { - processFilterService = new ProcessFilterService(null, null); + processFilterService = new ProcessFilterService(null); appsProcessService = new AppsProcessService(null, null); filterList = new ProcessFiltersComponent(processFilterService, appsProcessService); }); diff --git a/lib/process-services/process-list/services/process-filter.service.ts b/lib/process-services/process-list/services/process-filter.service.ts index 266a43babe..75b7f0d503 100644 --- a/lib/process-services/process-list/services/process-filter.service.ts +++ b/lib/process-services/process-list/services/process-filter.service.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { AlfrescoApiService, LogService } from '@alfresco/adf-core'; +import { AlfrescoApiService } from '@alfresco/adf-core'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { FilterProcessRepresentationModel } from '../models/filter-process.model'; @@ -24,8 +24,7 @@ import 'rxjs/add/observable/throw'; @Injectable() export class ProcessFilterService { - constructor(private alfrescoApiService: AlfrescoApiService, - private logService: LogService) { + constructor(private alfrescoApiService: AlfrescoApiService) { } getProcessFilters(appId: number): Observable { @@ -72,7 +71,7 @@ export class ProcessFilterService { * @param appId * @returns {FilterProcessRepresentationModel[]} */ - public createDefaultFilters(appId: number): Observable { + public createDefaultFilters(appId: number): Observable { let runningFilter = this.getRunningFilterInstance(appId); let runningObservable = this.addProcessFilter(runningFilter); @@ -103,7 +102,7 @@ export class ProcessFilterService { observer.complete(); }, (err: any) => { - this.logService.error(err); + this.handleProcessError(err) }); }); } diff --git a/lib/process-services/process-list/services/process.service.spec.ts b/lib/process-services/process-list/services/process.service.spec.ts index c260f92186..4f36e54d25 100644 --- a/lib/process-services/process-list/services/process.service.spec.ts +++ b/lib/process-services/process-list/services/process.service.spec.ts @@ -35,7 +35,6 @@ describe('ProcessService', () => { beforeEach(() => { TestBed.configureTestingModule({ - providers: [ ProcessService ] diff --git a/lib/process-services/process-list/services/process.service.ts b/lib/process-services/process-list/services/process.service.ts index fa4576efbd..3239cb1249 100644 --- a/lib/process-services/process-list/services/process.service.ts +++ b/lib/process-services/process-list/services/process.service.ts @@ -126,24 +126,24 @@ export class ProcessService { .catch(err => this.handleProcessError(err)); } - getProcessInstanceVariables(processDefinitionId: string): Observable { + getProcessInstanceVariables(processInstanceId: string): Observable { return Observable.fromPromise( - this.alfrescoApiService.getInstance().activiti.processInstanceVariablesApi.getProcessInstanceVariables(processDefinitionId) + this.alfrescoApiService.getInstance().activiti.processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId) ) .map((processVars: any[]) => processVars.map((pd) => new ProcessInstanceVariable(pd))) .catch(err => this.handleProcessError(err)); } - createOrUpdateProcessInstanceVariables(processDefinitionId: string, variables: ProcessInstanceVariable[]): Observable { + createOrUpdateProcessInstanceVariables(processInstanceId: string, variables: ProcessInstanceVariable[]): Observable { return Observable.fromPromise( - this.alfrescoApiService.getInstance().activiti.processInstanceVariablesApi.createOrUpdateProcessInstanceVariables(processDefinitionId, variables) + this.alfrescoApiService.getInstance().activiti.processInstanceVariablesApi.createOrUpdateProcessInstanceVariables(processInstanceId, variables) ) .catch(err => this.handleProcessError(err)); } - deleteProcessInstanceVariable(processDefinitionId: string, variableName: string): Observable { + deleteProcessInstanceVariable(processInstanceId: string, variableName: string): Observable { return Observable.fromPromise( - this.alfrescoApiService.getInstance().activiti.processInstanceVariablesApi.deleteProcessInstanceVariable(processDefinitionId, variableName) + this.alfrescoApiService.getInstance().activiti.processInstanceVariablesApi.deleteProcessInstanceVariable(processInstanceId, variableName) ) .catch(err => this.handleProcessError(err)); } diff --git a/lib/process-services/task-list/public-api.ts b/lib/process-services/task-list/public-api.ts index e8974702d2..c9a291d354 100644 --- a/lib/process-services/task-list/public-api.ts +++ b/lib/process-services/task-list/public-api.ts @@ -26,6 +26,7 @@ export * from './components/start-task.component'; export * from './services/tasklist.service'; export * from './services/process-upload.service'; +export * from './services/task-upload.service'; export * from './services/task-filter.service'; export * from './models/filter.model'; @@ -33,3 +34,4 @@ export * from './models/task-details.model'; export * from './models/task-details.event'; export * from './models/user-event.model'; export * from './models/start-task.model'; +export * from './models/task-list.model'; 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 7ba13184eb..b78daab0d7 100644 --- a/lib/process-services/task-list/services/process-upload.service.ts +++ b/lib/process-services/task-list/services/process-upload.service.ts @@ -34,8 +34,8 @@ export class ProcessUploadService extends UploadService { let opts = { isRelatedContent: true }; - let taskId = file.options.parentId; - let promise = this.instanceApi.getInstance().activiti.contentApi.createRelatedContentOnTask(taskId, file.file, opts); + let processInstanceId = file.options.parentId; + let promise = this.instanceApi.getInstance().activiti.contentApi.createRelatedContentOnProcessInstance(processInstanceId, file.file, opts); promise.catch(err => this.handleError(err)); diff --git a/lib/process-services/task-list/services/task-upload.service.ts b/lib/process-services/task-list/services/task-upload.service.ts new file mode 100644 index 0000000000..dd879a1b1a --- /dev/null +++ b/lib/process-services/task-list/services/task-upload.service.ts @@ -0,0 +1,49 @@ +/*! + * @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 { AlfrescoApiService, AppConfigService, UploadService } from '@alfresco/adf-core'; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/observable/throw'; + +@Injectable() +export class TaskUploadService extends UploadService { + + instanceApi: AlfrescoApiService; + + constructor(apiService: AlfrescoApiService, appConfigService: AppConfigService) { + super(apiService, appConfigService); + this.instanceApi = apiService; + } + + getUploadPromise(file: any): any { + let opts = { + isRelatedContent: true + }; + let taskId = file.options.parentId; + let promise = this.instanceApi.getInstance().activiti.contentApi.createRelatedContentOnTask(taskId, file.file, opts); + + promise.catch(err => this.handleError(err)); + + return promise; + } + + private handleError(error: any) { + return Observable.throw(error || 'Server error'); + } + +}