mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
(breadcrumb): show display names for Libraries
This commit is contained in:
parent
f3f9fe3bf9
commit
d0672a73a1
@ -19,7 +19,7 @@ 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, PathElement } 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, AlfrescoApiService } from 'ng2-alfresco-core';
|
||||||
|
|
||||||
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
||||||
import { ContentManagementService } from '../../common/services/content-management.service';
|
import { ContentManagementService } from '../../common/services/content-management.service';
|
||||||
@ -54,7 +54,8 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
private uploadService: UploadService,
|
private uploadService: UploadService,
|
||||||
private contentManagementService: ContentManagementService,
|
private contentManagementService: ContentManagementService,
|
||||||
private browsingFilesService: BrowsingFilesService,
|
private browsingFilesService: BrowsingFilesService,
|
||||||
private contentService: AlfrescoContentService) {
|
private contentService: AlfrescoContentService,
|
||||||
|
private apiService: AlfrescoApiService) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +191,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo: review this approach once 5.2.3 is out
|
// todo: review this approach once 5.2.3 is out
|
||||||
private updateCurrentNode(node: MinimalNodeEntryEntity) {
|
private async updateCurrentNode(node: MinimalNodeEntryEntity) {
|
||||||
this.nodePath = null;
|
this.nodePath = null;
|
||||||
|
|
||||||
if (node && node.path && node.path.elements) {
|
if (node && node.path && node.path.elements) {
|
||||||
@ -204,7 +205,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
if (elements[1].name === 'User Homes') {
|
if (elements[1].name === 'User Homes') {
|
||||||
elements.splice(0, 2);
|
elements.splice(0, 2);
|
||||||
} else if (elements[1].name === 'Sites') {
|
} else if (elements[1].name === 'Sites') {
|
||||||
this.normalizeSitePath(node);
|
await this.normalizeSitePath(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,24 +215,42 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo: review this approach once 5.2.3 is out
|
// todo: review this approach once 5.2.3 is out
|
||||||
private normalizeSitePath(node: MinimalNodeEntryEntity): void {
|
private async normalizeSitePath(node: MinimalNodeEntryEntity) {
|
||||||
const elements = node.path.elements;
|
const elements = node.path.elements;
|
||||||
|
|
||||||
// remove 'Sites'
|
// remove 'Sites'
|
||||||
elements.splice(1, 1);
|
elements.splice(1, 1);
|
||||||
|
|
||||||
if (node.name === 'documentLibrary') {
|
if (this.isSiteContainer(node)) {
|
||||||
node.name = elements[1].name;
|
// rename 'documentLibrary' entry to the target site display name
|
||||||
|
// clicking on the breadcrumb entry loads the site content
|
||||||
|
const parentNode = await this.apiService.nodesApi.getNodeInfo(node.parentId);
|
||||||
|
node.name = parentNode.properties['cm:title'] || parentNode.name;
|
||||||
|
|
||||||
|
// remove the site entry
|
||||||
elements.splice(1, 1);
|
elements.splice(1, 1);
|
||||||
} else {
|
} else {
|
||||||
|
// remove 'documentLibrary' in the middle of the path
|
||||||
const docLib = elements.findIndex(el => el.name === 'documentLibrary');
|
const docLib = elements.findIndex(el => el.name === 'documentLibrary');
|
||||||
if (docLib > -1) {
|
if (docLib > -1) {
|
||||||
|
const siteFragment = elements[docLib - 1];
|
||||||
|
const siteNode = await this.apiService.nodesApi.getNodeInfo(siteFragment.id);
|
||||||
|
|
||||||
|
// apply Site Name to the parent fragment
|
||||||
|
siteFragment.name = siteNode.properties['cm:title'] || siteNode.name;
|
||||||
elements.splice(docLib, 1);
|
elements.splice(docLib, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private isRootNode(nodeId: string): boolean {
|
isSiteContainer(node: MinimalNodeEntryEntity): boolean {
|
||||||
|
if (node && node.aspectNames && node.aspectNames.length > 0) {
|
||||||
|
return node.aspectNames.indexOf('st:siteContainer') >= 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user