mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Merge pull request #415 from Alfresco/dev-wabson-378
Add alt text for file and folder icons in documentlist
This commit is contained in:
@@ -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)}}
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user