Skip to content

Commit

Permalink
[ACA-3706] implement startedBy filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Silviu Popa authored and SilviuCPopa committed Oct 15, 2020
1 parent 9ccf489 commit 9175fbb
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 14 deletions.
3 changes: 2 additions & 1 deletion lib/core/services/oauth2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import { Injectable } from '@angular/core';
import { AlfrescoApiService } from './alfresco-api.service';
import { Observable, from } from 'rxjs';
import { Oauth2Auth } from '@alfresco/js-api';

export const JSON_TYPE = ['application/json'];

Expand All @@ -33,7 +34,7 @@ export interface OAuth2RequestParams {
export class OAuth2Service {
constructor(private alfrescoApiService: AlfrescoApiService) {}

get apiClient() {
get apiClient(): Oauth2Auth {
return this.alfrescoApiService.getInstance().oauth2Auth;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/process-services-cloud/src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"COMPLETED_BY": "Completed By",
"ID": "Id",
"INITIATOR": "Initiator",
"STARTED_BY": "Started by",
"APP_NAME": "Application Name",
"BUSINESS_KEY": "Business Key",
"DESCRIPTION": "Description",
Expand Down Expand Up @@ -206,6 +207,7 @@
"PROCESS_NAME": "Process Name",
"APP_VERSION": "AppReleaseVersion",
"STARTED_DATE": "Started Date",
"STARTED_BY": "Started by",
"COMPLETED_DATE": "Completed Date",
"DATE_RANGE": {
"NO_DATE": "No Date",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@
[options]="processFilterProperty.dateFilterOptions"
(dateTypeChange)="onDateTypeChange($event, processFilterProperty)"
(dateChanged)="onDateRangeFilterChanged($event, processFilterProperty)"></adf-cloud-date-range-filter>

<div fxFlex="23%" *ngIf="isUserSelectType(processFilterProperty)">
<adf-cloud-people
[preSelectUsers]="getPropertyValue(processFilterProperty, 'initiator')"
[title]="processFilterProperty.label"
[validate]="true"
[appName]="appName"
[mode]="processFilterProperty.selectionMode"
(changedUsers)="onChangedUser($event, processFilterProperty)"></adf-cloud-people>
</div>
</ng-container>
</div>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,12 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
);
}

onUsersChange(users: IdentityUserModel[], property: ProcessFilterProperties) {
this.getPropertyController(property).setValue(users.map(user => user.username));
onChangedUser(users: IdentityUserModel[], property: ProcessFilterProperties) {
if (property.attributes) {
this.editProcessFilterForm.get(property.attributes?.customKey).setValue(users);
} else {
this.getPropertyController(property).setValue(users);
}
}

hasError(property: ProcessFilterProperties): boolean {
Expand Down Expand Up @@ -495,6 +499,10 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
return property.type === 'number';
}

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

isDisabledAction(action: ProcessFilterAction): boolean {
return this.isDisabledForDefaultFilters(action) ? true : this.hasFormChanged(action);
}
Expand All @@ -510,6 +518,13 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
);
}

getPropertyValue(property: ProcessFilterProperties, key: string) {
if (!!property.attributes) {
return property.value[key];
}
return property.value;
}

hasFormChanged(action: ProcessFilterAction): boolean {
if (action.actionType === EditProcessFilterCloudComponent.ACTION_SAVE) {
return !this.formHasBeenChanged;
Expand Down Expand Up @@ -721,6 +736,16 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
type: 'date',
key: 'completedDate',
value: currentProcessFilter.completedDate || false
}),
new ProcessFilterProperties({
label: 'ADF_CLOUD_EDIT_PROCESS_FILTER.LABEL.STARTED_BY',
type: 'people',
key: 'startedBy',
attributes: { customKey: 'initiator' },
value: {
initiator: currentProcessFilter.initiator || []
},
selectionMode: 'multiple'
}),
new ProcessFilterProperties({
label: 'ADF_CLOUD_EDIT_PROCESS_FILTER.LABEL.COMPLETED_DATE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
import { DateCloudFilterType } from '../../../models/date-cloud-filter.model';
import { DateRangeFilterService } from '../../../common/date-range-filter/date-range-filter.service';
import { ComponentSelectionMode } from '../../../types';
import { IdentityUserModel } from '@alfresco/adf-core';

export class ProcessFilterCloudModel {

Expand All @@ -30,7 +32,7 @@ export class ProcessFilterCloudModel {
appVersion?: number;
processName: string;
processInstanceId: string;
initiator: string;
initiator: string | IdentityUserModel[];
status: string;
sort: string;
order: string;
Expand All @@ -49,7 +51,6 @@ export class ProcessFilterCloudModel {
private _completedTo: string;
private _startFrom: string;
private _startTo: string;
startedBy: string;

constructor(obj?: any) {
if (obj) {
Expand Down Expand Up @@ -80,7 +81,6 @@ export class ProcessFilterCloudModel {
this.completedFrom = obj._completedFrom || null;
this.completedTo = obj._completedTo || null;
this.completedDate = obj.completedDate || null;
this.startedBy = obj.startedBy || null;
}
}

Expand Down Expand Up @@ -170,6 +170,7 @@ export class ProcessFilterProperties {
attributes?: { [key: string]: string; };
options?: ProcessFilterOptions[];
dateFilterOptions?: DateCloudFilterType[];
selectionMode?: ComponentSelectionMode;

constructor(obj?: any) {
if (obj) {
Expand All @@ -180,6 +181,7 @@ export class ProcessFilterProperties {
this.attributes = obj.attributes || null;
this.options = obj.options || null;
this.dateFilterOptions = obj.dateFilterOptions || null;
this.selectionMode = obj.selectionMode || null;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { ProcessFilterDialogCloudComponent } from './components/process-filter-d
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: [ProcessFiltersCloudComponent, EditProcessFilterCloudComponent, ProcessFilterDialogCloudComponent],
exports: [ProcessFiltersCloudComponent, EditProcessFilterCloudComponent, ProcessFilterDialogCloudComponent],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Component, ViewEncapsulation, OnChanges, AfterContentInit, ContentChild
import { DataTableSchema, PaginatedComponent,
CustomEmptyContentTemplateDirective, AppConfigService,
UserPreferencesService, PaginationModel,
UserPreferenceValues, DataRowEvent, CustomLoadingContentTemplateDirective, DataCellEvent, DataRowActionEvent } from '@alfresco/adf-core';
UserPreferenceValues, DataRowEvent, CustomLoadingContentTemplateDirective, DataCellEvent, DataRowActionEvent, IdentityUserModel } from '@alfresco/adf-core';
import { ProcessListCloudService } from '../services/process-list-cloud.service';
import { BehaviorSubject } from 'rxjs';
import { processCloudPresetsDefaultModel } from '../models/process-cloud-preset.model';
Expand Down Expand Up @@ -53,7 +53,7 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan

/** Name of the initiator of the process. */
@Input()
initiator: string = '';
initiator: string | IdentityUserModel[];

/** Filter the processes to display only the ones with this ID. */
@Input()
Expand Down Expand Up @@ -110,9 +110,6 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
/** Filter the processes. Display only process with completedDate equal to the supplied date. */
@Input()
completedDate: string = '';
/** Filter the processes. Display only process with startedBy equal to the supplied values. */
@Input()
startedBy: string[] = [];

/**
* Row selection mode. Can be "none", "single" or "multiple".
Expand Down Expand Up @@ -331,7 +328,7 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
appVersion: this.appVersion,
maxItems: this.size,
skipCount: this.skipCount,
initiator: this.initiator,
initiator: this.getInitiatorValue(),
id: this.id,
name: this.name,
processDefinitionId: this.processDefinitionId,
Expand All @@ -346,7 +343,6 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
completedFrom: this.completedFrom,
completedTo: this.completedTo,
completedDate: this.completedDate,
startedBy: this.startedBy?.join(','),
sorting: this.sorting
};
return new ProcessQueryCloudRequestModel(requestNode);
Expand All @@ -370,4 +366,12 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
isValidSorting(sorting: ProcessListCloudSortingModel[]) {
return sorting.length && sorting[0].orderBy && sorting[0].direction;
}

private getInitiatorValue() {
if (!!this.initiator) {
const users = Object.values(this.initiator);
return users.length ? users.map(item => item.username).join(',') : this.initiator;
}
return this.initiator;
}
}

0 comments on commit 9175fbb

Please sign in to comment.