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"> + + + { RouterTestingModule ], declarations: [ + LocationLinkComponent, FavoritesComponent ] }) diff --git a/src/app/components/location-link/location-link.component.ts b/src/app/components/location-link/location-link.component.ts new file mode 100644 index 000000000..a81e2d591 --- /dev/null +++ b/src/app/components/location-link/location-link.component.ts @@ -0,0 +1,84 @@ +import { Component, Input, ChangeDetectionStrategy, OnInit, ViewEncapsulation } from '@angular/core'; +import { DataColumn, DataRow, DataTableAdapter } from 'ng2-alfresco-datatable'; +import { PathInfoEntity } from 'alfresco-js-api'; + +@Component({ + selector: 'app-location-link', + template: ` + + {{ 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 c3438c646..4607b41c5 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"> + + + { @@ -54,6 +55,7 @@ describe('RecentFiles Routed Component', () => { CommonModule ], declarations: [ + LocationLinkComponent, RecentFilesComponent ] }) diff --git a/src/app/components/shared-files/shared-files.component.html b/src/app/components/shared-files/shared-files.component.html index 77ad86999..142e62856 100644 --- a/src/app/components/shared-files/shared-files.component.html +++ b/src/app/components/shared-files/shared-files.component.html @@ -107,11 +107,13 @@ + title="APP.DOCUMENT_LIST.COLUMNS.LOCATION"> + + + + { @@ -51,6 +52,7 @@ describe('SharedFilesComponent', () => { CommonModule ], declarations: [ + LocationLinkComponent, SharedFilesComponent ] }) diff --git a/src/app/components/trashcan/trashcan.component.html b/src/app/components/trashcan/trashcan.component.html index 107d58efe..9675b9e96 100644 --- a/src/app/components/trashcan/trashcan.component.html +++ b/src/app/components/trashcan/trashcan.component.html @@ -66,27 +66,24 @@ - - {{ (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"> { let fixture; @@ -42,6 +43,7 @@ describe('TrashcanComponent', () => { CommonModule ], declarations: [ + LocationLinkComponent, TrashcanComponent ] }) diff --git a/src/app/ui/overrides/_alfresco-document-list.scss b/src/app/ui/overrides/_alfresco-document-list.scss index bdf5ea4ac..35af33836 100644 --- a/src/app/ui/overrides/_alfresco-document-list.scss +++ b/src/app/ui/overrides/_alfresco-document-list.scss @@ -89,6 +89,7 @@ adf-document-list { } } + .app-location-link, .adf-location-cell { a { text-decoration: none;