diff --git a/src/app/common/common.module.ts b/src/app/common/common.module.ts index 06a8d886c..5e008c78c 100644 --- a/src/app/common/common.module.ts +++ b/src/app/common/common.module.ts @@ -35,8 +35,6 @@ import { NodeRestoreDirective } from './directives/node-restore.directive'; import { NodePermanentDeleteDirective } from './directives/node-permanent-delete.directive'; import { NodeFavoriteDirective } from './directives/node-favorite.directive'; -import { NodeNameTooltipPipe } from './pipes/node-name-tooltip.pipe'; - import { ContentManagementService } from './services/content-management.service'; import { BrowsingFilesService } from './services/browsing-files.service'; import { NodeActionsService } from './services/node-actions.service'; @@ -63,9 +61,7 @@ export function declarations() { DownloadFileDirective, NodeRestoreDirective, NodePermanentDeleteDirective, - NodeFavoriteDirective, - - NodeNameTooltipPipe + NodeFavoriteDirective ]; } diff --git a/src/app/common/pipes/node-name-tooltip.pipe.spec.ts b/src/app/common/pipes/node-name-tooltip.pipe.spec.ts deleted file mode 100644 index aec9d63c3..000000000 --- a/src/app/common/pipes/node-name-tooltip.pipe.spec.ts +++ /dev/null @@ -1,145 +0,0 @@ -/*! - * @license - * Copyright 2017 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { MinimalNodeEntity } from 'alfresco-js-api'; -import { NodeNameTooltipPipe } from './node-name-tooltip.pipe'; - -describe('NodeNameTooltipPipe', () => { - - const nodeName = 'node-name'; - const nodeTitle = 'node-title'; - const nodeDescription = 'node-description'; - - let pipe: NodeNameTooltipPipe; - - beforeEach(() => { - pipe = new NodeNameTooltipPipe(); - }); - - it('should not transform when missing node', () => { - expect(pipe.transform(null)).toBe(null); - }); - - it('should not transform when missing node entry', () => { - expect(pipe.transform( {})).toBe(null); - }); - - it('should use title and description when all fields present', () => { - const node: any = { - entry: { - name: nodeName, - properties: { - 'cm:title': nodeTitle, - 'cm:description': nodeDescription - } - } - }; - let tooltip = pipe.transform(node); - expect(tooltip).toBe(`${nodeTitle}\n${nodeDescription}`); - }); - - it('should use name when other properties are missing', () => { - const node = { - entry: { - name: nodeName - } - }; - let tooltip = pipe.transform( node); - expect(tooltip).toBe(nodeName); - }); - - it('should display name when title and description are missing', () => { - const node: any = { - entry: { - name: nodeName, - properties: {} - } - }; - let tooltip = pipe.transform(node); - expect(tooltip).toBe(nodeName); - }); - - it('should use name and description when title is missing', () => { - const node: any = { - entry: { - name: nodeName, - properties: { - 'cm:title': null, - 'cm:description': nodeDescription - } - } - }; - let tooltip = pipe.transform(node); - expect(tooltip).toBe(`${nodeName}\n${nodeDescription}`); - }); - - it('should use name and title when description is missing', () => { - const node: any = { - entry: { - name: nodeName, - properties: { - 'cm:title': nodeTitle, - 'cm:description': null - } - } - }; - let tooltip = pipe.transform(node); - expect(tooltip).toBe(`${nodeName}\n${nodeTitle}`); - }); - - it('should use name if name and description are the same', () => { - const node: any = { - entry: { - name: nodeName, - properties: { - 'cm:title': null, - 'cm:description': nodeName - } - } - }; - let tooltip = pipe.transform(node); - expect(tooltip).toBe(nodeName); - }); - - it('should use name if name and title are the same', () => { - const node: any = { - entry: { - name: nodeName, - properties: { - 'cm:title': nodeName, - 'cm:description': null - } - } - }; - let tooltip = pipe.transform(node); - expect(tooltip).toBe(nodeName); - }); - - it('should use name if all values are the same', () => { - const node: any = { - entry: { - name: nodeName, - properties: { - 'cm:title': nodeName, - 'cm:description': nodeName - } - } - }; - let tooltip = pipe.transform(node); - expect(tooltip).toBe(nodeName); - }); -}); diff --git a/src/app/common/pipes/node-name-tooltip.pipe.ts b/src/app/common/pipes/node-name-tooltip.pipe.ts deleted file mode 100644 index d1e5e398b..000000000 --- a/src/app/common/pipes/node-name-tooltip.pipe.ts +++ /dev/null @@ -1,79 +0,0 @@ -/*! - * @license - * Copyright 2017 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Pipe, PipeTransform } from '@angular/core'; -import { MinimalNodeEntity } from 'alfresco-js-api'; -import { DataRow } from 'ng2-alfresco-datatable'; - -@Pipe({ - name: 'nodeNameTooltip' -}) -export class NodeNameTooltipPipe implements PipeTransform { - - transform(node: MinimalNodeEntity): string { - if (node) { - return this.getNodeTooltip(node); - } - return null; - } - - private containsLine(lines: string[], line: string): boolean { - return lines.some((item: string) => { - return item.toLowerCase() === line.toLowerCase(); - }); - } - - private removeDuplicateLines(lines: string[]): string[] { - const reducer = (acc: string[], line: string): string[] => { - if (!this.containsLine(acc, line)) { acc.push(line); } - return acc; - }; - - return lines.reduce(reducer, []); - } - - private getNodeTooltip(node: MinimalNodeEntity): string { - if (!node || !node.entry) { - return null; - } - - const { entry: { properties, name } } = node; - const lines = [ name ]; - - if (properties) { - const { - 'cm:title': title, - 'cm:description': description - } = properties; - - if (title && description) { - lines[0] = title; - lines[1] = description; - } - - if (title) { - lines[1] = title; - } - - if (description) { - lines[1] = description; - } - } - - return this.removeDuplicateLines(lines).join(`\n`); - } -} diff --git a/src/app/components/favorites/favorites.component.html b/src/app/components/favorites/favorites.component.html index 2a2948680..32d684417 100644 --- a/src/app/components/favorites/favorites.component.html +++ b/src/app/components/favorites/favorites.component.html @@ -111,7 +111,7 @@ class="app-name-column" title="APP.DOCUMENT_LIST.COLUMNS.NAME"> - {{ value }} + {{ value }} diff --git a/src/app/components/files/files.component.html b/src/app/components/files/files.component.html index 427409a7c..4fdd83895 100644 --- a/src/app/components/files/files.component.html +++ b/src/app/components/files/files.component.html @@ -116,7 +116,7 @@ class="app-name-column" title="APP.DOCUMENT_LIST.COLUMNS.NAME"> - {{ value }} + {{ value }} diff --git a/src/app/components/recent-files/recent-files.component.html b/src/app/components/recent-files/recent-files.component.html index 2a5bb08df..cfa07600b 100644 --- a/src/app/components/recent-files/recent-files.component.html +++ b/src/app/components/recent-files/recent-files.component.html @@ -103,7 +103,7 @@ class="app-name-column" title="APP.DOCUMENT_LIST.COLUMNS.NAME"> - {{ value }} + {{ value }} diff --git a/src/app/components/shared-files/shared-files.component.html b/src/app/components/shared-files/shared-files.component.html index 7d2d98732..77ad86999 100644 --- a/src/app/components/shared-files/shared-files.component.html +++ b/src/app/components/shared-files/shared-files.component.html @@ -101,7 +101,7 @@ class="app-name-column" title="APP.DOCUMENT_LIST.COLUMNS.NAME"> - {{ value }} + {{ value }} diff --git a/src/app/components/trashcan/trashcan.component.html b/src/app/components/trashcan/trashcan.component.html index 1575261a2..b56c2d586 100644 --- a/src/app/components/trashcan/trashcan.component.html +++ b/src/app/components/trashcan/trashcan.component.html @@ -61,7 +61,7 @@ class="app-name-column" title="APP.DOCUMENT_LIST.COLUMNS.NAME"> - {{ value }} + {{ value }}