siva kumar 6f526c3862 [ADF-3773] Filter definition in a component APS2 (#4016)
* * Genearated EditTaskFilterCloudComponent

* * Added unit tests to the editTaskFiltercomponent
* Added  unit tests to the  taskFilterDialog
* Added id selector

* * Added translation keys to the editTaskFilter component* Added translation keys related to the editTask in the en.json file* Changed FilterRepresentationModel to TaskFilterCloudRepresentationModel* Refactored editTaskFilterComponent* Created a deleteFilter method in the taskService

* * Refactored editTaskFilterComponent

* * used new editTaskFilterCloud component in the demo shell

* * Refactored editTaskFilter component* Updated unit tests

* Refresh the filters after the action
Reset the values after the EditComponentChanges
Improve the code

* * Added translate keys in demo shell for edittaskDialog component
* Modified  translate keys for editTaskFilterCLoud component

* * Added documentation to the editTaskFilter component.* Fixed a typo.* Fixed Failing Test cases. * Added a EditTaskFilterCloud png

* rebase to dev
fix bugs and improve integration

* * Fixed tsLint css error

* * Fixed tslint css error * Fixed one unit test

* Move the concern of save delete saveAs into the component
fix integration with Demo shell
fix bugs

* * Updated unit test to the recent changes

* * Updated editTaskFIlter doc
* Added unit tests to the taskFIlterDialog component

* * Updated editTaskFIlter doc* Added unit tests to the taskFIlterDialog component

* * Merged task filter models to a single model

* * Updated tests with new taskfilter model

* * Updated documentation for new taskfilter model

* * Used new taskfilter model in the demo

* * Improved filter selection method

* * Removed unnecessory tanslate keys from demo shell
* Modified filterCloudModel
* fixed unit tests to the recent changes

* * Improved change handling for filter properties

* * Improved unit tests
2018-12-05 15:27:21 +00:00

129 lines
3.9 KiB
TypeScript

/*!
* @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
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, ViewChild, OnInit } from '@angular/core';
import {
TaskListCloudComponent,
TaskFiltersCloudComponent,
TaskListCloudSortingModel,
TaskFilterCloudModel,
EditTaskFilterCloudComponent
} from '@alfresco/adf-process-services-cloud';
import { UserPreferencesService } from '@alfresco/adf-core';
import { Observable } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router';
@Component({
selector: 'app-task-list-cloud-demo',
templateUrl: 'task-list-cloud-demo.component.html',
styleUrls: ['task-list-cloud-demo.component.scss']
})
export class TaskListCloudDemoComponent implements OnInit {
@ViewChild('taskCloud')
taskCloud: TaskListCloudComponent;
@ViewChild('taskFiltersCloud')
taskFiltersCloud: TaskFiltersCloudComponent;
appDefinitionList: Observable<any>;
applicationName;
status: string = '';
showStartTask = false;
clickedRow: string = '';
filterTaskParam;
sortArray: TaskListCloudSortingModel[];
editedFilter: TaskFilterCloudModel;
currentFilter: TaskFilterCloudModel;
constructor(
private route: ActivatedRoute,
private router: Router,
private userPreference: UserPreferencesService
) {}
ngOnInit() {
this.route.params.subscribe((params) => {
this.applicationName = params.applicationName;
});
this.route.queryParams.subscribe( (params) => {
this.onFilterChange(params);
});
}
onFilterSelected(filter: TaskFilterCloudModel) {
this.currentFilter = Object.assign({}, filter);
this.sortArray = [new TaskListCloudSortingModel({ orderBy: this.currentFilter.sort, direction: this.currentFilter.order})];
this.router.navigate([`/cloud/${this.applicationName}/tasks/`], {
queryParams: this.currentFilter
});
}
onFilterChange(filter: any) {
this.editedFilter = Object.assign({}, this.currentFilter, filter);
this.sortArray = [new TaskListCloudSortingModel({ orderBy: this.editedFilter.sort, direction: this.editedFilter.order})];
}
onStartTask() {
this.showStartTask = true;
}
onStartTaskSuccess() {
this.showStartTask = false;
this.filterTaskParam = { name: 'My tasks'};
}
onCancelStartTask() {
this.showStartTask = false;
}
onChangePageSize(event) {
this.userPreference.paginationSize = event.maxItems;
}
onRowClick($event) {
this.clickedRow = $event;
}
onEditActions(event: any) {
if (event.actionType === EditTaskFilterCloudComponent.ACTION_SAVE) {
this.save(event.id);
} else if (event.actionType === EditTaskFilterCloudComponent.ACTION_SAVE_AS) {
this.saveAs(event.id);
} else if (event.actionType === EditTaskFilterCloudComponent.ACTION_DELETE) {
this.deleteFilter();
}
}
saveAs(filterId) {
this.taskFiltersCloud.filterParam = <any> {id : filterId};
this.taskFiltersCloud.getFilters(this.applicationName);
}
save(filterId) {
this.taskFiltersCloud.filterParam = <any> {id : filterId};
this.taskFiltersCloud.getFilters(this.applicationName);
}
deleteFilter() {
this.taskFiltersCloud.getFilters(this.applicationName);
}
}