Merge branch 'development' into dev-denys-70

This commit is contained in:
Denys Vuika 2016-07-13 17:22:27 +01:00
commit 00c28ecd52
11 changed files with 49 additions and 11 deletions

View File

@ -47,7 +47,7 @@
[context-menu]="getContextMenuActions(row, col)">
<div *ngSwitchCase="'image'" class="cell-value">
<i *ngIf="isIconValue(row, col)" class="material-icons icon-cell">{{asIconValue(row, col)}}</i>
<img *ngIf="!isIconValue(row, col)" class="image-cell" alt="" src="{{data.getValue(row, col)}}">
<img *ngIf="!isIconValue(row, col)" class="image-cell" alt="{{iconAltTextKey(data.getValue(row, col))|translate}}" src="{{data.getValue(row, col)}}">
</div>
<div *ngSwitchCase="'date'" class="cell-value">
{{data.getValue(row, col)}}

View File

@ -298,6 +298,12 @@ describe('DataTable', () => {
expect(dataTable.asIconValue(<DataRow> row, column)).toBe(null);
});
it('should parse icon values to a valid i18n key', () => {
expect(dataTable.iconAltTextKey('custom')).toBe('ICONS.custom');
expect(dataTable.iconAltTextKey('/path/to/custom')).toBe('ICONS.custom');
expect(dataTable.iconAltTextKey('/path/to/custom.svg')).toBe('ICONS.custom');
});
it('should require column and direction to evaluate sorting state', () => {
expect(dataTable.isColumnSorted(null, null)).toBeFalsy();
expect(dataTable.isColumnSorted(<DataColumn> {}, null)).toBeFalsy();

View File

@ -26,7 +26,10 @@ import {
TemplateRef
} from '@angular/core';
import { CONTEXT_MENU_DIRECTIVES } from 'ng2-alfresco-core';
import {
CONTEXT_MENU_DIRECTIVES,
AlfrescoPipeTranslate
} from 'ng2-alfresco-core';
import {
DataTableAdapter,
@ -45,7 +48,8 @@ declare let __moduleName: string;
selector: 'alfresco-datatable',
styleUrls: ['./datatable.component.css'],
templateUrl: './datatable.component.html',
directives: [CONTEXT_MENU_DIRECTIVES]
directives: [CONTEXT_MENU_DIRECTIVES],
pipes: [AlfrescoPipeTranslate]
})
export class DataTableComponent implements OnInit, AfterViewChecked {
@ -166,6 +170,10 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
return null;
}
iconAltTextKey(value: string) {
return 'ICONS.' + value.substring(value.lastIndexOf('/') + 1).replace(/\.[a-z]+/, '');
}
isColumnSorted(col: DataColumn, direction: string) {
if (col && direction) {
let sorting = this.data.getSorting();

View File

@ -0,0 +1,16 @@
{
"ICONS": {
"ft_ic_folder": "Folder",
"ft_ic_raster_image": "Image file",
"ft_ic_pdf": "PDF document",
"ft_ic_ms_excel": "Microsoft Excel file",
"ft_ic_ms_word": "Microsoft Word document",
"ft_ic_ms_powerpoint": "Microsoft PowerPoint file",
"ft_ic_video": "Video file",
"ft_ic_document": "Document file",
"ft_ic_website": "Web resource",
"ft_ic_archive": "Archive file",
"ft_ic_presentation": "Presentation file",
"ft_ic_spreadsheet": "Spreadsheet file"
}
}

View File

@ -96,7 +96,7 @@ describe('DocumentListBreadcrumb', () => {
});
it('should update document list on click', () => {
let documentList = new DocumentList(null, null);
let documentList = new DocumentList(null, null, null);
spyOn(documentList, 'displayFolderContent').and.stub();
let node = <PathNode> { name: 'name', path: '/path' };

View File

@ -34,7 +34,7 @@ describe('ContentColumnList', () => {
beforeEach(() => {
let documentListService = new DocumentListServiceMock();
documentList = new DocumentList(documentListService, null);
documentList = new DocumentList(documentListService, null, null);
actionList = new ContentActionList(documentList);
});

View File

@ -44,7 +44,7 @@ describe('ContentAction', () => {
documentActions = new DocumentActionsService(null, null);
folderActions = new FolderActionsService(null);
documentList = new DocumentList(documentServiceMock, null);
documentList = new DocumentList(documentServiceMock, null, null);
actionList = new ContentActionList(documentList);
});

View File

@ -35,7 +35,7 @@ describe('ContentColumnList', () => {
beforeEach(() => {
let service = new DocumentListServiceMock();
documentList = new DocumentList(service, null);
documentList = new DocumentList(service, null, null);
columnList = new ContentColumnList(documentList);
});

View File

@ -34,7 +34,7 @@ describe('ContentColumn', () => {
beforeEach(() => {
let service = new DocumentListServiceMock();
documentList = new DocumentList(service, null);
documentList = new DocumentList(service, null, null);
columnList = new ContentColumnList(documentList);
});

View File

@ -34,7 +34,7 @@ describe('DocumentList', () => {
beforeEach(() => {
documentListService = new DocumentListServiceMock();
let zone = new NgZone(false);
documentList = new DocumentList(documentListService, zone);
documentList = new DocumentList(documentListService, zone, null);
eventMock = {
preventDefault: function () {

View File

@ -31,7 +31,10 @@ import {
HostListener
} from '@angular/core';
import { Subject } from 'rxjs/Rx';
import { CONTEXT_MENU_DIRECTIVES } from 'ng2-alfresco-core';
import {
CONTEXT_MENU_DIRECTIVES,
AlfrescoTranslationService
} from 'ng2-alfresco-core';
import {
ALFRESCO_DATATABLE_DIRECTIVES,
@ -127,9 +130,14 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af
constructor(
private documentListService: DocumentListService,
private ngZone: NgZone) {
private ngZone: NgZone,
private translate: AlfrescoTranslationService) {
this.data = new ShareDataTableAdapter(this.documentListService, this.baseComponentPath, []);
if (translate) {
translate.addTranslationFolder('node_modules/ng2-alfresco-documentlist');
}
}
getContextActions(node: MinimalNodeEntity) {