mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-3992] Process Filter bug fixes and improvements (#6599)
* bug fixes * bug fixes * bug fixes * cleanup tests * travis workaround * travis workaround * travis workaround * travis workaround * travis workaround * travis workaround * Revert "travis workaround" This reverts commit b67efccfb0aab8c7f6b9235d01525487771b8123. * Revert "travis workaround" This reverts commit 448f4e6d1211771e914f35183860af6df3452c16. * Revert "travis workaround" This reverts commit 542fae649c0501a9150ccac2e5a2cd54ee39a690. * Revert "travis workaround" This reverts commit 12f58568fbb0f8d2defb4c21a3ab1683bc8aa312. * Revert "travis workaround" This reverts commit b0ffef3bee0f81faf6088be8b5c2b072ad2762e7. * Revert "travis workaround" This reverts commit c6d95a2ff3b38b543fea83d3fc53016ac657b3bb. * service fixes * remove junk tests * code fixes * reduce code complexity * update e2e * update e2e * fix i18n * e2e fixes * bug fixes * rebase and fix * properly serialize query params * rework process filters demo * remove dead code * code fixes * code fixes * e2e improvements * fix bug and remove e2e testing a bug * bug fixes for date ranges * fix e2e * fix unit test * reusable code * fix flaky e2e * fix angular cli version * remove useless e2e (already tested by unit tests) * remove useless e2e (already tested by unit tests) * demo shell fixes * remove fit * disable flaky test * update code as per review suggestions * fix after rebase * fix after rebase
This commit is contained in:
@@ -19,6 +19,8 @@ import { Component, ViewEncapsulation, Input, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { CloudLayoutService } from './services/cloud-layout.service';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { CloudProcessFiltersService } from './services/cloud-process-filters.service';
|
||||
import { ProcessFilterCloudModel } from '@alfresco/adf-process-services-cloud';
|
||||
@Component({
|
||||
selector: 'app-cloud-filters-demo',
|
||||
templateUrl: './cloud-filters-demo.component.html',
|
||||
@@ -42,7 +44,8 @@ export class CloudFiltersDemoComponent implements OnInit {
|
||||
constructor(
|
||||
private cloudLayoutService: CloudLayoutService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute
|
||||
private route: ActivatedRoute,
|
||||
private cloudProcessFiltersService: CloudProcessFiltersService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -63,11 +66,19 @@ export class CloudFiltersDemoComponent implements OnInit {
|
||||
}
|
||||
|
||||
onTaskFilterSelected(filter) {
|
||||
this.router.navigate([`/cloud/${this.appName}/tasks/`], { queryParams: filter });
|
||||
if (filter) {
|
||||
this.router.navigate([`/cloud/${this.appName}/tasks/`], {queryParams: filter});
|
||||
}
|
||||
}
|
||||
|
||||
onProcessFilterSelected(filter) {
|
||||
this.router.navigate([`/cloud/${this.appName}/processes/`], { queryParams: filter });
|
||||
onProcessFilterSelected(filter: ProcessFilterCloudModel) {
|
||||
if (filter) {
|
||||
const {appName} = this;
|
||||
const {id} = filter;
|
||||
|
||||
const queryParams = this.cloudProcessFiltersService.writeQueryParams(filter, appName, id);
|
||||
this.router.navigate([`/cloud/${appName}/processes/`], {queryParams});
|
||||
}
|
||||
}
|
||||
|
||||
onTaskFilterOpen(): boolean {
|
||||
|
@@ -145,6 +145,6 @@ export class CommunityProcessesCloudDemoComponent implements OnInit, OnDestroy {
|
||||
|
||||
onRowsSelected(nodes) {
|
||||
this.resetSelectedRows();
|
||||
this.selectedRows = nodes.map((node) => node.obj.entry);
|
||||
this.selectedRows = nodes.map((node) => node.obj);
|
||||
}
|
||||
}
|
||||
|
@@ -127,7 +127,7 @@ export class CommunityTasksCloudDemoComponent implements OnInit, OnDestroy {
|
||||
|
||||
onRowsSelected(nodes) {
|
||||
this.resetSelectedRows();
|
||||
this.selectedRows = nodes.map((node) => node.obj.entry);
|
||||
this.selectedRows = nodes.map((node) => node.obj);
|
||||
}
|
||||
|
||||
onFilterChange(filter: any) {
|
||||
|
@@ -2,9 +2,10 @@
|
||||
<adf-cloud-edit-process-filter
|
||||
[appName]="appName"
|
||||
[id]="filterId"
|
||||
[filterProperties]="processFilterProperties.filterProperties"
|
||||
[sortProperties]="processFilterProperties.sortProperties"
|
||||
[actions]="processFilterProperties.actions"
|
||||
[filterProperties]="filterProperties"
|
||||
[sortProperties]="filterSortProperties"
|
||||
[actions]="filterActions"
|
||||
[processFilter]="editedFilter"
|
||||
(filterChange)="onFilterChange($event)"
|
||||
(action)="onProcessFilterAction($event)">
|
||||
</adf-cloud-edit-process-filter>
|
||||
@@ -24,7 +25,7 @@
|
||||
[businessKey]="editedFilter['businessKey']"
|
||||
[lastModifiedFrom]="editedFilter.lastModifiedFrom"
|
||||
[lastModifiedTo]="editedFilter.lastModifiedTo"
|
||||
[sorting]="sortArray"
|
||||
[sorting]="[{orderBy: editedFilter.sort, direction: editedFilter.order}]"
|
||||
[selectionMode]="selectionMode"
|
||||
[stickyHeader]="true"
|
||||
[showActions]="actionMenu"
|
||||
|
@@ -15,42 +15,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
|
||||
import {
|
||||
ProcessListCloudComponent,
|
||||
ProcessFilterCloudModel,
|
||||
ProcessListCloudSortingModel,
|
||||
ProcessFiltersCloudComponent
|
||||
} from '@alfresco/adf-process-services-cloud';
|
||||
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { EditProcessFilterCloudComponent, ProcessFilterAction, ProcessFilterCloudModel, ProcessFilterCloudService } from '@alfresco/adf-process-services-cloud';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { UserPreferencesService, AppConfigService, DataCellEvent } from '@alfresco/adf-core';
|
||||
import { UserPreferencesService, DataCellEvent } from '@alfresco/adf-core';
|
||||
import { CloudLayoutService, CloudServiceSettings } from './services/cloud-layout.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { Pagination } from '@alfresco/js-api';
|
||||
import { CloudProcessFiltersService } from './services/cloud-process-filters.service';
|
||||
|
||||
@Component({
|
||||
templateUrl: './processes-cloud-demo.component.html',
|
||||
styleUrls: ['./processes-cloud-demo.component.scss']
|
||||
templateUrl: './processes-cloud-demo.component.html'
|
||||
})
|
||||
export class ProcessesCloudDemoComponent implements OnInit, OnDestroy {
|
||||
|
||||
public static ACTION_SAVE_AS = 'saveAs';
|
||||
public static ACTION_DELETE = 'delete';
|
||||
static PROCESS_FILTER_PROPERTY_KEYS = 'adf-edit-process-filter';
|
||||
|
||||
@ViewChild('processCloud')
|
||||
processCloud: ProcessListCloudComponent;
|
||||
|
||||
@ViewChild('processFiltersCloud')
|
||||
processFiltersCloud: ProcessFiltersCloudComponent;
|
||||
|
||||
appName: string = '';
|
||||
isFilterLoaded: boolean;
|
||||
isFilterLoaded = false;
|
||||
|
||||
filterId: string = '';
|
||||
sortArray: any = [];
|
||||
selectedRow: any;
|
||||
multiselect: boolean;
|
||||
selectionMode: string;
|
||||
@@ -61,7 +43,11 @@ export class ProcessesCloudDemoComponent implements OnInit, OnDestroy {
|
||||
actions: any[] = [];
|
||||
selectedAction: { id: number, name: string, actionType: string};
|
||||
selectedContextAction: { id: number, name: string, actionType: string};
|
||||
processFilterProperties: any = { filterProperties: [], sortProperties: [], actions: [] };
|
||||
|
||||
filterProperties: string[];
|
||||
filterSortProperties: string[];
|
||||
filterActions: string[];
|
||||
|
||||
processDetailsRedirection: boolean;
|
||||
|
||||
editedFilter: ProcessFilterCloudModel;
|
||||
@@ -73,24 +59,24 @@ export class ProcessesCloudDemoComponent implements OnInit, OnDestroy {
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private cloudLayoutService: CloudLayoutService,
|
||||
private userPreference: UserPreferencesService,
|
||||
private appConfig: AppConfigService) {
|
||||
const properties = this.appConfig.get<Array<any>>(ProcessesCloudDemoComponent.PROCESS_FILTER_PROPERTY_KEYS);
|
||||
if (properties) {
|
||||
this.processFilterProperties = properties;
|
||||
}
|
||||
private cloudProcessFiltersService: CloudProcessFiltersService,
|
||||
private processFilterCloudService: ProcessFilterCloudService,
|
||||
private userPreference: UserPreferencesService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.isFilterLoaded = false;
|
||||
this.route.parent.params.subscribe((params) => {
|
||||
this.appName = params.appName;
|
||||
});
|
||||
this.filterProperties = this.cloudProcessFiltersService.filterProperties;
|
||||
this.filterSortProperties = this.cloudProcessFiltersService.sortProperties;
|
||||
this.filterActions = this.cloudProcessFiltersService.actions;
|
||||
|
||||
this.route.queryParams.subscribe((params) => {
|
||||
this.isFilterLoaded = true;
|
||||
this.onFilterChange(params);
|
||||
|
||||
this.appName = params.appName;
|
||||
this.filterId = params.id;
|
||||
|
||||
const model = this.cloudProcessFiltersService.readQueryParams(params);
|
||||
this.loadFilter(model);
|
||||
});
|
||||
|
||||
this.cloudLayoutService.settings$
|
||||
@@ -134,31 +120,26 @@ export class ProcessesCloudDemoComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
onFilterChange(query: any) {
|
||||
this.editedFilter = Object.assign({}, query);
|
||||
this.sortArray = [
|
||||
new ProcessListCloudSortingModel({
|
||||
orderBy: this.editedFilter.sort,
|
||||
direction: this.editedFilter.order
|
||||
})
|
||||
];
|
||||
onFilterChange(filter: ProcessFilterCloudModel) {
|
||||
const queryParams = this.cloudProcessFiltersService.writeQueryParams(filter, this.appName, this.filterId);
|
||||
this.router.navigate([`/cloud/${this.appName}/processes/`], {queryParams});
|
||||
}
|
||||
|
||||
onProcessFilterAction(filterAction: any) {
|
||||
if (filterAction.actionType === ProcessesCloudDemoComponent.ACTION_DELETE) {
|
||||
onProcessFilterAction(filterAction: ProcessFilterAction) {
|
||||
if (filterAction.actionType === EditProcessFilterCloudComponent.ACTION_DELETE) {
|
||||
this.cloudLayoutService.setCurrentProcessFilterParam({ index: 0 });
|
||||
} else {
|
||||
this.cloudLayoutService.setCurrentProcessFilterParam({ id: filterAction.filter.id });
|
||||
}
|
||||
|
||||
if (filterAction.actionType === ProcessesCloudDemoComponent.ACTION_SAVE_AS) {
|
||||
this.router.navigate([`/cloud/${this.appName}/processes/`], { queryParams: filterAction.filter });
|
||||
if ([EditProcessFilterCloudComponent.ACTION_SAVE, EditProcessFilterCloudComponent.ACTION_SAVE_AS].includes(filterAction.actionType)) {
|
||||
this.onFilterChange(filterAction.filter);
|
||||
}
|
||||
}
|
||||
|
||||
onRowsSelected(nodes) {
|
||||
this.resetSelectedRows();
|
||||
this.selectedRows = nodes.map((node) => node.obj.entry);
|
||||
this.selectedRows = nodes.map((node) => node.obj);
|
||||
}
|
||||
|
||||
onShowRowActionsMenu(event: DataCellEvent) {
|
||||
@@ -197,4 +178,12 @@ export class ProcessesCloudDemoComponent implements OnInit, OnDestroy {
|
||||
const action = contextAction.model;
|
||||
this.selectedContextAction = {id: value.id, name: value.name, actionType: action.title};
|
||||
}
|
||||
|
||||
private loadFilter(model: ProcessFilterCloudModel) {
|
||||
if (model && model.appName && model.id) {
|
||||
this.processFilterCloudService.getFilterById(model.appName, model.id).subscribe(filter => {
|
||||
this.editedFilter = Object.assign({}, filter, model);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,55 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 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 { ProcessFilterCloudModel, ProcessFilterCloudService } from '@alfresco/adf-process-services-cloud';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CloudProcessFiltersService {
|
||||
constructor(private appConfigService: AppConfigService, private processFilterCloudService: ProcessFilterCloudService) {
|
||||
}
|
||||
|
||||
get filterProperties(): string[] {
|
||||
return this.appConfigService.get(
|
||||
'adf-edit-process-filter.filterProperties',
|
||||
['status', 'sort', 'order', 'processName']
|
||||
);
|
||||
}
|
||||
|
||||
get sortProperties(): string[] {
|
||||
return this.appConfigService.get(
|
||||
'adf-edit-process-filter.sortProperties',
|
||||
['id', 'name', 'status', 'startDate']
|
||||
);
|
||||
}
|
||||
|
||||
get actions(): string[] {
|
||||
return this.appConfigService.get(
|
||||
'adf-edit-process-filter.actions',
|
||||
['save', 'saveAs', 'delete']
|
||||
);
|
||||
}
|
||||
|
||||
readQueryParams(obj: Object): ProcessFilterCloudModel {
|
||||
return this.processFilterCloudService.readQueryParams(obj);
|
||||
}
|
||||
|
||||
writeQueryParams(value: Object, appName?: string, id?: string): Object {
|
||||
return this.processFilterCloudService.writeQueryParams(value, this.filterProperties, appName, id);
|
||||
}
|
||||
}
|
@@ -125,7 +125,7 @@ export class TasksCloudDemoComponent implements OnInit, OnDestroy {
|
||||
|
||||
onRowsSelected(nodes) {
|
||||
this.resetSelectedRows();
|
||||
this.selectedRows = nodes.map((node) => node.obj.entry);
|
||||
this.selectedRows = nodes.map((node) => node.obj);
|
||||
}
|
||||
|
||||
onFilterChange(filter: any) {
|
||||
|
Reference in New Issue
Block a user