From ba2395c7b2cd644ea5ecc6b2ef3922411dc62026 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Mon, 13 Nov 2017 16:21:58 +0000 Subject: [PATCH 1/2] location link component --- src/app/app.module.ts | 4 +- .../favorites/favorites.component.html | 7 +- .../location-link/location-link.component.ts | 84 +++++++++++++++++++ .../recent-files/recent-files.component.html | 7 +- .../shared-files/shared-files.component.html | 8 +- .../trashcan/trashcan.component.html | 19 ++--- .../ui/overrides/_alfresco-document-list.scss | 1 + 7 files changed, 109 insertions(+), 21 deletions(-) create mode 100644 src/app/components/location-link/location-link.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1030ea821..7cffa948b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -42,6 +42,7 @@ import { CurrentUserComponent } from './components/current-user/current-user.com import { SearchComponent } from './components/search/search.component'; import { SidenavComponent } from './components/sidenav/sidenav.component'; import { AboutComponent } from './components/about/about.component'; +import { LocationLinkComponent } from './components/location-link/location-link.component'; @NgModule({ imports: [ @@ -69,7 +70,8 @@ import { AboutComponent } from './components/about/about.component'; SharedFilesComponent, TrashcanComponent, PreviewComponent, - AboutComponent + AboutComponent, + LocationLinkComponent ], providers: [ { diff --git a/src/app/components/favorites/favorites.component.html b/src/app/components/favorites/favorites.component.html index 1ec5194c5..beebb6856 100644 --- a/src/app/components/favorites/favorites.component.html +++ b/src/app/components/favorites/favorites.component.html @@ -117,9 +117,10 @@ + title="APP.DOCUMENT_LIST.COLUMNS.LOCATION"> + + + + {{ displayText }} + + `, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, + // tslint:disable-next-line:use-host-property-decorator + host: { + 'class': 'app-location-link' + } +}) +export class LocationLinkComponent implements OnInit { + + @Input() + context: any; + + @Input() + link: any[]; + + @Input() + displayText = ''; + + @Input() + tooltip = ''; + + ngOnInit() { + if (this.context) { + const data: DataTableAdapter = this.context.data; + const col: DataColumn = this.context.col; + const row: DataRow = this.context.row; + const value: PathInfoEntity = data.getValue(row, col); + + if (value.name && value.elements) { + const isLibraryPath = this.isLibraryContent(value); + + this.displayText = this.getDisplayText(value); + this.tooltip = this.getTooltip(value); + + const parent = value.elements[value.elements.length - 1]; + const area = isLibraryPath ? '/libraries' : '/personal-files'; + + this.link = [ area, parent.id ]; + } + } + } + + private isLibraryContent(path: PathInfoEntity): boolean { + if (path && path.elements.length >= 2 && path.elements[1].name === 'Sites') { + return true; + } + return false; + } + + private getDisplayText(path: PathInfoEntity): string { + let result = path.elements[path.elements.length - 1].name; + + if (result === 'documentLibrary') { + result = path.elements[path.elements.length - 2].name; + } + + result = result.replace('Company Home', 'Personal Files'); + + return result; + } + + // todo: review once 5.2.3 is out + private getTooltip(path: PathInfoEntity): string { + let result = path.name; + + result = result.replace('documentLibrary/', ''); + result = result.replace('/documentLibrary', ''); + result = result.replace('/Company Home/Sites', 'File Libraries'); + result = result.replace('/Company Home', 'Personal Files'); + + return result; + } +} diff --git a/src/app/components/recent-files/recent-files.component.html b/src/app/components/recent-files/recent-files.component.html index cfa07600b..e04f08139 100644 --- a/src/app/components/recent-files/recent-files.component.html +++ b/src/app/components/recent-files/recent-files.component.html @@ -109,9 +109,10 @@ + title="APP.DOCUMENT_LIST.COLUMNS.LOCATION"> + + + + title="APP.DOCUMENT_LIST.COLUMNS.LOCATION"> + + + + - - {{ (value || '').split('/').pop() }} + + - - {{ value | adfFileSize }} - + title="APP.DOCUMENT_LIST.COLUMNS.SIZE" + type="fileSize"> - - {{ value | adfTimeAgo }} - + title="APP.DOCUMENT_LIST.COLUMNS.DELETED_ON" + type="date" + format="timeAgo"> Date: Mon, 13 Nov 2017 16:41:35 +0000 Subject: [PATCH 2/2] test fixes --- src/app/components/favorites/favorites.component.spec.ts | 5 +++-- .../components/recent-files/recent-files.component.spec.ts | 2 ++ .../components/shared-files/shared-files.component.spec.ts | 2 ++ src/app/components/trashcan/trashcan.component.spec.ts | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/components/favorites/favorites.component.spec.ts b/src/app/components/favorites/favorites.component.spec.ts index ec8e88cdb..8a2ab77d9 100644 --- a/src/app/components/favorites/favorites.component.spec.ts +++ b/src/app/components/favorites/favorites.component.spec.ts @@ -19,10 +19,10 @@ import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { TestBed, async } from '@angular/core/testing'; import { Observable } from 'rxjs/Rx'; - import { CoreModule, NodesApiService, AlfrescoApiService, AlfrescoContentService } from 'ng2-alfresco-core'; -import { CommonModule } from '../../common/common.module'; +import { CommonModule } from '../../common/common.module'; +import { LocationLinkComponent } from '../location-link/location-link.component'; import { ContentManagementService } from '../../common/services/content-management.service'; import { FavoritesComponent } from './favorites.component'; @@ -72,6 +72,7 @@ describe('Favorites Routed Component', () => { RouterTestingModule ], declarations: [ + LocationLinkComponent, FavoritesComponent ] }) diff --git a/src/app/components/recent-files/recent-files.component.spec.ts b/src/app/components/recent-files/recent-files.component.spec.ts index ba1defdc5..65f7dd14f 100644 --- a/src/app/components/recent-files/recent-files.component.spec.ts +++ b/src/app/components/recent-files/recent-files.component.spec.ts @@ -24,6 +24,7 @@ import { CoreModule, AlfrescoApiService } from 'ng2-alfresco-core'; import { CommonModule } from '../../common/common.module'; import { ContentManagementService } from '../../common/services/content-management.service'; +import { LocationLinkComponent } from '../location-link/location-link.component'; import { RecentFilesComponent } from './recent-files.component'; describe('RecentFiles Routed Component', () => { @@ -54,6 +55,7 @@ describe('RecentFiles Routed Component', () => { CommonModule ], declarations: [ + LocationLinkComponent, RecentFilesComponent ] }) diff --git a/src/app/components/shared-files/shared-files.component.spec.ts b/src/app/components/shared-files/shared-files.component.spec.ts index 169788d30..db214f73b 100644 --- a/src/app/components/shared-files/shared-files.component.spec.ts +++ b/src/app/components/shared-files/shared-files.component.spec.ts @@ -23,6 +23,7 @@ import { AlfrescoApiService } from 'ng2-alfresco-core'; import { CommonModule } from '../../common/common.module'; import { ContentManagementService } from '../../common/services/content-management.service'; +import { LocationLinkComponent } from '../location-link/location-link.component'; import { SharedFilesComponent } from './shared-files.component'; describe('SharedFilesComponent', () => { @@ -51,6 +52,7 @@ describe('SharedFilesComponent', () => { CommonModule ], declarations: [ + LocationLinkComponent, SharedFilesComponent ] }) diff --git a/src/app/components/trashcan/trashcan.component.spec.ts b/src/app/components/trashcan/trashcan.component.spec.ts index e5c8cdc96..b8c3e5c99 100644 --- a/src/app/components/trashcan/trashcan.component.spec.ts +++ b/src/app/components/trashcan/trashcan.component.spec.ts @@ -19,6 +19,7 @@ import { TestBed, async } from '@angular/core/testing'; import { CoreModule, AlfrescoApiService } from 'ng2-alfresco-core'; import { TrashcanComponent } from './trashcan.component'; import { CommonModule } from '../../common/common.module'; +import { LocationLinkComponent } from '../location-link/location-link.component'; describe('TrashcanComponent', () => { let fixture; @@ -42,6 +43,7 @@ describe('TrashcanComponent', () => { CommonModule ], declarations: [ + LocationLinkComponent, TrashcanComponent ] })