mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-10 14:11:17 +00:00
[ACS-7584] Filtering by type, name and content size (range) does not filter the data table
This commit is contained in:
@@ -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 { MetadataTabComponent } from './components/info-drawer/metadata-tab/metadata-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 { ToggleFavoriteLibraryComponent } from './components/toolbar/toggle-favorite-library/toggle-favorite-library.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.comments': CommentsTabComponent,
|
||||
'app.components.tabs.versions': VersionsTabComponent,
|
||||
'app.components.preview': PreviewComponent,
|
||||
'app.toolbar.toggleInfoDrawer': ToggleInfoDrawerComponent,
|
||||
'app.toolbar.toggleFavorite': ToggleFavoriteComponent,
|
||||
'app.toolbar.toggleFavoriteLibrary': ToggleFavoriteLibraryComponent,
|
||||
|
@@ -45,7 +45,6 @@
|
||||
[class]="column.class"
|
||||
[sortable]="column.sortable"
|
||||
[isHidden]="column.isHidden"
|
||||
[sortingKey]="column.sortingKey || column.key"
|
||||
>
|
||||
<ng-template let-context>
|
||||
<adf-dynamic-column [id]="column.template" [context]="context"> </adf-dynamic-column>
|
||||
@@ -65,7 +64,6 @@
|
||||
[class]="column.class"
|
||||
[sortable]="column.sortable"
|
||||
[isHidden]="column.isHidden"
|
||||
[sortingKey]="column.sortingKey || column.key"
|
||||
>
|
||||
</data-column>
|
||||
</ng-container>
|
||||
|
@@ -40,7 +40,6 @@
|
||||
[class]="column.class"
|
||||
[sortable]="column.sortable"
|
||||
[isHidden]="column.isHidden"
|
||||
[sortingKey]="column.sortingKey || column.key"
|
||||
>
|
||||
<ng-template let-context>
|
||||
<adf-dynamic-column [id]="column.template" [context]="context"> </adf-dynamic-column>
|
||||
@@ -60,7 +59,6 @@
|
||||
[class]="column.class"
|
||||
[sortable]="column.sortable"
|
||||
[isHidden]="column.isHidden"
|
||||
[sortingKey]="column.sortingKey || column.key"
|
||||
>
|
||||
</data-column>
|
||||
</ng-container>
|
||||
|
@@ -23,7 +23,7 @@
|
||||
[node]="nodeResult"
|
||||
[allowDropFiles]="true"
|
||||
[navigate]="false"
|
||||
[sorting]="['name', 'asc']"
|
||||
[sorting]="['name', 'ASC']"
|
||||
[imageResolver]="imageResolver"
|
||||
[headerFilters]="true"
|
||||
[filterValue]="queryParams"
|
||||
@@ -31,6 +31,7 @@
|
||||
[blurOnResize]="false"
|
||||
(node-dblclick)="handleNodeClick($event)"
|
||||
(name-click)="handleNodeClick($event)"
|
||||
(sorting-changed)="onSortingChanged($event)"
|
||||
(filterSelection)="onFilterSelected($event)"
|
||||
(error)="onError()"
|
||||
>
|
||||
|
@@ -39,7 +39,7 @@ import {
|
||||
} from '@alfresco/aca-shared';
|
||||
import { SetCurrentFolderAction, isAdmin, UploadFileVersionAction, showLoaderSelector } from '@alfresco/aca-shared/store';
|
||||
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 { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -74,13 +74,14 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
isAdmin = false;
|
||||
selectedNode: NodeEntry;
|
||||
queryParams = null;
|
||||
|
||||
showLoader$ = this.store.select(showLoaderSelector);
|
||||
private nodePath: PathElement[];
|
||||
|
||||
columns: DocumentListPresetRef[] = [];
|
||||
isFilterHeaderActive = false;
|
||||
|
||||
constructor(private contentApi: ContentApiService, private nodeActionsService: NodeActionsService, private route: ActivatedRoute) {
|
||||
constructor(private route: ActivatedRoute, private contentApi: ContentApiService, private nodeActionsService: NodeActionsService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -102,9 +103,9 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
this.isValidPath = true;
|
||||
|
||||
if (node?.entry?.isFolder) {
|
||||
void this.updateCurrentNode(node.entry);
|
||||
this.updateCurrentNode(node.entry);
|
||||
} else {
|
||||
void this.router.navigate(['/personal-files', node.entry.parentId], {
|
||||
this.router.navigate(['/personal-files', node.entry.parentId], {
|
||||
replaceUrl: true
|
||||
});
|
||||
}
|
||||
@@ -144,7 +145,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
const currentNodeId = this.route.snapshot.paramMap.get('folderId');
|
||||
const urlWithoutParams = decodeURIComponent(this.router.url).split('?')[0];
|
||||
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[] {
|
||||
@@ -344,12 +345,13 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
onFilterSelected(activeFilters: FilterSearch[]) {
|
||||
console.log(activeFilters)
|
||||
if (activeFilters.length) {
|
||||
this.showHeader = ShowHeaderMode.Always;
|
||||
this.isFilterHeaderActive = true;
|
||||
this.navigateToFilter(activeFilters);
|
||||
} else {
|
||||
void this.router.navigate(['.'], { relativeTo: this.route });
|
||||
this.router.navigate(['.'], { relativeTo: this.route });
|
||||
this.isFilterHeaderActive = false;
|
||||
this.showHeader = ShowHeaderMode.Data;
|
||||
this.onAllFilterCleared();
|
||||
@@ -368,7 +370,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
objectFromMap[filter.key] = paramValue;
|
||||
});
|
||||
|
||||
void this.router.navigate([], { relativeTo: this.route, queryParams: objectFromMap });
|
||||
this.router.navigate([], { relativeTo: this.route, queryParams: objectFromMap });
|
||||
}
|
||||
|
||||
onError() {
|
||||
|
@@ -66,6 +66,11 @@ export class DocumentListDirective implements OnInit, OnDestroy {
|
||||
this.router.url.startsWith('/search-libraries');
|
||||
|
||||
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`)) {
|
||||
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`));
|
||||
}
|
||||
|
||||
const mode = this.documentList.sortingMode;
|
||||
this.preferences.set(`${this.sortingPreferenceKey}.sorting.mode`, mode);
|
||||
if (mode === 'server') {
|
||||
this.restoreSorting();
|
||||
}
|
||||
this.documentList.sorting = [key, direction];
|
||||
// TODO: bug in ADF, the `sorting` binding is not updated when changed from code
|
||||
this.documentList.data.setSorting({ key, direction });
|
||||
}
|
||||
|
||||
this.documentList.ready
|
||||
@@ -109,9 +112,6 @@ export class DocumentListDirective implements OnInit, OnDestroy {
|
||||
@HostListener('sorting-changed', ['$event'])
|
||||
onSortingChanged(event: CustomEvent) {
|
||||
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.sortingKey`, event.detail.sortingKey);
|
||||
this.preferences.set(`${this.sortingPreferenceKey}.sorting.direction`, event.detail.direction);
|
||||
@@ -154,7 +154,6 @@ export class DocumentListDirective implements OnInit, OnDestroy {
|
||||
|
||||
onReady() {
|
||||
this.updateSelection();
|
||||
this.restoreSorting();
|
||||
}
|
||||
|
||||
private updateSelection() {
|
||||
@@ -177,40 +176,4 @@ export class DocumentListDirective implements OnInit, OnDestroy {
|
||||
this.documentList.resetSelection();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@
|
||||
import { DocumentListComponent, ShareDataRow, UploadService } from '@alfresco/adf-content-services';
|
||||
import { ShowHeaderMode } from '@alfresco/adf-core';
|
||||
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 { NodeEntry, Node, NodePaging } from '@alfresco/js-api';
|
||||
import { Observable, Subject, Subscription } from 'rxjs';
|
||||
@@ -207,7 +207,6 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
|
||||
return location.href.includes('viewer:view');
|
||||
}
|
||||
|
||||
@HostListener('sorting-changed', ['$event'])
|
||||
onSortingChanged(event: any) {
|
||||
this.filterSorting = event.detail.key + '-' + event.detail.direction;
|
||||
}
|
||||
|
@@ -25,18 +25,64 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { PageComponent } from './document-base-page.component';
|
||||
import { AppState, ReloadDocumentListAction, SetSelectedNodesAction, ViewNodeAction } from '@alfresco/aca-shared/store';
|
||||
import { AppExtensionService, LibTestingModule, discoveryApiServiceMockValue, DocumentBasePageServiceMock } from '@alfresco/aca-shared';
|
||||
import { NodeEntry, NodePaging } from '@alfresco/js-api';
|
||||
import { AppExtensionService } from '@alfresco/aca-shared';
|
||||
import { NodeEntry, NodePaging, RepositoryInfo, VersionInfo } from '@alfresco/js-api';
|
||||
import { DocumentBasePageService } from './document-base-page.service';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Component } from '@angular/core';
|
||||
import { Store, StoreModule } from '@ngrx/store';
|
||||
import { Component, Injectable } from '@angular/core';
|
||||
import { DiscoveryApiService, DocumentListComponent } from '@alfresco/adf-content-services';
|
||||
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 { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
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({
|
||||
selector: 'aca-test',
|
||||
@@ -61,11 +107,47 @@ describe('PageComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
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],
|
||||
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
|
||||
]
|
||||
});
|
||||
@@ -216,7 +298,20 @@ describe('Info Drawer state', () => {
|
||||
providers: [
|
||||
{ provide: DocumentBasePageService, useClass: DocumentBasePageServiceMock },
|
||||
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({
|
||||
initialState: { app: appState }
|
||||
})
|
||||
@@ -242,7 +337,7 @@ describe('Info Drawer state', () => {
|
||||
window.history.pushState({}, null, `${locationHref}#test`);
|
||||
fixture.detectChanges();
|
||||
|
||||
void fixture.whenStable().then(() => {
|
||||
fixture.whenStable().then(() => {
|
||||
component.infoDrawerOpened$.subscribe((state) => {
|
||||
expect(state).toBe(true);
|
||||
done();
|
||||
@@ -261,7 +356,7 @@ describe('Info Drawer state', () => {
|
||||
window.history.pushState({}, null, `${locationHref}#test(viewer:view)`);
|
||||
fixture.detectChanges();
|
||||
|
||||
void fixture.whenStable().then(() => {
|
||||
fixture.whenStable().then(() => {
|
||||
component.infoDrawerOpened$.subscribe((state) => {
|
||||
expect(state).toBe(true);
|
||||
done();
|
||||
|
Reference in New Issue
Block a user