mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-10 14:11:42 +00:00
[AAE-9284] Changes en base edit task filter to be able to save and restore filters
This commit is contained in:
@@ -178,7 +178,8 @@
|
||||
"TOOL_TIP": {
|
||||
"SAVE": "Save filter",
|
||||
"SAVE_AS": "Save filter as",
|
||||
"DELETE": "Delete filter"
|
||||
"DELETE": "Delete filter",
|
||||
"RESTORE":"Restore filter"
|
||||
},
|
||||
"LABEL": {
|
||||
"APP_NAME": "ApplicationName",
|
||||
|
@@ -13,7 +13,7 @@
|
||||
matTooltip="{{ filterAction.tooltip | translate}}"
|
||||
[attr.data-automation-id]="'adf-filter-action-' + filterAction.actionType"
|
||||
[disabled]="isDisabledAction(filterAction)"
|
||||
(click)="executeFilterActions(filterAction)">
|
||||
(click)="executeFilterActions($event, filterAction)">
|
||||
<adf-icon [value]="filterAction.icon"></adf-icon>
|
||||
</button>
|
||||
</ng-container>
|
||||
|
@@ -16,13 +16,13 @@
|
||||
*/
|
||||
|
||||
import { OnChanges, SimpleChanges, OnInit, OnDestroy, Directive, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { AssignmentType, FilterOptions, TaskFilterAction, TaskFilterProperties, TaskStatusFilter } from '../../models/filter-cloud.model';
|
||||
import { AssignmentType, FilterOptions, TaskFilterAction, TaskFilterCloudModel, TaskFilterProperties, TaskStatusFilter } from '../../models/filter-cloud.model';
|
||||
import { TaskCloudService } from './../../../services/task-cloud.service';
|
||||
import { AppsProcessCloudService } from './../../../../app/services/apps-process-cloud.service';
|
||||
import { DateCloudFilterType, DateRangeFilter } from '../../../../models/date-cloud-filter.model';
|
||||
import moment, { Moment } from 'moment';
|
||||
import { AbstractControl, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { debounceTime, filter, finalize, switchMap, takeUntil } from 'rxjs/operators';
|
||||
import { debounceTime, filter, finalize, switchMap, takeUntil, tap } from 'rxjs/operators';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { DateAdapter } from '@angular/material/core';
|
||||
import { TranslationService, UserPreferencesService, UserPreferenceValues } from '@alfresco/adf-core';
|
||||
@@ -31,6 +31,7 @@ import { MatDialog } from '@angular/material/dialog';
|
||||
import { IdentityUserModel } from '../../../../people/models/identity-user.model';
|
||||
import { IdentityGroupModel } from '../../../../group/models/identity-group.model';
|
||||
import { MatSelectChange } from '@angular/material/select';
|
||||
import { TaskFilterCloudService } from '../../services/task-filter-cloud.service';
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
@@ -46,6 +47,8 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
||||
public static ACTION_SAVE = 'save';
|
||||
public static ACTION_SAVE_AS = 'saveAs';
|
||||
public static ACTION_DELETE = 'delete';
|
||||
public static ACTION_SAVE_DEFAULT = 'saveDefaultFilter';
|
||||
public static ACTION_RESTORE = 'restoreDefaultFilter';
|
||||
public static APP_RUNNING_STATUS: string = 'RUNNING';
|
||||
public static APPLICATION_NAME: string = 'appName';
|
||||
public static PROCESS_DEFINITION_NAME: string = 'processDefinitionName';
|
||||
@@ -117,7 +120,7 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
||||
label: 'ADF_CLOUD_TASK_FILTERS.STATUS.ALL'
|
||||
};
|
||||
|
||||
taskFilter: T;
|
||||
taskFilter: TaskFilterCloudModel;
|
||||
changedTaskFilter: T;
|
||||
|
||||
/** Emitted when a task filter property changes. */
|
||||
@@ -134,7 +137,8 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
||||
protected appsProcessCloudService: AppsProcessCloudService,
|
||||
protected taskCloudService: TaskCloudService,
|
||||
protected dialog: MatDialog,
|
||||
protected translateService: TranslationService) {
|
||||
protected translateService: TranslationService,
|
||||
protected taskFilterCloudService: TaskFilterCloudService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -172,6 +176,16 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
||||
actionType: BaseEditTaskFilterCloudComponent.ACTION_DELETE,
|
||||
icon: 'delete',
|
||||
tooltip: 'ADF_CLOUD_EDIT_TASK_FILTER.TOOL_TIP.DELETE'
|
||||
},
|
||||
{
|
||||
actionType: BaseEditTaskFilterCloudComponent.ACTION_SAVE_DEFAULT,
|
||||
icon: 'adf:save',
|
||||
tooltip: 'ADF_CLOUD_EDIT_TASK_FILTER.TOOL_TIP.SAVE'
|
||||
},
|
||||
{
|
||||
actionType: BaseEditTaskFilterCloudComponent.ACTION_RESTORE,
|
||||
icon: 'settings_backup_restore',
|
||||
tooltip: 'ADF_CLOUD_EDIT_TASK_FILTER.TOOL_TIP.RESTORE'
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -221,14 +235,19 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
||||
return name.replace(regExt, '-');
|
||||
}
|
||||
|
||||
executeFilterActions(action: TaskFilterAction): void {
|
||||
executeFilterActions(event: Event, action: TaskFilterAction): void {
|
||||
if (action.actionType === BaseEditTaskFilterCloudComponent.ACTION_SAVE) {
|
||||
this.save(action);
|
||||
} else if (action.actionType === BaseEditTaskFilterCloudComponent.ACTION_SAVE_AS) {
|
||||
this.saveAs(action);
|
||||
} else if (action.actionType === BaseEditTaskFilterCloudComponent.ACTION_DELETE) {
|
||||
this.delete(action);
|
||||
} else if (action.actionType === BaseEditTaskFilterCloudComponent.ACTION_SAVE_DEFAULT) {
|
||||
this.save(action);
|
||||
} else if (action.actionType === BaseEditTaskFilterCloudComponent.ACTION_RESTORE) {
|
||||
this.reset(action);
|
||||
}
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
getRunningApplications() {
|
||||
@@ -520,6 +539,16 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
||||
});
|
||||
}
|
||||
|
||||
reset(resetAction: TaskFilterAction) {
|
||||
this.taskFilterCloudService.resetTaskFilterToDefaults(this.appName, this.taskFilter).pipe(
|
||||
tap((filters: TaskFilterCloudModel[]) => {
|
||||
resetAction.filter = filters.find(defaultFilter => defaultFilter.name === this.taskFilter.name) || this.taskFilter;
|
||||
this.action.emit(resetAction);
|
||||
}),
|
||||
switchMap(() => this.restoreDefaultTaskFilters()))
|
||||
.subscribe(() => { });
|
||||
}
|
||||
|
||||
checkMandatoryFilterProperties() {
|
||||
if (this.filterProperties === undefined || this.filterProperties.length === 0) {
|
||||
this.filterProperties = this.getDefaultFilterProperties();
|
||||
@@ -541,6 +570,6 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
||||
|
||||
protected abstract restoreDefaultTaskFilters(): Observable<T[]>;
|
||||
protected abstract addFilter(filterToAdd: T): Observable<any>;
|
||||
protected abstract deleteFilter(filterToDelete: T): Observable<T[]>;
|
||||
protected abstract deleteFilter(filterToDelete: TaskFilterCloudModel): Observable<TaskFilterCloudModel[]>;
|
||||
protected abstract updateFilter(filterToUpdate: T): Observable<any>;
|
||||
}
|
||||
|
@@ -42,12 +42,12 @@ export class EditTaskFilterCloudComponent extends BaseEditTaskFilterCloudCompone
|
||||
formBuilder: UntypedFormBuilder,
|
||||
dialog: MatDialog,
|
||||
translateService: TranslationService,
|
||||
private taskFilterCloudService: TaskFilterCloudService,
|
||||
taskFilterCloudService: TaskFilterCloudService,
|
||||
dateAdapter: DateAdapter<Moment>,
|
||||
userPreferencesService: UserPreferencesService,
|
||||
appsProcessCloudService: AppsProcessCloudService,
|
||||
taskCloudService: TaskCloudService) {
|
||||
super(formBuilder, dateAdapter, userPreferencesService, appsProcessCloudService, taskCloudService, dialog, translateService);
|
||||
super(formBuilder, dateAdapter, userPreferencesService, appsProcessCloudService, taskCloudService, dialog, translateService, taskFilterCloudService);
|
||||
}
|
||||
|
||||
assignNewFilter(model: TaskFilterCloudModel) {
|
||||
|
@@ -369,4 +369,19 @@ export class TaskFilterCloudService extends BaseCloudService {
|
||||
return this.notificationCloudService.makeGQLQuery(appName, TASK_EVENT_SUBSCRIPTION_QUERY)
|
||||
.pipe(map((events: any) => events.data.engineEvents));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the task filters to the default configuration if it exists and stores it.
|
||||
* If there is no default configuration for the task cloud filter with the provided filter name,
|
||||
* then it changes nothing but stores the current values of the filter
|
||||
*
|
||||
* @param appName Name of the target app
|
||||
* @param filter The task filter to be restored to defaults
|
||||
* @returns Observable of task filters details
|
||||
*/
|
||||
resetTaskFilterToDefaults(appName: string, filter: TaskFilterCloudModel): Observable<TaskFilterCloudModel[]> {
|
||||
const defaultFilter = this.defaultTaskFilters(appName).find(defaultFilterDefinition => defaultFilterDefinition.name === filter.name) || filter;
|
||||
defaultFilter.id = filter.id;
|
||||
return this.updateFilter(defaultFilter);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user