Add alt text for mimetype icons in search component

Refs #302
This commit is contained in:
Will Abson
2016-06-29 16:44:58 +01:00
parent 1334f52e20
commit f92539db19
6 changed files with 78 additions and 35 deletions

View File

@@ -53,9 +53,9 @@ export class AlfrescoSearchAutocompleteComponent implements OnChanges {
@Output()
preview: EventEmitter<any> = new EventEmitter();
constructor(private _alfrescoSearchService: AlfrescoSearchService,
constructor(private alfrescoSearchService: AlfrescoSearchService,
private translate: AlfrescoTranslationService,
private _alfrescoThumbnailService: AlfrescoThumbnailService) {
private alfrescoThumbnailService: AlfrescoThumbnailService) {
if (translate) {
translate.addTranslationFolder('node_modules/ng2-alfresco-search');
}
@@ -74,7 +74,7 @@ export class AlfrescoSearchAutocompleteComponent implements OnChanges {
*/
public displaySearchResults(searchTerm) {
if (searchTerm !== null && searchTerm !== '') {
this._alfrescoSearchService
this.alfrescoSearchService
.getLiveSearchResults(searchTerm)
.subscribe(
results => {
@@ -94,13 +94,26 @@ export class AlfrescoSearchAutocompleteComponent implements OnChanges {
* @param node Node to get URL for.
* @returns {string} URL address.
*/
_getMimeTypeIcon(node: any): string {
getMimeTypeIcon(node: any): string {
if (node.entry.content && node.entry.content.mimeType) {
let icon = this._alfrescoThumbnailService.getMimeTypeIcon(node.entry.content.mimeType);
let icon = this.alfrescoThumbnailService.getMimeTypeIcon(node.entry.content.mimeType);
return `${this.baseComponentPath}/img/${icon}`;
}
}
/**
* Gets thumbnail message key for the given document node, which can be used to look up alt text
* @param node Node to get URL for.
* @returns {string} URL address.
*/
getMimeTypeKey(node: any): string {
if (node.entry.content && node.entry.content.mimeType) {
return 'SEARCH.ICONS.' + this.alfrescoThumbnailService.getMimeTypeKey(node.entry.content.mimeType);
} else {
return '';
}
}
onItemClick(node, event?: Event): void {
if (event) {
event.preventDefault();