[ADF-2451] Reviewed component docs (#3113)

* [ADF-2451] Reviewed component docs

* [ADF-2451] Updated review date on tasklist service docs
This commit is contained in:
Andy Stark
2018-03-22 17:27:30 +00:00
committed by Eugenio Romano
parent 10d437b30b
commit ea0f783015
6 changed files with 274 additions and 690 deletions

View File

@@ -1,7 +1,9 @@
--- ---
Added: v2.0.0 Added: v2.0.0
Status: Active Status: Active
Last reviewed: 2018-03-21
--- ---
# DataTable component # DataTable component
Displays data as a table with customizable columns and presentation. Displays data as a table with customizable columns and presentation.
@@ -25,7 +27,7 @@ See it live: [DataTable Quickstart](https://embed.plnkr.co/80qr4YFBeHjLMdAV0F6l/
- [Card view](#card-view) - [Card view](#card-view)
- [Custom Empty content template](#custom-empty-content-template) - [Custom Empty content template](#custom-empty-content-template)
- [Loading content template](#loading-content-template) - [Loading content template](#loading-content-template)
- [Events](#events-1) - [Using events](#using-events)
- [See also](#see-also) - [See also](#see-also)
@@ -123,33 +125,33 @@ export class DataTableDemo {
### Properties ### Properties
| Name | Type | Default | Description | | Name | Type | Default value | Description |
| ---- | ---- | ------- | ----------- | | ---- | ---- | ------------- | ----------- |
| 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. | | data | `DataTableAdapter` | | Data source for the table |
| rowStyle | string | | The inline style to apply to every row, see [NgStyle](https://angular.io/docs/ts/latest/api/common/index/NgStyle-directive.html) docs for more details and usage examples | | display | `string` | `DisplayMode.List` | Selects the display mode of the table. Can be "list" or "gallery". |
| rowStyleClass | string | | The CSS class to apply to every row | | rows | `any[]` | `[]` | The rows that the datatable will show. |
| data | DataTableAdapter | instance of **ObjectDataTableAdapter** | data source | | 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. |
| rows | Object\[] | \[] | The rows that the datatable should show | | multiselect | `boolean` | `false` | Toggles multiple row selection, which renders checkboxes at the beginning of each row. |
| multiselect | boolean | false | Toggles multiple row selection, renders checkboxes at the beginning of each row | | actions | `boolean` | `false` | Toggles the data actions column. |
| actions | boolean | false | Toggles data actions column | | actionsPosition | `string` | `'right'` | Position of the actions dropdown menu. Can be "left" or "right". |
| actionsPosition | string (left\|right) | right | Position of the actions dropdown menu. | | fallbackThumbnail | `string` | | Fallback image for rows where the thumbnail is missing. |
| fallbackThumbnail | string | | Fallback image for row where thumbnail is missing | | contextMenu | `boolean` | `false` | Toggles custom context menu for the component. |
| contextMenu | boolean | false | Toggles custom context menu for the component | | allowDropFiles | `boolean` | `false` | Toggles file drop support for rows (see [Upload directive](upload.directive.md) for further details). |
| allowDropFiles | boolean | false | Toggle file drop support for rows (see **ng2-alfresco-core/UploadDirective** for more details) | | rowStyle | `string` | | The inline style to apply to every row. See [NgStyle](https://angular.io/docs/ts/latest/api/common/index/NgStyle-directive.html) docs for more details and usage examples. |
| loading | boolean | false | Flag that indicates if the datatable is in loading state and needs to show the loading template. Read the documentation above to see how to configure a loading template | | rowStyleClass | `string` | `''` | The CSS class to apply to every row. |
| showHeader | boolean | true | Toggles header visibility | | showHeader | `boolean` | `true` | Toggles the header. |
| display | string | 'list' | change the display mode can be one of the values provided by the enum : **list**, **gallery** | | loading | `boolean` | `false` | Flag that indicates if the datatable is in loading state and needs to show the loading template (see the docs to learn how to configure a loading template). |
| selection | DataRow\[] | \[] | Contains selected rows | | noPermission | `boolean` | `false` | Flag that indicates if the datatable should show the "no permission" template. |
### Events ### Events
| Name | Description | | Name | Type | Description |
| ---- | ----------- | | ---- | ---- | ----------- |
| [rowClick](#rowclick-event) | Emitted when user clicks the row | | rowClick | `EventEmitter<DataRowEvent>` | Emitted when the user clicks a row. |
| [rowDblClick](#rowdblclick-event) | Emitted when user double-clicks the row | | rowDblClick | `EventEmitter<DataRowEvent>` | Emitted when the user double-clicks a row. |
| [showRowContextMenu](#showrowcontextmenu-event) | Emitted before context menu is displayed for a row | | showRowContextMenu | `EventEmitter<DataCellEvent>` | Emitted before the context menu is displayed for a row. |
| [showRowActionsMenu](#showrowactionsmenu-event) | Emitted before actions menu is displayed for a row | | showRowActionsMenu | `EventEmitter<DataCellEvent>` | Emitted before the actions menu is displayed for a row. |
| [executeRowAction](#executerowaction-event) | Emitted when row action is executed by user | | executeRowAction | `EventEmitter<DataRowActionEvent>` | Emitted when the user executes a row action. |
## Details ## Details
@@ -158,17 +160,17 @@ export class DataTableDemo {
The column layout and row data are supplied to the table using an object that implements the The column layout and row data are supplied to the table using an object that implements the
DataTableAdapter interface. This interface hides the internal details of the class that provides DataTableAdapter interface. This interface hides the internal details of the class that provides
the data, which gives a lot of flexibility in how the data can be stored and accessed. The DataTable the data, which gives a lot of flexibility in how the data can be stored and accessed. The DataTable
library includes a standard adapter class called ObjectDataTableAdapter that is useful for many library includes a standard adapter class called `ObjectDataTableAdapter` that is useful in many
common uses. See the [DataTableAdapter](datatable-adapter.interface.md) for full details about the interface and common cases. See the [DataTableAdapter](datatable-adapter.interface.md) for full details about the interface and the `ObjectDataTableAdapter` class.
the ObjectDataTableAdapter class.
### Customizing columns ### Customizing columns
You can define custom HTML templates for columns and also add tooltips, automatic column title translation and other features. See the DataColumn component page for more information. You can define custom HTML templates for columns and also add tooltips, automatic column title translation and other features. See the [Data Column component](data-column.component.md) page
for more information.
### DataTable DOM Events ### DataTable DOM Events
Below are the DOM events raised by DataTable component. Below are the DOM events emitted by the DataTable component.
These events bubble up the component tree and can be handled by any parent component. These events bubble up the component tree and can be handled by any parent component.
| Name | Description | | Name | Description |
@@ -200,7 +202,7 @@ onRowClick(event) {
### Card view ### Card view
If you want to enable the card view mode you need to set to 'gallery' the input parameter [display] : Set the `display` property to "gallery" to enable Card View mode:
```html ```html
<adf-datatable <adf-datatable
@@ -211,10 +213,9 @@ If you want to enable the card view mode you need to set to 'gallery' the input
![card-view](../docassets/images/document-list-card-view.png) ![card-view](../docassets/images/document-list-card-view.png)
### Custom Empty content template ### Custom Empty content template
You can add a template that will be shown when there are no results in your datatable: You can add a template that will be shown when there are no rows in your datatable:
```html ```html
<adf-datatable <adf-datatable
@@ -238,9 +239,11 @@ You can add a template that will be shown when there are no results in your data
</adf-datatable> </adf-datatable>
``` ```
You can use the empty list component if you want to show the default ADF empty template. You can use the empty list component to show the default ADF empty template.
You can use any HTML layout or Angular component as a content of the empty template section by using the special `<adf-empty-list-header>, <adf-empty-list-body>, <adf-empty-list-footer>` elements: You can place any HTML layout or Angular component as content in the empty template section
by using the `<adf-empty-list-header>`, `<adf-empty-list-body>`, and `<adf-empty-list-footer>`
elements:
```html ```html
<adf-datatable <adf-datatable
@@ -265,7 +268,7 @@ You can use any HTML layout or Angular component as a content of the empty templ
| Name | Type | Default | Description | | Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- | | ---- | ---- | ------- | ----------- |
| emptyListImageUrl | String | empty_doc_lib.svg | The default image used as background | | emptyListImageUrl | String | empty_doc_lib.svg | The default image used as the background |
| emptyMsg | String | This list is empty | The default title message | | emptyMsg | String | This list is empty | The default title message |
| dragDropMsg | String | Drag and drop | The default drag and drop message | | dragDropMsg | String | Drag and drop | The default drag and drop message |
| additionalMsg | String | Drag and drop | The default additional message | | additionalMsg | String | Drag and drop | The default additional message |
@@ -274,7 +277,7 @@ You can use any HTML layout or Angular component as a content of the empty templ
### Loading content template ### Loading content template
You can add a template that will be shown during the loading of your data: You can add a template to be shown while your data is loading:
```html ```html
<adf-datatable <adf-datatable
@@ -308,15 +311,15 @@ You can add a template that will be shown during the loading of your data:
} }
``` ```
Note: the `<loading-content-template>` and `<no-content-template>` can be used together Note: the `<loading-content-template>` and `<no-content-template>` can be used together.
### Events ### Using events
#### row-keyup DOM event #### row-keyup DOM event
Raised on the 'keyup' event for the focused row. Emitted on the 'keyup' event for the focused row.
This is an instance of the `CustomEvent` with the `details` property containing the following object: This is an instance of `CustomEvent` with the `details` property containing the following object:
```ts ```ts
row: DataRow, row: DataRow,
@@ -326,7 +329,7 @@ sender: any
#### rowClick event #### rowClick event
Emitted when user clicks a row. Emitted when the user clicks a row.
Event properties: Event properties:
@@ -344,11 +347,11 @@ onRowClicked(event: DataRowEvent) {
} }
``` ```
This event is cancellable, you can use `event.preventDefault()` to prevent default behaviour. This event is cancellable. You can use `event.preventDefault()` to prevent the default behavior.
#### rowDblClick event #### rowDblClick event
Emitted when user double-clicks a row. Emitted when the user double-clicks a row.
Event properties: Event properties:
@@ -366,14 +369,14 @@ onRowDblClicked(event: DataRowEvent) {
} }
``` ```
This event is cancellable, you can use `event.preventDefault()` to prevent default behaviour. This event is cancellable. You can use `event.preventDefault()` to prevent the default behavior.
#### showRowContextMenu event #### showRowContextMenu event
Emitted before context menu is displayed for a row. Emitted before the context menu is displayed for a row.
Note that DataTable itself does not populate context menu items, Note that the DataTable itself does not populate the context menu with items.
you can provide all necessary content via handler. You can provide all necessary content via the handler.
Event properties: Event properties:
@@ -396,17 +399,17 @@ onShowRowContextMenu(event: DataCellEvent) {
} }
``` ```
This event is cancellable, you can use `event.preventDefault()` to prevent default behaviour. This event is cancellable. You can use `event.preventDefault()` to prevent the default behavior.
DataTable will automatically render provided menu items. The DataTable will automatically render the supplied menu items.
See the [ContextMenu](https://www.npmjs.com/package/ng2-alfresco-core) See the [ContextMenu](https://www.npmjs.com/package/ng2-alfresco-core)
documentation for more details on context actions format and behaviour. documentation for more details on the format and behavior of context actions.
#### showRowActionsMenu event #### showRowActionsMenu event
Emitted before actions menu is displayed for a row. Emitted before the actions menu is displayed for a row.
Requires `actions` property to be set to `true`. Requires the `actions` property to be set to `true`.
Event properties: Event properties:
@@ -417,19 +420,19 @@ value: {
} }
``` ```
Note that DataTable itself does not populate action menu items, Note that the DataTable itself does not populate the action menu with items.
you can provide all necessary content via handler. You can provide all necessary content via the handler.
This event is cancellable, you can use `event.preventDefault()` to prevent default behaviour. This event is cancellable. You can use `event.preventDefault()` to prevent the default behavior.
#### executeRowAction event #### executeRowAction event
Emitted when a row action is executed by the user. Emitted when the user executes a row action.
Usually accompanies `showRowActionsMenu` event. This usually accompanies a `showRowActionsMenu` event.
DataTable itself does not execute actions but provides support for external The DataTable itself does not execute actions but provides support for external
integration. If there were actions provided with `showRowActionsMenu` event integration. If actions are provided using the `showRowActionsMenu` event
then `executeRowAction` will be automatically executed when user clicks then `executeRowAction` will be automatically executed when the user clicks a
corresponding menu item. corresponding menu item.
```html ```html
@@ -467,16 +470,12 @@ onExecuteRowAction(event: DataRowActionEvent) {
![](../docassets/images/datatable-actions-console.png) ![](../docassets/images/datatable-actions-console.png)
Developers are allowed to use any payloads as row actions. You can use any payloads for row actions. The only requirement for the objects is that they
The only requirement for the objects is having `title` property. must have a `title` property.
Once corresponding action is clicked in the dropdown menu DataTable invokes `executeRowAction` event When an action is selected in the dropdown menu, the DataTable invokes the `executeRowAction` event.
where you can handle the process, inspect the action payload and all custom properties defined earlier, Use this to handle the response, inspect the action payload (and all custom properties defined
and do corresponding actions. earlier), and perform the corresponding actions.
<!-- Don't edit the See also section. Edit seeAlsoGraph.json and run config/generateSeeAlso.js -->
<!-- seealso start -->
## See also ## See also
@@ -484,4 +483,3 @@ and do corresponding actions.
- [Pagination component](pagination.component.md) - [Pagination component](pagination.component.md)
- [DataTableAdapter](datatable-adapter.interface.md) - [DataTableAdapter](datatable-adapter.interface.md)
- [Document list component](../content-services/document-list.component.md) - [Document list component](../content-services/document-list.component.md)
<!-- seealso end -->

View File

@@ -1,28 +1,97 @@
--- ---
Added: v2.0.0 Added: v2.0.0
Status: Active Status: Active
Last reviewed: 2018-03-22
--- ---
# Tasklist Service # Tasklist Service
Manage Task Instances. Manages Task Instances.
## Importing
```ts
import { TaskListService, TaskDetailsModel, TaskQueryRequestRepresentationModel, TaskListModel, Form } from '@alfresco/adf-process-services';
import { TaskUpdateRepresentation } from 'alfresco-js-api';
export class SomePageComponent implements OnInit {
constructor(private tasklistService: TaskListService) {
}
```
## Methods ## Methods
#### getTaskDetails(taskId: string): Observable`<TaskDetailsModel>` - `getFilterForTaskById(taskId: string, filterList: FilterRepresentationModel[]): Observable<FilterRepresentationModel>`
Gets all the filters in the list that belong to a task.
- `taskId` - ID of the target task
- `filterList` - List of filters to search through
- `isTaskRelatedToFilter(taskId: string, filter: FilterRepresentationModel): Observable<FilterRepresentationModel>`
Checks if a taskId is filtered with the given filter.
- `taskId` - ID of the target task
- `filter` - The filter you want to check
- `getTasks(requestNode: TaskQueryRequestRepresentationModel): Observable<TaskListModel>`
Gets all the tasks matching the supplied query.
- `requestNode` - Query to search for tasks
- `findTasksByState(requestNode: TaskQueryRequestRepresentationModel, state?: string): Observable<TaskListModel>`
Gets tasks matching a query and state value.
- `requestNode` - Query to search for tasks
- `state` - (Optional) Task state. Can be "open" or "completed".
- `findAllTaskByState(requestNode: TaskQueryRequestRepresentationModel, state?: string): Observable<TaskListModel>`
Gets all tasks matching a query and state value.
- `requestNode` - Query to search for tasks.
- `state` - (Optional) Task state. Can be "open" or "completed".
- `findAllTasksWithoutState(requestNode: TaskQueryRequestRepresentationModel): Observable<TaskListModel>`
Get all tasks matching the supplied query but ignoring the task state.
- `requestNode` - Query to search for tasks
- `getTaskDetails(taskId: string): Observable<TaskDetailsModel>`
Gets details for a task.
- `taskId` - ID of the target task.
- `getTaskChecklist(id: string): Observable<TaskDetailsModel[]>`
Gets the checklist for a task.
- `id` - ID of the target task
- `getFormList(): Observable<Form[]>`
Gets all available reusable forms.
Get Task Instance metadata for passed in Task Instance ID: - `attachFormToATask(taskId: string, formId: number): Observable<any>`
Attaches a form to a task.
- `taskId` - ID of the target task
- `formId` - ID of the form to add
- `addTask(task: TaskDetailsModel): Observable<TaskDetailsModel>`
Adds a subtask (ie, a checklist task) to a parent task.
- `task` - The task to add
- `deleteTask(taskId: string): Observable<TaskDetailsModel>`
Deletes a subtask (ie, a checklist task) from a parent task.
- `taskId` - The task to delete
- `completeTask(taskId: string): any`
Gives completed status to a task.
- `taskId` - ID of the target task
- `getTotalTasks(requestNode: TaskQueryRequestRepresentationModel): Observable<any>`
Gets the total number of the tasks found by a query.
- `requestNode` - Query to search for tasks
- `createNewTask(task: TaskDetailsModel): Observable<TaskDetailsModel>`
Creates a new standalone task.
- `task` - Details of the new task
- `assignTask(taskId: string, requestNode: any): Observable<TaskDetailsModel>`
Assigns a task to a user or group.
- `taskId` - The task to assign
- `requestNode` - User or group to assign the task to
- `assignTaskByUserId(taskId: string, userId: number): Observable<TaskDetailsModel>`
Assigns a task to a user.
- `taskId` - ID of the task to assign
- `userId` - ID of the user to assign the task to
- `claimTask(taskId: string): Observable<TaskDetailsModel>`
Claims a task for the current user.
- `taskId` - ID of the task to claim
- `unclaimTask(taskId: string): Observable<TaskDetailsModel>`
Unclaims a task for the current user.
- `taskId` - ID of the task to unclaim
- `updateTask(taskId: any, updated): Observable<TaskDetailsModel>`
Updates the details (name, description, due date) for a task.
- `taskId` - ID of the task to update
- `updated` - Data to update the task (as a \`TaskUpdateRepresentation\` instance).
- `fetchTaskAuditPdfById(taskId: string): Observable<Blob>`
Fetches the Task Audit information in PDF format.
- `taskId` - ID of the target task
- `fetchTaskAuditJsonById(taskId: string): Observable<any>`
Fetch the Task Audit information in JSON format
- `taskId` - ID of the target task
## Details
### Task details
Several of the methods return one or more `TaskDetailsModel` instances corresponding
to tasks or subtasks matched by a query of some kind. For example, `getTaskDetails`
could be used as shown below:
```ts ```ts
const taskInstanceId = '15303'; const taskInstanceId = '15303';
@@ -33,9 +102,9 @@ this.tasklistService.getTaskDetails(taskInstanceId).subscribe( (taskInstance: Ta
}); });
``` ```
The `taskInstanceId` refers to a Task Instance identifier in APS. The resulting `TaskDetailsModel` object contains information like the following:
The returned `taskInstance` object is of type `TaskDetailsModel` and looks like in this sample:
```
adhocTaskCanBeReassigned: false adhocTaskCanBeReassigned: false
assignee: UserProcessModel {pictureId: null, id: 1, email: "admin@app.activiti.com", firstName: null, lastName: "Administrator"} assignee: UserProcessModel {pictureId: null, id: 1, email: "admin@app.activiti.com", firstName: null, lastName: "Administrator"}
category: null category: null
@@ -67,64 +136,12 @@ The returned `taskInstance` object is of type `TaskDetailsModel` and looks like
processInstanceName: null processInstanceName: null
processInstanceStartUserId: "1" processInstanceStartUserId: "1"
taskDefinitionKey: "clarifyInvoice" taskDefinitionKey: "clarifyInvoice"
#### getTaskChecklist(id: string): Observable`<TaskDetailsModel[]>`
Get all the sub-task instances for a Task Instance, also called the check list:
```ts
const parentTaskId = '15303';
this.tasklistService.getTaskChecklist(parentTaskId).subscribe( (subTasks: TaskDetailsModel[]) => {
console.log('Sub Tasks: ', subTasks);
}, error => {
console.log('Error: ', error);
});
``` ```
The response is an array of `TaskDetailsModel` representing the sub-tasks: ### Queries
Sub Tasks: Some of the methods run a search query contained in a `TaskQueryRequestRepresentationModel` and
0: return the matched tasks. Below is an example of how you might run a query using `getTasks`:
adhocTaskCanBeReassigned: false
assignee: UserProcessModel {pictureId: null, id: 1, email: "admin@app.activiti.com", firstName: null, lastName: "Administrator"}
category: "2"
created: "2017-10-29T07:29:28.881+0000"
description: null
dueDate: null
duration: null
endDate: null
executionId: null
formKey: null
id: "74745"
initiatorCanCompleteTask: false
involvedPeople: undefined
managerOfCandidateGroup: false
memberOfCandidateGroup: false
memberOfCandidateUsers: false
name: "Double check invoice amount"
parentTaskId: "15303"
parentTaskName: "Clarify Invoice - Invoice-10292.pdf"
priority: 50
processDefinitionCategory: null
processDefinitionDeploymentId: null
processDefinitionDescription: null
processDefinitionId: null
processDefinitionKey: null
processDefinitionName: null
processDefinitionVersion: 0
processInstanceId: null
processInstanceName: null
processInstanceStartUserId: null
taskDefinitionKey: null
1 :
{processDefinitionVersion: 0, id: "74746", name: "Verify with the person that did the purchase", priority: 50, assignee: UserProcessModel, …}
Looking at the `TaskDetailsModel` for a sub-task we can see that it has a parent task ID that matches what we specified
when calling this method.
#### getTasks(requestNode: TaskQueryRequestRepresentationModel): Observable`<TaskListModel>`
Get tasks matching passed in query definition:
```ts ```ts
const taskQuery: TaskQueryRequestRepresentationModel = { const taskQuery: TaskQueryRequestRepresentationModel = {
@@ -146,22 +163,23 @@ this.tasklistService.getTasks(taskQuery).subscribe( (taskListModel: TaskListMode
}); });
``` ```
In the above example we query for all Task Instances associated with a Process Application with In this example, the query specifies all Task Instances for the process app with
ID 2. We set `size` to 5, which means that the query will return max 5 task instances. ID 2. Setting the `size` property to 5 ensures the query will return no more than
five task instances in the results.
We can mix and match the query parameters to narrow down the task list that is returned. You can use various query parameters to narrow down the scope of the results.
If you are just interested in Task Instances related to a specific Process Instance, If you are only interested in task instances related to a specific process instance,
then set the `processInstanceId`. If you want to see all tasks related to a specific type of processes, then you can set the `processInstanceId` accordingly. If you want all tasks related to
then you should set the `processDefinitionId` property. a type of process then you can use `processDefinitionId`.
You can use the `state` property to define if only `completed` or only `open` tasks should be returned. If you Use the `state` property to indicate that you want only "completed" or "open" tasks (this
specify `null` for state then `open` will be assumed. defaults to "open" if you leave it undefined).
The `assignment` property can be used to filter tasks based on how they are assigned (or not assigned yet). The `assignment` property filters tasks based on how they are assigned (or not assigned yet).
Use `assignee` if you are interested in tasks that are assigned to a user. If you want to see Use `assignee` if you are interested in tasks that are assigned to a user. If you want to see
pooled tasks (i.e. tasks that needs to be claimed by a user), then use `candidate`. pooled tasks (i.e. tasks that needs to be claimed by a user), then use `candidate`.
A `TaskListModel` object is returned for a successful query and the `data` property is an array of A successful query returns a `TaskListModel` with the `data` property set to an array of
`TaskDetailsModel`: `TaskDetailsModel`:
data: data:
@@ -175,480 +193,17 @@ A `TaskListModel` object is returned for a successful query and the `data` prope
start: 0 start: 0
total: 10 total: 10
We can see that this query resulted in 10 tasks (see `total`), but only 5 were returned as we set `size` to `5`. The `total` property indicates that actual number of tasks that were found, but the `size` property
limited the found set to five items.
#### getTotalTasks(requestNode: TaskQueryRequestRepresentationModel): Observable`<any>` ### Importing
Get total number of tasks matching passed in query definition:
```ts ```ts
const taskQuery: TaskQueryRequestRepresentationModel = { import { TaskListService, TaskDetailsModel, TaskQueryRequestRepresentationModel, TaskListModel, Form } from '@alfresco/adf-process-services';
appDefinitionId: '2', import { TaskUpdateRepresentation } from 'alfresco-js-api';
processInstanceId: null,
processDefinitionId: null,
text: null,
assignment: null,
state: 'open',
sort: 'created_asc',
page: 0,
size: 5,
start: null
};
this.tasklistService.getTotalTasks(taskQuery).subscribe( (response: any) => {
console.log('Total: ', response);
}, error => {
console.log('Error: ', error);
});
```
This is pretty much the same type of query as the `getTasks` method, except that here we just export class SomePageComponent implements OnInit {
return how many Task Instances it matched in the `total` property:
data:[] constructor(private tasklistService: TaskListService) {
size: 0
start: 0
total: 10
When you call this method it always sets the `size` property to `0`.
#### findTasksByState(requestNode: TaskQueryRequestRepresentationModel, state?: string): Observable`<TaskListModel>`
Find and return Task Instances by state `open` or `completed` and query model:
```ts
const taskState = 'open';
const taskQuery: TaskQueryRequestRepresentationModel = {
appDefinitionId: '2',
processInstanceId: null,
processDefinitionId: null,
text: null,
assignment: null,
state: 'open',
sort: 'created_asc',
page: 0,
size: 5,
start: null
};
this.tasklistService.findTasksByState(taskQuery, taskState).subscribe( (taskList: TaskListModel) => {
console.log('Task list: ', taskList);
}, error => {
console.log('Error: ', error);
});
```
The number of tasks that are returned is controlled by the `size` property.
This is a convenience method on top of the `getTasks` method. It overwrites the `requestNode.state` property
with passed in `state` before making the call to `getTasks`.
For an example of the response see the `getTasks` method.
#### findAllTaskByState(requestNode: TaskQueryRequestRepresentationModel, state?: string): Observable`<TaskListModel>`
Find and return all Task Instances by state `open` or `completed` and query model:
```ts
const taskState = 'open';
const taskQuery: TaskQueryRequestRepresentationModel = {
appDefinitionId: '2',
processInstanceId: null,
processDefinitionId: null,
text: null,
assignment: null,
state: 'open',
sort: 'created_asc',
page: 0,
size: 5,
start: null
};
this.tasklistService.findAllTaskByState(taskQuery, taskState).subscribe( (taskList: TaskListModel) => {
console.log('Task list: ', taskList);
}, error => {
console.log('Error: ', error);
});
```
This is a convenience method on top of the `getTasks` method. It overwrites the `requestNode.state` property with
passed in `state` before making any other calls. Before making the `getTasks` call it will first call the
`getTotalTasks` method to get the total number of tasks that match query and state. It then overwrite the
`requestNode.size` with the total so all matching tasks are returned when finnally making the `getTasks` call.
**Note** that this can return a lot of data if you are not careful.
#### findAllTasksWithoutState(requestNode: TaskQueryRequestRepresentationModel): Observable`<TaskListModel>`
Find and return all Task Instances that matches query model, regardless of state:
```ts
const taskQuery: TaskQueryRequestRepresentationModel = {
appDefinitionId: '2',
processInstanceId: null,
processDefinitionId: null,
text: null,
assignment: null,
state: null,
sort: 'created_asc',
page: 0,
size: 5,
start: null
};
this.tasklistService.findAllTasksWithoutState(taskQuery).subscribe( (taskList: TaskListModel) => {
console.log('Task list: ', taskList);
}, error => {
console.log('Error: ', error);
});
```
This method can be used when you have a task query that should return all tasks regardless of the state they
are in. You cannot achieve this with the `getTasks` method. If you specify a `size` it is overwritten.
Internally it basically calls `findTasksByState(requestNode, 'open')` and
`findAllTaskByState(requestNode, 'completed')`.
**Note** that this can return a lot of data if you are not careful.
#### assignTaskByUserId(taskId: string, userId: number): Observable`<TaskDetailsModel>`
Assign a Task Instance to a user via the User ID:
```ts
const taskId = '15303';
const userId = 1;
this.tasklistService.assignTaskByUserId(taskId, userId).subscribe( (taskInstance: TaskDetailsModel) => {
console.log('Task instance: ', taskInstance);
}, error => {
console.log('Error: ', error);
});
```
The user ID identifies a User in APS.
#### assignTask(taskId: string, requestNode: any): Observable`<TaskDetailsModel>`
Assign a task to a user via a user object with an `id` property, for example:
```ts
const taskId = '15303';
const user = { id: 1, email: 'admin@app.activiti.com', firstName: 'APS', lastName: 'Admin' };
this.tasklistService.assignTask(taskId, user).subscribe( (taskInstance: TaskDetailsModel) => {
console.log('Task instance: ', taskInstance);
}, error => {
console.log('Error: ', error);
});
```
This method does the same as the `assignTaskByUserId` method, the only difference is that this
method can be used when you have an object where the User ID is contained in an `id` property.
#### claimTask(taskId: string): Observable`<TaskDetailsModel>`
Claim a pooled task (i.e. candidate task) as current user so it can be worked on and later on completed:
```ts
const taskId = '15368';
this.tasklistService.claimTask(taskId).subscribe( (taskInstance: TaskDetailsModel) => {
console.log('Task instance: ', taskInstance);
}, error => {
console.log('Error: ', error);
});
```
The response will be `null` if the task was claimed successfully.
The task assignment changes from `candidate` to `assignee`.
#### unclaimTask(taskId: string): Observable`<TaskDetailsModel>`
Return a claimed task to the pool (i.e. make it a candidate task):
```ts
const taskId = '15368';
this.tasklistService.unclaimTask(taskId).subscribe( (taskInstance: TaskDetailsModel) => {
console.log('Task instance: ', taskInstance);
}, error => {
console.log('Error: ', error);
});
```
The task assignment changes from `assignee` to `candidate`.
#### completeTask(taskId: string)
Complete a Task Instance as current user and progress Process Instance:
```ts
const taskId = '15176';
this.tasklistService.completeTask(taskId);
```
This only works if the Task Instance has only one Outcome (i.e. the default `Complete` one).
If the Task Instance has multiple Outcomes, such as Approve and Reject, then this method does not
work, and the Task Instance has to be completed via its associated form. Otherwise you will see an error such as:
_ERROR Error: Uncaught (in promise): Error: {"message":"Task must be completed using it's form","messageKey":"GENERAL.ERROR.BAD-REQUEST"}_
#### updateTask(taskId: any, updated): Observable`<TaskDetailsModel>`
Update name, description, and due date for a Task Instance:
```ts
const taskId = '80002';
const updateData: TaskUpdateRepresentation = {
description: 'Updated description',
dueDate: new Date(2018, 1, 10, 11, 0, 0, 0),
name: 'Updated name'
};
this.tasklistService.updateTask(taskId, updateData).subscribe( (updatedTaskDetails: TaskDetailsModel) => {
console.log('Updated task: ', updatedTaskDetails);
}, error => {
console.log('Error: ', error);
});
```
The response is all info about the updated Task Instance, in this example a stand-alone task was updated so there
is no associated process:
adhocTaskCanBeReassigned: false
assignee: undefined
category: null
created: Mon Nov 13 2017 16:34:49 GMT+0000 (GMT) {}
description: "Updated description"
dueDate: Sat Feb 10 2018 11:00:00 GMT+0000 (GMT) {}
duration: NaN
endDate: null
executionId: null
formKey: "5005"
id: "80002"
initiatorCanCompleteTask: false
managerOfCandidateGroup: false
memberOfCandidateGroup: false
memberOfCandidateUsers: false
name: "Updated name"
parentTaskId: null
parentTaskName: null
priority: 50
processDefinitionCategory: null
processDefinitionDeploymentId: null
processDefinitionDescription: null
processDefinitionId: null
processDefinitionKey: null
processDefinitionName: null
processDefinitionVersion: 0
processInstanceId: null
processInstanceName: null
processInstanceStartUserId: null
taskDefinitionKey: null
#### createNewTask(task: TaskDetailsModel): Observable`<TaskDetailsModel>`
Create a new stand-alone Task Instance that is not associated with a Process Instance:
```ts
const taskDetails = new TaskDetailsModel({
name: 'Some Task',
description: 'A new stand-alone task'
});
this.tasklistService.createNewTask(taskDetails).subscribe( (createdTaskDetails: TaskDetailsModel) => {
console.log('Created task details: ', createdTaskDetails);
}, error => {
console.log('Error: ', error);
});
```
In this case we are creating a disconnected Task Instance that is not associated with a form (i.e. `formKey: null`)
and that is not assigned to a user (i.e. `assignee: null`).
The response looks like this, we can see that an ID was generated for the Task Instance:
Created task details:
adhocTaskCanBeReassigned: false
assignee: null
category: null
created: Mon Nov 13 2017 16:34:49 GMT+0000 (GMT) {}
description: "A new stand-alone task"
dueDate: null
duration: null
endDate: null
executionId: null
formKey: null
id: "80002"
initiatorCanCompleteTask: false
involvedPeople: undefined
managerOfCandidateGroup: false
memberOfCandidateGroup: false
memberOfCandidateUsers: false
name: "Some Task"
parentTaskId: null
parentTaskName: null
priority: 50
processDefinitionCategory: null
processDefinitionDeploymentId: null
processDefinitionDescription: null
processDefinitionId: null
processDefinitionKey: null
processDefinitionName: null
processDefinitionVersion: 0
processInstanceId: null
processInstanceName: null
processInstanceStartUserId: null
taskDefinitionKey: null
See the `attachFormToATask` method for how to attach a form to the User Task. And see the `assignTaskByUserId` method
for how to assign a user to the new Task Instance.
#### attachFormToATask(taskId: string, formId: number): Observable`<any>`
Attach a form to a User Task:
```ts
const taskId = '80002';
const formId = 5005;
this.tasklistService.attachFormToATask(taskId, formId).subscribe( (response: any) => {
console.log('Assign form response: ', response);
}, error => {
console.log('Error: ', error);
});
```
In this case we need to have a task created and know the ID for it, such as with the `createNewTask` method.
We also need to have a form defined in APS and know the ID for it (you can see the ID for a form in the URL
in APS when you work with it). See the `getFormList` method for how fetch a list of available forms.
The response will be `null` if form was attached successfully to task.
#### getFormList(): Observable`<Form []>`
Get a list of the available reusable forms:
```ts
this.tasklistService.getFormList().subscribe( (formList: Form[]) => {
console.log('Available forms: ', formList);
}, error => {
console.log('Error: ', error);
});
```
A successful response looks like this:
Available forms:
0:
id: 5005
name: "Name Info"
1: {name: "cm:folder", id: 3012}
2: {name: "Alfresco Node Form", id: 3011}
3: {name: "Employee", id: 3010}
The form id property can be used with the `attachFormToATask` method.
**Note**. Referenced forms that are associated with specific tasks in a process are not included in this list.
Only reusable forms are included.
#### addTask(task: TaskDetailsModel): Observable`<TaskDetailsModel>`
Add a Sub-Task (i.e. checklist task) to a parent Task Instance:
```ts
const parentTaskId = '80002';
const subTaskDetails = new TaskDetailsModel({
parentTaskId: parentTaskId,
name: 'Check the invoice amount'
});
this.tasklistService.addTask(subTaskDetails).subscribe( (updatedTaskDetails: TaskDetailsModel) => {
console.log('Sub-task info: ', updatedTaskDetails);
}, error => {
console.log('Error: ', error);
});
```
The response includes the new sub-task id and also parent task name.
In this example the parent task was just a stand-alone task, so no process information is included:
adhocTaskCanBeReassigned: false
assignee: null
category: null
created: Tue Nov 14 2017 13:32:41 GMT+0000 (GMT) {}
description: null
dueDate: null
duration: null
endDate: null
executionId: null
formKey: null
id: "80003"
initiatorCanCompleteTask: false
involvedPeople: undefined
managerOfCandidateGroup: false
memberOfCandidateGroup: false
memberOfCandidateUsers: false
name: "Check the invoice amount"
parentTaskId: "80002"
parentTaskName: "Some Task"
priority: 50
processDefinitionCategory: null
processDefinitionDeploymentId: null
processDefinitionDescription: null
processDefinitionId: null
processDefinitionKey: null
processDefinitionName: null
processDefinitionVersion: 0
processInstanceId: null
processInstanceName: null
processInstanceStartUserId:null
taskDefinitionKey: null
#### deleteTask(taskId: string): Observable`<TaskDetailsModel>`
Delete a Sub-Task (i.e. checklist task):
```ts
const taskId = '75100'; // Sub-task ID
this.tasklistService.deleteTask(taskId).subscribe( (taskDetails: TaskDetailsModel) => {
console.log('Deleted task info: ', taskDetails);
}, error => {
console.log('Error: ', error);
});
```
**Note**. you can only delete so called checklist tasks with this method.
#### fetchTaskAuditJsonById(taskId: string): Observable`<any>`
Fetch Task Audit log as JSON for a Task Instance ID:
```ts
const taskId = '15368';
this.tasklistService.fetchTaskAuditJsonById(taskId)
.subscribe( auditJson => {
console.log('Task Audit: ', auditJson);
}, error => {
console.log('Error: ', error);
});
```
The response is JSON object with the Task Instance audit log:
{
taskId: "15368",
taskName: "Approve by someone in Accounting",
processInstanceId: "15361",
processDefinitionName: "Process With Pooled task",
processDefinitionVersion: 1,
} }
#### fetchTaskAuditPdfById(taskId: string): Observable`<Blob>`
Fetch Task Audit log as JSON for a Task Instance ID:
```ts
this.tasklistService.fetchTaskAuditPdfById(taskId)
.subscribe( (auditPdf: Blob) => {
console.log('Task Audit: ', auditPdf);
}, error => {
console.log('Error: ', error);
});
``` ```
The response is PDF with the Task Instance audit log.

View File

@@ -8,6 +8,10 @@ var unist = require("../unistHelpers");
var typescript_1 = require("typescript"); var typescript_1 = require("typescript");
// Max number of characters in the text for the default value column. // Max number of characters in the text for the default value column.
var maxDefaultTextLength = 20; var maxDefaultTextLength = 20;
var nameExceptions = {
"datatable.component": "DataTableComponent",
"tasklist.service": "TaskListService"
};
function initPhase(aggData) { function initPhase(aggData) {
} }
exports.initPhase = initPhase; exports.initPhase = initPhase;
@@ -214,6 +218,8 @@ function initialCap(str) {
return str[0].toUpperCase() + str.substr(1); return str[0].toUpperCase() + str.substr(1);
} }
function fixAngularFilename(rawName) { function fixAngularFilename(rawName) {
if (nameExceptions[rawName])
return nameExceptions[rawName];
var name = rawName.replace(/\]|\(|\)/g, ''); var name = rawName.replace(/\]|\(|\)/g, '');
var fileNameSections = name.split('.'); var fileNameSections = name.split('.');
var compNameSections = fileNameSections[0].split('-'); var compNameSections = fileNameSections[0].split('-');

View File

@@ -12,6 +12,12 @@ import { JsxEmit, isClassDeclaration, PropertyDeclaration } from "typescript";
// Max number of characters in the text for the default value column. // Max number of characters in the text for the default value column.
const maxDefaultTextLength = 20; const maxDefaultTextLength = 20;
let nameExceptions = {
"datatable.component": "DataTableComponent",
"tasklist.service": "TaskListService"
}
export function initPhase(aggData) { export function initPhase(aggData) {
} }
@@ -301,6 +307,9 @@ function initialCap(str: string) {
function fixAngularFilename(rawName: string) { function fixAngularFilename(rawName: string) {
if (nameExceptions[rawName])
return nameExceptions[rawName];
var name = rawName.replace(/\]|\(|\)/g, ''); var name = rawName.replace(/\]|\(|\)/g, '');
var fileNameSections = name.split('.'); var fileNameSections = name.split('.');

View File

@@ -54,89 +54,92 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck
@ContentChild(DataColumnListComponent) @ContentChild(DataColumnListComponent)
columnList: DataColumnListComponent; columnList: DataColumnListComponent;
/* Data source for the table */ /** Data source for the table */
@Input() @Input()
data: DataTableAdapter; data: DataTableAdapter;
/* change the display mode of the table list or gallery */ /** Selects the display mode of the table. Can be "list" or "gallery". */
@Input() @Input()
display: string = DisplayMode.List; display: string = DisplayMode.List;
/* The rows that the datatable will show */ /** The rows that the datatable will show. */
@Input() @Input()
rows: any[] = []; rows: any[] = [];
/* Row selection mode. Can be none, `single` or `multiple`. For `multiple` mode, /** 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. * you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows.
*/ */
@Input() @Input()
selectionMode: string = 'single'; // none|single|multiple selectionMode: string = 'single'; // none|single|multiple
/* Toggles multiple row selection, which renders checkboxes at the beginning of each row */ /** Toggles multiple row selection, which renders checkboxes at the beginning of each row. */
@Input() @Input()
multiselect: boolean = false; multiselect: boolean = false;
/* Toggles data actions column */ /** Toggles the data actions column. */
@Input() @Input()
actions: boolean = false; actions: boolean = false;
/* Position of the actions dropdown menu. Can be "left" or "right". */ /** Position of the actions dropdown menu. Can be "left" or "right". */
@Input() @Input()
actionsPosition: string = 'right'; // left|right actionsPosition: string = 'right'; // left|right
/* Fallback image for row where thumbnail is missing */ /** Fallback image for rows where the thumbnail is missing. */
@Input() @Input()
fallbackThumbnail: string; fallbackThumbnail: string;
/* Toggles custom context menu for the component */ /** Toggles custom context menu for the component. */
@Input() @Input()
contextMenu: boolean = false; contextMenu: boolean = false;
/* Toggle file drop support for rows (see Upload Directive for further details) */ /** Toggles file drop support for rows (see
* [Upload directive](upload.directive.md) for further details).
*/
@Input() @Input()
allowDropFiles: boolean = false; allowDropFiles: boolean = false;
/* The inline style to apply to every row. See /** The inline style to apply to every row. See
* [NgStyle](https://angular.io/docs/ts/latest/api/common/index/NgStyle-directive.html) * [NgStyle](https://angular.io/docs/ts/latest/api/common/index/NgStyle-directive.html)
* docs for more details and usage examples. * docs for more details and usage examples.
*/ */
@Input() @Input()
rowStyle: string; rowStyle: string;
/* The CSS class to apply to every row */ /** The CSS class to apply to every row. */
@Input() @Input()
rowStyleClass: string = ''; rowStyleClass: string = '';
/* Toggles the header */ /** Toggles the header. */
@Input() @Input()
showHeader: boolean = true; showHeader: boolean = true;
/* Emitted when user clicks the row */ /** Emitted when the user clicks a row. */
@Output() @Output()
rowClick = new EventEmitter<DataRowEvent>(); rowClick = new EventEmitter<DataRowEvent>();
/* Emitted when user double-clicks the row */ /** Emitted when the user double-clicks a row. */
@Output() @Output()
rowDblClick = new EventEmitter<DataRowEvent>(); rowDblClick = new EventEmitter<DataRowEvent>();
/* Emitted before context menu is displayed for a row */ /** Emitted before the context menu is displayed for a row. */
@Output() @Output()
showRowContextMenu = new EventEmitter<DataCellEvent>(); showRowContextMenu = new EventEmitter<DataCellEvent>();
/* Emitted before actions menu is displayed for a row */ /** Emitted before the actions menu is displayed for a row. */
@Output() @Output()
showRowActionsMenu = new EventEmitter<DataCellEvent>(); showRowActionsMenu = new EventEmitter<DataCellEvent>();
/* Emitted when row action is executed by user */ /** Emitted when the user executes a row action. */
@Output() @Output()
executeRowAction = new EventEmitter<DataRowActionEvent>(); executeRowAction = new EventEmitter<DataRowActionEvent>();
/* Flag that indicates if the datatable is in loading state and needs to show the /** Flag that indicates if the datatable is in loading state and needs to show the
* loading template (see the docs to learn how to configure a loading template). * loading template (see the docs to learn how to configure a loading template).
*/ */
@Input() @Input()
loading: boolean = false; loading: boolean = false;
/** Flag that indicates if the datatable should show the "no permission" template. */
@Input() @Input()
noPermission: boolean = false; noPermission: boolean = false;

View File

@@ -41,9 +41,9 @@ export class TaskListService {
} }
/** /**
* Return all the filters in the list where the task id belong * Gets all the filters in the list that belong to a task.
* @param taskId - string * @param taskId ID of the target task
* @param filter - FilterRepresentationModel [] * @param filterList List of filters to search through
*/ */
getFilterForTaskById(taskId: string, filterList: FilterRepresentationModel[]): Observable<FilterRepresentationModel> { getFilterForTaskById(taskId: string, filterList: FilterRepresentationModel[]): Observable<FilterRepresentationModel> {
return Observable.from(filterList) return Observable.from(filterList)
@@ -52,8 +52,8 @@ export class TaskListService {
} }
/** /**
* Return the search node for query task based on the given filter * Gets the search query for a task based on the supplied filter.
* @param filter - FilterRepresentationModel * @param filter The filter to use
*/ */
private generateTaskRequestNodeFromFilter(filter: FilterRepresentationModel): TaskQueryRequestRepresentationModel { private generateTaskRequestNodeFromFilter(filter: FilterRepresentationModel): TaskQueryRequestRepresentationModel {
let requestNode = { let requestNode = {
@@ -66,9 +66,9 @@ export class TaskListService {
} }
/** /**
* Check if a taskId is filtered with the given filter * Checks if a taskId is filtered with the given filter.
* @param taskId - string * @param taskId ID of the target task
* @param filter - FilterRepresentationModel * @param filter The filter you want to check
*/ */
isTaskRelatedToFilter(taskId: string, filter: FilterRepresentationModel): Observable<FilterRepresentationModel> { isTaskRelatedToFilter(taskId: string, filter: FilterRepresentationModel): Observable<FilterRepresentationModel> {
let requestNodeForFilter = this.generateTaskRequestNodeFromFilter(filter); let requestNodeForFilter = this.generateTaskRequestNodeFromFilter(filter);
@@ -79,8 +79,8 @@ export class TaskListService {
} }
/** /**
* Retrieve all the tasks filtered by filterModel * Gets all the tasks matching the supplied query.
* @param filter - TaskFilterRepresentationModel * @param requestNode Query to search for tasks
*/ */
getTasks(requestNode: TaskQueryRequestRepresentationModel): Observable<TaskListModel> { getTasks(requestNode: TaskQueryRequestRepresentationModel): Observable<TaskListModel> {
return Observable.fromPromise(this.callApiTasksFiltered(requestNode)) return Observable.fromPromise(this.callApiTasksFiltered(requestNode))
@@ -91,8 +91,9 @@ export class TaskListService {
} }
/** /**
* Retrieve tasks filtered by filterModel and state * Gets tasks matching a query and state value.
* @param filter - TaskFilterRepresentationModel * @param requestNode Query to search for tasks
* @param state Task state. Can be "open" or "completed".
*/ */
findTasksByState(requestNode: TaskQueryRequestRepresentationModel, state?: string): Observable<TaskListModel> { findTasksByState(requestNode: TaskQueryRequestRepresentationModel, state?: string): Observable<TaskListModel> {
if (state) { if (state) {
@@ -102,8 +103,9 @@ export class TaskListService {
} }
/** /**
* Retrieve all tasks filtered by filterModel and state * Gets all tasks matching a query and state value.
* @param filter - TaskFilterRepresentationModel * @param requestNode Query to search for tasks.
* @param state Task state. Can be "open" or "completed".
*/ */
findAllTaskByState(requestNode: TaskQueryRequestRepresentationModel, state?: string): Observable<TaskListModel> { findAllTaskByState(requestNode: TaskQueryRequestRepresentationModel, state?: string): Observable<TaskListModel> {
if (state) { if (state) {
@@ -116,8 +118,8 @@ export class TaskListService {
} }
/** /**
* Retrieve all tasks filtered by filterModel irrespective of state * Get all tasks matching the supplied query but ignoring the task state.
* @param filter - TaskFilterRepresentationModel * @param requestNode Query to search for tasks
*/ */
findAllTasksWithoutState(requestNode: TaskQueryRequestRepresentationModel): Observable<TaskListModel> { findAllTasksWithoutState(requestNode: TaskQueryRequestRepresentationModel): Observable<TaskListModel> {
return Observable.forkJoin( return Observable.forkJoin(
@@ -134,8 +136,8 @@ export class TaskListService {
} }
/** /**
* Retrieve all the task details * Gets details for a task.
* @param id - taskId * @param taskId ID of the target task.
*/ */
getTaskDetails(taskId: string): Observable<TaskDetailsModel> { getTaskDetails(taskId: string): Observable<TaskDetailsModel> {
return Observable.fromPromise(this.callApiTaskDetails(taskId)) return Observable.fromPromise(this.callApiTaskDetails(taskId))
@@ -146,8 +148,8 @@ export class TaskListService {
} }
/** /**
* Retrieve all the task's checklist * Gets the checklist for a task.
* @param id - taskId * @param id ID of the target task
*/ */
getTaskChecklist(id: string): Observable<TaskDetailsModel[]> { getTaskChecklist(id: string): Observable<TaskDetailsModel[]> {
return Observable.fromPromise(this.callApiTaskChecklist(id)) return Observable.fromPromise(this.callApiTaskChecklist(id))
@@ -162,7 +164,7 @@ export class TaskListService {
} }
/** /**
* Retrieve all the form shared with this user * Gets all available reusable forms.
*/ */
getFormList(): Observable<Form []> { getFormList(): Observable<Form []> {
let opts = { let opts = {
@@ -181,13 +183,18 @@ export class TaskListService {
}).catch(err => this.handleError(err)); }).catch(err => this.handleError(err));
} }
/**
* Attaches a form to a task.
* @param taskId ID of the target task
* @param formId ID of the form to add
*/
attachFormToATask(taskId: string, formId: number): Observable<any> { attachFormToATask(taskId: string, formId: number): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.attachForm(taskId, {'formId': formId})).catch(err => this.handleError(err)); return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.attachForm(taskId, {'formId': formId})).catch(err => this.handleError(err));
} }
/** /**
* Add a task * Adds a subtask (ie, a checklist task) to a parent task.
* @param task - TaskDetailsModel * @param task The task to add
*/ */
addTask(task: TaskDetailsModel): Observable<TaskDetailsModel> { addTask(task: TaskDetailsModel): Observable<TaskDetailsModel> {
return Observable.fromPromise(this.callApiAddTask(task)) return Observable.fromPromise(this.callApiAddTask(task))
@@ -198,8 +205,8 @@ export class TaskListService {
} }
/** /**
* Delete a task * Deletes a subtask (ie, a checklist task) from a parent task.
* @param taskId - string * @param taskId The task to delete
*/ */
deleteTask(taskId: string): Observable<TaskDetailsModel> { deleteTask(taskId: string): Observable<TaskDetailsModel> {
return Observable.fromPromise(this.callApiDeleteTask(taskId)) return Observable.fromPromise(this.callApiDeleteTask(taskId))
@@ -207,8 +214,8 @@ export class TaskListService {
} }
/** /**
* Make the task completed * Gives completed status to a task.
* @param id - taskId * @param taskId ID of the target task
*/ */
completeTask(taskId: string) { completeTask(taskId: string) {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.completeTask(taskId)) return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.completeTask(taskId))
@@ -217,8 +224,8 @@ export class TaskListService {
} }
/** /**
* Return the total number of the tasks by filter * Gets the total number of the tasks found by a query.
* @param requestNode - TaskFilterRepresentationModel * @param requestNode Query to search for tasks
*/ */
public getTotalTasks(requestNode: TaskQueryRequestRepresentationModel): Observable<any> { public getTotalTasks(requestNode: TaskQueryRequestRepresentationModel): Observable<any> {
requestNode.size = 0; requestNode.size = 0;
@@ -229,8 +236,8 @@ export class TaskListService {
} }
/** /**
* Create a new standalone task * Creates a new standalone task.
* @param task - TaskDetailsModel * @param task Details of the new task
*/ */
createNewTask(task: TaskDetailsModel): Observable<TaskDetailsModel> { createNewTask(task: TaskDetailsModel): Observable<TaskDetailsModel> {
return Observable.fromPromise(this.callApiCreateTask(task)) return Observable.fromPromise(this.callApiCreateTask(task))
@@ -241,9 +248,9 @@ export class TaskListService {
} }
/** /**
* Assign task to user/group * Assigns a task to a user or group.
* @param taskId - string * @param taskId The task to assign
* @param requestNode - any * @param requestNode User or group to assign the task to
*/ */
assignTask(taskId: string, requestNode: any): Observable<TaskDetailsModel> { assignTask(taskId: string, requestNode: any): Observable<TaskDetailsModel> {
let assignee = {assignee: requestNode.id}; let assignee = {assignee: requestNode.id};
@@ -254,6 +261,11 @@ export class TaskListService {
}).catch(err => this.handleError(err)); }).catch(err => this.handleError(err));
} }
/**
* Assigns a task to a user.
* @param taskId ID of the task to assign
* @param userId ID of the user to assign the task to
*/
assignTaskByUserId(taskId: string, userId: number): Observable<TaskDetailsModel> { assignTaskByUserId(taskId: string, userId: number): Observable<TaskDetailsModel> {
let assignee = {assignee: userId}; let assignee = {assignee: userId};
return Observable.fromPromise(this.callApiAssignTask(taskId, assignee)) return Observable.fromPromise(this.callApiAssignTask(taskId, assignee))
@@ -264,8 +276,8 @@ export class TaskListService {
} }
/** /**
* Claim a task * Claims a task for the current user.
* @param id - taskId * @param taskId ID of the task to claim
*/ */
claimTask(taskId: string): Observable<TaskDetailsModel> { claimTask(taskId: string): Observable<TaskDetailsModel> {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.claimTask(taskId)) return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.claimTask(taskId))
@@ -273,8 +285,8 @@ export class TaskListService {
} }
/** /**
* Unclaim a task * Unclaims a task for the current user.
* @param id - taskId * @param taskId ID of the task to unclaim
*/ */
unclaimTask(taskId: string): Observable<TaskDetailsModel> { unclaimTask(taskId: string): Observable<TaskDetailsModel> {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.unclaimTask(taskId)) return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.unclaimTask(taskId))
@@ -282,8 +294,9 @@ export class TaskListService {
} }
/** /**
* Update due date * Updates the details (name, description, due date) for a task.
* @param dueDate - the new due date * @param taskId ID of the task to update
* @param updated Data to update the task (as a `TaskUpdateRepresentation` instance).
*/ */
updateTask(taskId: any, updated): Observable<TaskDetailsModel> { updateTask(taskId: any, updated): Observable<TaskDetailsModel> {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.updateTask(taskId, updated)) return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.updateTask(taskId, updated))
@@ -291,8 +304,8 @@ export class TaskListService {
} }
/** /**
* fetch the Task Audit information as a pdf * Fetches the Task Audit information in PDF format.
* @param taskId - the task id * @param taskId ID of the target task
*/ */
fetchTaskAuditPdfById(taskId: string): Observable<Blob> { fetchTaskAuditPdfById(taskId: string): Observable<Blob> {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.getTaskAuditPdf(taskId)) return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.getTaskAuditPdf(taskId))
@@ -300,8 +313,8 @@ export class TaskListService {
} }
/** /**
* fetch the Task Audit information in a json format * Fetch the Task Audit information in JSON format
* @param taskId - the task id * @param taskId ID of the target task
*/ */
fetchTaskAuditJsonById(taskId: string): Observable<any> { fetchTaskAuditJsonById(taskId: string): Observable<any> {
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.getTaskAuditJson(taskId)) return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.getTaskAuditJson(taskId))