mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[ADF-2035] Drag and drop is not working on Processes - attachment List (#2736)
* fix upload for process attachment list export ActivitiContentService ProcessService.createOrUpdateProcessInstanceVariables has incorrect method signature * fix signature methods * fix test parameters
This commit is contained in:
parent
2f07fa339d
commit
bdc06e3eed
@ -1,15 +1,17 @@
|
||||
<div id="attachment-process-list" *ngIf="processInstanceId">
|
||||
<h5>Attachments</h5>
|
||||
<div class="adf-no-form-container">
|
||||
|
||||
<adf-upload-drag-area
|
||||
[parentId]="processInstanceId"
|
||||
[disabled]="isCompletedProcess()">
|
||||
|
||||
<adf-process-attachment-list #processAttachList
|
||||
*ngIf="processInstanceId"
|
||||
[disabled]="isCompletedProcess()"
|
||||
[processInstanceId]="processInstanceId"
|
||||
(attachmentClick)="onAttachmentClick($event)">
|
||||
*ngIf="processInstanceId"
|
||||
[disabled]="isCompletedProcess()"
|
||||
[processInstanceId]="processInstanceId"
|
||||
(attachmentClick)="onAttachmentClick($event)">
|
||||
</adf-process-attachment-list>
|
||||
|
||||
</adf-upload-drag-area>
|
||||
|
||||
<adf-create-process-attachment
|
||||
|
@ -28,15 +28,16 @@ import { UploadService } from '@alfresco/adf-core';
|
||||
|
||||
export class ProcessAttachmentsComponent implements OnInit, OnChanges {
|
||||
|
||||
@Input()
|
||||
processInstanceId: string;
|
||||
|
||||
@ViewChild(ProcessAttachmentListComponent)
|
||||
processAttachList: ProcessAttachmentListComponent;
|
||||
|
||||
fileShowed: boolean = false;
|
||||
@Input()
|
||||
processInstanceId: string;
|
||||
|
||||
fileShowed = false;
|
||||
content: Blob;
|
||||
contentName: string;
|
||||
|
||||
processInstance: ProcessInstance;
|
||||
|
||||
constructor(private uploadService: UploadService, private processService: ProcessService) {
|
||||
@ -48,7 +49,8 @@ export class ProcessAttachmentsComponent implements OnInit, OnChanges {
|
||||
|
||||
ngOnChanges() {
|
||||
if (this.processInstanceId) {
|
||||
this.processService.getProcess(this.processInstanceId).subscribe((processInstance: ProcessInstance) => {
|
||||
this.processService.getProcess(this.processInstanceId)
|
||||
.subscribe((processInstance: ProcessInstance) => {
|
||||
this.processInstance = processInstance;
|
||||
});
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,17 +1,24 @@
|
||||
<div id="attachment-task-list" *ngIf="taskId">
|
||||
<div class="adf-no-form-container">
|
||||
|
||||
<adf-upload-drag-area
|
||||
[parentId]="taskId">
|
||||
|
||||
<adf-task-attachment-list #taskAttachList
|
||||
[disabled]="isCompletedTask()"
|
||||
(attachmentClick)="onAttachmentClick($event)"
|
||||
[taskId]="taskId">
|
||||
[taskId]="taskId"
|
||||
(attachmentClick)="onAttachmentClick($event)">
|
||||
<div adf-empty-list>
|
||||
<div adf-empty-list-header class="adf-empty-list-header"> {{'ADF_TASK_LIST.ATTACHMENT.EMPTY.HEADER' | translate}} </div>
|
||||
<div adf-empty-list-header class="adf-empty-list-header"> {{'ADF_TASK_LIST.ATTACHMENT.EMPTY.HEADER'
|
||||
| translate}}
|
||||
</div>
|
||||
<div adf-empty-list-body>
|
||||
<div fxHide.lt-md="true" class="adf-empty-list-drag_drop">{{'ADF_TASK_LIST.ATTACHMENT.EMPTY.DRAG-AND-DROP.TITLE' | translate}}</div>
|
||||
<div fxHide.lt-md="true" class="adf-empty-list__any-files-here-to-add"> {{'ADF_TASK_LIST.ATTACHMENT.EMPTY.DRAG-AND-DROP.SUBTITLE' | translate}} </div>
|
||||
<div fxHide.lt-md="true" class="adf-empty-list-drag_drop">
|
||||
{{'ADF_TASK_LIST.ATTACHMENT.EMPTY.DRAG-AND-DROP.TITLE' | translate}}
|
||||
</div>
|
||||
<div fxHide.lt-md="true" class="adf-empty-list__any-files-here-to-add">
|
||||
{{'ADF_TASK_LIST.ATTACHMENT.EMPTY.DRAG-AND-DROP.SUBTITLE' | translate}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</adf-task-attachment-list>
|
||||
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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<FilterProcessRepresentationModel[]> {
|
||||
@ -72,7 +71,7 @@ export class ProcessFilterService {
|
||||
* @param appId
|
||||
* @returns {FilterProcessRepresentationModel[]}
|
||||
*/
|
||||
public createDefaultFilters(appId: number): Observable<any[]> {
|
||||
public createDefaultFilters(appId: number): Observable<FilterProcessRepresentationModel[]> {
|
||||
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)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ describe('ProcessService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
||||
providers: [
|
||||
ProcessService
|
||||
]
|
||||
|
@ -126,24 +126,24 @@ export class ProcessService {
|
||||
.catch(err => this.handleProcessError(err));
|
||||
}
|
||||
|
||||
getProcessInstanceVariables(processDefinitionId: string): Observable<ProcessInstanceVariable[]> {
|
||||
getProcessInstanceVariables(processInstanceId: string): Observable<ProcessInstanceVariable[]> {
|
||||
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<ProcessInstanceVariable[]> {
|
||||
createOrUpdateProcessInstanceVariables(processInstanceId: string, variables: ProcessInstanceVariable[]): Observable<ProcessInstanceVariable[]> {
|
||||
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<void> {
|
||||
deleteProcessInstanceVariable(processInstanceId: string, variableName: string): Observable<void> {
|
||||
return Observable.fromPromise(
|
||||
this.alfrescoApiService.getInstance().activiti.processInstanceVariablesApi.deleteProcessInstanceVariable(processDefinitionId, variableName)
|
||||
this.alfrescoApiService.getInstance().activiti.processInstanceVariablesApi.deleteProcessInstanceVariable(processInstanceId, variableName)
|
||||
)
|
||||
.catch(err => this.handleProcessError(err));
|
||||
}
|
||||
|
@ -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';
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user