[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

@@ -221,7 +221,8 @@
"ERROR_MESSAGE": { "ERROR_MESSAGE": {
"APP_ID_REQUIRED_ERROR": "Insert App ID", "APP_ID_REQUIRED_ERROR": "Insert App ID",
"APP_ID_TYPE_ERROR": "App ID must be a number", "APP_ID_TYPE_ERROR": "App ID must be a number",
"NUMBER_TYPE_ERROR": "Value must be a number" "NUMBER_TYPE_ERROR": "Value must be a number",
"NUMBER_GREATER_THAN": "Value must be greater than or equal to {{ value }}"
}, },
"TOOLTIP_MESSAGE": { "TOOLTIP_MESSAGE": {
"START_INPUT": "Starting page" "START_INPUT": "Starting page"

View File

@@ -64,6 +64,12 @@
matInput matInput
class="form-control" class="form-control"
[formControl]="taskSize"> [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>
<mat-form-field> <mat-form-field>
@@ -72,6 +78,12 @@
matInput matInput
class="form-control" class="form-control"
[formControl]="taskPage"> [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>
<mat-form-field> <mat-form-field>

View File

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