[ACS-7584] Filtering by type, name and content size (range) does not filter the data table

This commit is contained in:
Jacek Pluta
2024-05-22 09:38:51 +02:00
parent 9cb617ccae
commit d2697a4146
8 changed files with 127 additions and 73 deletions

View File

@@ -55,7 +55,6 @@ import { CommentsTabComponent } from './components/info-drawer/comments-tab/comm
import { LibraryMetadataTabComponent } from './components/info-drawer/library-metadata-tab/library-metadata-tab.component'; import { LibraryMetadataTabComponent } from './components/info-drawer/library-metadata-tab/library-metadata-tab.component';
import { MetadataTabComponent } from './components/info-drawer/metadata-tab/metadata-tab.component'; import { MetadataTabComponent } from './components/info-drawer/metadata-tab/metadata-tab.component';
import { VersionsTabComponent } from './components/info-drawer/versions-tab/versions-tab.component'; import { VersionsTabComponent } from './components/info-drawer/versions-tab/versions-tab.component';
import { PreviewComponent } from '@alfresco/aca-content/viewer';
import { ToggleEditOfflineComponent } from './components/toolbar/toggle-edit-offline/toggle-edit-offline.component'; import { ToggleEditOfflineComponent } from './components/toolbar/toggle-edit-offline/toggle-edit-offline.component';
import { ToggleFavoriteLibraryComponent } from './components/toolbar/toggle-favorite-library/toggle-favorite-library.component'; import { ToggleFavoriteLibraryComponent } from './components/toolbar/toggle-favorite-library/toggle-favorite-library.component';
import { ToggleFavoriteComponent } from './components/toolbar/toggle-favorite/toggle-favorite.component'; import { ToggleFavoriteComponent } from './components/toolbar/toggle-favorite/toggle-favorite.component';
@@ -132,7 +131,6 @@ export class ContentServiceExtensionModule {
'app.components.tabs.library.metadata': LibraryMetadataTabComponent, 'app.components.tabs.library.metadata': LibraryMetadataTabComponent,
'app.components.tabs.comments': CommentsTabComponent, 'app.components.tabs.comments': CommentsTabComponent,
'app.components.tabs.versions': VersionsTabComponent, 'app.components.tabs.versions': VersionsTabComponent,
'app.components.preview': PreviewComponent,
'app.toolbar.toggleInfoDrawer': ToggleInfoDrawerComponent, 'app.toolbar.toggleInfoDrawer': ToggleInfoDrawerComponent,
'app.toolbar.toggleFavorite': ToggleFavoriteComponent, 'app.toolbar.toggleFavorite': ToggleFavoriteComponent,
'app.toolbar.toggleFavoriteLibrary': ToggleFavoriteLibraryComponent, 'app.toolbar.toggleFavoriteLibrary': ToggleFavoriteLibraryComponent,

View File

@@ -45,7 +45,6 @@
[class]="column.class" [class]="column.class"
[sortable]="column.sortable" [sortable]="column.sortable"
[isHidden]="column.isHidden" [isHidden]="column.isHidden"
[sortingKey]="column.sortingKey || column.key"
> >
<ng-template let-context> <ng-template let-context>
<adf-dynamic-column [id]="column.template" [context]="context"> </adf-dynamic-column> <adf-dynamic-column [id]="column.template" [context]="context"> </adf-dynamic-column>
@@ -65,7 +64,6 @@
[class]="column.class" [class]="column.class"
[sortable]="column.sortable" [sortable]="column.sortable"
[isHidden]="column.isHidden" [isHidden]="column.isHidden"
[sortingKey]="column.sortingKey || column.key"
> >
</data-column> </data-column>
</ng-container> </ng-container>

View File

@@ -40,7 +40,6 @@
[class]="column.class" [class]="column.class"
[sortable]="column.sortable" [sortable]="column.sortable"
[isHidden]="column.isHidden" [isHidden]="column.isHidden"
[sortingKey]="column.sortingKey || column.key"
> >
<ng-template let-context> <ng-template let-context>
<adf-dynamic-column [id]="column.template" [context]="context"> </adf-dynamic-column> <adf-dynamic-column [id]="column.template" [context]="context"> </adf-dynamic-column>
@@ -60,7 +59,6 @@
[class]="column.class" [class]="column.class"
[sortable]="column.sortable" [sortable]="column.sortable"
[isHidden]="column.isHidden" [isHidden]="column.isHidden"
[sortingKey]="column.sortingKey || column.key"
> >
</data-column> </data-column>
</ng-container> </ng-container>

View File

@@ -23,7 +23,7 @@
[node]="nodeResult" [node]="nodeResult"
[allowDropFiles]="true" [allowDropFiles]="true"
[navigate]="false" [navigate]="false"
[sorting]="['name', 'asc']" [sorting]="['name', 'ASC']"
[imageResolver]="imageResolver" [imageResolver]="imageResolver"
[headerFilters]="true" [headerFilters]="true"
[filterValue]="queryParams" [filterValue]="queryParams"
@@ -31,6 +31,7 @@
[blurOnResize]="false" [blurOnResize]="false"
(node-dblclick)="handleNodeClick($event)" (node-dblclick)="handleNodeClick($event)"
(name-click)="handleNodeClick($event)" (name-click)="handleNodeClick($event)"
(sorting-changed)="onSortingChanged($event)"
(filterSelection)="onFilterSelected($event)" (filterSelection)="onFilterSelected($event)"
(error)="onError()" (error)="onError()"
> >

View File

@@ -39,7 +39,7 @@ import {
} from '@alfresco/aca-shared'; } from '@alfresco/aca-shared';
import { SetCurrentFolderAction, isAdmin, UploadFileVersionAction, showLoaderSelector } from '@alfresco/aca-shared/store'; import { SetCurrentFolderAction, isAdmin, UploadFileVersionAction, showLoaderSelector } from '@alfresco/aca-shared/store';
import { debounceTime, takeUntil } from 'rxjs/operators'; import { debounceTime, takeUntil } from 'rxjs/operators';
import { BreadcrumbModule, DocumentListModule, FileUploadEvent, FilterSearch, ShareDataRow, UploadModule } from '@alfresco/adf-content-services'; import { FilterSearch, ShareDataRow, FileUploadEvent, BreadcrumbModule, UploadModule, DocumentListModule } from '@alfresco/adf-content-services';
import { DocumentListPresetRef, ExtensionsModule } from '@alfresco/adf-extensions'; import { DocumentListPresetRef, ExtensionsModule } from '@alfresco/adf-extensions';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@@ -74,13 +74,14 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
isAdmin = false; isAdmin = false;
selectedNode: NodeEntry; selectedNode: NodeEntry;
queryParams = null; queryParams = null;
showLoader$ = this.store.select(showLoaderSelector); showLoader$ = this.store.select(showLoaderSelector);
private nodePath: PathElement[]; private nodePath: PathElement[];
columns: DocumentListPresetRef[] = []; columns: DocumentListPresetRef[] = [];
isFilterHeaderActive = false; isFilterHeaderActive = false;
constructor(private contentApi: ContentApiService, private nodeActionsService: NodeActionsService, private route: ActivatedRoute) { constructor(private route: ActivatedRoute, private contentApi: ContentApiService, private nodeActionsService: NodeActionsService) {
super(); super();
} }
@@ -102,9 +103,9 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
this.isValidPath = true; this.isValidPath = true;
if (node?.entry?.isFolder) { if (node?.entry?.isFolder) {
void this.updateCurrentNode(node.entry); this.updateCurrentNode(node.entry);
} else { } else {
void this.router.navigate(['/personal-files', node.entry.parentId], { this.router.navigate(['/personal-files', node.entry.parentId], {
replaceUrl: true replaceUrl: true
}); });
} }
@@ -144,7 +145,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
const currentNodeId = this.route.snapshot.paramMap.get('folderId'); const currentNodeId = this.route.snapshot.paramMap.get('folderId');
const urlWithoutParams = decodeURIComponent(this.router.url).split('?')[0]; const urlWithoutParams = decodeURIComponent(this.router.url).split('?')[0];
const urlToNavigate: string[] = this.getUrlToNavigate(urlWithoutParams, currentNodeId, nodeId); const urlToNavigate: string[] = this.getUrlToNavigate(urlWithoutParams, currentNodeId, nodeId);
void this.router.navigate(urlToNavigate); this.router.navigate(urlToNavigate);
} }
private getUrlToNavigate(currentURL: string, currentNodeId: string, nextNodeId: string): string[] { private getUrlToNavigate(currentURL: string, currentNodeId: string, nextNodeId: string): string[] {
@@ -344,12 +345,13 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
} }
onFilterSelected(activeFilters: FilterSearch[]) { onFilterSelected(activeFilters: FilterSearch[]) {
console.log(activeFilters)
if (activeFilters.length) { if (activeFilters.length) {
this.showHeader = ShowHeaderMode.Always; this.showHeader = ShowHeaderMode.Always;
this.isFilterHeaderActive = true; this.isFilterHeaderActive = true;
this.navigateToFilter(activeFilters); this.navigateToFilter(activeFilters);
} else { } else {
void this.router.navigate(['.'], { relativeTo: this.route }); this.router.navigate(['.'], { relativeTo: this.route });
this.isFilterHeaderActive = false; this.isFilterHeaderActive = false;
this.showHeader = ShowHeaderMode.Data; this.showHeader = ShowHeaderMode.Data;
this.onAllFilterCleared(); this.onAllFilterCleared();
@@ -368,7 +370,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
objectFromMap[filter.key] = paramValue; objectFromMap[filter.key] = paramValue;
}); });
void this.router.navigate([], { relativeTo: this.route, queryParams: objectFromMap }); this.router.navigate([], { relativeTo: this.route, queryParams: objectFromMap });
} }
onError() { onError() {

View File

@@ -66,6 +66,11 @@ export class DocumentListDirective implements OnInit, OnDestroy {
this.router.url.startsWith('/search-libraries'); this.router.url.startsWith('/search-libraries');
if (this.sortingPreferenceKey) { if (this.sortingPreferenceKey) {
const current = this.documentList.sorting;
const key = this.preferences.get(`${this.sortingPreferenceKey}.sorting.sortingKey`, current[0]);
const direction = this.preferences.get(`${this.sortingPreferenceKey}.sorting.direction`, current[1]);
if (this.preferences.hasItem(`${this.sortingPreferenceKey}.columns.width`)) { if (this.preferences.hasItem(`${this.sortingPreferenceKey}.columns.width`)) {
this.documentList.setColumnsWidths = JSON.parse(this.preferences.get(`${this.sortingPreferenceKey}.columns.width`)); this.documentList.setColumnsWidths = JSON.parse(this.preferences.get(`${this.sortingPreferenceKey}.columns.width`));
} }
@@ -78,11 +83,9 @@ export class DocumentListDirective implements OnInit, OnDestroy {
this.documentList.setColumnsOrder = JSON.parse(this.preferences.get(`${this.sortingPreferenceKey}.columns.order`)); this.documentList.setColumnsOrder = JSON.parse(this.preferences.get(`${this.sortingPreferenceKey}.columns.order`));
} }
const mode = this.documentList.sortingMode; this.documentList.sorting = [key, direction];
this.preferences.set(`${this.sortingPreferenceKey}.sorting.mode`, mode); // TODO: bug in ADF, the `sorting` binding is not updated when changed from code
if (mode === 'server') { this.documentList.data.setSorting({ key, direction });
this.restoreSorting();
}
} }
this.documentList.ready this.documentList.ready
@@ -109,9 +112,6 @@ export class DocumentListDirective implements OnInit, OnDestroy {
@HostListener('sorting-changed', ['$event']) @HostListener('sorting-changed', ['$event'])
onSortingChanged(event: CustomEvent) { onSortingChanged(event: CustomEvent) {
if (this.sortingPreferenceKey) { if (this.sortingPreferenceKey) {
if (this.documentList.sortingMode === 'client') {
this.storePreviousSorting();
}
this.preferences.set(`${this.sortingPreferenceKey}.sorting.key`, event.detail.key); this.preferences.set(`${this.sortingPreferenceKey}.sorting.key`, event.detail.key);
this.preferences.set(`${this.sortingPreferenceKey}.sorting.sortingKey`, event.detail.sortingKey); this.preferences.set(`${this.sortingPreferenceKey}.sorting.sortingKey`, event.detail.sortingKey);
this.preferences.set(`${this.sortingPreferenceKey}.sorting.direction`, event.detail.direction); this.preferences.set(`${this.sortingPreferenceKey}.sorting.direction`, event.detail.direction);
@@ -154,7 +154,6 @@ export class DocumentListDirective implements OnInit, OnDestroy {
onReady() { onReady() {
this.updateSelection(); this.updateSelection();
this.restoreSorting();
} }
private updateSelection() { private updateSelection() {
@@ -177,40 +176,4 @@ export class DocumentListDirective implements OnInit, OnDestroy {
this.documentList.resetSelection(); this.documentList.resetSelection();
this.store.dispatch(new SetSelectedNodesAction([])); this.store.dispatch(new SetSelectedNodesAction([]));
} }
private setSorting(key: string, direction: string) {
this.documentList.sorting = [key, direction];
this.documentList.data.setSorting({ key, direction });
}
private storePreviousSorting() {
if (this.preferences.hasItem(`${this.sortingPreferenceKey}.sorting.key`)) {
const keyToSave = this.preferences.get(`${this.sortingPreferenceKey}.sorting.key`);
if (!keyToSave.includes(this.documentList.sorting[0])) {
const dirToSave = this.preferences.get(`${this.sortingPreferenceKey}.sorting.direction`);
this.preferences.set(`${this.sortingPreferenceKey}.sorting.previousKey`, keyToSave);
this.preferences.set(`${this.sortingPreferenceKey}.sorting.previousDirection`, dirToSave);
}
}
}
private restoreSorting() {
const [previousKey, previousDir] = [
this.preferences.get(`${this.sortingPreferenceKey}.sorting.previousKey`, null),
this.preferences.get(`${this.sortingPreferenceKey}.sorting.previousDirection`, null)
];
const [currentKey, currentDir] = [
this.preferences.get(`${this.sortingPreferenceKey}.sorting.key`, null),
this.preferences.get(`${this.sortingPreferenceKey}.sorting.direction`, null)
];
if (previousKey) {
this.setSorting(previousKey, previousDir);
}
if (currentKey) {
this.setSorting(currentKey, currentDir);
}
}
} }

View File

@@ -25,7 +25,7 @@
import { DocumentListComponent, ShareDataRow, UploadService } from '@alfresco/adf-content-services'; import { DocumentListComponent, ShareDataRow, UploadService } from '@alfresco/adf-content-services';
import { ShowHeaderMode } from '@alfresco/adf-core'; import { ShowHeaderMode } from '@alfresco/adf-core';
import { ContentActionRef, DocumentListPresetRef, SelectionState } from '@alfresco/adf-extensions'; import { ContentActionRef, DocumentListPresetRef, SelectionState } from '@alfresco/adf-extensions';
import { OnDestroy, OnInit, OnChanges, ViewChild, SimpleChanges, Directive, inject, HostListener } from '@angular/core'; import { OnDestroy, OnInit, OnChanges, ViewChild, SimpleChanges, Directive, inject } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { NodeEntry, Node, NodePaging } from '@alfresco/js-api'; import { NodeEntry, Node, NodePaging } from '@alfresco/js-api';
import { Observable, Subject, Subscription } from 'rxjs'; import { Observable, Subject, Subscription } from 'rxjs';
@@ -207,7 +207,6 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
return location.href.includes('viewer:view'); return location.href.includes('viewer:view');
} }
@HostListener('sorting-changed', ['$event'])
onSortingChanged(event: any) { onSortingChanged(event: any) {
this.filterSorting = event.detail.key + '-' + event.detail.direction; this.filterSorting = event.detail.key + '-' + event.detail.direction;
} }

View File

@@ -25,18 +25,64 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PageComponent } from './document-base-page.component'; import { PageComponent } from './document-base-page.component';
import { AppState, ReloadDocumentListAction, SetSelectedNodesAction, ViewNodeAction } from '@alfresco/aca-shared/store'; import { AppState, ReloadDocumentListAction, SetSelectedNodesAction, ViewNodeAction } from '@alfresco/aca-shared/store';
import { AppExtensionService, LibTestingModule, discoveryApiServiceMockValue, DocumentBasePageServiceMock } from '@alfresco/aca-shared'; import { AppExtensionService } from '@alfresco/aca-shared';
import { NodeEntry, NodePaging } from '@alfresco/js-api'; import { NodeEntry, NodePaging, RepositoryInfo, VersionInfo } from '@alfresco/js-api';
import { DocumentBasePageService } from './document-base-page.service'; import { DocumentBasePageService } from './document-base-page.service';
import { Store } from '@ngrx/store'; import { Store, StoreModule } from '@ngrx/store';
import { Component } from '@angular/core'; import { Component, Injectable } from '@angular/core';
import { DiscoveryApiService, DocumentListComponent } from '@alfresco/adf-content-services'; import { DiscoveryApiService, DocumentListComponent } from '@alfresco/adf-content-services';
import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { AuthModule, MaterialModule } from '@alfresco/adf-core'; import { AuthModule, MaterialModule, PipeModule } from '@alfresco/adf-core';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { Subscription } from 'rxjs'; import { EffectsModule } from '@ngrx/effects';
import { BehaviorSubject, Observable, of, Subscription } from 'rxjs';
export const INITIAL_APP_STATE: AppState = {
appName: 'Alfresco Content Application',
logoPath: 'assets/images/alfresco-logo-white.svg',
customCssPath: '',
webFontPath: '',
sharedUrl: '',
user: {
isAdmin: null,
id: null,
firstName: '',
lastName: ''
},
selection: {
nodes: [],
libraries: [],
isEmpty: true,
count: 0
},
navigation: {
currentFolder: null
},
currentNodeVersion: null,
infoDrawerOpened: false,
infoDrawerPreview: false,
infoDrawerMetadataAspect: '',
showFacetFilter: true,
fileUploadingDialog: true,
showLoader: false,
repository: {
status: {
isQuickShareEnabled: true
}
} as any
};
@Injectable()
class DocumentBasePageServiceMock extends DocumentBasePageService {
canUpdateNode(): boolean {
return true;
}
canUploadContent(): boolean {
return true;
}
}
@Component({ @Component({
selector: 'aca-test', selector: 'aca-test',
@@ -61,11 +107,47 @@ describe('PageComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [LibTestingModule, MaterialModule, AuthModule.forRoot()], imports: [
NoopAnimationsModule,
HttpClientModule,
RouterTestingModule,
MaterialModule,
AuthModule.forRoot(),
StoreModule.forRoot(
{ app: (state) => state },
{
initialState: {
app: INITIAL_APP_STATE
},
runtimeChecks: {
strictStateImmutability: false,
strictActionImmutability: false
}
}
),
EffectsModule.forRoot([]),
PipeModule
],
declarations: [TestComponent], declarations: [TestComponent],
providers: [ providers: [
{ provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock }, {
{ provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue }, provide: DocumentBasePageService,
useClass: DocumentBasePageServiceMock
},
{
provide: DiscoveryApiService,
useValue: {
ecmProductInfo$: new BehaviorSubject<RepositoryInfo | null>(null),
getEcmProductInfo: (): Observable<RepositoryInfo> =>
of(
new RepositoryInfo({
version: {
major: '10.0.0'
} as VersionInfo
})
)
}
},
AppExtensionService AppExtensionService
] ]
}); });
@@ -216,7 +298,20 @@ describe('Info Drawer state', () => {
providers: [ providers: [
{ provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock }, { provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock },
AppExtensionService, AppExtensionService,
{ provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue }, {
provide: DiscoveryApiService,
useValue: {
ecmProductInfo$: new BehaviorSubject<RepositoryInfo | null>(null),
getEcmProductInfo: (): Observable<RepositoryInfo> =>
of(
new RepositoryInfo({
version: {
major: '10.0.0'
} as VersionInfo
})
)
}
},
provideMockStore({ provideMockStore({
initialState: { app: appState } initialState: { app: appState }
}) })
@@ -242,7 +337,7 @@ describe('Info Drawer state', () => {
window.history.pushState({}, null, `${locationHref}#test`); window.history.pushState({}, null, `${locationHref}#test`);
fixture.detectChanges(); fixture.detectChanges();
void fixture.whenStable().then(() => { fixture.whenStable().then(() => {
component.infoDrawerOpened$.subscribe((state) => { component.infoDrawerOpened$.subscribe((state) => {
expect(state).toBe(true); expect(state).toBe(true);
done(); done();
@@ -261,7 +356,7 @@ describe('Info Drawer state', () => {
window.history.pushState({}, null, `${locationHref}#test(viewer:view)`); window.history.pushState({}, null, `${locationHref}#test(viewer:view)`);
fixture.detectChanges(); fixture.detectChanges();
void fixture.whenStable().then(() => { fixture.whenStable().then(() => {
component.infoDrawerOpened$.subscribe((state) => { component.infoDrawerOpened$.subscribe((state) => {
expect(state).toBe(true); expect(state).toBe(true);
done(); done();