diff --git a/.husky/pre-commit b/.husky/pre-commit index 36af219892..324a2f944e 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,5 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" +export NODE_OPTIONS=--max_old_space_size=8192 npx lint-staged diff --git a/demo-shell/src/app/components/process-service/task-attachments.component.ts b/demo-shell/src/app/components/process-service/task-attachments.component.ts index 6f4317d977..9152c5d415 100644 --- a/demo-shell/src/app/components/process-service/task-attachments.component.ts +++ b/demo-shell/src/app/components/process-service/task-attachments.component.ts @@ -16,12 +16,13 @@ */ import { Component, Input, OnChanges, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; -import { TaskAttachmentListComponent, TaskDetailsModel, TaskListService, TaskUploadService } from '@alfresco/adf-process-services'; +import { TaskAttachmentListComponent, TaskListService, TaskUploadService } from '@alfresco/adf-process-services'; import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core'; import { DiscoveryApiService, UploadService } from '@alfresco/adf-content-services'; import { PreviewService } from '../../services/preview.service'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; +import { TaskRepresentation } from '@alfresco/js-api'; /** * Provide a task upload service factory @@ -55,7 +56,7 @@ export class TaskAttachmentsComponent implements OnInit, OnChanges, OnDestroy { @Input() taskId: string; - taskDetails: TaskDetailsModel; + taskDetails: TaskRepresentation; private onDestroy$ = new Subject(); diff --git a/docs/process-services/components/checklist.component.md b/docs/process-services/components/checklist.component.md index a40e3249d3..45b99eebe5 100644 --- a/docs/process-services/components/checklist.component.md +++ b/docs/process-services/components/checklist.component.md @@ -2,10 +2,10 @@ Title: Checklist Component Added: v2.0.0 Status: Active -Last reviewed: 2018-11-19 +Last reviewed: 2024-05-21 --- -# [Checklist Component](../../../lib/process-services/src/lib/task-list/components/checklist.component.ts "Defined in checklist.component.ts") +# Checklist Component Shows the checklist task functionality. @@ -23,16 +23,16 @@ Shows the checklist task functionality. ### Properties -| Name | Type | Default value | Description | -| ---- | ---- | ------------- | ----------- | -| assignee | `string` | | (required) The assignee id that the subtasks are assigned to. | -| readOnly | `boolean` | false | Toggle readonly state of the form. All form widgets will render as readonly if enabled. | -| taskId | `string` | | (required) The id of the parent task to which subtasks are attached. | +| Name | Type | Default value | Description | +|----------|-----------|---------------|-----------------------------------------------------------------------------------------| +| assignee | `string` | | (required) The assignee id that the subtasks are assigned to. | +| readOnly | `boolean` | false | Toggle readonly state of the form. All form widgets will render as readonly if enabled. | +| taskId | `string` | | (required) The id of the parent task to which subtasks are attached. | ### Events -| Name | Type | Description | -| ---- | ---- | ----------- | -| checklistTaskCreated | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>` | Emitted when a new checklist task is created. | -| checklistTaskDeleted | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when a checklist task is deleted. | -| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when an error occurs. | +| Name | Type | Description | +|----------------------|------------------------------------|-----------------------------------------------| +| checklistTaskCreated | `EventEmitter` | Emitted when a new checklist task is created. | +| checklistTaskDeleted | `EventEmitter` | Emitted when a checklist task is deleted. | +| error | `EventEmitter` | Emitted when an error occurs. | diff --git a/docs/process-services/components/task-details.component.md b/docs/process-services/components/task-details.component.md index d84603ad71..4f21be779f 100644 --- a/docs/process-services/components/task-details.component.md +++ b/docs/process-services/components/task-details.component.md @@ -2,10 +2,10 @@ Title: Task Details component Added: v2.0.0 Status: Active -Last reviewed: 2018-11-13 +Last reviewed: 2024-05-21 --- -# [Task Details component](../../../lib/process-services/src/lib/task-list/components/task-details.component.ts "Defined in task-details.component.ts") +# Task Details Component Shows the details of the task ID passed in as input. @@ -21,45 +21,45 @@ Shows the details of the task ID passed in as input. ### Properties -| Name | Type | Default value | Description | -| ---- | ---- | ------------- | ----------- | -| debugMode | `boolean` | false | Toggles debug mode. | -| fieldValidators | [`FormFieldValidator`](../../../lib/core/src/lib/form/components/widgets/core/form-field-validator.ts)`[]` | \[] | Field validators for use with the form. | -| readOnlyForm | `boolean` | false | Toggles read-only state of the form. All form widgets render as read-only if enabled. | -| showChecklist | `boolean` | true | Toggles `Checklist` feature for the Header component. | -| showComments | `boolean` | true | Toggles `Comments` feature for the Header component. | -| showFormCompleteButton | `boolean` | true | Toggles rendering of the `Complete` outcome button. | -| showFormRefreshButton | `boolean` | true | Toggles rendering of the `Refresh` button. | -| showFormSaveButton | `boolean` | true | Toggles rendering of the `Save` outcome button. | -| showFormTitle | `boolean` | false | Toggles rendering of the form title. | -| showHeader | `boolean` | true | Toggles task details Header component. | -| showHeaderContent | `boolean` | true | Toggles collapsed/expanded state of the Header component. | -| showInvolvePeople | `boolean` | true | Toggles `Involve People` feature for the Header component. | -| showNextTask | `boolean` | true | Automatically renders the next task when the current one is completed. | -| taskId | `string` | | (**required**) The id of the task whose details we are asking for. | +| Name | Type | Default value | Description | +|------------------------|------------------------|---------------|---------------------------------------------------------------------------------------| +| debugMode | `boolean` | false | Toggles debug mode. | +| fieldValidators | `FormFieldValidator[]` | \[] | Field validators for use with the form. | +| readOnlyForm | `boolean` | false | Toggles read-only state of the form. All form widgets render as read-only if enabled. | +| showChecklist | `boolean` | true | Toggles `Checklist` feature for the Header component. | +| showComments | `boolean` | true | Toggles `Comments` feature for the Header component. | +| showFormCompleteButton | `boolean` | true | Toggles rendering of the `Complete` outcome button. | +| showFormRefreshButton | `boolean` | true | Toggles rendering of the `Refresh` button. | +| showFormSaveButton | `boolean` | true | Toggles rendering of the `Save` outcome button. | +| showFormTitle | `boolean` | false | Toggles rendering of the form title. | +| showHeader | `boolean` | true | Toggles task details Header component. | +| showHeaderContent | `boolean` | true | Toggles collapsed/expanded state of the Header component. | +| showInvolvePeople | `boolean` | true | Toggles `Involve People` feature for the Header component. | +| showNextTask | `boolean` | true | Automatically renders the next task when the current one is completed. | +| taskId | `string` | | (**required**) The id of the task whose details we are asking for. | ### Events -| Name | Type | Description | -| ---- | ---- | ----------- | -| assignTask | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when a task is assigned. | -| claimedTask | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when a task is claimed. | -| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when an error occurs. | -| executeOutcome | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`FormOutcomeEvent`](../../../lib/core/src/lib/form/components/widgets/core/form-outcome-event.model.ts)`>` | Emitted when any outcome is executed. Default behaviour can be prevented via `event.preventDefault()`. | -| formCompleted | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`FormModel`](../../../lib/core/src/lib/form/components/widgets/core/form.model.ts)`>` | Emitted when the form is submitted with the `Complete` outcome. | -| formContentClicked | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`ContentLinkModel`](../../../lib/core/src/lib/form/components/widgets/core/content-link.model.ts)`>` | Emitted when the form field content is clicked. | -| formLoaded | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`FormModel`](../../../lib/core/src/lib/form/components/widgets/core/form.model.ts)`>` | Emitted when the form is loaded or reloaded. | -| formSaved | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`FormModel`](../../../lib/core/src/lib/form/components/widgets/core/form.model.ts)`>` | Emitted when the form is submitted with the `Save` or custom outcomes. | -| taskCreated | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>` | Emitted when a checklist task is created. | -| taskDeleted | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when a checklist task is deleted. | -| unClaimedTask | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when a task is unclaimed. | +| Name | Type | Description | +|--------------------|------------------------------------|--------------------------------------------------------------------------------------------------------| +| assignTask | `EventEmitter` | Emitted when a task is assigned. | +| claimedTask | `EventEmitter` | Emitted when a task is claimed. | +| error | `EventEmitter` | Emitted when an error occurs. | +| executeOutcome | `EventEmitter` | Emitted when any outcome is executed. Default behaviour can be prevented via `event.preventDefault()`. | +| formCompleted | `EventEmitter` | Emitted when the form is submitted with the `Complete` outcome. | +| formContentClicked | `EventEmitter` | Emitted when the form field content is clicked. | +| formLoaded | `EventEmitter` | Emitted when the form is loaded or reloaded. | +| formSaved | `EventEmitter` | Emitted when the form is submitted with the `Save` or custom outcomes. | +| taskCreated | `EventEmitter` | Emitted when a checklist task is created. | +| taskDeleted | `EventEmitter` | Emitted when a checklist task is deleted. | +| unClaimedTask | `EventEmitter` | Emitted when a task is unclaimed. | ## Details ### Custom 'empty Task Details' template -By default the [Task Details component](task-details.component.md) shows a simple "No Tasks" message when there are -no details. You can change this by adding the a custom HTML template as in the following +By default, the [Task Details component](task-details.component.md) shows "No Tasks" message when there are +no details. You can change this by adding a custom HTML template as in the following example: ```html @@ -67,7 +67,7 @@ example:

Sorry, no tasks here

- + example
diff --git a/docs/process-services/components/task-header.component.md b/docs/process-services/components/task-header.component.md index 0c430b8951..00eb0de76b 100644 --- a/docs/process-services/components/task-header.component.md +++ b/docs/process-services/components/task-header.component.md @@ -2,10 +2,10 @@ Title: Task Header component Added: v2.0.0 Status: Active -Last reviewed: 2019-01-14 +Last reviewed: 2024-05-21 --- -# [Task Header component](../../../lib/process-services/src/lib/task-list/components/task-header.component.ts "Defined in task-header.component.ts") +# Task Header Component Shows all the information related to a task. @@ -23,18 +23,18 @@ Shows all the information related to a task. ### Properties -| Name | Type | Default value | Description | -| ---- | ---- | ------------- | ----------- | -| formName | `string` | null | The name of the form. | -| showClaimRelease | `boolean` | true | Toggles display of the claim/release button. | -| taskDetails | [`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts) | | (required) Details related to the task. | +| Name | Type | Default value | Description | +|------------------|----------------------|---------------|----------------------------------------------| +| formName | `string` | null | The name of the form. | +| showClaimRelease | `boolean` | true | Toggles display of the claim/release button. | +| taskDetails | `TaskRepresentation` | | Details related to the task. | ### Events -| Name | Type | Description | -| ---- | ---- | ----------- | -| claim | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when the task is claimed. | -| unclaim | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`` | Emitted when the task is unclaimed (ie, requeue). | +| Name | Type | Description | +|---------|---------------------|---------------------------------------------------| +| claim | `EventEmitter` | Emitted when the task is claimed. | +| unclaim | `EventEmitter` | Emitted when the task is unclaimed (ie, requeue). | ## Details @@ -43,16 +43,32 @@ The component populates an internal array of By default all properties are displayed: -**_assignee_**, **_status_**, **_priority_**, **_dueDate_**, **_category_**, **_parentName_**, **_created_**, **_id_**, **_description_**, **_formName_**. +- **_assignee_** +- **_status_** +- **_priority_** +- **_dueDate_** +- **_category_** +- **_parentName_** +- **_created_** +- **_id_** +- **_description_** +- **_formName_**. However, you can also choose which properties to show using a configuration in `app.config.json`: ```json +{ "adf-task-header": { - "presets": { - "properties" : [ "assignee", "status", "priority", "parentName"] - } - }, + "presets": { + "properties": [ + "assignee", + "status", + "priority", + "parentName" + ] + } + } +} ``` With this configuration, only the four listed properties will be shown. diff --git a/docs/process-services/components/task-list.component.md b/docs/process-services/components/task-list.component.md index ae22c76615..2f1c1fd48b 100644 --- a/docs/process-services/components/task-list.component.md +++ b/docs/process-services/components/task-list.component.md @@ -5,7 +5,7 @@ Status: Active Last reviewed: 2019-02-08 --- -# [Task List component](../../../lib/process-services/src/lib/task-list/components/task-list.component.ts "Defined in task-list.component.ts") +# Task List Component Renders a list containing all the tasks matched by the parameters specified. @@ -51,32 +51,32 @@ when the task list is empty: ### Properties -| Name | Type | Default value | Description | -| ---- | ---- | ------------- | ----------- | -| appId | `number` | | The id of the app. | -| assignment | `string` | | The assignment of the process. Possible values are: "assignee" (the current user is the assignee), "candidate" (the current user is a task candidate, "group_x" (the task is assigned to a group where the current user is a member, no value (the current user is involved). | -| blurOnResize | `boolean` | true | Toggles blur when columns of the list are being resized. | -| data | [`DataTableAdapter`](../../../lib/core/src/lib/datatable/data/datatable-adapter.ts) | | Data source object that represents the number and the type of the columns that you want to show. | -| dueAfter | `string` | | Filter the tasks. Display only tasks with `created_date` after `dueAfter`. | -| dueBefore | `string` | | Filter the tasks. Display only tasks with `created_date` before `dueBefore`. | -| isResizingEnabled | `boolean` | false | Toggles column resizing for task list. | -| includeProcessInstance | `boolean` | | Toggles inclusion of Process Instances | -| landingTaskId | `string` | | Define which task id should be selected after reloading. If the task id doesn't exist or nothing is passed then the first task will be selected. | -| multiselect | `boolean` | false | Toggles multiple row selection, renders checkboxes at the beginning of each row | -| name | `string` | | Name of the tasklist. | -| page | `number` | 0 | The page number of the tasks to fetch. | -| presetColumn | `string` | | Custom preset column schema in JSON format. | -| processDefinitionId | `string` | | The Definition Id of the process. | -| processInstanceId | `string` | | The Instance Id of the process. | -| selectFirstRow | `boolean` | true | Toggles default selection of the first row | -| selectionMode | `string` | "single" | Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode, you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows. | -| showContextMenu | `boolean` | false | Toggles custom context menu for the component. | -| size | `number` | | The number of tasks to fetch. Default value: 25. | -| sort | `string` | | Define the sort order of the tasks. Possible values are : `created-desc`, `created-asc`, `due-desc`, `due-asc` | -| start | `number` | | Starting point of the list within the full set of tasks. | -| state | `string` | | Current state of the process. Possible values are: `completed`, `active`. | -| stickyHeader | `boolean` | false | Toggles the sticky header mode. | -| taskId | `string` | | The id of a task | +| Name | Type | Default value | Description | +|------------------------|-------------------------------------------------------------------------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| appId | `number` | | The id of the app. | +| assignment | `string` | | The assignment of the process. Possible values are: "assignee" (the current user is the assignee), "candidate" (the current user is a task candidate, "group_x" (the task is assigned to a group where the current user is a member, no value (the current user is involved). | +| blurOnResize | `boolean` | true | Toggles blur when columns of the list are being resized. | +| data | [`DataTableAdapter`](../../../lib/core/src/lib/datatable/data/datatable-adapter.ts) | | Data source object that represents the number and the type of the columns that you want to show. | +| dueAfter | `string` | | Filter the tasks. Display only tasks with `created_date` after `dueAfter`. | +| dueBefore | `string` | | Filter the tasks. Display only tasks with `created_date` before `dueBefore`. | +| isResizingEnabled | `boolean` | false | Toggles column resizing for task list. | +| includeProcessInstance | `boolean` | | Toggles inclusion of Process Instances | +| landingTaskId | `string` | | Define which task id should be selected after reloading. If the task id doesn't exist or nothing is passed then the first task will be selected. | +| multiselect | `boolean` | false | Toggles multiple row selection, renders checkboxes at the beginning of each row | +| name | `string` | | Name of the tasklist. | +| page | `number` | 0 | The page number of the tasks to fetch. | +| presetColumn | `string` | | Custom preset column schema in JSON format. | +| processDefinitionId | `string` | | The Definition Id of the process. | +| processInstanceId | `string` | | The Instance Id of the process. | +| selectFirstRow | `boolean` | true | Toggles default selection of the first row | +| selectionMode | `string` | "single" | Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode, you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows. | +| showContextMenu | `boolean` | false | Toggles custom context menu for the component. | +| size | `number` | | The number of tasks to fetch. Default value: 25. | +| sort | `string` | | Define the sort order of the tasks. Possible values are : `created-desc`, `created-asc`, `due-desc`, `due-asc` | +| start | `number` | | Starting point of the list within the full set of tasks. | +| state | `string` | | Current state of the process. Possible values are: `completed`, `active`. | +| stickyHeader | `boolean` | false | Toggles the sticky header mode. | +| taskId | `string` | | The id of a task | ### Events @@ -95,12 +95,11 @@ renders details of any chosen instance. ### Setting the column schema -You can configure the list to show any of the properties of the -[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts) +You can configure the list to show any of the properties of the `TaskRepresentation` class. The example below shows how to set up the column schema from HTML: ```html - + @@ -111,23 +110,27 @@ class. The example below shows how to set up the column schema from HTML: You can also set a static custom schema declaration in `app.config.json` as shown below: ```json -"adf-task-list": { +{ + "adf-task-list": { "presets": { "customSchema": [ - { + { "key": "name", "type": "text", "title": "name", - "sortable": true - }], + "sortable": true + } + ], "default": [ { "key": "name", "type": "text", "title": "name", "sortable": true - }], + } + ] } + } } ``` @@ -141,23 +144,27 @@ You can also set a static custom schema declaration in `app.config.json` as show You can use an HTML-based schema and an `app.config.json` custom schema declaration at the same time: ```json -"adf-task-list": { +{ + "adf-task-list": { "presets": { "customSchema": [ - { + { "key": "id", "type": "text", "title": "Id", - "sortable": true - }], + "sortable": true + } + ], "default": [ { "key": "name", "type": "text", "title": "name", "sortable": true - }], + } + ] } + } } ``` @@ -197,7 +204,7 @@ let sortParam = 'created-desc'; ### Pagination strategy -The Tasklist also supports pagination as shown in the example below: +The TaskList also supports pagination as shown in the example below: ```html ` - List of process instances -- **getProcessTasks**(processInstanceId: `string`, state?: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`[]>`
+- **getProcessTasks**(processInstanceId: `string`, state?: `string`): `Observable`
Gets task instances for a process instance. - _processInstanceId:_ `string` - ID of the process instance - _state:_ `string` - (Optional) Task state filter (can be "active" or "completed") - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`[]>` - Array of task instance details -- **getProcesses**(requestNode: [`ProcessFilterParamRepresentationModel`](../../../lib/process-services/src/lib/process-list/models/filter-process.model.ts), processDefinitionKey?: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessListModel`](../../../lib/process-services/src/lib/process-list/models/process-list.model.ts)`>`
+ - **Returns** `Observable` - Array of task instance details +- **getProcesses**(requestNode: `ProcessFilterParamRepresentationModel, processDefinitionKey?: `string`): `Observable`
Gets processes for a filter and optionally a process definition. - _requestNode:_ [`ProcessFilterParamRepresentationModel`](../../../lib/process-services/src/lib/process-list/models/filter-process.model.ts) - Filter for instances - _processDefinitionKey:_ `string` - (Optional) Limits returned instances to a process definition diff --git a/docs/process-services/services/tasklist.service.md b/docs/process-services/services/tasklist.service.md index 94b0f884c4..e87cc3f4ed 100644 --- a/docs/process-services/services/tasklist.service.md +++ b/docs/process-services/services/tasklist.service.md @@ -17,53 +17,53 @@ import { TaskListService } from '@alfresco/adf-process-services'; ### Methods -- **addTask**(task: [`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>`
+- **addTask**(task: `TaskRepresentation`): `Observable`
Adds a subtask (ie, a checklist task) to a parent task. - - _task:_ [`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts) - The task to add - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>` - The subtask that was added -- **assignTask**(taskId: `string`, requestNode: `any`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>`
+ - _task:_ `TaskRepresentation` - The task to add + - **Returns** `Observable` - The subtask that was added +- **assignTask**(taskId: `string`, requestNode: `any`): `Observable`
Assigns a task to a user or group. - _taskId:_ `string` - The task to assign - _requestNode:_ `any` - User or group to assign the task to - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>` - Details of the assigned task -- **assignTaskByUserId**(taskId: `string`, userId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>`
+ - **Returns** `Observable` - Details of the assigned task +- **assignTaskByUserId**(taskId: `string`, userId: `string`): `Observable`
Assigns a task to a user. - _taskId:_ `string` - ID of the task to assign - _userId:_ `string` - ID of the user to assign the task to - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>` - Details of the assigned task + - **Returns** `ObservableTaskRepresentation>` - Details of the assigned task - **attachFormToATask**(taskId: `string`, formId: `number`): [`Observable`](http://reactivex.io/documentation/observable.html)``
Attaches a form to a task. - _taskId:_ `string` - ID of the target task - _formId:_ `number` - ID of the form to add - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`` - Null response notifying when the operation is complete -- **claimTask**(taskId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>`
+ - **Returns** `Observable` - Null response notifying when the operation is complete +- **claimTask**(taskId: `string`): `Observable`
Claims a task for the current user. - _taskId:_ `string` - ID of the task to claim - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>` - Details of the claimed task -- **completeTask**(taskId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)``
+ - **Returns** `Observable` - Details of the claimed task +- **completeTask**(taskId: `string`): `Observable`
Gives completed status to a task. - _taskId:_ `string` - ID of the target task - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`` - Null response notifying when the operation is complete -- **createNewTask**(task: [`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>`
+ - **Returns** `Observable` - Null response notifying when the operation is complete +- **createNewTask**(task: `TaskRepresentation`): `Observable`
Creates a new standalone task. - - _task:_ [`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts) - Details of the new task - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>` - Details of the newly created task -- **deleteForm**(taskId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>`
+ - _task:_ `TaskDetailsModel` - Details of the new task + - **Returns** `Observable` - Details of the newly created task +- **deleteForm**(taskId: `string`): `Observable`
Deletes a form from a task. - _taskId:_ `string` - Task id related to form - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>` - Null response notifying when the operation is complete -- **deleteTask**(taskId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>`
+ - **Returns** `Observable` - Null response notifying when the operation is complete +- **deleteTask**(taskId: `string`): `Observable`
Deletes a subtask (ie, a checklist task) from a parent task. - _taskId:_ `string` - The task to delete - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>` - Null response notifying when the operation is complete -- **fetchTaskAuditJsonById**(taskId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)``
+ - **Returns** `Observable` - Null response notifying when the operation is complete +- **fetchTaskAuditJsonById**(taskId: `string`): `Observable`
Fetch the Task Audit information in JSON format - _taskId:_ `string` - ID of the target task - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`` - JSON data -- **fetchTaskAuditPdfById**(taskId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)`>`
+ - **Returns** `Observable` - JSON data +- **fetchTaskAuditPdfById**(taskId: `string`): `Observable`
Fetches the Task Audit information in PDF format. - _taskId:_ `string` - ID of the target task - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)`>` - Binary PDF data + - **Returns** `Observable` - Binary PDF data - **findTasksByState**(requestNode: `TaskQueryRequestRepresentationModel`, state?: `string`): `Observable`
Gets tasks matching a query and state value. - _requestNode:_ `TaskQueryRequestRepresentationModel` - Query to search for tasks @@ -76,12 +76,12 @@ import { TaskListService } from '@alfresco/adf-process-services'; - **Returns** `Observable` - Filters belonging to the task - **getFormList**(): `Observable`
Gets all available reusable forms. - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Form`](../../../lib/process-services/src/lib/task-list/models/form.model.ts)`[]>` - Array of form details -- **getTaskChecklist**(id: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`[]>`
+ - **Returns** `Observable` - Array of form details +- **getTaskChecklist**(id: `string`): `Observable`
Gets the checklist for a task. - _id:_ `string` - ID of the target task - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`[]>` - Array of checklist task details -- **getTaskDetails**(taskId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>`
+ - **Returns** `Observable` - Array of checklist task details +- **getTaskDetails**(taskId: `string`): `Observable`
Gets details for a task. - _taskId:_ `string` - ID of the target task. - **Returns** `Observable` - Task details @@ -101,18 +101,18 @@ import { TaskListService } from '@alfresco/adf-process-services'; - **unclaimTask**(taskId: `string`): `Observable`
Un-claims a task for the current user. - _taskId:_ `string` - ID of the task to unclaim - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>` - Null response notifying when the operation is complete -- **updateTask**(taskId: `string`, updated: [`TaskUpdateRepresentation`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/activiti-rest-api/docs/TaskUpdateRepresentation.md)): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>`
+ - **Returns** `Observable` - Null response notifying when the operation is complete +- **updateTask**(taskId: `string`, updated: `TaskUpdateRepresentation`): `Observable`
Updates the details (name, description, due date) for a task. - _taskId:_ `string` - ID of the task to update - - _updated:_ [`TaskUpdateRepresentation`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/activiti-rest-api/docs/TaskUpdateRepresentation.md) - Data to update the task (as a [`TaskUpdateRepresentation`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/activiti-rest-api/docs/TaskUpdateRepresentation.md) instance). - - **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts)`>` - Updated task details + - _updated:_ `TaskUpdateRepresentation`) - Data to update the task (as a `TaskUpdateRepresentation`) instance). + - **Returns** `Observable` - Updated task details ## Details ### Task details -Several of the methods return one or more [`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts) instances corresponding +Several of the methods return one or more `TaskRepresentation` instances corresponding to tasks or subtasks matched by a query of some kind. For example, `getTaskDetails` could be used as shown below: @@ -125,7 +125,7 @@ this.tasklistService.getTaskDetails(taskInstanceId).subscribe( (taskInstance: Ta }); ``` -The resulting [`TaskDetailsModel`](../../../lib/process-services/src/lib/task-list/models/task-details.model.ts) object contains information like the following: +The resulting `TaskRepresentation` object contains information like the following: ```text adhocTaskCanBeReassigned: false diff --git a/lib/core/src/lib/auth/public-api.ts b/lib/core/src/lib/auth/public-api.ts index 418269f035..98808c6cf0 100644 --- a/lib/core/src/lib/auth/public-api.ts +++ b/lib/core/src/lib/auth/public-api.ts @@ -30,6 +30,7 @@ export * from './services/identity-group.service'; export * from './services/jwt-helper.service'; export * from './services/oauth2.service'; export * from './services/user-access.service'; +export * from './services/oidc-authentication.service'; export * from './basic-auth/basic-alfresco-auth.service'; export * from './basic-auth/process-auth'; diff --git a/lib/process-services/src/lib/compat/types.ts b/lib/process-services/src/lib/compat/types.ts index d0b8875e9c..eaa8bc5fcb 100644 --- a/lib/process-services/src/lib/compat/types.ts +++ b/lib/process-services/src/lib/compat/types.ts @@ -20,6 +20,7 @@ import { LightUserRepresentation, ProcessInstanceRepresentation, RestVariable, + TaskRepresentation, UserRepresentation, UserTaskFilterRepresentation } from '@alfresco/js-api'; @@ -45,4 +46,7 @@ export type UserProcessModel = LightUserRepresentation; /** @deprecated use js-api/RestVariable instead */ export type ProcessInstanceVariable = RestVariable; +/** @deprecated use js-api/TaskRepresentation instead */ +export type TaskDetailsModel = TaskRepresentation; + export { ProcessDefinitionRepresentation } from '@alfresco/js-api'; diff --git a/lib/process-services/src/lib/mock/task/task-details.mock.ts b/lib/process-services/src/lib/mock/task/task-details.mock.ts index b5e49d27be..431d49958a 100644 --- a/lib/process-services/src/lib/mock/task/task-details.mock.ts +++ b/lib/process-services/src/lib/mock/task/task-details.mock.ts @@ -15,10 +15,9 @@ * limitations under the License. */ -import { UserRepresentation } from '@alfresco/js-api'; -import { TaskDetailsModel } from '../../task-list/models/task-details.model'; +import { TaskRepresentation, UserRepresentation } from '@alfresco/js-api'; -export const standaloneTaskWithoutForm = new TaskDetailsModel({ +export const standaloneTaskWithoutForm = new TaskRepresentation({ id: '200', name: 'Standalone Task Without Form', description: null, @@ -29,7 +28,7 @@ export const standaloneTaskWithoutForm = new TaskDetailsModel({ lastName: 'Adams', email: 'wilbur@app.activiti.com' }, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: null, duration: null, @@ -58,7 +57,7 @@ export const standaloneTaskWithoutForm = new TaskDetailsModel({ memberOfCandidateGroup: false }); -export const completedStandaloneTaskWithoutForm = new TaskDetailsModel({ +export const completedStandaloneTaskWithoutForm = new TaskRepresentation({ id: '200', name: 'Standalone Task Without Form', description: null, @@ -69,7 +68,7 @@ export const completedStandaloneTaskWithoutForm = new TaskDetailsModel({ lastName: 'Adams', email: 'wilbur@app.activiti.com' }, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: new Date(), duration: null, @@ -98,7 +97,7 @@ export const completedStandaloneTaskWithoutForm = new TaskDetailsModel({ memberOfCandidateGroup: false }); -export const taskDetailsMock = new TaskDetailsModel({ +export const taskDetailsMock = new TaskRepresentation({ id: '91', name: 'Request translation', description: null, @@ -109,7 +108,7 @@ export const taskDetailsMock = new TaskDetailsModel({ lastName: 'Adams', email: 'wilbur@app.activiti.com' }, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: null, duration: null, @@ -138,13 +137,13 @@ export const taskDetailsMock = new TaskDetailsModel({ memberOfCandidateGroup: false }); -export const initiatorCanCompleteTaskDetailsMock = new TaskDetailsModel({ +export const initiatorCanCompleteTaskDetailsMock = new TaskRepresentation({ id: '91', name: 'Request translation', description: null, category: null, assignee: { email: 'mock-user-email' }, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: null, duration: null, @@ -173,13 +172,13 @@ export const initiatorCanCompleteTaskDetailsMock = new TaskDetailsModel({ memberOfCandidateGroup: false }); -export const initiatorWithCandidatesTaskDetailsMock = new TaskDetailsModel({ +export const initiatorWithCandidatesTaskDetailsMock = new TaskRepresentation({ id: '91', name: 'Request translation', description: null, category: null, assignee: null, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: null, duration: null, @@ -221,13 +220,13 @@ export const initiatorWithCandidatesTaskDetailsMock = new TaskDetailsModel({ memberOfCandidateGroup: true }); -export const taskDetailsWithOutAssigneeMock = new TaskDetailsModel({ +export const taskDetailsWithOutAssigneeMock = new TaskRepresentation({ id: '91', name: 'Request translation', description: null, category: null, assignee: undefined, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: null, duration: null, @@ -256,13 +255,13 @@ export const taskDetailsWithOutAssigneeMock = new TaskDetailsModel({ memberOfCandidateGroup: false }); -export const claimableTaskDetailsMock = new TaskDetailsModel({ +export const claimableTaskDetailsMock = new TaskRepresentation({ id: '91', name: 'Request translation', description: null, category: null, assignee: null, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: null, duration: null, @@ -296,7 +295,7 @@ export const claimableTaskDetailsMock = new TaskDetailsModel({ memberOfCandidateUsers: false }); -export const claimedTaskDetailsMock = new TaskDetailsModel({ +export const claimedTaskDetailsMock = new TaskRepresentation({ id: '91', name: 'Request translation', description: null, @@ -307,7 +306,7 @@ export const claimedTaskDetailsMock = new TaskDetailsModel({ lastName: 'Adams', email: 'wilbur@app.activiti.com' }, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: null, duration: null, @@ -349,7 +348,7 @@ export const claimedTaskDetailsMock = new TaskDetailsModel({ memberOfCandidateUsers: true }); -export const claimedByGroupMemberMock = new TaskDetailsModel({ +export const claimedByGroupMemberMock = new TaskRepresentation({ id: '91', name: 'Request translation', description: null, @@ -360,7 +359,7 @@ export const claimedByGroupMemberMock = new TaskDetailsModel({ lastName: 'fake-last-name', email: 'fake@app.activiti.com' }, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: null, duration: null, @@ -399,7 +398,7 @@ export const claimedByGroupMemberMock = new TaskDetailsModel({ memberOfCandidateUsers: true }); -export const taskDetailsWithOutCandidateGroup = new TaskDetailsModel({ +export const taskDetailsWithOutCandidateGroup = new TaskRepresentation({ id: '91', name: 'Request translation', description: null, @@ -410,7 +409,7 @@ export const taskDetailsWithOutCandidateGroup = new TaskDetailsModel({ lastName: 'Adams', email: 'wilbur@app.activiti.com' }, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: null, duration: null, @@ -441,7 +440,7 @@ export const taskDetailsWithOutCandidateGroup = new TaskDetailsModel({ ] }); -export const completedTaskWithFormMock = new TaskDetailsModel({ +export const completedTaskWithFormMock = new TaskRepresentation({ id: '91', name: 'Request translation', description: null, @@ -452,7 +451,7 @@ export const completedTaskWithFormMock = new TaskDetailsModel({ lastName: 'Adams', email: 'wilbur@app.activiti.com' }, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: new Date(), duration: null, @@ -471,7 +470,7 @@ export const completedTaskWithFormMock = new TaskDetailsModel({ memberOfCandidateUsers: false }); -export const completedTaskDetailsMock = new TaskDetailsModel({ +export const completedTaskDetailsMock = new TaskRepresentation({ id: '91', name: 'Request translation', description: null, @@ -482,7 +481,7 @@ export const completedTaskDetailsMock = new TaskDetailsModel({ lastName: 'Adams', email: 'wilbur@app.activiti.com' }, - created: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), dueDate: null, endDate: new Date(), duration: null, @@ -501,14 +500,14 @@ export const completedTaskDetailsMock = new TaskDetailsModel({ memberOfCandidateUsers: false }); -export const taskDetailsWithOutFormMock = new TaskDetailsModel({ +export const taskDetailsWithOutFormMock = new TaskRepresentation({ id: '91', name: 'Request translation', description: 'fake description', category: null, assignee: { id: 1001, firstName: 'Admin', lastName: 'Paul', email: 'fake-email@gmail.com' }, - created: '2016-11-03T15:25:42.749+0000', - dueDate: '2016-11-03T15:25:42.749+0000', + created: new Date('2016-11-03T15:25:42.749+0000'), + dueDate: new Date('2016-11-03T15:25:42.749+0000'), endDate: null, duration: null, priority: 50, @@ -791,20 +790,20 @@ export const taskFormMock = { globalDateFormat: 'D-M-YYYY' }; -export const tasksMock = [new TaskDetailsModel(taskDetailsMock)]; +export const tasksMock = [taskDetailsMock]; -export const noDataMock = [ - new TaskDetailsModel({ - id: 1005, +export const noDataMock: any[] = [ + { + id: '1005', message: 'example-message', - created: '2017-10-06T11:54:53.443+0000', + created: new Date('2017-10-06T11:54:53.443+0000'), createdBy: { id: 4004, firstName: 'gadget', lastName: 'inspector', email: 'gadget@inspector.com' } - }) + } ]; export const involvedUserTaskForm = { @@ -935,7 +934,7 @@ export const fakeUser = new UserRepresentation({ tenantName: 'abc' }); -export const completedProcessTaskWithoutForm = new TaskDetailsModel({ +export const completedProcessTaskWithoutForm = new TaskRepresentation({ id: '49', name: 'process task without form', description: null, @@ -946,9 +945,9 @@ export const completedProcessTaskWithoutForm = new TaskDetailsModel({ lastName: 'User', email: 'hruser@example.com' }, - created: '2021-07-08T07:39:27.046+0000', + created: new Date('2021-07-08T07:39:27.046+0000'), dueDate: null, - endDate: '2021-07-08T07:39:35.817+0000', + endDate: new Date('2021-07-08T07:39:35.817+0000'), duration: 8771, priority: 0, parentTaskId: null, diff --git a/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.spec.ts b/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.spec.ts index f193882c18..55c5973281 100644 --- a/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.spec.ts +++ b/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.spec.ts @@ -19,7 +19,6 @@ import { SimpleChange } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { of } from 'rxjs'; -import { TaskDetailsModel } from '../../task-list'; import { taskDetailsMock } from '../../mock'; import { ProcessService } from './../services/process.service'; import { ProcessInstanceTasksComponent } from './process-instance-tasks.component'; @@ -27,7 +26,7 @@ import { ProcessTestingModule } from '../../testing/process.testing.module'; import { HarnessLoader } from '@angular/cdk/testing'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { MatListItemHarness } from '@angular/material/list/testing'; -import { ProcessInstanceRepresentation } from '@alfresco/js-api'; +import { ProcessInstanceRepresentation, TaskRepresentation } from '@alfresco/js-api'; describe('ProcessInstanceTasksComponent', () => { let component: ProcessInstanceTasksComponent; @@ -46,7 +45,7 @@ describe('ProcessInstanceTasksComponent', () => { component = fixture.componentInstance; loader = TestbedHarnessEnvironment.loader(fixture); - spyOn(processService, 'getProcessTasks').and.returnValue(of([new TaskDetailsModel(taskDetailsMock)])); + spyOn(processService, 'getProcessTasks').and.returnValue(of([new TaskRepresentation(taskDetailsMock)])); }); it('should initially render message about no active tasks if no process instance ID provided', () => { diff --git a/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.ts b/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.ts index 28edf2fd88..18733a4fa2 100644 --- a/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.ts +++ b/lib/process-services/src/lib/process-list/components/process-instance-tasks.component.ts @@ -19,10 +19,10 @@ import { DatePipe } from '@angular/common'; import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild, OnDestroy } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { Observable, Observer, Subject } from 'rxjs'; -import { TaskDetailsEvent, TaskDetailsModel } from '../../task-list'; +import { TaskDetailsEvent } from '../../task-list'; import { ProcessService } from './../services/process.service'; import { share, takeUntil } from 'rxjs/operators'; -import { ProcessInstanceRepresentation } from '@alfresco/js-api'; +import { ProcessInstanceRepresentation, TaskRepresentation } from '@alfresco/js-api'; @Component({ selector: 'adf-process-instance-tasks', @@ -55,20 +55,20 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr @Output() taskClick = new EventEmitter(); - activeTasks: TaskDetailsModel[] = []; - completedTasks: TaskDetailsModel[] = []; - task$: Observable; - completedTask$: Observable; + activeTasks: TaskRepresentation[] = []; + completedTasks: TaskRepresentation[] = []; + task$: Observable; + completedTask$: Observable; message: string; processId: string; - private taskObserver: Observer; - private completedTaskObserver: Observer; + private taskObserver: Observer; + private completedTaskObserver: Observer; private onDestroy$ = new Subject(); constructor(private processService: ProcessService, private dialog: MatDialog) { - this.task$ = new Observable((observer) => (this.taskObserver = observer)).pipe(share()); - this.completedTask$ = new Observable((observer) => (this.completedTaskObserver = observer)).pipe(share()); + this.task$ = new Observable((observer) => (this.taskObserver = observer)).pipe(share()); + this.completedTask$ = new Observable((observer) => (this.completedTaskObserver = observer)).pipe(share()); } ngOnInit() { @@ -150,7 +150,7 @@ export class ProcessInstanceTasksComponent implements OnInit, OnChanges, OnDestr } } - clickTask(task: TaskDetailsModel) { + clickTask(task: TaskRepresentation) { const args = new TaskDetailsEvent(task); this.taskClick.emit(args); } diff --git a/lib/process-services/src/lib/process-list/services/process.service.spec.ts b/lib/process-services/src/lib/process-list/services/process.service.spec.ts index c1704df69f..d062cb610c 100644 --- a/lib/process-services/src/lib/process-list/services/process.service.spec.ts +++ b/lib/process-services/src/lib/process-list/services/process.service.spec.ts @@ -20,22 +20,21 @@ import { exampleProcess } from '../../mock'; import { ProcessService } from './process.service'; import { CoreModule, DateFnsUtils } from '@alfresco/adf-core'; import { ProcessTestingModule } from '../../testing/process.testing.module'; -import { ProcessInstanceQueryRepresentation, ProcessDefinitionRepresentation, RestVariable } from '@alfresco/js-api'; -import { TaskDetailsModel } from '@alfresco/adf-process-services'; +import { ProcessInstanceQueryRepresentation, ProcessDefinitionRepresentation, RestVariable, TaskRepresentation } from '@alfresco/js-api'; const fakeTasksList = { data: [ - new TaskDetailsModel({ - id: 1, + new TaskRepresentation({ + id: '1', name: 'Task 1', - processInstanceId: 1000, - created: '2016-11-10T03:37:30.010+0000' + processInstanceId: '1000', + created: new Date('2016-11-10T03:37:30.010+0000') }), - new TaskDetailsModel({ - id: 2, + new TaskRepresentation({ + id: '2', name: 'Task 2', - processInstanceId: 1000, - created: '2016-11-10T03:37:30.010+0000' + processInstanceId: '1000', + created: new Date('2016-11-10T03:37:30.010+0000') }) ] }; diff --git a/lib/process-services/src/lib/process-list/services/process.service.ts b/lib/process-services/src/lib/process-list/services/process.service.ts index cd4c5383b7..19641e54c3 100644 --- a/lib/process-services/src/lib/process-list/services/process.service.ts +++ b/lib/process-services/src/lib/process-list/services/process.service.ts @@ -16,7 +16,7 @@ */ import { AlfrescoApiService, DateFnsUtils, FormValues } from '@alfresco/adf-core'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { FormDefinitionRepresentation, ProcessDefinitionsApi, @@ -28,10 +28,10 @@ import { RestVariable, ResultListDataRepresentationProcessInstanceRepresentation, TasksApi, - ProcessDefinitionRepresentation + ProcessDefinitionRepresentation, + TaskRepresentation } from '@alfresco/js-api'; import { from, Observable } from 'rxjs'; -import { TaskDetailsModel } from '../../task-list'; import { map } from 'rxjs/operators'; import { DatePipe } from '@angular/common'; @@ -39,6 +39,8 @@ import { DatePipe } from '@angular/common'; providedIn: 'root' }) export class ProcessService { + private alfrescoApiService = inject(AlfrescoApiService); + private _tasksApi: TasksApi; get tasksApi(): TasksApi { return (this._tasksApi ||= new TasksApi(this.alfrescoApiService.getInstance())); @@ -59,8 +61,6 @@ export class ProcessService { return (this._processInstanceVariablesApi ||= new ProcessInstanceVariablesApi(this.alfrescoApiService.getInstance())); } - constructor(private alfrescoApiService: AlfrescoApiService) {} - /** * Gets process instances for a filter and optionally a process definition. * @@ -174,7 +174,7 @@ export class ProcessService { * @param state Task state filter (can be "active" or "completed") * @returns Array of task instance details */ - getProcessTasks(processInstanceId: string, state?: string): Observable { + getProcessTasks(processInstanceId: string, state?: string): Observable { const taskOpts = state ? { processInstanceId, diff --git a/lib/process-services/src/lib/task-list/components/checklist.component.spec.ts b/lib/process-services/src/lib/task-list/components/checklist.component.spec.ts index 6bd429e774..916f7f3e00 100644 --- a/lib/process-services/src/lib/task-list/components/checklist.component.spec.ts +++ b/lib/process-services/src/lib/task-list/components/checklist.component.spec.ts @@ -17,11 +17,11 @@ import { SimpleChange } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { TaskDetailsModel } from '../models/task-details.model'; import { ChecklistComponent } from './checklist.component'; import { ProcessTestingModule } from '../../testing/process.testing.module'; import { TaskListService } from './../services/tasklist.service'; import { of } from 'rxjs'; +import { TaskRepresentation } from '@alfresco/js-api'; describe('ChecklistComponent', () => { let checklistComponent: ChecklistComponent; @@ -37,7 +37,7 @@ describe('ChecklistComponent', () => { service = TestBed.inject(TaskListService); spyOn(service, 'getTaskChecklist').and.returnValue( of([ - new TaskDetailsModel({ + new TaskRepresentation({ id: 'fake-check-changed-id', name: 'fake-check-changed-name' }) @@ -65,7 +65,7 @@ describe('ChecklistComponent', () => { beforeEach(() => { checklistComponent.taskId = 'fake-task-id'; checklistComponent.checklist.push( - new TaskDetailsModel({ + new TaskRepresentation({ id: 'fake-check-id', name: 'fake-check-name' }) @@ -90,7 +90,7 @@ describe('ChecklistComponent', () => { checklistComponent.taskId = 'fake-task-id'; checklistComponent.readOnly = false; checklistComponent.checklist.push( - new TaskDetailsModel({ + new TaskRepresentation({ id: 'fake-check-id', name: 'fake-check-name' }) @@ -148,7 +148,7 @@ describe('ChecklistComponent', () => { it('should show task checklist', () => { checklistComponent.checklist.push( - new TaskDetailsModel({ + new TaskRepresentation({ id: 'fake-check-id', name: 'fake-check-name' }) @@ -160,16 +160,16 @@ describe('ChecklistComponent', () => { it('should not show delete icon when checklist task is completed', () => { checklistComponent.checklist.push( - new TaskDetailsModel({ + new TaskRepresentation({ id: 'fake-check-id', name: 'fake-check-name' }) ); checklistComponent.checklist.push( - new TaskDetailsModel({ + new TaskRepresentation({ id: 'fake-completed-id', name: 'fake-completed-name', - endDate: '2018-05-23T11:25:14.552+0000' + endDate: new Date('2018-05-23T11:25:14.552+0000') }) ); fixture.detectChanges(); @@ -182,7 +182,7 @@ describe('ChecklistComponent', () => { it('should add checklist', async () => { spyOn(service, 'addTask').and.returnValue( of( - new TaskDetailsModel({ + new TaskRepresentation({ id: 'fake-check-added-id', name: 'fake-check-added-name' }) @@ -205,7 +205,7 @@ describe('ChecklistComponent', () => { checklistComponent.taskId = 'new-fake-task-id'; checklistComponent.checklist.push( - new TaskDetailsModel({ + new TaskRepresentation({ id: 'fake-check-id', name: 'fake-check-name' }) @@ -229,7 +229,7 @@ describe('ChecklistComponent', () => { spyOn(service, 'deleteTask').and.returnValue(of(null)); checklistComponent.taskId = 'new-fake-task-id'; checklistComponent.checklist.push( - new TaskDetailsModel({ + new TaskRepresentation({ id: 'fake-check-id', name: 'fake-check-name' }) @@ -250,7 +250,7 @@ describe('ChecklistComponent', () => { it('should show load task checklist on change', async () => { checklistComponent.taskId = 'new-fake-task-id'; checklistComponent.checklist.push( - new TaskDetailsModel({ + new TaskRepresentation({ id: 'fake-check-id', name: 'fake-check-name' }) @@ -271,7 +271,7 @@ describe('ChecklistComponent', () => { it('should show empty checklist when task id is null', async () => { checklistComponent.taskId = 'new-fake-task-id'; checklistComponent.checklist.push( - new TaskDetailsModel({ + new TaskRepresentation({ id: 'fake-check-id', name: 'fake-check-name' }) @@ -294,9 +294,9 @@ describe('ChecklistComponent', () => { }); it('should emit checklist task created event when the checklist is successfully added', (done) => { - spyOn(service, 'addTask').and.returnValue(of(new TaskDetailsModel({ id: 'fake-check-added-id', name: 'fake-check-added-name' }))); + spyOn(service, 'addTask').and.returnValue(of(new TaskRepresentation({ id: 'fake-check-added-id', name: 'fake-check-added-name' }))); - const disposableCreated = checklistComponent.checklistTaskCreated.subscribe((taskAdded: TaskDetailsModel) => { + const disposableCreated = checklistComponent.checklistTaskCreated.subscribe((taskAdded) => { fixture.detectChanges(); expect(taskAdded.id).toEqual('fake-check-added-id'); expect(taskAdded.name).toEqual('fake-check-added-name'); diff --git a/lib/process-services/src/lib/task-list/components/checklist.component.ts b/lib/process-services/src/lib/task-list/components/checklist.component.ts index c57ef2ec3f..124bc84dbc 100644 --- a/lib/process-services/src/lib/task-list/components/checklist.component.ts +++ b/lib/process-services/src/lib/task-list/components/checklist.component.ts @@ -17,8 +17,8 @@ import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; -import { TaskDetailsModel } from '../models/task-details.model'; import { TaskListService } from './../services/tasklist.service'; +import { TaskRepresentation } from '@alfresco/js-api'; @Component({ selector: 'adf-checklist', @@ -41,11 +41,11 @@ export class ChecklistComponent implements OnChanges { /** (required) The assignee id that the subtasks are assigned to. */ @Input() - assignee: string; + assignee: number; /** Emitted when a new checklist task is created. */ @Output() - checklistTaskCreated = new EventEmitter(); + checklistTaskCreated = new EventEmitter(); /** Emitted when a checklist task is deleted. */ @Output() @@ -60,7 +60,7 @@ export class ChecklistComponent implements OnChanges { taskName: string; - checklist: TaskDetailsModel[] = []; + checklist: TaskRepresentation[] = []; constructor(private taskListService: TaskListService, private dialog: MatDialog) {} @@ -95,7 +95,7 @@ export class ChecklistComponent implements OnChanges { } public add() { - const newTask = new TaskDetailsModel({ + const newTask = new TaskRepresentation({ name: this.taskName, parentTaskId: this.taskId, assignee: { id: this.assignee } diff --git a/lib/process-services/src/lib/task-list/components/start-task.component.spec.ts b/lib/process-services/src/lib/task-list/components/start-task.component.spec.ts index ede706ee43..617af897d4 100644 --- a/lib/process-services/src/lib/task-list/components/start-task.component.spec.ts +++ b/lib/process-services/src/lib/task-list/components/start-task.component.spec.ts @@ -21,10 +21,10 @@ import { TaskListService } from '../services/tasklist.service'; import { StartTaskComponent } from './start-task.component'; import { ProcessTestingModule } from '../../testing/process.testing.module'; import { taskDetailsMock } from '../../mock/task/task-details.mock'; -import { TaskDetailsModel } from '../models/task-details.model'; import { HarnessLoader } from '@angular/cdk/testing'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { MatButtonHarness } from '@angular/material/button/testing'; +import { TaskRepresentation } from '@alfresco/js-api'; describe('StartTaskComponent', () => { let component: StartTaskComponent; @@ -99,7 +99,7 @@ describe('StartTaskComponent', () => { it('should send on success event when the task is started', () => { const successSpy = spyOn(component.success, 'emit'); - component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock); + component.taskDetailsModel = new TaskRepresentation(taskDetailsMock); component.taskForm.controls['name'].setValue('fakeName'); fixture.detectChanges(); const createTaskButton = element.querySelector('#button-start'); @@ -124,7 +124,7 @@ describe('StartTaskComponent', () => { it('should not emit success event when data not present', () => { const successSpy = spyOn(component.success, 'emit'); - component.taskDetailsModel = new TaskDetailsModel(null); + component.taskDetailsModel = new TaskRepresentation(null); fixture.detectChanges(); const createTaskButton = element.querySelector('#button-start'); createTaskButton.click(); @@ -158,7 +158,7 @@ describe('StartTaskComponent', () => { component.taskForm.controls['name'].setValue('fakeName'); component.taskForm.controls['formKey'].setValue(1204); component.appId = 42; - component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock); + component.taskDetailsModel = new TaskRepresentation(taskDetailsMock); fixture.detectChanges(); const createTaskButton = element.querySelector('#button-start'); createTaskButton.click(); @@ -183,7 +183,7 @@ describe('StartTaskComponent', () => { component.taskForm.controls['name'].setValue('fakeName'); component.taskForm.controls['formKey'].setValue(null); component.appId = 42; - component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock); + component.taskDetailsModel = new TaskRepresentation(taskDetailsMock); fixture.detectChanges(); const createTaskButton = element.querySelector('#button-start'); createTaskButton.click(); @@ -243,7 +243,7 @@ describe('StartTaskComponent', () => { it('should assign task with id of selected user assigned', () => { const successSpy = spyOn(component.success, 'emit'); - component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock); + component.taskDetailsModel = new TaskRepresentation(taskDetailsMock); component.taskForm.controls['name'].setValue('fakeName'); component.taskForm.controls['formKey'].setValue(1204); component.appId = 42; @@ -265,7 +265,7 @@ describe('StartTaskComponent', () => { component.taskForm.controls['formKey'].setValue(1204); component.appId = 42; component.assigneeId = null; - component.taskDetailsModel = new TaskDetailsModel(taskDetailsMock); + component.taskDetailsModel = new TaskRepresentation(taskDetailsMock); fixture.detectChanges(); const createTaskButton = element.querySelector('#button-start'); createTaskButton.click(); @@ -280,7 +280,7 @@ describe('StartTaskComponent', () => { it('should not attach a form when a form id is not selected', () => { const attachFormToATask = spyOn(service, 'attachFormToATask').and.returnValue(of([])); - spyOn(service, 'createNewTask').and.returnValue(of(new TaskDetailsModel({ id: 'task-id' }))); + spyOn(service, 'createNewTask').and.returnValue(of(new TaskRepresentation({ id: 'task-id' }))); component.taskForm.controls['name'].setValue('fakeName'); fixture.detectChanges(); const createTaskButton = element.querySelector('#button-start'); diff --git a/lib/process-services/src/lib/task-list/components/start-task.component.ts b/lib/process-services/src/lib/task-list/components/start-task.component.ts index c0d7a34cfa..77a3f7af0c 100644 --- a/lib/process-services/src/lib/task-list/components/start-task.component.ts +++ b/lib/process-services/src/lib/task-list/components/start-task.component.ts @@ -20,11 +20,11 @@ import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation, OnDe import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core'; import { EMPTY, Observable, Subject } from 'rxjs'; import { Form } from '../models/form.model'; -import { TaskDetailsModel } from '../models/task-details.model'; import { TaskListService } from './../services/tasklist.service'; import { switchMap, defaultIfEmpty, takeUntil } from 'rxjs/operators'; import { UntypedFormBuilder, AbstractControl, Validators, UntypedFormGroup, UntypedFormControl } from '@angular/forms'; import { isValid } from 'date-fns'; +import { TaskRepresentation } from '@alfresco/js-api'; const FORMAT_DATE = 'DD/MM/YYYY'; const MAX_LENGTH = 255; @@ -60,7 +60,7 @@ export class StartTaskComponent implements OnInit, OnDestroy { @Output() error = new EventEmitter(); - taskDetailsModel: TaskDetailsModel = new TaskDetailsModel(); + taskDetailsModel = new TaskRepresentation(); forms$: Observable; assigneeId: number; field: FormFieldModel; @@ -213,7 +213,7 @@ export class StartTaskComponent implements OnInit, OnDestroy { return response; } - private assignTaskByUserId(taskId: string, userId: string): Observable { + private assignTaskByUserId(taskId: string, userId: string): Observable { if (taskId && userId) { return this.taskService.assignTaskByUserId(taskId, userId); } diff --git a/lib/process-services/src/lib/task-list/components/task-details.component.html b/lib/process-services/src/lib/task-list/components/task-details.component.html index 7bfe0717bf..20a38d1604 100644 --- a/lib/process-services/src/lib/task-list/components/task-details.component.html +++ b/lib/process-services/src/lib/task-list/components/task-details.component.html @@ -92,7 +92,7 @@ diff --git a/lib/process-services/src/lib/task-list/components/task-details.component.spec.ts b/lib/process-services/src/lib/task-list/components/task-details.component.spec.ts index 608e2f25c1..b1f7c3e318 100644 --- a/lib/process-services/src/lib/task-list/components/task-details.component.spec.ts +++ b/lib/process-services/src/lib/task-list/components/task-details.component.spec.ts @@ -20,7 +20,6 @@ import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { of, throwError } from 'rxjs'; import { FormModel, FormOutcomeEvent, FormOutcomeModel, CommentModel, User } from '@alfresco/adf-core'; -import { TaskDetailsModel } from '../models/task-details.model'; import { noDataMock, taskDetailsMock, taskFormMock, tasksMock, taskDetailsWithOutAssigneeMock } from '../../mock'; import { TaskListService } from './../services/tasklist.service'; import { TaskDetailsComponent } from './task-details.component'; @@ -32,7 +31,7 @@ import { PeopleProcessService } from '../../common/services/people-process.servi import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { HarnessLoader } from '@angular/cdk/testing'; import { MatDialogHarness } from '@angular/material/dialog/testing'; -import { LightUserRepresentation } from '@alfresco/js-api'; +import { LightUserRepresentation, TaskRepresentation } from '@alfresco/js-api'; const fakeUser: LightUserRepresentation = { id: 0, @@ -41,12 +40,12 @@ const fakeUser: LightUserRepresentation = { email: 'fake@mail.com' }; -const fakeTaskAssignResponse = new TaskDetailsModel({ +const fakeTaskAssignResponse: any = { id: 'fake-id', firstName: 'fake-name', lastName: 'fake-last', email: 'fake@mail.com' -}); +}; describe('TaskDetailsComponent', () => { let taskListService: TaskListService; @@ -295,7 +294,7 @@ describe('TaskDetailsComponent', () => { it('should emit a task created event when checklist task is created', () => { const emitSpy: jasmine.Spy = spyOn(component.taskCreated, 'emit'); - const mockTask = new TaskDetailsModel(taskDetailsMock); + const mockTask = new TaskRepresentation(taskDetailsMock); component.onChecklistTaskCreated(mockTask); expect(emitSpy).toHaveBeenCalled(); }); @@ -307,7 +306,7 @@ describe('TaskDetailsComponent', () => { component.showHeaderContent = true; component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) }); component.taskPeople = []; - component.taskDetails = new TaskDetailsModel(taskDetailsMock); + component.taskDetails = new TaskRepresentation(taskDetailsMock); component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000'); fixture.detectChanges(); @@ -319,7 +318,7 @@ describe('TaskDetailsComponent', () => { component.showHeaderContent = true; component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) }); component.taskPeople = []; - component.taskDetails = new TaskDetailsModel(taskDetailsMock); + component.taskDetails = new TaskRepresentation(taskDetailsMock); component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000'); fixture.detectChanges(); @@ -331,7 +330,7 @@ describe('TaskDetailsComponent', () => { component.showHeaderContent = true; component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) }); component.taskPeople = [fakeUser]; - component.taskDetails = new TaskDetailsModel(taskDetailsMock); + component.taskDetails = new TaskRepresentation(taskDetailsMock); component.taskDetails.endDate = null; fixture.detectChanges(); @@ -343,7 +342,7 @@ describe('TaskDetailsComponent', () => { component.showHeaderContent = true; component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) }); component.taskPeople = [fakeUser]; - component.taskDetails = new TaskDetailsModel(taskDetailsMock); + component.taskDetails = new TaskRepresentation(taskDetailsMock); component.taskDetails.endDate = new Date('2017-10-03T17:03:57.311+0000'); fixture.detectChanges(); @@ -355,7 +354,7 @@ describe('TaskDetailsComponent', () => { component.showHeaderContent = true; component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) }); component.taskPeople = []; - component.taskDetails = new TaskDetailsModel(taskDetailsMock); + component.taskDetails = new TaskRepresentation(taskDetailsMock); fixture.detectChanges(); expect(component.showComments).toBe(true); @@ -365,7 +364,7 @@ describe('TaskDetailsComponent', () => { component.showComments = false; component.ngOnChanges({ taskId: new SimpleChange('123', '456', true) }); component.taskPeople = []; - component.taskDetails = new TaskDetailsModel(taskDetailsMock); + component.taskDetails = new TaskRepresentation(taskDetailsMock); fixture.detectChanges(); expect(component.showComments).toBeFalse(); diff --git a/lib/process-services/src/lib/task-list/components/task-details.component.ts b/lib/process-services/src/lib/task-list/components/task-details.component.ts index 1291e60513..58e16ddd84 100644 --- a/lib/process-services/src/lib/task-list/components/task-details.component.ts +++ b/lib/process-services/src/lib/task-list/components/task-details.component.ts @@ -39,12 +39,11 @@ import { } from '@angular/core'; import { MatDialog, MatDialogRef } from '@angular/material/dialog'; import { Observable, Observer, of, Subject } from 'rxjs'; -import { TaskDetailsModel } from '../models/task-details.model'; import { TaskListService } from './../services/tasklist.service'; import { catchError, share, takeUntil } from 'rxjs/operators'; import { TaskFormComponent } from './task-form/task-form.component'; import { PeopleProcessService } from '../../common/services/people-process.service'; -import { LightUserRepresentation, TaskQueryRepresentation } from '@alfresco/js-api'; +import { LightUserRepresentation, TaskQueryRepresentation, TaskRepresentation } from '@alfresco/js-api'; @Component({ selector: 'adf-task-details', @@ -132,7 +131,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy { /** Emitted when a checklist task is created. */ @Output() - taskCreated = new EventEmitter(); + taskCreated = new EventEmitter(); /** Emitted when a checklist task is deleted. */ @Output() @@ -161,7 +160,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy { @Output() unClaimedTask = new EventEmitter(); - taskDetails: TaskDetailsModel; + taskDetails: TaskRepresentation; taskFormName: string = null; taskPeople: LightUserRepresentation[] = []; noTaskDetailsTemplateComponent: TemplateRef; @@ -256,7 +255,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy { this.formLoaded.emit(form); } - onChecklistTaskCreated(task: TaskDetailsModel): void { + onChecklistTaskCreated(task: TaskRepresentation): void { this.taskCreated.emit(task); } @@ -376,7 +375,7 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy { this.taskListService.getTasks(requestNode).subscribe( (response) => { if (response && response.length > 0) { - this.taskDetails = new TaskDetailsModel(response[0]); + this.taskDetails = new TaskRepresentation(response[0]); } else { this.reset(); } diff --git a/lib/process-services/src/lib/task-list/components/task-form/task-form.component.spec.ts b/lib/process-services/src/lib/task-list/components/task-form/task-form.component.spec.ts index 70b62d5003..b04f9b2997 100644 --- a/lib/process-services/src/lib/task-list/components/task-form/task-form.component.spec.ts +++ b/lib/process-services/src/lib/task-list/components/task-form/task-form.component.spec.ts @@ -41,12 +41,12 @@ import { taskDetailsWithOutFormMock, taskFormMock } from '../../../mock/task/task-details.mock'; -import { TaskDetailsModel } from '../../models/task-details.model'; import { ProcessTestingModule } from '../../../testing/process.testing.module'; import { By } from '@angular/platform-browser'; import { TaskFormService } from '../../../form/services/task-form.service'; import { TaskService } from '../../../form/services/task.service'; import { PeopleProcessService } from '../../../common/services/people-process.service'; +import { TaskRepresentation } from '@alfresco/js-api'; describe('TaskFormComponent', () => { let component: TaskFormComponent; @@ -282,7 +282,7 @@ describe('TaskFormComponent', () => { it('Should be able to show completed message and cancel button for the completed task without form', async () => { completedTaskDetailsMock.formKey = null; - component.taskDetails = new TaskDetailsModel(completedTaskDetailsMock); + component.taskDetails = new TaskRepresentation(completedTaskDetailsMock); fixture.detectChanges(); await fixture.whenStable(); const completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button'); @@ -297,7 +297,7 @@ describe('TaskFormComponent', () => { it('Should not display complete button to the completed task without form', async () => { completedTaskDetailsMock.formKey = null; - component.taskDetails = new TaskDetailsModel(completedTaskDetailsMock); + component.taskDetails = new TaskRepresentation(completedTaskDetailsMock); fixture.detectChanges(); await fixture.whenStable(); const completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button'); @@ -312,7 +312,7 @@ describe('TaskFormComponent', () => { }); it('Should be able to show no form message if the task does not attached a form', async () => { - component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock); + component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock); fixture.detectChanges(); await fixture.whenStable(); const completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button'); @@ -326,7 +326,7 @@ describe('TaskFormComponent', () => { }); it('Should be able display complete button to a task without form', async () => { - component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock); + component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock); fixture.detectChanges(); await fixture.whenStable(); const completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button'); @@ -336,7 +336,7 @@ describe('TaskFormComponent', () => { it('Should be able to complete a task with no form when complete button is clicked', async () => { fixture.detectChanges(); - component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock); + component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock); fixture.detectChanges(); await fixture.whenStable(); const completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button'); @@ -347,7 +347,7 @@ describe('TaskFormComponent', () => { it('Should emit error event in case complete task service fails', async () => { const errorSpy: jasmine.Spy = spyOn(component.error, 'emit'); completeTaskSpy.and.returnValue(throwError({ message: 'servce failed' })); - component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock); + component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock); fixture.detectChanges(); await fixture.whenStable(); const formSelector = element.querySelector('adf-form'); @@ -361,7 +361,7 @@ describe('TaskFormComponent', () => { it('Should be able to emit cancel event on task with no-form when cancel button is clicked', async () => { const cancelSpy = spyOn(component.cancel, 'emit'); getTaskDetailsSpy.and.returnValue(of(taskDetailsWithOutFormMock)); - component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock); + component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock); fixture.detectChanges(); await fixture.whenStable(); const cancelButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-cancel-button'); @@ -370,7 +370,7 @@ describe('TaskFormComponent', () => { }); it('Should display the template in a process task with no Form', async () => { - component.taskDetails = new TaskDetailsModel(taskDetailsWithOutFormMock); + component.taskDetails = new TaskRepresentation(taskDetailsWithOutFormMock); fixture.detectChanges(); await fixture.whenStable(); let formMessage = fixture.debugElement.nativeElement.querySelector('.adf-empty-content__title'); @@ -383,7 +383,7 @@ describe('TaskFormComponent', () => { expect(subMessage.innerText).toContain('ADF_TASK_FORM.EMPTY_FORM.SUBTITLE'); completeButtonElement.click(); - component.taskDetails = new TaskDetailsModel(completedProcessTaskWithoutForm); + component.taskDetails = new TaskRepresentation(completedProcessTaskWithoutForm); fixture.detectChanges(); await fixture.whenStable(); @@ -394,8 +394,8 @@ describe('TaskFormComponent', () => { expect(formMessage.innerText).toContain('ADF_TASK_FORM.COMPLETED_TASK.TITLE'); expect(subMessage.innerText).toContain('ADF_TASK_FORM.COMPLETED_TASK.SUBTITLE'); expect(cancelButton).not.toBeNull(); - expect(cancelButton['disabled']).toEqual(false, 'cancel button not visible for completed task'); - expect(completeButtonElement).toBeNull('complete button shown for completed task'); + expect(cancelButton['disabled']).toEqual(false); + expect(completeButtonElement).toBeNull(); expect(taskListService.completeTask).toHaveBeenCalled(); }); }); @@ -407,7 +407,7 @@ describe('TaskFormComponent', () => { }); it('Should display empty template in case standalone task does not attached a form', async () => { - component.taskDetails = new TaskDetailsModel(standaloneTaskWithoutForm); + component.taskDetails = new TaskRepresentation(standaloneTaskWithoutForm); fixture.detectChanges(); await fixture.whenStable(); const taskStandAlone = element.querySelector('adf-task-standalone'); @@ -418,7 +418,7 @@ describe('TaskFormComponent', () => { it('Should be able display attach form button for a standalone task without form', async () => { const showAttachFormSpy = spyOn(component.showAttachForm, 'emit'); - component.taskDetails = new TaskDetailsModel(standaloneTaskWithoutForm); + component.taskDetails = new TaskRepresentation(standaloneTaskWithoutForm); fixture.detectChanges(); await fixture.whenStable(); const attacheFormButton = fixture.debugElement.nativeElement.querySelector('#adf-no-form-attach-form-button'); @@ -452,7 +452,7 @@ describe('TaskFormComponent', () => { expect(formMessage.innerText).toContain('ADF_TASK_LIST.STANDALONE_TASK.NO_FORM_MESSAGE'); completeButtonElement.click(); - component.taskDetails = new TaskDetailsModel(completedStandaloneTaskWithoutForm); + component.taskDetails = new TaskRepresentation(completedStandaloneTaskWithoutForm); fixture.detectChanges(); await fixture.whenStable(); @@ -460,8 +460,8 @@ describe('TaskFormComponent', () => { completeButtonElement = fixture.debugElement.nativeElement.querySelector('#adf-no-form-complete-button'); attacheFormButton = fixture.debugElement.nativeElement.querySelector('#adf-no-form-attach-form-button'); expect(formMessage.innerText).toContain('ADF_TASK_LIST.STANDALONE_TASK.COMPLETE_TASK_MESSAGE'); - expect(attacheFormButton).toBeNull('attach form button shown for completed task'); - expect(completeButtonElement).toBeNull('complete button shown for completed task'); + expect(attacheFormButton).toBeNull(); + expect(completeButtonElement).toBeNull(); expect(taskListService.completeTask).toHaveBeenCalled(); }); }); diff --git a/lib/process-services/src/lib/task-list/components/task-form/task-form.component.ts b/lib/process-services/src/lib/task-list/components/task-form/task-form.component.ts index cced43d238..1414fb4277 100644 --- a/lib/process-services/src/lib/task-list/components/task-form/task-form.component.ts +++ b/lib/process-services/src/lib/task-list/components/task-form/task-form.component.ts @@ -17,9 +17,8 @@ import { Component, OnInit, Input, Output, EventEmitter, SimpleChanges, ViewEncapsulation, OnChanges } from '@angular/core'; import { FormModel, ContentLinkModel, FormFieldValidator, FormOutcomeEvent, TranslationService, FormFieldModel } from '@alfresco/adf-core'; -import { TaskDetailsModel } from '../../models/task-details.model'; import { TaskListService } from '../../services/tasklist.service'; -import { UserRepresentation } from '@alfresco/js-api'; +import { TaskRepresentation, UserRepresentation } from '@alfresco/js-api'; import { Observable } from 'rxjs'; import { PeopleProcessService } from '../../../common'; @@ -119,7 +118,7 @@ export class TaskFormComponent implements OnInit, OnChanges { @Output() taskUnclaimed = new EventEmitter(); - taskDetails: TaskDetailsModel; + taskDetails: TaskRepresentation; currentLoggedUser: UserRepresentation; loading: boolean = false; internalReadOnlyForm: boolean = false; diff --git a/lib/process-services/src/lib/task-list/components/task-header.component.spec.ts b/lib/process-services/src/lib/task-list/components/task-header.component.spec.ts index 6f3fed31cf..ba4215a443 100644 --- a/lib/process-services/src/lib/task-list/components/task-header.component.spec.ts +++ b/lib/process-services/src/lib/task-list/components/task-header.component.spec.ts @@ -27,12 +27,11 @@ import { claimedByGroupMemberMock, taskDetailsWithOutCandidateGroup } from '../../mock'; - -import { TaskDetailsModel } from '../models/task-details.model'; import { TaskListService } from './../services/tasklist.service'; import { TaskHeaderComponent } from './task-header.component'; import { ProcessTestingModule } from '../../testing/process.testing.module'; import { PeopleProcessService } from '../../common/services/people-process.service'; +import { TaskRepresentation } from '@alfresco/js-api'; describe('TaskHeaderComponent', () => { let service: TaskListService; @@ -64,7 +63,7 @@ describe('TaskHeaderComponent', () => { service = TestBed.inject(TaskListService); peopleProcessService = TestBed.inject(PeopleProcessService); spyOn(peopleProcessService, 'getCurrentUserInfo').and.returnValue(of(fakeBpmAssignedUser)); - component.taskDetails = new TaskDetailsModel(taskDetailsMock); + component.taskDetails = new TaskRepresentation(taskDetailsMock); appConfigService = TestBed.inject(AppConfigService); }); @@ -133,12 +132,12 @@ describe('TaskHeaderComponent', () => { await fixture.whenStable(); const datePicker = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-dueDate"]`)); - expect(datePicker).not.toBeNull('Datepicker should be in DOM'); + expect(datePicker).not.toBeNull(); }); describe('Claiming', () => { it('should be able display the claim/release button if showClaimRelease set to true', async () => { - component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock); + component.taskDetails = new TaskRepresentation(claimableTaskDetailsMock); component.showClaimRelease = true; component.refreshData(); @@ -150,7 +149,7 @@ describe('TaskHeaderComponent', () => { }); it('should not be able display the claim/release button if showClaimRelease set to false', async () => { - component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock); + component.taskDetails = new TaskRepresentation(claimableTaskDetailsMock); component.showClaimRelease = false; component.refreshData(); @@ -162,7 +161,7 @@ describe('TaskHeaderComponent', () => { }); it('should display the claim button if no assignee', async () => { - component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock); + component.taskDetails = new TaskRepresentation(claimableTaskDetailsMock); component.refreshData(); @@ -174,7 +173,7 @@ describe('TaskHeaderComponent', () => { }); it('should display the claim button if the task is claimable', async () => { - component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock); + component.taskDetails = new TaskRepresentation(claimableTaskDetailsMock); component.refreshData(); fixture.detectChanges(); @@ -186,7 +185,7 @@ describe('TaskHeaderComponent', () => { }); it('should not display the claim/requeue button if the task is not claimable ', async () => { - component.taskDetails = new TaskDetailsModel(taskDetailsWithOutCandidateGroup); + component.taskDetails = new TaskRepresentation(taskDetailsWithOutCandidateGroup); component.refreshData(); fixture.detectChanges(); @@ -202,7 +201,7 @@ describe('TaskHeaderComponent', () => { }); it('should display the requeue button if task is claimed by the current logged-in user', async () => { - component.taskDetails = new TaskDetailsModel(claimedTaskDetailsMock); + component.taskDetails = new TaskRepresentation(claimedTaskDetailsMock); component.refreshData(); fixture.detectChanges(); @@ -214,7 +213,7 @@ describe('TaskHeaderComponent', () => { }); it('should not display the requeue button to logged in user if task is claimed by other candidate member', async () => { - component.taskDetails = new TaskDetailsModel(claimedByGroupMemberMock); + component.taskDetails = new TaskRepresentation(claimedByGroupMemberMock); component.refreshData(); fixture.detectChanges(); @@ -226,7 +225,7 @@ describe('TaskHeaderComponent', () => { }); it('should display the claim button if the task is claimable by candidates members', async () => { - component.taskDetails = new TaskDetailsModel(claimableTaskDetailsMock); + component.taskDetails = new TaskRepresentation(claimableTaskDetailsMock); component.refreshData(); fixture.detectChanges(); @@ -239,7 +238,7 @@ describe('TaskHeaderComponent', () => { }); it('should not display the requeue button if the task is completed', async () => { - component.taskDetails = new TaskDetailsModel(completedTaskDetailsMock); + component.taskDetails = new TaskRepresentation(completedTaskDetailsMock); component.refreshData(); fixture.detectChanges(); diff --git a/lib/process-services/src/lib/task-list/components/task-header.component.ts b/lib/process-services/src/lib/task-list/components/task-header.component.ts index 222dc302ba..941cffaaa0 100644 --- a/lib/process-services/src/lib/task-list/components/task-header.component.ts +++ b/lib/process-services/src/lib/task-list/components/task-header.component.ts @@ -26,9 +26,9 @@ import { CardViewIntItemModel, CardViewItemLengthValidator } from '@alfresco/adf-core'; -import { TaskDetailsModel } from '../models/task-details.model'; import { PeopleProcessService } from '../../common/services/people-process.service'; import { TaskDescriptionValidator } from '../validators/task-description.validator'; +import { TaskRepresentation } from '@alfresco/js-api'; @Component({ selector: 'adf-task-header', @@ -43,7 +43,7 @@ export class TaskHeaderComponent implements OnChanges, OnInit { /** (required) Details related to the task. */ @Input() - taskDetails: TaskDetailsModel; + taskDetails: TaskRepresentation; /** Toggles display of the claim/release button. */ @Input() diff --git a/lib/process-services/src/lib/task-list/models/task-details.event.ts b/lib/process-services/src/lib/task-list/models/task-details.event.ts index 9f4e194437..66fb481b64 100644 --- a/lib/process-services/src/lib/task-list/models/task-details.event.ts +++ b/lib/process-services/src/lib/task-list/models/task-details.event.ts @@ -15,14 +15,13 @@ * limitations under the License. */ -import { TaskDetailsModel } from './task-details.model'; +import { TaskRepresentation } from '@alfresco/js-api'; export class TaskDetailsEvent { - - private _value: TaskDetailsModel; + private _value: TaskRepresentation; private _defaultPrevented: boolean = false; - get value(): TaskDetailsModel { + get value(): TaskRepresentation { return this._value; } @@ -30,7 +29,7 @@ export class TaskDetailsEvent { return this._defaultPrevented; } - constructor(value: TaskDetailsModel) { + constructor(value: TaskRepresentation) { this._value = value; } diff --git a/lib/process-services/src/lib/task-list/models/task-details.model.ts b/lib/process-services/src/lib/task-list/models/task-details.model.ts deleted file mode 100644 index eccdca44cf..0000000000 --- a/lib/process-services/src/lib/task-list/models/task-details.model.ts +++ /dev/null @@ -1,111 +0,0 @@ -/*! - * @license - * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * 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. - */ - -/** - * This object represent the details of a task. - */ -import { LightUserRepresentation, TaskRepresentation } from '@alfresco/js-api'; -import { UserGroupModel } from './user-group.model'; - -export class TaskDetailsModel implements TaskRepresentation { - id?: string; - name?: string; - assignee?: LightUserRepresentation; - priority?: number; - adhocTaskCanBeReassigned?: boolean; - category?: string; - created?: Date; - description?: string; - parentName?: string; - dueDate?: Date; - duration?: number; - endDate?: Date; - executionId?: string; - formKey?: string; - initiatorCanCompleteTask?: boolean; - managerOfCandidateGroup?: boolean; - memberOfCandidateGroup?: boolean; - memberOfCandidateUsers?: boolean; - involvedGroups?: UserGroupModel[]; - involvedPeople?: LightUserRepresentation[]; - parentTaskId?: string; - parentTaskName?: string; - processDefinitionCategory?: string; - processDefinitionDeploymentId?: string; - processDefinitionDescription?: string; - processDefinitionId?: string; - processDefinitionKey?: string; - processDefinitionName?: string; - processDefinitionVersion?: number = 0; - processInstanceId?: string; - processInstanceName?: string; - processInstanceStartUserId?: string; - taskDefinitionKey?: string; - - constructor(obj?: any) { - if (obj) { - this.id = obj.id || null; - this.name = obj.name || null; - this.priority = obj.priority; - this.assignee = obj.assignee; - this.adhocTaskCanBeReassigned = obj.adhocTaskCanBeReassigned; - this.category = obj.category || null; - this.created = obj.created || null; - this.description = obj.description || null; - this.dueDate = obj.dueDate || null; - this.duration = obj.duration || null; - this.endDate = obj.endDate || null; - this.executionId = obj.executionId || null; - this.formKey = obj.formKey || null; - this.initiatorCanCompleteTask = !!obj.initiatorCanCompleteTask; - this.managerOfCandidateGroup = !!obj.managerOfCandidateGroup; - this.memberOfCandidateGroup = !!obj.memberOfCandidateGroup; - this.memberOfCandidateUsers = !!obj.memberOfCandidateUsers; - this.involvedGroups = obj.involvedGroups; - this.involvedPeople = obj.involvedPeople; - this.parentTaskId = obj.parentTaskId || null; - this.parentTaskName = obj.parentTaskName || null; - this.processDefinitionCategory = obj.processDefinitionCategory || null; - this.processDefinitionDeploymentId = obj.processDefinitionDeploymentId || null; - this.processDefinitionDescription = obj.processDefinitionDescription || null; - this.processDefinitionId = obj.processDefinitionId || null; - this.processDefinitionKey = obj.processDefinitionKey || null; - this.processDefinitionName = obj.processDefinitionName || null; - this.processDefinitionVersion = obj.processDefinitionVersion || 0; - this.processInstanceId = obj.processInstanceId || null; - this.processInstanceName = obj.processInstanceName || null; - this.processInstanceStartUserId = obj.processInstanceStartUserId || null; - this.taskDefinitionKey = obj.taskDefinitionKey || null; - } - } - - getFullName(): string { - let fullName: string = ''; - - if (this.assignee) { - const firstName: string = this.assignee.firstName ? this.assignee.firstName : ''; - const lastName: string = this.assignee.lastName ? this.assignee.lastName : ''; - fullName = `${firstName} ${lastName}`; - } - - return fullName.trim(); - } - - isCompleted(): boolean { - return !!this.endDate; - } -} diff --git a/lib/process-services/src/lib/task-list/public-api.ts b/lib/process-services/src/lib/task-list/public-api.ts index 5bdfa40edf..c2d256ee13 100644 --- a/lib/process-services/src/lib/task-list/public-api.ts +++ b/lib/process-services/src/lib/task-list/public-api.ts @@ -36,7 +36,6 @@ export * from './services/task-filter.service'; export * from './models/form.model'; export * from './models/task-details.event'; -export * from './models/task-details.model'; export * from './models/user-event.model'; export * from './models/user-group.model'; diff --git a/lib/process-services/src/lib/task-list/services/task-filter.service.ts b/lib/process-services/src/lib/task-list/services/task-filter.service.ts index fb702d6479..7f1f0a4273 100644 --- a/lib/process-services/src/lib/task-list/services/task-filter.service.ts +++ b/lib/process-services/src/lib/task-list/services/task-filter.service.ts @@ -16,7 +16,7 @@ */ import { AlfrescoApiService } from '@alfresco/adf-core'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Observable, forkJoin, from } from 'rxjs'; import { map } from 'rxjs/operators'; import { UserFiltersApi, UserTaskFilterRepresentation } from '@alfresco/js-api'; @@ -25,14 +25,14 @@ import { UserFiltersApi, UserTaskFilterRepresentation } from '@alfresco/js-api'; providedIn: 'root' }) export class TaskFilterService { + private apiService = inject(AlfrescoApiService); + private _userFiltersApi: UserFiltersApi; get userFiltersApi(): UserFiltersApi { this._userFiltersApi = this._userFiltersApi ?? new UserFiltersApi(this.apiService.getInstance()); return this._userFiltersApi; } - constructor(private apiService: AlfrescoApiService) {} - /** * Creates and returns the default filters for a process app. * diff --git a/lib/process-services/src/lib/task-list/services/tasklist.service.ts b/lib/process-services/src/lib/task-list/services/tasklist.service.ts index 042d3938be..61393838db 100644 --- a/lib/process-services/src/lib/task-list/services/tasklist.service.ts +++ b/lib/process-services/src/lib/task-list/services/tasklist.service.ts @@ -20,7 +20,6 @@ import { Injectable } from '@angular/core'; import { Observable, from, of } from 'rxjs'; import { map, catchError, flatMap, filter } from 'rxjs/operators'; import { Form } from '../models/form.model'; -import { TaskDetailsModel } from '../models/task-details.model'; import { TaskUpdateRepresentation, ModelsApi, @@ -29,7 +28,8 @@ import { ChecklistsApi, ResultListDataRepresentationTaskRepresentation, TaskQueryRepresentation, - UserTaskFilterRepresentation + UserTaskFilterRepresentation, + TaskRepresentation } from '@alfresco/js-api'; @Injectable({ @@ -121,8 +121,8 @@ export class TaskListService { * @param taskId ID of the target task. * @returns Task details */ - getTaskDetails(taskId: string): Observable { - return from(this.tasksApi.getTask(taskId)).pipe(map((details) => new TaskDetailsModel(details))); + getTaskDetails(taskId: string): Observable { + return from(this.tasksApi.getTask(taskId)); } /** @@ -131,8 +131,8 @@ export class TaskListService { * @param id ID of the target task * @returns Array of checklist task details */ - getTaskChecklist(id: string): Observable { - return from(this.checklistsApi.getChecklist(id)).pipe(map((response) => response.data.map((checklist) => new TaskDetailsModel(checklist)))); + getTaskChecklist(id: string): Observable { + return from(this.checklistsApi.getChecklist(id)).pipe(map((response) => response.data)); } /** @@ -167,8 +167,8 @@ export class TaskListService { * @param task The task to add * @returns The subtask that was added */ - addTask(task: TaskDetailsModel): Observable { - return from(this.checklistsApi.addSubtask(task.parentTaskId, task)).pipe(map((response) => new TaskDetailsModel(response))); + addTask(task: TaskRepresentation): Observable { + return from(this.checklistsApi.addSubtask(task.parentTaskId, task)); } /** @@ -207,8 +207,8 @@ export class TaskListService { * @param task Details of the new task * @returns Details of the newly created task */ - createNewTask(task: TaskDetailsModel): Observable { - return from(this.tasksApi.createNewTask(task)).pipe(map((response) => new TaskDetailsModel(response))); + createNewTask(task: TaskRepresentation): Observable { + return from(this.tasksApi.createNewTask(task)); } /** @@ -218,9 +218,9 @@ export class TaskListService { * @param requestNode User or group to assign the task to * @returns Details of the assigned task */ - assignTask(taskId: string, requestNode: any): Observable { + assignTask(taskId: string, requestNode: any): Observable { const assignee = { assignee: requestNode.id }; - return from(this.taskActionsApi.assignTask(taskId, assignee)).pipe(map((response) => new TaskDetailsModel(response))); + return from(this.taskActionsApi.assignTask(taskId, assignee)); } /** @@ -230,10 +230,10 @@ export class TaskListService { * @param userId ID of the user to assign the task to * @returns Details of the assigned task */ - assignTaskByUserId(taskId: string, userId: string): Observable { + assignTaskByUserId(taskId: string, userId: string): Observable { const assignee = { assignee: userId }; - return from(this.taskActionsApi.assignTask(taskId, assignee)).pipe(map((response) => new TaskDetailsModel(response))); + return from(this.taskActionsApi.assignTask(taskId, assignee)); } /** @@ -242,7 +242,7 @@ export class TaskListService { * @param taskId ID of the task to claim * @returns Details of the claimed task */ - claimTask(taskId: string): Observable { + claimTask(taskId: string): Observable { return from(this.taskActionsApi.claimTask(taskId)); } @@ -252,7 +252,7 @@ export class TaskListService { * @param taskId ID of the task to unclaim * @returns Null response notifying when the operation is complete */ - unclaimTask(taskId: string): Observable { + unclaimTask(taskId: string): Observable { return from(this.taskActionsApi.unclaimTask(taskId)); } @@ -263,8 +263,8 @@ export class TaskListService { * @param updated Data to update the task (as a `TaskUpdateRepresentation` instance). * @returns Updated task details */ - updateTask(taskId: string, updated: TaskUpdateRepresentation): Observable { - return from(this.tasksApi.updateTask(taskId, updated)).pipe(map((result) => result as TaskDetailsModel)); + updateTask(taskId: string, updated: TaskUpdateRepresentation): Observable { + return from(this.tasksApi.updateTask(taskId, updated)); } /**