[ADF-3103] Added new inputs, columns and overall improvement to Task List Demo (#3653)

* Added columns, inputs and error message alert

* [ADF-3103] Fixed variable name typo

* Add basic documentation
This commit is contained in:
Maurizio Vitale
2018-08-03 15:06:13 +01:00
committed by Eugenio Romano
parent 8d8ab1e682
commit 547c56aeef
8 changed files with 150 additions and 22 deletions

View File

@@ -218,8 +218,14 @@
"INHERITED_PERMISSIONS_BUTTON": "Permission Inherited" "INHERITED_PERMISSIONS_BUTTON": "Permission Inherited"
}, },
"TASK_LIST_DEMO": { "TASK_LIST_DEMO": {
"APP_ID_REQUIRED_ERROR": "Insert App Id", "ERROR_MESSAGE": {
"APP_ID_TYPE_ERROR": "App Id must be a number" "APP_ID_REQUIRED_ERROR": "Insert App Id",
"APP_ID_TYPE_ERROR": "App Id must be a number",
"NUMBER_TYPE_ERROR": "Value must be a number"
},
"TOOLTIP_MESSAGE": {
"START_INPUT": "Starting page"
}
}, },
"PROCESS_LIST_DEMO": { "PROCESS_LIST_DEMO": {
"APP_ID_REQUIRED_ERROR": "Insert App Id", "APP_ID_REQUIRED_ERROR": "Insert App Id",

View File

@@ -140,7 +140,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
blobFile: any; blobFile: any;
flag = true; flag = true;
presetColoum = 'default'; presetColumn = 'default';
showTaskTab: boolean; showTaskTab: boolean;
showProcessTab: boolean; showProcessTab: boolean;

View File

@@ -8,10 +8,10 @@
class="form-control" class="form-control"
[formControl]="taskAppId"> [formControl]="taskAppId">
<mat-error *ngIf="taskAppId.hasError('required')"> <mat-error *ngIf="taskAppId.hasError('required')">
{{ 'TASK_LIST_DEMO.APP_ID_REQUIRED_ERROR' | translate }} {{ 'TASK_LIST_DEMO.ERROR_MESSAGE.APP_ID_REQUIRED_ERROR' | translate }}
</mat-error> </mat-error>
<mat-error *ngIf="taskAppId.hasError('pattern')"> <mat-error *ngIf="taskAppId.hasError('pattern')">
{{ 'TASK_LIST_DEMO.APP_ID_TYPE_ERROR' | translate }} {{ 'TASK_LIST_DEMO.ERROR_MESSAGE.APP_ID_TYPE_ERROR' | translate }}
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
@@ -23,13 +23,51 @@
[formControl]="taskName"> [formControl]="taskName">
</mat-form-field> </mat-form-field>
<mat-form-field>
<mat-label>Task Id</mat-label>
<input
matInput
class="form-control"
[formControl]="taskId">
</mat-form-field>
<mat-form-field>
<mat-label>Start</mat-label>
<input
matInput
class="form-control"
matTooltip="{{ 'TASK_LIST_DEMO.TOOLTIP_MESSAGE.START_INPUT' | translate }}"
[formControl]="taskStart">
<mat-error *ngIf="taskStart.hasError('pattern')">
{{ 'TASK_LIST_DEMO.ERROR_MESSAGE.NUMBER_TYPE_ERROR' | translate }}
</mat-error>
</mat-form-field>
<mat-form-field> <mat-form-field>
<mat-label>ProcessDefinitionId</mat-label> <mat-label>ProcessDefinitionId</mat-label>
<input <input
matInput matInput
class="form-control" class="form-control"
[formControl]="taskProcessDefinitionId"> [formControl]="taskProcessDefinitionId">
<mat-hint>SimpleProcess:1:2</mat-hint> <mat-hint>E.g. SimpleProcess:1:2</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>ProcessInstanceId</mat-label>
<input
matInput
class="form-control"
[formControl]="taskProcessInstanceId">
<mat-hint>E.g. 12345</mat-hint>
</mat-form-field>
<mat-form-field>
<mat-label>Process Instance</mat-label>
<mat-select
class="form-control"
[formControl]="taskIncludeProcessInstance">
<mat-option *ngFor="let includeProcessInstanceOption of includeProcessInstanceOptions" [value]="includeProcessInstanceOption.value">{{ includeProcessInstanceOption.title }}</mat-option>
</mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
@@ -55,25 +93,38 @@
<mat-select <mat-select
class="form-control" class="form-control"
[formControl]="taskSort"> [formControl]="taskSort">
<mat-option *ngFor="let sortOption of sortOptions" [value]="sortOptions.value">{{ sortOption.title }}</mat-option> <mat-option *ngFor="let sortOption of sortOptions" [value]="sortOption.value">{{ sortOption.title }}</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<div class="adf-reset-button">
<button mat-raised-button (click)="resetTaskForm()">Reset</button>
</div>
</form> </form>
</div> </div>
<div class="adf-reset-button">
<button mat-raised-button (click)="resetTaskForm()">Reset</button>
</div>
<div> <div>
<adf-tasklist <adf-tasklist
[appId]="appId" [appId]="appId"
[taskId]="id"
[name]="name" [name]="name"
[processDefinitionId]="processDefinitionId" [processDefinitionId]="processDefinitionId"
[processInstanceId]="processInstanceId"
[assignment]="assignment" [assignment]="assignment"
[state]="state" [state]="state"
[sort]="sort" [sort]="sort"
[start]="start"
[includeProcessInstance]="includeProcessInstance"
(error)="onError($event)"
#taskList> #taskList>
<data-columns>
<data-column key="id" title="Id"></data-column>
<data-column key="name" title="Name"></data-column>
<data-column key="description" title="Description"></data-column>
<data-column key="created" title="Created"></data-column>
<data-column key="dueDate" title="Due Date"></data-column>
<data-column key="processInstanceId" title="Process Instance Id"></data-column>
<data-column key="processDefinitionId" title="Process Definition Id"></data-column>
</data-columns>
</adf-tasklist> </adf-tasklist>
<adf-pagination <adf-pagination

View File

@@ -1,12 +1,18 @@
.task-list-demo-inputs { .task-list-demo-inputs {
margin-top: 100px; margin: 100px auto 0 auto;
margin-bottom: 50px; width: 80%;
display: flex; display: flex;
flex: wrap;
justify-content: space-evenly; justify-content: space-evenly;
& mat-form-field {
margin: 20px 0;
width: calc(100% * (1/4) - 10px);
}
} }
.adf-reset-button { .adf-reset-button {
margin-top: 50px; margin-bottom: 50px;
display: flex; display: flex;
justify-content: center; justify-content: center;
} }

View File

@@ -18,7 +18,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormControl, AbstractControl } from '@angular/forms'; import { FormGroup, FormBuilder, Validators, FormControl, AbstractControl } from '@angular/forms';
import { ActivatedRoute, Params } from '@angular/router'; import { ActivatedRoute, Params } from '@angular/router';
import { NotificationService } from '@alfresco/adf-core';
@Component({ @Component({
templateUrl: './task-list-demo.component.html', templateUrl: './task-list-demo.component.html',
@@ -35,8 +35,12 @@ export class TaskListDemoComponent implements OnInit {
appId: number; appId: number;
id: string;
processDefinitionId: string; processDefinitionId: string;
processInstanceId: string;
state: string; state: string;
assignment: string; assignment: string;
@@ -45,11 +49,20 @@ export class TaskListDemoComponent implements OnInit {
sort: string; sort: string;
start: number;
includeProcessInstance: boolean;
assignmentOptions = [ assignmentOptions = [
{value: 'assignee', title: 'Assignee'}, {value: 'assignee', title: 'Assignee'},
{value: 'candidate', title: 'Candidate'} {value: 'candidate', title: 'Candidate'}
]; ];
includeProcessInstanceOptions = [
{value: 'include', title: 'Include'},
{value: 'exclude', title: 'Exclude'}
];
stateOptions = [ stateOptions = [
{value: 'all', title: 'All'}, {value: 'all', title: 'All'},
{value: 'active', title: 'Active'}, {value: 'active', title: 'Active'},
@@ -64,7 +77,8 @@ export class TaskListDemoComponent implements OnInit {
]; ];
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private formBuilder: FormBuilder) { private formBuilder: FormBuilder,
private notificationService: NotificationService) {
} }
ngOnInit() { ngOnInit() {
@@ -78,20 +92,24 @@ export class TaskListDemoComponent implements OnInit {
}); });
} }
this.appId = this.defaultAppId;
this.errorMessage = 'Insert App Id'; this.errorMessage = 'Insert App Id';
this.buildForm(); this.buildForm();
} }
buildForm() { buildForm() {
this.taskListForm = this.formBuilder.group({ this.taskListForm = this.formBuilder.group({
taskAppId: new FormControl(this.defaultAppId, [Validators.required, Validators.pattern('^[0-9]*$')]), taskAppId: new FormControl(this.defaultAppId, [Validators.required, Validators.pattern('^[0-9]*$')]),
taskName: new FormControl(''), taskName: new FormControl(''),
taskId: new FormControl(''),
taskProcessDefinitionId: new FormControl(''), taskProcessDefinitionId: new FormControl(''),
taskProcessInstanceId: new FormControl(''),
taskAssignment: new FormControl(''), taskAssignment: new FormControl(''),
taskState: new FormControl(''), taskState: new FormControl(''),
taskSort: new FormControl('') taskSort: new FormControl(''),
taskStart: new FormControl('', [Validators.pattern('^[0-9]*$')]),
taskIncludeProcessInstance: new FormControl('')
}); });
this.taskListForm.valueChanges this.taskListForm.valueChanges
@@ -101,16 +119,27 @@ export class TaskListDemoComponent implements OnInit {
this.filterTasks(taskFilter); this.filterTasks(taskFilter);
} }
}); });
} }
filterTasks(taskFilter: any) { filterTasks(taskFilter: any) {
this.appId = taskFilter.taskAppId; this.appId = taskFilter.taskAppId;
this.id = taskFilter.taskId;
this.processDefinitionId = taskFilter.taskProcessDefinitionId; this.processDefinitionId = taskFilter.taskProcessDefinitionId;
this.processInstanceId = taskFilter.taskProcessInstanceId;
this.name = taskFilter.taskName; this.name = taskFilter.taskName;
this.assignment = taskFilter.taskAssignment; this.assignment = taskFilter.taskAssignment;
this.state = taskFilter.taskState; this.state = taskFilter.taskState;
this.sort = taskFilter.taskSort; this.sort = taskFilter.taskSort;
this.start = taskFilter.taskStart;
this.includeProcessInstance = taskFilter.taskIncludeProcessInstance === 'include';
}
onError($event) {
const errorMessage = JSON.parse($event.message).message;
this.notificationService.openSnackMessageAction(errorMessage, 'Reset', 5000).onAction().subscribe(() => {
this.resetTaskForm();
});
} }
resetTaskForm() { resetTaskForm() {
@@ -125,10 +154,18 @@ export class TaskListDemoComponent implements OnInit {
return this.taskListForm.get('taskAppId'); return this.taskListForm.get('taskAppId');
} }
get taskId(): AbstractControl {
return this.taskListForm.get('taskId');
}
get taskProcessDefinitionId(): AbstractControl { get taskProcessDefinitionId(): AbstractControl {
return this.taskListForm.get('taskProcessDefinitionId'); return this.taskListForm.get('taskProcessDefinitionId');
} }
get taskProcessInstanceId(): AbstractControl {
return this.taskListForm.get('taskProcessInstanceId');
}
get taskName(): AbstractControl { get taskName(): AbstractControl {
return this.taskListForm.get('taskName'); return this.taskListForm.get('taskName');
} }
@@ -144,4 +181,12 @@ export class TaskListDemoComponent implements OnInit {
get taskSort(): AbstractControl { get taskSort(): AbstractControl {
return this.taskListForm.get('taskSort'); return this.taskListForm.get('taskSort');
} }
get taskIncludeProcessInstance(): AbstractControl {
return this.taskListForm.get('taskIncludeProcessInstance');
}
get taskStart(): AbstractControl {
return this.taskListForm.get('taskStart');
}
} }

View File

@@ -51,10 +51,13 @@ Renders a list containing all the tasks matched by the parameters specified.
| multiselect | `boolean` | false | Toggles multiple row selection, renders checkboxes at the beginning of each row | | multiselect | `boolean` | false | Toggles multiple row selection, renders checkboxes at the beginning of each row |
| name | `string` | | Name of the tasklist. | | name | `string` | | Name of the tasklist. |
| page | `number` | 0 | The page number of the tasks to fetch. | | page | `number` | 0 | The page number of the tasks to fetch. |
| start | `number` | 0 | Another approach to specify which page you want load. |
| processDefinitionKey | `string` | | (**Deprecated:** 2.4.0) The Definition Key of the process. | | processDefinitionKey | `string` | | (**Deprecated:** 2.4.0) The Definition Key of the process. |
| processDefinitionId | `string` | | The Definition Id of the process. | | processDefinitionId | `string` | | The Definition Id of the process. |
| processInstanceId | `string` | | The Instance Id of the process. | | processInstanceId | `string` | | The Instance Id of the process. |
| taskId | `string` | | The taskId you want to be fetched. |
| selectFirstRow | `boolean` | true | Toggles default selection of the first row | | selectFirstRow | `boolean` | true | Toggles default selection of the first row |
| includeProcessInstance | `boolean` | false | Include the process instance info |
| 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. | | 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. |
| size | `number` | [`PaginationComponent`](../core/pagination.component.md).DEFAULT_PAGINATION.maxItems | The number of tasks to fetch. Default value: 25. | | size | `number` | [`PaginationComponent`](../core/pagination.component.md).DEFAULT_PAGINATION.maxItems | 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` | | sort | `string` | | Define the sort order of the tasks. Possible values are : `created-desc`, `created-asc`, `due-desc`, `due-asc` |

View File

@@ -111,6 +111,18 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
@Input() @Input()
selectFirstRow: boolean = true; selectFirstRow: boolean = true;
/** The id of a task */
@Input()
taskId: string;
/** Toggles inclusion of Process Instances */
@Input()
includeProcessInstance: boolean;
/** Starting point of the */
@Input()
start: number = 0;
/** Emitted when a task in the list is clicked */ /** Emitted when a task in the list is clicked */
@Output() @Output()
rowClick: EventEmitter<string> = new EventEmitter<string>(); rowClick: EventEmitter<string> = new EventEmitter<string>();
@@ -321,7 +333,7 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
/** /**
* Optimize name field * Optimize name field
* @param istances * @param instances
*/ */
private optimizeNames(instances: any[]): any[] { private optimizeNames(instances: any[]): any[] {
instances = instances.map(t => { instances = instances.map(t => {
@@ -344,10 +356,11 @@ export class TaskListComponent extends DataTableSchema implements OnChanges, Aft
assignment: this.assignment, assignment: this.assignment,
state: this.state, state: this.state,
sort: this.sort, sort: this.sort,
landingTaskId: this.landingTaskId,
page: this.page, page: this.page,
size: this.size, size: this.size,
start: 0 start: this.start,
taskId: this.taskId,
includeProcessInstance: this.includeProcessInstance
}; };
return new TaskQueryRequestRepresentationModel(requestNode); return new TaskQueryRequestRepresentationModel(requestNode);
} }

View File

@@ -118,6 +118,8 @@ export class TaskQueryRequestRepresentationModel implements TaskQueryRequestRepr
sort: string; sort: string;
page: number; page: number;
size: number; size: number;
taskId: string;
includeProcessInstance: boolean;
constructor(obj?: any) { constructor(obj?: any) {
if (obj) { if (obj) {
@@ -131,6 +133,8 @@ export class TaskQueryRequestRepresentationModel implements TaskQueryRequestRepr
this.sort = obj.sort || null; this.sort = obj.sort || null;
this.page = obj.page || 0; this.page = obj.page || 0;
this.size = obj.size || 25; this.size = obj.size || 25;
this.taskId = obj.taskId || null;
this.includeProcessInstance = obj.includeProcessInstance;
} }
} }
} }