mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
* [ACA-3471] too long french translation doesn't fix in the UI (#1499) * [ACA-3538] Fix search result layout (#1500) * [ACA-3468] Enable Document List filters in ACA * [ACA-3468] Get pagination settings from document list * [ACA-3468] Move event handlers and pagination to page component * [ACA-3468] Remove useless OnChanges * [ACA-3468] Fix linter * [ACA-3468] Add test for document list definition * [ACA-3468] Fix lint * [ACA-3468] Remove identifier * [ACA-3468] Update to lastest ADF alpha to fix search result * [ACA-3468] Update to lastest ADF alpha * Fixed unit test * re-enable tests * rollback changes to test * fix reload * * fixed search e2e * fix issue with page reload on search results * update tests Co-authored-by: arditdomi <32884230+arditdomi@users.noreply.github.com> Co-authored-by: PizzaVito <vito.albano.123@gmail.com> Co-authored-by: Denys Vuika <denys.vuika@gmail.com> Co-authored-by: dhrn <dharan.g@muraai.com>
200 lines
5.8 KiB
TypeScript
200 lines
5.8 KiB
TypeScript
/*!
|
|
* @license
|
|
* Alfresco Example Content Application
|
|
*
|
|
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
|
*
|
|
* This file is part of the Alfresco Example Content Application.
|
|
* If the software was purchased under a paid Alfresco license, the terms of
|
|
* the paid license agreement will prevail. Otherwise, the software is
|
|
* provided under the following open source license terms:
|
|
*
|
|
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
import {
|
|
DocumentListComponent,
|
|
ShareDataRow
|
|
} from '@alfresco/adf-content-services';
|
|
import { ShowHeaderMode } from '@alfresco/adf-core';
|
|
import { ContentActionRef, SelectionState } from '@alfresco/adf-extensions';
|
|
import {
|
|
OnDestroy,
|
|
OnInit,
|
|
OnChanges,
|
|
ViewChild,
|
|
SimpleChanges
|
|
} from '@angular/core';
|
|
import { Store } from '@ngrx/store';
|
|
import {
|
|
MinimalNodeEntity,
|
|
MinimalNodeEntryEntity,
|
|
Pagination,
|
|
NodePaging
|
|
} from '@alfresco/js-api';
|
|
import { Observable, Subject, Subscription } from 'rxjs';
|
|
import { takeUntil, map } from 'rxjs/operators';
|
|
import { ContentManagementService } from '../services/content-management.service';
|
|
import {
|
|
AppStore,
|
|
ReloadDocumentListAction,
|
|
getCurrentFolder,
|
|
getAppSelection,
|
|
getDocumentDisplayMode,
|
|
isInfoDrawerOpened,
|
|
getSharedUrl,
|
|
ViewNodeAction,
|
|
ViewNodeExtras,
|
|
SetSelectedNodesAction
|
|
} from '@alfresco/aca-shared/store';
|
|
import { isLocked, isLibrary, AppExtensionService } from '@alfresco/aca-shared';
|
|
|
|
export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
|
|
onDestroy$: Subject<boolean> = new Subject<boolean>();
|
|
|
|
@ViewChild(DocumentListComponent)
|
|
documentList: DocumentListComponent;
|
|
|
|
title = 'Page';
|
|
infoDrawerOpened$: Observable<boolean>;
|
|
node: MinimalNodeEntryEntity;
|
|
selection: SelectionState;
|
|
documentDisplayMode$: Observable<string>;
|
|
sharedPreviewUrl$: Observable<string>;
|
|
actions: Array<ContentActionRef> = [];
|
|
viewerToolbarActions: Array<ContentActionRef> = [];
|
|
canUpdateNode = false;
|
|
canUpload = false;
|
|
nodeResult: NodePaging;
|
|
pagination: Pagination;
|
|
showHeader = ShowHeaderMode.Always;
|
|
|
|
protected subscriptions: Subscription[] = [];
|
|
|
|
constructor(
|
|
protected store: Store<AppStore>,
|
|
protected extensions: AppExtensionService,
|
|
protected content: ContentManagementService
|
|
) {}
|
|
|
|
ngOnInit() {
|
|
this.sharedPreviewUrl$ = this.store.select(getSharedUrl);
|
|
this.infoDrawerOpened$ = this.store.select(isInfoDrawerOpened).pipe(
|
|
map(infoDrawerState => {
|
|
return !this.isOutletPreviewUrl() && infoDrawerState;
|
|
})
|
|
);
|
|
|
|
this.documentDisplayMode$ = this.store.select(getDocumentDisplayMode);
|
|
|
|
this.store
|
|
.select(getAppSelection)
|
|
.pipe(takeUntil(this.onDestroy$))
|
|
.subscribe(selection => {
|
|
this.selection = selection;
|
|
this.actions = this.extensions.getAllowedToolbarActions();
|
|
this.viewerToolbarActions = this.extensions.getViewerToolbarActions();
|
|
this.canUpdateNode =
|
|
this.selection.count === 1 &&
|
|
this.content.canUpdateNode(selection.first);
|
|
});
|
|
|
|
this.store
|
|
.select(getCurrentFolder)
|
|
.pipe(takeUntil(this.onDestroy$))
|
|
.subscribe(node => {
|
|
this.canUpload = node && this.content.canUploadContent(node);
|
|
});
|
|
|
|
if (this.documentList && this.documentList.pagination) {
|
|
this.documentList.pagination
|
|
.pipe(takeUntil(this.onDestroy$))
|
|
.subscribe((newPagination: Pagination) => {
|
|
this.pagination = newPagination;
|
|
});
|
|
}
|
|
}
|
|
|
|
ngOnChanges(changes: SimpleChanges) {
|
|
if (changes.nodeResult && changes.nodeResult.currentValue) {
|
|
this.nodeResult = changes.nodeResult.currentValue;
|
|
}
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.subscriptions.forEach(subscription => subscription.unsubscribe());
|
|
this.subscriptions = [];
|
|
|
|
this.onDestroy$.next(true);
|
|
this.onDestroy$.complete();
|
|
}
|
|
|
|
showPreview(node: MinimalNodeEntity, extras?: ViewNodeExtras) {
|
|
if (node && node.entry) {
|
|
const id =
|
|
(node as any).entry.nodeId || (node as any).entry.guid || node.entry.id;
|
|
|
|
this.store.dispatch(new ViewNodeAction(id, extras));
|
|
}
|
|
}
|
|
|
|
getParentNodeId(): string {
|
|
return this.node ? this.node.id : null;
|
|
}
|
|
|
|
imageResolver(row: ShareDataRow): string | null {
|
|
if (isLocked(row.node)) {
|
|
return 'assets/images/baseline-lock-24px.svg';
|
|
}
|
|
|
|
if (isLibrary(row.node)) {
|
|
return 'assets/images/baseline-library_books-24px.svg';
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
reload(selectedNode?: MinimalNodeEntity): void {
|
|
if (this.isOutletPreviewUrl()) {
|
|
return;
|
|
}
|
|
|
|
this.store.dispatch(new ReloadDocumentListAction());
|
|
if (selectedNode) {
|
|
this.store.dispatch(new SetSelectedNodesAction([selectedNode]));
|
|
}
|
|
}
|
|
|
|
trackByActionId(_: number, action: ContentActionRef) {
|
|
return action.id;
|
|
}
|
|
|
|
trackById(_: number, obj: { id: string }) {
|
|
return obj.id;
|
|
}
|
|
|
|
private isOutletPreviewUrl(): boolean {
|
|
return location.href.includes('viewer:view');
|
|
}
|
|
|
|
onFilterUpdate(newNodePaging: NodePaging) {
|
|
this.nodeResult = newNodePaging;
|
|
}
|
|
|
|
onAllFilterCleared() {
|
|
this.documentList.node = null;
|
|
this.store.dispatch(new ReloadDocumentListAction());
|
|
}
|
|
}
|