mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3308] Process list filter by fields (#3588)
* process list component created * process list renamed * routing fix
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<div class="process-list-inputs">
|
||||
|
||||
<form [formGroup]="processListForm">
|
||||
<mat-form-field>
|
||||
<mat-label>App Id</mat-label>
|
||||
<input
|
||||
matInput
|
||||
class="form-control"
|
||||
[formControl]="processAppId">
|
||||
<mat-error *ngIf="processAppId.hasError('required')">
|
||||
{{ 'PROCESS_LIST_DEMO.APP_ID_REQUIRED_ERROR' | translate }}
|
||||
</mat-error>
|
||||
<mat-error *ngIf="processAppId.hasError('pattern')">
|
||||
{{ 'PROCESS_LIST_DEMO.APP_ID_TYPE_ERROR' | translate }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Process Name</mat-label>
|
||||
<input
|
||||
matInput
|
||||
class="form-control"
|
||||
[formControl]="processName">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>ProcessDefinitionId</mat-label>
|
||||
<input
|
||||
matInput
|
||||
class="form-control"
|
||||
[formControl]="processDefinitionId">
|
||||
<mat-hint>SimpleProcess:1:2</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>State</mat-label>
|
||||
<mat-select
|
||||
class="form-control"
|
||||
[formControl]="processState">
|
||||
<mat-option *ngFor="let stateOption of stateOptions" [value]="stateOption.value">{{ stateOption.title }}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Sort</mat-label>
|
||||
<mat-select
|
||||
class="form-control"
|
||||
[formControl]="processSort">
|
||||
<mat-option *ngFor="let sortOption of sortOptions" [value]="sortOption.value">{{ sortOption.title }}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<div class="adf-reset-button">
|
||||
<button mat-raised-button (click)="resetProcessForm()">Reset</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<adf-process-instance-list
|
||||
#processList
|
||||
[appId]="appId"
|
||||
[processDefinitionKey]="processDefId"
|
||||
[state]="state"
|
||||
[sort]="sort"
|
||||
[name]="name">
|
||||
</adf-process-instance-list>
|
||||
|
||||
<adf-pagination
|
||||
[target]="processList">
|
||||
</adf-pagination>
|
||||
</div>
|
||||
|
@@ -0,0 +1,17 @@
|
||||
.process-list-inputs {
|
||||
margin-top: 100px;
|
||||
margin-bottom: 50px;
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.adf-reset-button {
|
||||
margin-top: 50px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.process-list-error-message {
|
||||
color: red;
|
||||
text-align: center;
|
||||
}
|
@@ -0,0 +1,124 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators, FormControl, AbstractControl } from '@angular/forms';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: './process-list-demo.component.html',
|
||||
styleUrls: [`./process-list-demo.component.scss`],
|
||||
})
|
||||
|
||||
export class ProcessListDemoComponent implements OnInit {
|
||||
|
||||
processListForm: FormGroup;
|
||||
|
||||
defaultAppId: number;
|
||||
|
||||
appId: number;
|
||||
|
||||
name: string;
|
||||
|
||||
processDefId: string;
|
||||
|
||||
state: string;
|
||||
|
||||
sort: string;
|
||||
|
||||
stateOptions = [
|
||||
{value: 'all', title: 'All'},
|
||||
{value: 'active', title: 'Active'},
|
||||
{value: 'completed', title: 'Completed'}
|
||||
];
|
||||
|
||||
sortOptions = [
|
||||
{value: 'created-asc', title: 'Created (asc)'},
|
||||
{value: 'created-desc', title: 'Created (desc)'},
|
||||
{value: 'due-asc', title: 'Due (asc)'},
|
||||
{value: 'due-desc', title: 'Due (desc)'}
|
||||
];
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private formBuilder: FormBuilder) {}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.route) {
|
||||
this.route.params.forEach((params: Params) => {
|
||||
this.defaultAppId = params['id'] ? +params['id'] : 0;
|
||||
});
|
||||
}
|
||||
this.appId = this.defaultAppId;
|
||||
this.buildForm();
|
||||
}
|
||||
|
||||
buildForm() {
|
||||
this.processListForm = this.formBuilder.group({
|
||||
processAppId: new FormControl(this.defaultAppId, [Validators.required, Validators.pattern('^[0-9]*$')]),
|
||||
processName: new FormControl(''),
|
||||
processDefinitionId: new FormControl(''),
|
||||
processState: new FormControl(''),
|
||||
processSort: new FormControl('')
|
||||
});
|
||||
|
||||
this.processListForm.valueChanges
|
||||
.debounceTime(500)
|
||||
.subscribe(processFilter => {
|
||||
if (this.isFormValid()) {
|
||||
this.filterProcesses(processFilter);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
filterProcesses(processFilter: any) {
|
||||
this.appId = processFilter.processAppId;
|
||||
this.name = processFilter.processName;
|
||||
this.processDefId = processFilter.processDefinitionId;
|
||||
this.state = processFilter.processState;
|
||||
this.sort = processFilter.processSort;
|
||||
}
|
||||
|
||||
isFormValid() {
|
||||
return this.processListForm && this.processListForm.dirty && this.processListForm.valid;
|
||||
}
|
||||
|
||||
resetProcessForm() {
|
||||
this.processListForm.reset();
|
||||
}
|
||||
|
||||
get processAppId(): AbstractControl {
|
||||
return this.processListForm.get('processAppId');
|
||||
}
|
||||
|
||||
get processName(): AbstractControl {
|
||||
return this.processListForm.get('processName');
|
||||
}
|
||||
|
||||
get processDefinitionId(): AbstractControl {
|
||||
return this.processListForm.get('processDefinitionId');
|
||||
}
|
||||
|
||||
get processState(): AbstractControl {
|
||||
return this.processListForm.get('processState');
|
||||
}
|
||||
|
||||
get processSort(): AbstractControl {
|
||||
return this.processListForm.get('processSort');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user