[ACA-2832] Select node after reload (#1267)

* Select node after reload
This commit is contained in:
Martin Muller
2019-11-28 10:57:31 +01:00
committed by GitHub
parent 1ce013bb74
commit 5791622f6e
3 changed files with 21 additions and 8 deletions
+5 -3
View File
@@ -54,6 +54,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
isValidPath = true; isValidPath = true;
isSmallScreen = false; isSmallScreen = false;
isAdmin = false; isAdmin = false;
selectedNode: MinimalNodeEntity;
private nodePath: PathElement[]; private nodePath: PathElement[];
@@ -147,6 +148,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
navigateTo(node: MinimalNodeEntity) { navigateTo(node: MinimalNodeEntity) {
if (node && node.entry) { if (node && node.entry) {
this.selectedNode = node;
const { id, isFolder } = node.entry; const { id, isFolder } = node.entry;
if (isFolder) { if (isFolder) {
@@ -176,7 +178,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
// check root and child nodes // check root and child nodes
if (node && node.entry && node.entry.parentId === this.getParentNodeId()) { if (node && node.entry && node.entry.parentId === this.getParentNodeId()) {
this.reload(); this.reload(this.selectedNode);
return; return;
} }
@@ -214,7 +216,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
if (alreadyDisplayedParentFolder) { if (alreadyDisplayedParentFolder) {
return; return;
} }
this.reload(); this.reload(this.selectedNode);
} }
onContentCopied(nodes: MinimalNodeEntity[]) { onContentCopied(nodes: MinimalNodeEntity[]) {
@@ -224,7 +226,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
); );
}); });
if (newNode) { if (newNode) {
this.reload(); this.reload(this.selectedNode);
} }
} }
+6 -2
View File
@@ -44,7 +44,8 @@ import {
isInfoDrawerOpened, isInfoDrawerOpened,
getSharedUrl, getSharedUrl,
ViewNodeAction, ViewNodeAction,
ViewNodeExtras ViewNodeExtras,
SetSelectedNodesAction
} from '@alfresco/aca-shared/store'; } from '@alfresco/aca-shared/store';
import { isLocked, isLibrary } from '../utils/node.utils'; import { isLocked, isLibrary } from '../utils/node.utils';
@@ -131,8 +132,11 @@ export abstract class PageComponent implements OnInit, OnDestroy {
return null; return null;
} }
reload(): void { reload(selectedNode?: MinimalNodeEntity): void {
this.store.dispatch(new ReloadDocumentListAction()); this.store.dispatch(new ReloadDocumentListAction());
if (selectedNode) {
this.store.dispatch(new SetSelectedNodesAction([selectedNode]));
}
} }
trackByActionId(_: number, action: ContentActionRef) { trackByActionId(_: number, action: ContentActionRef) {
+10 -3
View File
@@ -32,12 +32,14 @@ import { Store } from '@ngrx/store';
import { SetSelectedNodesAction } from '@alfresco/aca-shared/store'; import { SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { takeUntil, filter } from 'rxjs/operators'; import { takeUntil, filter } from 'rxjs/operators';
import { ContentManagementService } from '../services/content-management.service'; import { ContentManagementService } from '../services/content-management.service';
import { MinimalNodeEntity } from '@alfresco/js-api';
@Directive({ @Directive({
selector: '[acaDocumentList]' selector: '[acaDocumentList]'
}) })
export class DocumentListDirective implements OnInit, OnDestroy { export class DocumentListDirective implements OnInit, OnDestroy {
private isLibrary = false; private isLibrary = false;
selectedNode: MinimalNodeEntity;
onDestroy$ = new Subject<boolean>(); onDestroy$ = new Subject<boolean>();
@@ -88,7 +90,7 @@ export class DocumentListDirective implements OnInit, OnDestroy {
.subscribe(() => this.onReady()); .subscribe(() => this.onReady());
this.content.reload.pipe(takeUntil(this.onDestroy$)).subscribe(() => { this.content.reload.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
this.reload(); this.reload(this.selectedNode);
}); });
this.content.reset.pipe(takeUntil(this.onDestroy$)).subscribe(() => { this.content.reset.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
@@ -119,6 +121,7 @@ export class DocumentListDirective implements OnInit, OnDestroy {
onNodeSelect(event: CustomEvent) { onNodeSelect(event: CustomEvent) {
if (!!event.detail && !!event.detail.node) { if (!!event.detail && !!event.detail.node) {
this.updateSelection(); this.updateSelection();
this.selectedNode = event.detail.node;
} }
} }
@@ -140,9 +143,13 @@ export class DocumentListDirective implements OnInit, OnDestroy {
this.store.dispatch(new SetSelectedNodesAction(selection)); this.store.dispatch(new SetSelectedNodesAction(selection));
} }
private reload() { private reload(selectedNode?: MinimalNodeEntity) {
this.documentList.resetSelection(); this.documentList.resetSelection();
this.store.dispatch(new SetSelectedNodesAction([])); if (selectedNode) {
this.store.dispatch(new SetSelectedNodesAction([selectedNode]));
} else {
this.store.dispatch(new SetSelectedNodesAction([]));
}
this.documentList.reload(); this.documentList.reload();
} }