mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACA-4728] fix file order in viewer (#3631)
* [ACA-4728] fix file order in viewer * [ACA-4728] refactor viewer and preview, save and restore previous sorting in viewer and document pages when client sorting, add viewer unit tests * [ACA-4728] remove duplicated license * [ACA-4728] add missing imports * [ACA-4728] address comments, improve initial sorting setting, improve tests, reduce duplication * [ACA-4728] further reduce code duplication, remove/replace faulty unit tests * [ACA-4728] move reusable unit test config to testing module * [ACA-4728] address comments * [ACA-4728] address comment - remove reduntant if * [ACA-4728] update headers in new files
This commit is contained in:
committed by
GitHub
parent
12c0b87c09
commit
92a1e25271
@@ -63,7 +63,7 @@ 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/preview';
|
||||
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';
|
||||
|
@@ -45,6 +45,7 @@
|
||||
[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>
|
||||
@@ -64,6 +65,7 @@
|
||||
[class]="column.class"
|
||||
[sortable]="column.sortable"
|
||||
[isHidden]="column.isHidden"
|
||||
[sortingKey]="column.sortingKey || column.key"
|
||||
>
|
||||
</data-column>
|
||||
</ng-container>
|
||||
|
@@ -40,6 +40,7 @@
|
||||
[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>
|
||||
@@ -59,6 +60,7 @@
|
||||
[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,7 +31,6 @@
|
||||
[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 { FilterSearch, ShareDataRow, FileUploadEvent, BreadcrumbModule, UploadModule, DocumentListModule } from '@alfresco/adf-content-services';
|
||||
import { BreadcrumbModule, DocumentListModule, FileUploadEvent, FilterSearch, ShareDataRow, UploadModule } from '@alfresco/adf-content-services';
|
||||
import { DocumentListPresetRef, ExtensionsModule } from '@alfresco/adf-extensions';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -74,14 +74,13 @@ 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 route: ActivatedRoute, private contentApi: ContentApiService, private nodeActionsService: NodeActionsService) {
|
||||
constructor(private contentApi: ContentApiService, private nodeActionsService: NodeActionsService, private route: ActivatedRoute) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -103,9 +102,9 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
this.isValidPath = true;
|
||||
|
||||
if (node?.entry?.isFolder) {
|
||||
this.updateCurrentNode(node.entry);
|
||||
void this.updateCurrentNode(node.entry);
|
||||
} else {
|
||||
this.router.navigate(['/personal-files', node.entry.parentId], {
|
||||
void this.router.navigate(['/personal-files', node.entry.parentId], {
|
||||
replaceUrl: true
|
||||
});
|
||||
}
|
||||
@@ -145,7 +144,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);
|
||||
this.router.navigate(urlToNavigate);
|
||||
void this.router.navigate(urlToNavigate);
|
||||
}
|
||||
|
||||
private getUrlToNavigate(currentURL: string, currentNodeId: string, nextNodeId: string): string[] {
|
||||
@@ -350,7 +349,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
this.isFilterHeaderActive = true;
|
||||
this.navigateToFilter(activeFilters);
|
||||
} else {
|
||||
this.router.navigate(['.'], { relativeTo: this.route });
|
||||
void this.router.navigate(['.'], { relativeTo: this.route });
|
||||
this.isFilterHeaderActive = false;
|
||||
this.showHeader = ShowHeaderMode.Data;
|
||||
this.onAllFilterCleared();
|
||||
@@ -369,7 +368,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
objectFromMap[filter.key] = paramValue;
|
||||
});
|
||||
|
||||
this.router.navigate([], { relativeTo: this.route, queryParams: objectFromMap });
|
||||
void this.router.navigate([], { relativeTo: this.route, queryParams: objectFromMap });
|
||||
}
|
||||
|
||||
onError() {
|
||||
|
@@ -44,6 +44,7 @@
|
||||
[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>
|
||||
@@ -63,6 +64,7 @@
|
||||
[resizable]="column.resizable"
|
||||
[sortable]="column.sortable"
|
||||
[isHidden]="column.isHidden"
|
||||
[sortingKey]="column.sortingKey || column.key"
|
||||
>
|
||||
</data-column>
|
||||
</ng-container>
|
||||
|
@@ -40,6 +40,7 @@
|
||||
[draggable]="column.draggable"
|
||||
[resizable]="column.resizable"
|
||||
[isHidden]="column.isHidden"
|
||||
[sortingKey]="column.sortingKey || column.key"
|
||||
>
|
||||
<ng-template let-context>
|
||||
<adf-dynamic-column [id]="column.template" [context]="context"> </adf-dynamic-column>
|
||||
@@ -59,6 +60,7 @@
|
||||
[isHidden]="column.isHidden"
|
||||
[draggable]="column.draggable"
|
||||
[resizable]="column.resizable"
|
||||
[sortingKey]="column.sortingKey || column.key"
|
||||
>
|
||||
</data-column>
|
||||
</ng-container>
|
||||
|
@@ -39,6 +39,7 @@
|
||||
[isHidden]="column.isHidden"
|
||||
[draggable]="column.draggable"
|
||||
[resizable]="column.resizable"
|
||||
[sortingKey]="column.sortingKey || column.key"
|
||||
>
|
||||
<ng-template let-context>
|
||||
<adf-dynamic-column [id]="column.template" [context]="context"> </adf-dynamic-column>
|
||||
@@ -58,6 +59,7 @@
|
||||
[class]="column.class"
|
||||
[sortable]="column.sortable"
|
||||
[isHidden]="column.isHidden"
|
||||
[sortingKey]="column.sortingKey || column.key"
|
||||
>
|
||||
</data-column>
|
||||
</ng-container>
|
||||
|
@@ -45,6 +45,7 @@
|
||||
[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>
|
||||
@@ -64,6 +65,7 @@
|
||||
[draggable]="column.draggable"
|
||||
[resizable]="column.resizable"
|
||||
[isHidden]="column.isHidden"
|
||||
[sortingKey]="column.sortingKey || column.key"
|
||||
>
|
||||
</data-column>
|
||||
</ng-container>
|
||||
|
@@ -66,11 +66,6 @@ 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`));
|
||||
}
|
||||
@@ -83,9 +78,11 @@ export class DocumentListDirective implements OnInit, OnDestroy {
|
||||
this.documentList.setColumnsOrder = JSON.parse(this.preferences.get(`${this.sortingPreferenceKey}.columns.order`));
|
||||
}
|
||||
|
||||
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 });
|
||||
const mode = this.documentList.sortingMode;
|
||||
this.preferences.set(`${this.sortingPreferenceKey}.sorting.mode`, mode);
|
||||
if (mode === 'server') {
|
||||
this.restoreSorting();
|
||||
}
|
||||
}
|
||||
|
||||
this.documentList.ready
|
||||
@@ -112,6 +109,9 @@ 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,6 +154,7 @@ export class DocumentListDirective implements OnInit, OnDestroy {
|
||||
|
||||
onReady() {
|
||||
this.updateSelection();
|
||||
this.restoreSorting();
|
||||
}
|
||||
|
||||
private updateSelection() {
|
||||
@@ -180,4 +181,40 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user