Skip to content

Commit

Permalink
[ACA-3643] - add completedBy filter on tasks (#5924)
Browse files Browse the repository at this point in the history
* [ACA-3643] - add completedBy filter on tasks

* send user id as query parameter

* preselect users

* rebase and reset filter

Co-authored-by: Silviu Popa <p3701014@L3700101120.ness.com>
  • Loading branch information
SilviuCPopa and Silviu Popa committed Sep 24, 2020
1 parent fe61c6d commit 0119c74
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 6 deletions.
7 changes: 5 additions & 2 deletions lib/process-services-cloud/src/lib/i18n/en.json
Expand Up @@ -11,6 +11,7 @@
"STATUS": "Status",
"START_DATE": "Start Date",
"COMPLETED_DATE": "Completed Date",
"COMPLETED_BY": "Completed By",
"ID": "Id",
"INITIATOR": "Initiator",
"APP_NAME": "Application Name",
Expand Down Expand Up @@ -89,7 +90,8 @@
"LAST_MODIFIED": "Last Modified",
"DUE_DATE": "Due Date",
"CREATED": "Created",
"JSON_CELL": "Json"
"JSON_CELL": "Json",
"COMPLETED_BY": "Completed By"
},
"LIST": {
"MESSAGES": {
Expand Down Expand Up @@ -142,7 +144,8 @@
"OWNER": "Owner",
"DUE_DATE": "DueDate",
"SORT": "Sort",
"START_DATE": "StartDate"
"START_DATE": "StartDate",
"COMPLETED_BY": "Completed By"
},
"DIALOG": {
"TITLE": "Save filter as",
Expand Down
Expand Up @@ -73,6 +73,16 @@
[options]="taskFilterProperty.dateFilterOptions"
(dateTypeChange)="onDateTypeChange($event, taskFilterProperty)"
(dateChanged)="onDateRangeFilterChanged($event, taskFilterProperty)"></adf-cloud-date-range-filter>

<div fxFlex="23%" class="adf-edit-task-filter-checkbox" *ngIf="isUserSelectType(taskFilterProperty)">
<adf-cloud-people
[preSelectUsers]="taskFilterProperty.value | async"
[title]="taskFilterProperty.label"
[validate]="true"
[appName]="appName"
[mode]="taskFilterProperty.selectionMode"
(changedUsers)="onChangedUser($event, taskFilterProperty)"></adf-cloud-people>
</div>
</ng-container>
</div>
</form>
Expand Down
Expand Up @@ -20,14 +20,14 @@ import { AbstractControl, FormGroup, FormBuilder } from '@angular/forms';
import { DateAdapter } from '@angular/material/core';
import { MatDialog } from '@angular/material/dialog';
import { debounceTime, filter, takeUntil, finalize, switchMap } from 'rxjs/operators';
import { Subject, Observable } from 'rxjs';
import { Subject, Observable, of } from 'rxjs';
import moment from 'moment-es6';
import { Moment } from 'moment';

import { TaskFilterCloudModel, TaskFilterProperties, FilterOptions, TaskFilterAction } from './../models/filter-cloud.model';
import { TaskFilterCloudService } from '../services/task-filter-cloud.service';
import { TaskFilterDialogCloudComponent } from './task-filter-dialog-cloud.component';
import { TranslationService, UserPreferencesService, UserPreferenceValues } from '@alfresco/adf-core';
import { TranslationService, UserPreferencesService, UserPreferenceValues, IdentityUserModel, IdentityUserService } from '@alfresco/adf-core';
import { AppsProcessCloudService } from '../../../app/services/apps-process-cloud.service';
import { ApplicationInstanceModel } from '../../../app/models/application-instance.model';
import { DateCloudFilterType, DateRangeFilter } from '../../../models/date-cloud-filter.model';
Expand Down Expand Up @@ -140,6 +140,7 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
private dateAdapter: DateAdapter<Moment>,
private userPreferencesService: UserPreferencesService,
private appsProcessCloudService: AppsProcessCloudService,
private identityUserService: IdentityUserService,
private taskCloudService: TaskCloudService) {
}

Expand Down Expand Up @@ -352,6 +353,10 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
);
}

onChangedUser(users: IdentityUserModel[], userProperty: TaskFilterProperties) {
this.getPropertyController(userProperty).setValue(users[0]?.username);
}

hasError(property: TaskFilterProperties): boolean {
return this.getPropertyController(property).errors && this.getPropertyController(property).errors.invalid;
}
Expand Down Expand Up @@ -507,6 +512,10 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
return property.type === 'checkbox';
}

isUserSelectType(property: TaskFilterProperties): boolean {
return property.type === 'people';
}

isDisabledAction(action: TaskFilterAction): boolean {
return this.isDisabledForDefaultFilters(action) ? true : this.hasFormChanged(action);
}
Expand All @@ -532,6 +541,13 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
return false;
}

getUserByUsername(username: string): Observable<IdentityUserModel[]> {
if (username) {
return this.identityUserService.findUserByUsername(username);
}
return of([]);
}

createFilterActions(): TaskFilterAction[] {
return [
new TaskFilterAction({
Expand Down Expand Up @@ -690,6 +706,13 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
DateCloudFilterType.NEXT_7_DAYS,
DateCloudFilterType.RANGE
]
}),
new TaskFilterProperties({
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.COMPLETED_BY',
type: 'people',
key: 'completedBy',
value: this.getUserByUsername(currentTaskFilter.completedBy),
selectionMode: 'single'
})
];
}
Expand Down
Expand Up @@ -17,6 +17,7 @@

import { DateCloudFilterType } from '../../../models/date-cloud-filter.model';
import { DateRangeFilterService } from '../../../common/date-range-filter/date-range-filter.service';
import { ComponentSelectionMode } from '../../../types';

export class TaskFilterCloudModel {
id: string;
Expand All @@ -43,6 +44,7 @@ export class TaskFilterCloudModel {
standalone: boolean;
lastModifiedFrom: Date;
lastModifiedTo: Date;
completedBy: string;

private _dueDateFrom: string;
private _dueDateTo: string;
Expand Down Expand Up @@ -76,6 +78,7 @@ export class TaskFilterCloudModel {
this.standalone = obj.standalone || null;
this.lastModifiedFrom = obj.lastModifiedFrom || null;
this.lastModifiedTo = obj.lastModifiedTo || null;
this.completedBy = obj.completedBy || null;
}
}

Expand Down Expand Up @@ -159,6 +162,7 @@ export class TaskFilterProperties {
attributes?: { [key: string]: string; };
options?: FilterOptions[];
dateFilterOptions?: DateCloudFilterType[];
selectionMode?: ComponentSelectionMode;

constructor(obj?: any) {
if (obj) {
Expand All @@ -169,6 +173,7 @@ export class TaskFilterProperties {
this.attributes = obj.attributes || null;
this.options = obj.options || null;
this.dateFilterOptions = obj.dateFilterOptions || null;
this.selectionMode = obj.selectionMode || null;
}
}
}
Expand Up @@ -28,6 +28,7 @@ import { TaskFilterDialogCloudComponent } from './components/task-filter-dialog-
import { AppListCloudModule } from './../../app/app-list-cloud.module';
import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core';
import { ProcessCommonModule } from '../../common/process-common.module';
import { PeopleCloudModule } from '../../people/people-cloud.module';

@NgModule({
imports: [
Expand All @@ -39,7 +40,8 @@ import { ProcessCommonModule } from '../../common/process-common.module';
MaterialModule,
AppListCloudModule,
CoreModule,
ProcessCommonModule
ProcessCommonModule,
PeopleCloudModule
],
declarations: [TaskFiltersCloudComponent, EditTaskFilterCloudComponent, TaskFilterDialogCloudComponent],
exports: [TaskFiltersCloudComponent, EditTaskFilterCloudComponent],
Expand Down
Expand Up @@ -114,6 +114,10 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
@Input()
priority: number;

/** Filter the tasks. Display only tasks with createdBy equal to the supplied value. */
@Input()
completedBy: number;

/** Filter the tasks. Display only the tasks that belong to a process in case is false or tasks that doesn't belong to a process in case of true. */
@Input()
standalone: boolean = false;
Expand Down Expand Up @@ -365,7 +369,8 @@ export class TaskListCloudComponent extends DataTableSchema implements OnChanges
maxItems: this.size,
skipCount: this.skipCount,
sorting: this.sorting,
standalone: this.standalone
standalone: this.standalone,
completedBy: this.completedBy
};
return new TaskQueryCloudRequestModel(requestNode);
}
Expand Down
Expand Up @@ -39,6 +39,7 @@ export class TaskQueryCloudRequestModel {
processDefinitionName?: string;
processInstanceId?: string;
status?: string;
completedBy?: string;
maxItems: number;
skipCount: number;
sorting?: TaskListCloudSortingModel[];
Expand Down Expand Up @@ -66,6 +67,7 @@ export class TaskQueryCloudRequestModel {
this.processDefinitionName = obj.processDefinitionName;
this.processInstanceId = obj.processInstanceId;
this.status = obj.status;
this.completedBy = obj.completedBy;
this.maxItems = obj.maxItems;
this.skipCount = obj.skipCount;
this.sorting = obj.sorting;
Expand Down

0 comments on commit 0119c74

Please sign in to comment.