Merge pull request #49 from Alfresco/dev-denys-ACA-960

[ACA-960] location link component
This commit is contained in:
Cilibiu Bogdan
2017-11-14 10:30:53 +02:00
committed by GitHub
11 changed files with 118 additions and 23 deletions

View File

@@ -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: [
{

View File

@@ -117,9 +117,10 @@
<data-column
key="path"
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION"
type="location"
format="/personal-files">
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION">
<ng-template let-context>
<app-location-link [context]="context"></app-location-link>
</ng-template>
</data-column>
<data-column

View File

@@ -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
]
})

View File

@@ -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: `
<a href="" [title]="tooltip" [routerLink]="link">
{{ displayText }}
</a>
`,
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;
}
}

View File

@@ -109,9 +109,10 @@
<data-column
key="path"
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION"
type="location"
format="/personal-files">
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION">
<ng-template let-context>
<app-location-link [context]="context"></app-location-link>
</ng-template>
</data-column>
<data-column

View File

@@ -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
]
})

View File

@@ -107,11 +107,13 @@
<data-column
key="path"
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION"
type="location"
format="/personal-files">
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION">
<ng-template let-context>
<app-location-link [context]="context"></app-location-link>
</ng-template>
</data-column>
<data-column
key="content.sizeInBytes"
title="APP.DOCUMENT_LIST.COLUMNS.SIZE"

View File

@@ -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
]
})

View File

@@ -66,27 +66,24 @@
</data-column>
<data-column
key="path.name"
key="path"
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION">
<ng-template let-value="value">
<span title="{{ value }}">{{ (value || '').split('/').pop() }}</span>
<ng-template let-context>
<app-location-link [context]="context"></app-location-link>
</ng-template>
</data-column>
<data-column
key="content.sizeInBytes"
title="APP.DOCUMENT_LIST.COLUMNS.SIZE">
<ng-template let-value="value">
<span title="{{ value }} bytes">{{ value | adfFileSize }}</span>
</ng-template>
title="APP.DOCUMENT_LIST.COLUMNS.SIZE"
type="fileSize">
</data-column>
<data-column
key="archivedAt"
title="APP.DOCUMENT_LIST.COLUMNS.DELETED_ON">
<ng-template let-value="value">
<span title="{{ value | date:'medium' }}">{{ value | adfTimeAgo }}</span>
</ng-template>
title="APP.DOCUMENT_LIST.COLUMNS.DELETED_ON"
type="date"
format="timeAgo">
</data-column>
<data-column

View File

@@ -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
]
})

View File

@@ -89,6 +89,7 @@ adf-document-list {
}
}
.app-location-link,
.adf-location-cell {
a {
text-decoration: none;