Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-7584] Filtering by type, name and content size (range) does not … #3853

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions projects/aca-content/src/lib/aca-content.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ <h1 class="aca-page-title">{{ 'APP.BROWSE.LIBRARIES.MENU.FAVORITE_LIBRARIES.TITL
[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>
Expand All @@ -65,7 +64,6 @@ <h1 class="aca-page-title">{{ 'APP.BROWSE.LIBRARIES.MENU.FAVORITE_LIBRARIES.TITL
[class]="column.class"
[sortable]="column.sortable"
[isHidden]="column.isHidden"
[sortingKey]="column.sortingKey || column.key"
>
</data-column>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ <h1 class="aca-page-title">{{ 'APP.BROWSE.FAVORITES.TITLE' | translate }}</h1>
[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>
Expand All @@ -60,7 +59,6 @@ <h1 class="aca-page-title">{{ 'APP.BROWSE.FAVORITES.TITLE' | translate }}</h1>
[class]="column.class"
[sortable]="column.sortable"
[isHidden]="column.isHidden"
[sortingKey]="column.sortingKey || column.key"
>
</data-column>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
[node]="nodeResult"
[allowDropFiles]="true"
[navigate]="false"
[sorting]="['name', 'asc']"
[sorting]="['name', 'ASC']"
[imageResolver]="imageResolver"
[headerFilters]="true"
[filterValue]="queryParams"
[isResizingEnabled]="true"
[blurOnResize]="false"
(node-dblclick)="handleNodeClick($event)"
(name-click)="handleNodeClick($event)"
(sorting-changed)="onSortingChanged($event)"
(filterSelection)="onFilterSelected($event)"
(error)="onError()"
>
Expand Down
16 changes: 9 additions & 7 deletions projects/aca-content/src/lib/components/files/files.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
}

Expand All @@ -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
});
}
Expand Down Expand Up @@ -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[] {
Expand Down Expand Up @@ -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();
Expand All @@ -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() {
Expand Down
53 changes: 8 additions & 45 deletions projects/aca-content/src/lib/directives/document-list.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`));
}
Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -154,7 +154,6 @@ export class DocumentListDirective implements OnInit, OnDestroy {

onReady() {
this.updateSelection();
this.restoreSorting();
}

private updateSelection() {
Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
]
});
Expand Down Expand Up @@ -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 }
})
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Loading