[AAE-3326] Content node selector - sort files by createdAt desc by de… (#6674)

* [AAE-3326] Content node selector - sort files by createdAt desc by default

* Fix process custom filter cloud e2e
This commit is contained in:
arditdomi
2021-02-16 16:16:06 +01:00
committed by GitHub
parent cf0c95b3d1
commit 76ac996c48
4 changed files with 36 additions and 3 deletions

View File

@@ -160,7 +160,7 @@ describe('Process list cloud', () => {
await setFilter({ order: SORT_DIRECTION.DESC}); await setFilter({ order: SORT_DIRECTION.DESC});
await waitTillContentLoaded(); await waitTillContentLoaded();
await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.ASC, 'Name')).toBe(true); await expect(await processList.getDataTable().checkListIsSorted(SORT_DIRECTION.DESC, 'Name')).toBe(true);
}); });
it('[C291783] Should display processes ordered by id when Id is selected from sort dropdown', async () => { it('[C291783] Should display processes ordered by id when Id is selected from sort dropdown', async () => {

View File

@@ -79,6 +79,7 @@
[contextMenuActions]="false" [contextMenuActions]="false"
[contentActions]="false" [contentActions]="false"
[allowDropFiles]="false" [allowDropFiles]="false"
[sorting]="sorting"
sortingMode="server" sortingMode="server"
[where]="where" [where]="where"
(folderChange)="onFolderChange($event)" (folderChange)="onFolderChange($event)"

View File

@@ -19,7 +19,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Node, NodeEntry, NodePaging, RequestScope, ResultSetPaging, SiteEntry, SitePaging } from '@alfresco/js-api'; import { Node, NodeEntry, NodePaging, RequestScope, ResultSetPaging, SiteEntry, SitePaging } from '@alfresco/js-api';
import { FileModel, FileUploadStatus, NodesApiService, setupTestBed, SitesService, UploadService } from '@alfresco/adf-core'; import { AppConfigService, FileModel, FileUploadStatus, NodesApiService, setupTestBed, SitesService, UploadService } from '@alfresco/adf-core';
import { of, throwError } from 'rxjs'; import { of, throwError } from 'rxjs';
import { DropdownBreadcrumbComponent } from '../breadcrumb'; import { DropdownBreadcrumbComponent } from '../breadcrumb';
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component'; import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
@@ -1247,5 +1247,31 @@ describe('ContentNodeSelectorPanelComponent', () => {
expect(toggleFiltersPanelButton).toEqual(null); expect(toggleFiltersPanelButton).toEqual(null);
}); });
}); });
describe('Sorting', () => {
let appConfigService: AppConfigService;
beforeEach(() => {
appConfigService = TestBed.inject(AppConfigService);
});
it('should read the sorting value from appConfig json in case it is present', async () => {
const fakeSortingConfig = ['fakeKey', 'fakeAsc'];
appConfigService.config = Object.assign(appConfigService.config, {
'adf-content-node-selector': { sorting: fakeSortingConfig }
});
fixture.detectChanges();
expect(component.sorting).toEqual(fakeSortingConfig);
});
it('should take default sorting when there is no content node selector sorting config in appConfig json', async () => {
appConfigService.config = null;
fixture.detectChanges();
expect(component.sorting).toEqual(['createdAt', 'desc']);
});
});
}); });
}); });

View File

@@ -36,7 +36,9 @@ import {
UploadService, UploadService,
FileUploadCompleteEvent, FileUploadCompleteEvent,
FileUploadDeleteEvent, FileUploadDeleteEvent,
FileModel FileModel,
AppConfigService,
DataSorting
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { Node, NodePaging, Pagination, SiteEntry, SitePaging, NodeEntry, QueryBody, RequestScope } from '@alfresco/js-api'; import { Node, NodePaging, Pagination, SiteEntry, SitePaging, NodeEntry, QueryBody, RequestScope } from '@alfresco/js-api';
@@ -250,6 +252,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
target: PaginatedComponent; target: PaginatedComponent;
preselectedNodes: NodeEntry[] = []; preselectedNodes: NodeEntry[] = [];
sorting: string[] | DataSorting;
searchPanelExpanded: boolean = false; searchPanelExpanded: boolean = false;
@@ -261,6 +264,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
private nodesApiService: NodesApiService, private nodesApiService: NodesApiService,
private uploadService: UploadService, private uploadService: UploadService,
private sitesService: SitesService, private sitesService: SitesService,
private appConfigService: AppConfigService,
private contentNodeSelectorPanelService: ContentNodeSelectorPanelService) { private contentNodeSelectorPanelService: ContentNodeSelectorPanelService) {
} }
@@ -331,6 +335,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
.subscribe((currentNode: Node) => { .subscribe((currentNode: Node) => {
this.currentFolder.emit(currentNode); this.currentFolder.emit(currentNode);
}); });
this.sorting = this.appConfigService.get('adf-content-node-selector.sorting', ['createdAt', 'desc']);
} }
ngOnDestroy() { ngOnDestroy() {