From b0ee202402541e985f31317ceea432099260a683 Mon Sep 17 00:00:00 2001 From: BVier <26220150+BVier@users.noreply.github.com> Date: Mon, 9 Dec 2019 15:43:38 +0100 Subject: [PATCH] TSK-982: Beautify Task-Query for History-Events --- .../services/task-query/task-query.service.ts | 61 +++++++------------ .../task-query/task-query.component.ts | 24 +------- web/src/app/models/task-history-event.ts | 4 ++ 3 files changed, 27 insertions(+), 62 deletions(-) diff --git a/web/src/app/history/services/task-query/task-query.service.ts b/web/src/app/history/services/task-query/task-query.service.ts index 5f8da5c7c..dd21706eb 100644 --- a/web/src/app/history/services/task-query/task-query.service.ts +++ b/web/src/app/history/services/task-query/task-query.service.ts @@ -19,52 +19,33 @@ export class TaskQueryService { queryTask( orderBy: string = 'created', sortDirection: string = Direction.ASC, - taskId: string, - parentBPI: string, - BPI: string, - eventType: string, - userId: string, - domain: string, - workbasketKey: string, - porCompany: string, - porSystem: string, - porInstance: string, - porType: string, - porValue: string, - taskClassificationKey: string, - taskClassificationCategory: string, - attachmentClassificationKey: string, - custom1: string, - custom2: string, - custom3: string, - custom4: string, - created: string, + searchForValues: TaskHistoryEventData, allPages: boolean = false ): Observable { return this.httpClient.get(`${this.url}/v1/task-history-event${this.getQueryParameters( orderBy, sortDirection, - taskId, - parentBPI, - BPI, - eventType, - userId, - domain, - workbasketKey, - porCompany, - porSystem, - porInstance, - porType, - porValue, - taskClassificationKey, - taskClassificationCategory, - attachmentClassificationKey, - custom1, - custom2, - custom3, - custom4, - created, + searchForValues.taskId, + searchForValues.parentBusinessProcessId, + searchForValues.businessProcessId, + searchForValues.eventType, + searchForValues.userId, + searchForValues.domain, + searchForValues.workbasketKey, + searchForValues.porCompany, + searchForValues.porSystem, + searchForValues.porInstance, + searchForValues.porType, + searchForValues.porValue, + searchForValues.taskClassificationKey, + searchForValues.taskClassificationCategory, + searchForValues.attachmentClassificationKey, + searchForValues.custom1, + searchForValues.custom2, + searchForValues.custom3, + searchForValues.custom4, + searchForValues.created, allPages )}`); diff --git a/web/src/app/history/task-query/task-query.component.ts b/web/src/app/history/task-query/task-query.component.ts index 290d4619f..8026b9ac5 100644 --- a/web/src/app/history/task-query/task-query.component.ts +++ b/web/src/app/history/task-query/task-query.component.ts @@ -25,7 +25,6 @@ export class TaskQueryComponent implements OnInit { orderBy = new SortingModel(TaskanaQueryParameters.parameters.CREATED); orientationSubscription: Subscription; taskQuerySubscription: Subscription; - created = undefined; taskQueryForm = new FormGroup({ }); @@ -181,26 +180,7 @@ export class TaskQueryComponent implements OnInit { this.taskQuerySubscription = this.taskQueryService.queryTask( this.orderBy.sortBy.replace(/([A-Z])|([0-9])/g, (g) => `-${g[0].toLowerCase()}`), this.orderBy.sortDirection, - this.taskQueryForm.get('taskId') ? this.taskQueryForm.get('taskId').value : undefined, - this.taskQueryForm.get('parentBusinessProcessId') ? this.taskQueryForm.get('parentBusinessProcessId').value : undefined, - this.taskQueryForm.get('businessProcessId') ? this.taskQueryForm.get('businessProcessId').value : undefined, - this.taskQueryForm.get('eventType') ? this.taskQueryForm.get('eventType').value : undefined, - this.taskQueryForm.get('userId') ? this.taskQueryForm.get('userId').value : undefined, - this.taskQueryForm.get('domain') ? this.taskQueryForm.get('domain').value : undefined, - this.taskQueryForm.get('workbasketKey') ? this.taskQueryForm.get('workbasketKey').value : undefined, - this.taskQueryForm.get('porCompany') ? this.taskQueryForm.get('porCompany').value : undefined, - this.taskQueryForm.get('porSystem') ? this.taskQueryForm.get('porSystem').value : undefined, - this.taskQueryForm.get('porInstance') ? this.taskQueryForm.get('porInstance').value : undefined, - this.taskQueryForm.get('porType') ? this.taskQueryForm.get('porType').value : undefined, - this.taskQueryForm.get('porValue') ? this.taskQueryForm.get('porValue').value : undefined, - this.taskQueryForm.get('taskClassificationKey') ? this.taskQueryForm.get('taskClassificationKey').value : undefined, - this.taskQueryForm.get('taskClassificationCategory') ? this.taskQueryForm.get('taskClassificationCategory').value : undefined, - this.taskQueryForm.get('attachmentClassificationKey') ? this.taskQueryForm.get('attachmentClassificationKey').value : undefined, - this.taskQueryForm.get('custom1') ? this.taskQueryForm.get('custom1').value : undefined, - this.taskQueryForm.get('custom2') ? this.taskQueryForm.get('custom2').value : undefined, - this.taskQueryForm.get('custom3') ? this.taskQueryForm.get('custom3').value : undefined, - this.taskQueryForm.get('custom4') ? this.taskQueryForm.get('custom4').value : undefined, - this.created ? this.created.toISOString().substring(0, 10) : undefined, + new TaskHistoryEventData(this.taskQueryForm.value), false).subscribe(taskQueryResource => { this.requestInProgressService.setRequestInProgress(false); if (!taskQueryResource.taskHistoryEvents) { @@ -231,7 +211,7 @@ export class TaskQueryComponent implements OnInit { } updateDate($event: string) { - this.created = new Date($event); + this.taskQueryForm.get('created').setValue($event.substring(0, 10)); this.performRequest(); } diff --git a/web/src/app/models/task-history-event.ts b/web/src/app/models/task-history-event.ts index 2d3aed532..0780c65cc 100644 --- a/web/src/app/models/task-history-event.ts +++ b/web/src/app/models/task-history-event.ts @@ -28,4 +28,8 @@ export class TaskHistoryEventData { oldData = ''; newData = ''; page = new Page(); + + public constructor(init?: Partial) { + Object.assign(this, init); + } }