mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACA-1091] Destination picker is not completely translated [ADF-2000] (#186)
* [ACA-1091] Destination picker is not completely translated [ADF-2000] translate title taking into consideration also multiple selections for copy/move action * [ACA-1091] updated unit tests * [ACA-1091] removed translation to french as this will be added by the translation team and refactored title translation code
This commit is contained in:
committed by
Cilibiu Bogdan
parent
b28eabc63d
commit
34e322e9f6
@@ -27,7 +27,7 @@ import { TestBed, async } from '@angular/core/testing';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { OverlayModule } from '@angular/cdk/overlay';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { AlfrescoApiService, NodesApiService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, NodesApiService, TranslationService } from '@alfresco/adf-core';
|
||||
import { DocumentListService } from '@alfresco/adf-content-services';
|
||||
|
||||
import { CommonModule } from '../common.module';
|
||||
@@ -285,12 +285,17 @@ describe('NodeActionsService', () => {
|
||||
let fileToCopy;
|
||||
let folderToCopy;
|
||||
let destinationFolder;
|
||||
let translationService: TranslationService;
|
||||
|
||||
beforeEach(() => {
|
||||
fileToCopy = new TestNode(fileId, isFile, 'file-name');
|
||||
folderToCopy = new TestNode();
|
||||
destinationFolder = new TestNode(folderDestinationId);
|
||||
translationService = TestBed.get(TranslationService);
|
||||
|
||||
spyOn(translationService, 'instant').and.callFake(key => {
|
||||
return key;
|
||||
});
|
||||
});
|
||||
|
||||
it('should be called', () => {
|
||||
@@ -324,7 +329,8 @@ describe('NodeActionsService', () => {
|
||||
expect(testContentNodeSelectorComponentData).toBeDefined();
|
||||
expect(testContentNodeSelectorComponentData.data.rowFilter({node: destinationFolder})).toBeDefined();
|
||||
expect(testContentNodeSelectorComponentData.data.imageResolver({node: destinationFolder})).toBeDefined();
|
||||
expect(testContentNodeSelectorComponentData.data.title).toBe('copy to ...');
|
||||
expect(testContentNodeSelectorComponentData.data.title).toBe('NODE_SELECTOR.COPY_ITEMS');
|
||||
expect(translationService.instant).toHaveBeenCalledWith('NODE_SELECTOR.COPY_ITEMS', {name: ''});
|
||||
|
||||
destinationFolder.entry['allowableOperations'] = ['update'];
|
||||
expect(testContentNodeSelectorComponentData.data.imageResolver({node: destinationFolder})).toBeDefined();
|
||||
@@ -346,7 +352,8 @@ describe('NodeActionsService', () => {
|
||||
|
||||
expect(spyOnBatchOperation).toHaveBeenCalled();
|
||||
expect(testContentNodeSelectorComponentData).toBeDefined();
|
||||
expect(testContentNodeSelectorComponentData.data.title).toBe('copy \'entry-name\' to ...');
|
||||
expect(testContentNodeSelectorComponentData.data.title).toBe('NODE_SELECTOR.COPY_ITEM');
|
||||
expect(translationService.instant).toHaveBeenCalledWith('NODE_SELECTOR.COPY_ITEM', {name: 'entry-name'});
|
||||
});
|
||||
|
||||
it('should use the ContentNodeSelectorComponentData object without file name in title, if no name exists', () => {
|
||||
@@ -365,7 +372,8 @@ describe('NodeActionsService', () => {
|
||||
|
||||
expect(spyOnBatchOperation).toHaveBeenCalled();
|
||||
expect(testContentNodeSelectorComponentData).toBeDefined();
|
||||
expect(testContentNodeSelectorComponentData.data.title).toBe('copy to ...');
|
||||
expect(testContentNodeSelectorComponentData.data.title).toBe('NODE_SELECTOR.COPY_ITEMS');
|
||||
expect(translationService.instant).toHaveBeenCalledWith('NODE_SELECTOR.COPY_ITEMS', {name: ''});
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -27,7 +27,7 @@ import { Injectable } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { Observable, Subject } from 'rxjs/Rx';
|
||||
|
||||
import { AlfrescoApiService, ContentService, NodesApiService, DataColumn } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, ContentService, NodesApiService, DataColumn, TranslationService } from '@alfresco/adf-core';
|
||||
import { DocumentListService, ContentNodeSelectorComponent, ContentNodeSelectorComponentData } from '@alfresco/adf-content-services';
|
||||
import { MinimalNodeEntity, MinimalNodeEntryEntity, SitePaging } from 'alfresco-js-api';
|
||||
|
||||
@@ -44,7 +44,8 @@ export class NodeActionsService {
|
||||
private dialog: MatDialog,
|
||||
private documentListService: DocumentListService,
|
||||
private apiService: AlfrescoApiService,
|
||||
private nodesApi: NodesApiService) {}
|
||||
private nodesApi: NodesApiService,
|
||||
private translation: TranslationService) {}
|
||||
|
||||
/**
|
||||
* Copy node list
|
||||
@@ -175,11 +176,6 @@ export class NodeActionsService {
|
||||
getContentNodeSelection(action: string, contentEntities: MinimalNodeEntity[]): Subject<MinimalNodeEntryEntity[]> {
|
||||
const currentParentFolderId = this.getFirstParentId(contentEntities);
|
||||
|
||||
let nodeEntryName = '';
|
||||
if (contentEntities.length === 1 && contentEntities[0].entry.name) {
|
||||
nodeEntryName = `'${contentEntities[0].entry.name}' `;
|
||||
}
|
||||
|
||||
const customDropdown: SitePaging = {
|
||||
list: {
|
||||
entries: [
|
||||
@@ -199,8 +195,10 @@ export class NodeActionsService {
|
||||
}
|
||||
};
|
||||
|
||||
const title = this.getTitleTranslation(action, contentEntities);
|
||||
|
||||
const data: ContentNodeSelectorComponentData = {
|
||||
title: `${action} ${nodeEntryName}to ...`,
|
||||
title: title,
|
||||
currentFolderId: currentParentFolderId,
|
||||
actionName: action,
|
||||
dropdownHideMyFiles: true,
|
||||
@@ -238,6 +236,17 @@ export class NodeActionsService {
|
||||
return data.select;
|
||||
}
|
||||
|
||||
getTitleTranslation(action: string, nodes: MinimalNodeEntity[] = []): string {
|
||||
let keyPrefix = 'ITEMS';
|
||||
let name = '';
|
||||
|
||||
if (nodes.length === 1 && nodes[0].entry.name) {
|
||||
name = nodes[0].entry.name;
|
||||
keyPrefix = 'ITEM';
|
||||
}
|
||||
return this.translation.instant(`NODE_SELECTOR.${action.toUpperCase()}_${keyPrefix}`, {name});
|
||||
}
|
||||
|
||||
private hasEntityCreatePermission(entry: MinimalNodeEntryEntity): boolean {
|
||||
return this.contentService.hasPermission(entry, 'create');
|
||||
}
|
||||
|
@@ -185,5 +185,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"NODE_SELECTOR": {
|
||||
"COPY_ITEM": "Copy '{{ name }}' to ...",
|
||||
"COPY_ITEMS": "Copy to ...",
|
||||
"MOVE_ITEM": "Move '{{ name }}' to ...",
|
||||
"MOVE_ITEMS": "Move to ...",
|
||||
"SEARCH": "Search"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user