mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
workaround for Libraries breadcrumb
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
import { Observable, Subscription } from 'rxjs/Rx';
|
import { Observable, Subscription } from 'rxjs/Rx';
|
||||||
import { Component, ViewChild, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
import { Component, ViewChild, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
||||||
import { Router, ActivatedRoute, Params } from '@angular/router';
|
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||||
import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, NodePaging } from 'alfresco-js-api';
|
import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, NodePaging, PathElement } from 'alfresco-js-api';
|
||||||
import { UploadService, FileUploadEvent, NodesApiService, AlfrescoContentService } from 'ng2-alfresco-core';
|
import { UploadService, FileUploadEvent, NodesApiService, AlfrescoContentService } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
||||||
@@ -34,6 +34,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
private routeData: any = {};
|
private routeData: any = {};
|
||||||
isValidPath = true;
|
isValidPath = true;
|
||||||
|
|
||||||
|
private nodePath: PathElement[];
|
||||||
private onCopyNode: Subscription;
|
private onCopyNode: Subscription;
|
||||||
private onRemoveItem: Subscription;
|
private onRemoveItem: Subscription;
|
||||||
private onCreateFolder: Subscription;
|
private onCreateFolder: Subscription;
|
||||||
@@ -144,6 +145,12 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onBreadcrumbNavigate(route: PathElementEntity) {
|
onBreadcrumbNavigate(route: PathElementEntity) {
|
||||||
|
// todo: review this approach once 5.2.3 is out
|
||||||
|
if (this.nodePath && this.nodePath.length > 0) {
|
||||||
|
if (this.nodePath[1].name === 'Sites' && this.nodePath[2].id === route.id) {
|
||||||
|
return this.navigate(this.nodePath[3].id);
|
||||||
|
}
|
||||||
|
}
|
||||||
this.navigate(route.id);
|
this.navigate(route.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,21 +189,48 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: review this approach once 5.2.3 is out
|
||||||
private updateCurrentNode(node: MinimalNodeEntryEntity) {
|
private updateCurrentNode(node: MinimalNodeEntryEntity) {
|
||||||
this.node = node;
|
this.nodePath = null;
|
||||||
|
|
||||||
if (node.path && node.path.elements) {
|
if (node && node.path && node.path.elements) {
|
||||||
const elements = node.path.elements;
|
const elements = node.path.elements;
|
||||||
|
|
||||||
// todo: review this approach once 5.2.3 is out
|
this.nodePath = elements.map(pathElement => {
|
||||||
if (elements.length > 1 && elements[1].name === 'User Homes') {
|
return Object.assign({}, pathElement);
|
||||||
elements.splice(0, 2);
|
});
|
||||||
|
|
||||||
|
if (elements.length > 1) {
|
||||||
|
if (elements[1].name === 'User Homes') {
|
||||||
|
elements.splice(0, 2);
|
||||||
|
} else if (elements[1].name === 'Sites') {
|
||||||
|
this.normalizeSitePath(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.node = node;
|
||||||
this.browsingFilesService.onChangeParent.next(node);
|
this.browsingFilesService.onChangeParent.next(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: review this approach once 5.2.3 is out
|
||||||
|
private normalizeSitePath(node: MinimalNodeEntryEntity): void {
|
||||||
|
const elements = node.path.elements;
|
||||||
|
|
||||||
|
// remove 'Sites'
|
||||||
|
elements.splice(1, 1);
|
||||||
|
|
||||||
|
if (node.name === 'documentLibrary') {
|
||||||
|
node.name = elements[1].name;
|
||||||
|
elements.splice(1, 1);
|
||||||
|
} else {
|
||||||
|
const docLib = elements.findIndex(el => el.name === 'documentLibrary');
|
||||||
|
if (docLib > -1) {
|
||||||
|
elements.splice(docLib, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private isRootNode(nodeId: string): boolean {
|
private isRootNode(nodeId: string): boolean {
|
||||||
if (this.node && this.node.path && this.node.path.elements && this.node.path.elements.length > 0) {
|
if (this.node && this.node.path && this.node.path.elements && this.node.path.elements.length > 0) {
|
||||||
return this.node.path.elements[0].id === nodeId;
|
return this.node.path.elements[0].id === nodeId;
|
||||||
|
Reference in New Issue
Block a user