[ADF-1045] Process Attachments List - Improve the component (#2067)

* Create two different ProcessUpload service on for task one for process because the API are different
Move the attachment task list and process list in different component outside the activiti demo component

* Move the create task/process attachment in the child component
This commit is contained in:
Maurizio Vitale
2017-07-11 10:21:04 +01:00
committed by Eugenio Romano
parent 2a16bf2f34
commit 50fef106a8
14 changed files with 252 additions and 105 deletions

View File

@@ -35,6 +35,7 @@ import {
} from './src/components/index';
import { ActivitiProcessService } from './src/services/activiti-process.service';
import { ProcessUploadService } from './src/services/process-upload.service';
// components
export * from './src/components/activiti-processlist.component';
@@ -43,6 +44,7 @@ export * from './src/components/activiti-process-instance-details.component';
export * from './src/components/activiti-start-process.component';
export * from './src/components/adf-process-attachment-list.component';
export * from './src/components/adf-create-process-attachment.component';
export * from './src/services/process-upload.service';
// models
export * from './src/models/index';
@@ -64,7 +66,8 @@ export const ACTIVITI_PROCESSLIST_DIRECTIVES: [any] = [
];
export const ACTIVITI_PROCESSLIST_PROVIDERS: [any] = [
ActivitiProcessService
ActivitiProcessService,
ProcessUploadService
];
@NgModule({

View File

@@ -64,6 +64,16 @@ export class ActivitiProcessAttachmentListComponent implements OnChanges {
this.loadAttachmentsByProcessInstanceId(this.processInstanceId);
}
add(content: any): void {
this.attachments.push({
id: content.id,
name: content.name,
created: content.created,
createdBy: content.createdBy.firstName + ' ' + content.createdBy.lastName,
icon: this.thumbnailService.getMimeTypeIcon(content.mimeType)
});
}
private loadAttachmentsByProcessInstanceId(processInstanceId: string) {
if (processInstanceId) {
this.reset();

View File

@@ -0,0 +1,39 @@
/*!
* @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 { AlfrescoApiService, AppConfigService, UploadService } from 'ng2-alfresco-core';
@Injectable()
export class ProcessUploadService extends UploadService {
instanceApi: AlfrescoApiService;
constructor(apiService: AlfrescoApiService, appConfigService: AppConfigService) {
super(apiService, appConfigService);
this.instanceApi = apiService;
}
getUploadPromise(file: any) {
let opts = {
isRelatedContent: true
};
let processId = file.options.parentId;
return this.instanceApi.getInstance().activiti.contentApi.createRelatedContentOnProcessInstance(processId, file.file, opts);
}
}