[ADF-5219] Refactor Document list Filters (#6092)

* First commit

* Second commit

* Commit 4

* Add unit tests

* Fix unit tests

* Add documentation for breaking change

* Fix rebase

* Fix unit test
This commit is contained in:
davidcanonieto
2020-09-25 11:08:15 +02:00
committed by GitHub
parent df2e53110c
commit b0a46f7eac
31 changed files with 796 additions and 631 deletions

View File

@@ -39,7 +39,8 @@ import {
UploadFilesEvent,
ConfirmDialogComponent,
LibraryDialogComponent,
ContentMetadataService
ContentMetadataService,
FilterSearch
} from '@alfresco/adf-content-services';
import { SelectAppsDialogComponent, ProcessFormRenderingService } from '@alfresco/adf-process-services';
@@ -79,9 +80,9 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
toolbarColor = 'default';
selectionModes = [
{value: 'none', viewValue: 'None'},
{value: 'single', viewValue: 'Single'},
{value: 'multiple', viewValue: 'Multiple'}
{ value: 'none', viewValue: 'None' },
{ value: 'single', viewValue: 'Single' },
{ value: 'multiple', viewValue: 'Multiple' }
];
// The identifier of a node. You can also use one of these well-known aliases: -my- | -shared- | -root-
@@ -165,7 +166,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
navigationRoute = '/files';
@Input()
enableCustomHeaderFilter = false;
headerFilters = false;
@Input()
paramValues: Map<any, any> = null;
@@ -365,7 +366,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
getCurrentDocumentListNode(): MinimalNodeEntity[] {
if (this.documentList.folderNode) {
return [{entry: this.documentList.folderNode}];
return [{ entry: this.documentList.folderNode }];
} else {
return [];
}
@@ -464,7 +465,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
if (this.contentService.hasAllowableOperations(contentEntry, 'update')) {
this.dialog.open(VersionManagerDialogAdapterComponent, {
data: {contentEntry: contentEntry, showComments: showComments, allowDownload: allowDownload},
data: { contentEntry: contentEntry, showComments: showComments, allowDownload: allowDownload },
panelClass: 'adf-version-manager-dialog',
width: '630px'
});
@@ -677,11 +678,30 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
return '';
}
onFilterUpdate(newNodePaging: NodePaging) {
this.nodeResult = newNodePaging;
onFilterSelected(activeFilters: FilterSearch[]) {
if (activeFilters.length) {
this.navigateToFilter(activeFilters);
} else {
this.clearFilterNavigation();
}
}
onAllFilterCleared() {
navigateToFilter(activeFilters: FilterSearch[]) {
const objectFromMap = {};
activeFilters.forEach((filter: FilterSearch) => {
let paramValue = null;
if (filter.value && filter.value.from && filter.value.to) {
paramValue = `${filter.value.from}||${filter.value.to}`;
} else {
paramValue = filter.value;
}
objectFromMap[filter.key] = paramValue;
});
this.router.navigate([], { relativeTo: this.route, queryParams: objectFromMap });
}
clearFilterNavigation() {
this.documentList.node = null;
if (this.currentFolderId === '-my-') {
this.router.navigate([this.navigationRoute, '']);
@@ -691,21 +711,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
this.documentList.reload();
}
onFilterSelected(currentActiveFilters: Map<string, string>) {
const objectFromMap = {};
currentActiveFilters.forEach((value: any, key) => {
let paramValue = null;
if (value && value.from && value.to) {
paramValue = `${value.from}||${value.to}`;
} else {
paramValue = value;
}
objectFromMap[key] = paramValue;
});
this.router.navigate([], { relativeTo: this.route, queryParams: objectFromMap });
}
setPreselectNodes(nodes: string) {
this.selectedNodes = this.getArrayFromString(nodes);
this.documentList.reload();