[ADF-3573] Task list pagination on Task List Demo page fix (#3823)

* [ADF-3573] Task list pagination on Task List Demo page fix

* [ADF-3573] Added minimum values for size per page and page inputs
This commit is contained in:
davidcanonieto
2018-09-25 21:32:24 +01:00
committed by Eugenio Romano
parent 580cd3440f
commit ab4f964f7f
3 changed files with 25 additions and 9 deletions

View File

@@ -64,6 +64,12 @@
matInput
class="form-control"
[formControl]="taskSize">
<mat-error *ngIf="taskSize.hasError('min')">
{{ 'TASK_LIST_DEMO.ERROR_MESSAGE.NUMBER_GREATER_THAN' | translate: { value: minValue } }}
</mat-error>
<mat-error *ngIf="taskSize.hasError('pattern')">
{{ 'TASK_LIST_DEMO.ERROR_MESSAGE.NUMBER_TYPE_ERROR' | translate }}
</mat-error>
</mat-form-field>
<mat-form-field>
@@ -72,6 +78,12 @@
matInput
class="form-control"
[formControl]="taskPage">
<mat-error *ngIf="taskPage.hasError('min')">
{{ 'TASK_LIST_DEMO.ERROR_MESSAGE.NUMBER_GREATER_THAN' | translate: { value: minValue } }}
</mat-error>
<mat-error *ngIf="taskPage.hasError('pattern')">
{{ 'TASK_LIST_DEMO.ERROR_MESSAGE.NUMBER_TYPE_ERROR' | translate }}
</mat-error>
</mat-form-field>
<mat-form-field>

View File

@@ -31,6 +31,7 @@ export class TaskListDemoComponent implements OnInit {
taskListForm: FormGroup;
errorMessage: string;
minValue = 1;
appId: number;
defaultAppId: number;
@@ -101,8 +102,8 @@ export class TaskListDemoComponent implements OnInit {
taskAssignment: new FormControl(''),
taskState: new FormControl(''),
taskSort: new FormControl(''),
taskSize: new FormControl(''),
taskPage: new FormControl(''),
taskSize: new FormControl('', [Validators.pattern('^[0-9]*$'), Validators.min(this.minValue)]),
taskPage: new FormControl('', [Validators.pattern('^[0-9]*$'), Validators.min(this.minValue)]),
taskDueAfter: new FormControl(''),
taskDueBefore: new FormControl(''),
taskStart: new FormControl('', [Validators.pattern('^[0-9]*$')]),
@@ -130,17 +131,19 @@ export class TaskListDemoComponent implements OnInit {
this.state = taskFilter.taskState;
this.sort = taskFilter.taskSort;
this.start = taskFilter.taskStart;
this.dueAfter = taskFilter.taskDueAfter;
this.dueBefore = taskFilter.taskDueBefore;
if (taskFilter.taskSize) {
this.size = parseInt(taskFilter.taskSize, 10);
}
let pageValue = parseInt(taskFilter.taskPage, 10);
if ( pageValue > 0) {
this.page = pageValue - 1;
if (taskFilter.taskPage) {
let pageValue = parseInt(taskFilter.taskPage, 10);
this.page = pageValue > 0 ? pageValue - 1 : pageValue;
} else {
this.page = pageValue;
this.page = 0;
}
this.dueAfter = taskFilter.taskDueAfter;
this.dueBefore = taskFilter.taskDueBefore;
this.includeProcessInstance = taskFilter.taskIncludeProcessInstance === 'include';
}