diff --git a/demo-shell/src/app/app.routes.ts b/demo-shell/src/app/app.routes.ts index 3c945bc23b..b64e02b594 100644 --- a/demo-shell/src/app/app.routes.ts +++ b/demo-shell/src/app/app.routes.ts @@ -140,6 +140,11 @@ export const appRoutes: Routes = [ component: ShowDiagramComponent, canActivate: [AuthGuardBpm] }, + { + path: 'activiti/apps/:appId/report', + component: ProcessServiceComponent, + canActivate: [AuthGuardBpm] + }, // TODO: check if neeeded { path: 'activiti/appId/:appId', 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 916f393df1..657320cbb8 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 @@ -29,7 +29,7 @@ import { Output } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; -import { ProcessInstanceFilterRepresentation, Pagination } from 'alfresco-js-api'; +import { ProcessInstanceFilterRepresentation, Pagination, UserProcessInstanceFilterRepresentation } from 'alfresco-js-api'; import { FORM_FIELD_VALIDATORS, FormEvent, FormFieldEvent, FormRenderingService, FormService, DynamicTableRow, ValidateDynamicTableRowEvent, AppConfigService, PaginationComponent, UserPreferenceValues @@ -63,10 +63,15 @@ import { Subscription } from 'rxjs/Subscription'; import { /*CustomEditorComponent*/ CustomStencil01 } from './custom-editor/custom-editor.component'; import { DemoFieldValidator } from './demo-field-validator'; import { PreviewService } from '../../services/preview.service'; +import { Location } from '@angular/common'; const currentProcessIdNew = '__NEW__'; const currentTaskIdNew = '__NEW__'; +const TASK_ROUTE = 0; +const PROCESS_ROUTE = 1; +const REPORT_ROUTE = 2; + @Component({ selector: 'app-process-service', templateUrl: './process-service.component.html', @@ -108,7 +113,6 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit @Input() appId: number = null; - @Input() filterSelected: object = null; @Output() @@ -137,8 +141,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit taskFilter: FilterRepresentationModel; report: any; - processFilter: ProcessInstanceFilterRepresentation; - + processFilter: UserProcessInstanceFilterRepresentation; sub: Subscription; blobFile: any; flag = true; @@ -162,6 +165,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit private preview: PreviewService, formRenderingService: FormRenderingService, formService: FormService, + private location: Location, private preferenceService: UserPreferencesService) { this.dataTasks = new ObjectDataTableAdapter(); this.dataTasks.setSorting(new DataSorting('created', 'desc')); @@ -237,7 +241,6 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit onTaskFilterClick(filter: FilterRepresentationModel): void { this.applyTaskFilter(filter); this.resetTaskPaginationPage(); - this.router.navigate(['/activiti/apps', this.appId || 0, 'tasks', filter.id]); } resetTaskPaginationPage() { @@ -245,13 +248,14 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit } onTabChange(event: any): void { - this.showProcessPagination = event.index === 1; - this.paginationPageSize = this.preferenceService.paginationSize; - if (this.processList) { - this.processList.reload(); - } - if (this.taskList) { - this.taskList.reload(); + const index = event.index; + this.showProcessPagination = index === PROCESS_ROUTE; + if (index === TASK_ROUTE) { + this.relocateLocationToTask(); + } else if (index === PROCESS_ROUTE) { + this.relocateLocationToProcess(); + } else if (index === REPORT_ROUTE) { + this.relocateLocationToReport(); } } @@ -269,10 +273,12 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit } applyTaskFilter(filter: FilterRepresentationModel) { - this.taskFilter = filter; + this.taskFilter = Object.assign({}, filter); + if (filter && this.taskList) { this.taskList.hasCustomDataSource = false; } + this.relocateLocationToTask(); } onStartTaskSuccess(event: any): void { @@ -289,9 +295,10 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit this.currentTaskId = this.taskList.getCurrentId(); } - onProcessFilterClick(event: ProcessInstanceFilterRepresentation): void { + onProcessFilterClick(event: UserProcessInstanceFilterRepresentation): void { this.processFilter = event; this.resetProcessPaginationPage(); + this.relocateLocationToProcess(); } resetProcessPaginationPage() { @@ -385,6 +392,18 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit this.router.navigate([`/activiti/apps/${this.appId}/processes/`]); } + relocateLocationToProcess(): void { + this.location.go(`/activiti/apps/${this.appId || 0}/processes/${this.processFilter.id}`); + } + + relocateLocationToTask(): void { + this.location.go(`/activiti/apps/${this.appId || 0}/tasks/${this.taskFilter.id}`); + } + + relocateLocationToReport(): void { + this.location.go(`/activiti/apps/${this.appId || 0}/report/`); + } + onContentClick(content: any): void { if (content.contentBlob) { this.preview.showBlob(content.name, content.contentBlob); diff --git a/docs/process-services/filter.model.md b/docs/process-services/filter.model.md index cdcd1afed7..954ca64466 100644 --- a/docs/process-services/filter.model.md +++ b/docs/process-services/filter.model.md @@ -26,7 +26,7 @@ class AppDefinitionRepresentationModel { } class FilterParamsModel { - id: string; + id: number; name: string; index: number; } diff --git a/lib/process-services/task-list/components/task-filters.component.html b/lib/process-services/task-list/components/task-filters.component.html index 0e4679d3bb..41569373cb 100644 --- a/lib/process-services/task-list/components/task-filters.component.html +++ b/lib/process-services/task-list/components/task-filters.component.html @@ -1,6 +1,6 @@