mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
fix: ng2-alfresco-search
This commit is contained in:
parent
f954930678
commit
d973c39462
@ -26,8 +26,8 @@ declare let componentHandler: any;
|
||||
declare let dialogPolyfill: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'activiti-process-instance-comments',
|
||||
moduleId: module.id,
|
||||
templateUrl: './activiti-comments.component.html',
|
||||
styleUrls: ['./activiti-comments.component.css'],
|
||||
providers: [ActivitiProcessService]
|
||||
|
@ -24,8 +24,8 @@ import { Observable, Observer } from 'rxjs/Rx';
|
||||
declare let componentHandler: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'activiti-process-instance-filters',
|
||||
moduleId: module.id,
|
||||
templateUrl: './activiti-filters.component.html',
|
||||
styleUrls: ['activiti-filters.component.css']
|
||||
})
|
||||
|
@ -26,8 +26,8 @@ import { ProcessInstance } from '../models/process-instance.model';
|
||||
declare let componentHandler: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'activiti-process-instance-details',
|
||||
moduleId: module.id,
|
||||
templateUrl: './activiti-process-instance-details.component.html',
|
||||
styleUrls: ['./activiti-process-instance-details.component.css']
|
||||
})
|
||||
|
@ -24,8 +24,8 @@ import { DatePipe } from '@angular/common';
|
||||
declare let componentHandler: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'activiti-process-instance-header',
|
||||
moduleId: module.id,
|
||||
templateUrl: './activiti-process-instance-header.component.html',
|
||||
styleUrls: ['./activiti-process-instance-header.component.css']
|
||||
})
|
||||
|
@ -27,8 +27,8 @@ declare let componentHandler: any;
|
||||
declare let dialogPolyfill: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'activiti-process-instance-tasks',
|
||||
moduleId: module.id,
|
||||
templateUrl: './activiti-process-instance-tasks.component.html',
|
||||
styleUrls: ['./activiti-process-instance-tasks.component.css']
|
||||
})
|
||||
|
@ -24,8 +24,8 @@ import { ProcessInstance } from '../models/process-instance.model';
|
||||
import { ActivitiProcessService } from '../services/activiti-process.service';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'activiti-process-instance-list',
|
||||
moduleId: module.id,
|
||||
styleUrls: [ './activiti-processlist.component.css' ],
|
||||
templateUrl: './activiti-processlist.component.html'
|
||||
})
|
||||
|
@ -24,8 +24,8 @@ declare let componentHandler: any;
|
||||
declare let dialogPolyfill: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'activiti-start-process-dialog',
|
||||
moduleId: module.id,
|
||||
templateUrl: './activiti-start-process-dialog.component.html',
|
||||
styleUrls: ['./activiti-start-process-dialog.component.css']
|
||||
})
|
||||
|
@ -26,8 +26,8 @@ declare let componentHandler: any;
|
||||
declare let dialogPolyfill: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'activiti-start-process',
|
||||
moduleId: module.id,
|
||||
templateUrl: './activiti-start-process.component.html',
|
||||
styleUrls: ['./activiti-start-process.component.css']
|
||||
})
|
||||
|
@ -24,6 +24,7 @@ import {
|
||||
import { DocumentList } from '../document-list';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'alfresco-document-list-breadcrumb',
|
||||
templateUrl: './breadcrumb.component.html',
|
||||
styleUrls: ['./breadcrumb.component.css']
|
||||
|
@ -134,11 +134,14 @@ describe('AlfrescoSearchAutocompleteComponent', () => {
|
||||
spyOn(thumbnailService, 'getMimeTypeIcon').and.returnValue('fake-type-icon.svg');
|
||||
spyOn(thumbnailService, 'getMimeTypeKey').and.returnValue('FAKE_TYPE');
|
||||
|
||||
let path = 'http://localhost/fake-type-icon.svg';
|
||||
spyOn(component, 'resolveIconPath').and.returnValue(path);
|
||||
|
||||
component.resultsLoad.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
let imgEl = <any> element.querySelector('#result_row_0 img');
|
||||
expect(imgEl).not.toBeNull();
|
||||
expect(imgEl.src).toBe('../img/fake-type-icon.svg');
|
||||
expect(imgEl.src).toBe(path);
|
||||
expect(imgEl.alt).toBe('SEARCH.ICONS.FAKE_TYPE');
|
||||
done();
|
||||
});
|
||||
|
@ -124,10 +124,25 @@ export class AlfrescoSearchAutocompleteComponent implements OnInit, OnChanges {
|
||||
getMimeTypeIcon(node: any): string {
|
||||
if (node.entry.content && node.entry.content.mimeType) {
|
||||
let icon = this.alfrescoThumbnailService.getMimeTypeIcon(node.entry.content.mimeType);
|
||||
return require(`./../img/${icon}`);
|
||||
return this.resolveIconPath(icon);
|
||||
}
|
||||
}
|
||||
|
||||
resolveIconPath(icon: string): string {
|
||||
let result = null;
|
||||
try {
|
||||
// webpack
|
||||
result = require(`./../img/${icon}`);
|
||||
} catch (e) {
|
||||
// system.js
|
||||
if (module && module.id) {
|
||||
let baseComponentPath = module.id.replace('/components/alfresco-search-autocomplete.component.js', '');
|
||||
result = `${baseComponentPath}/img/${icon}`;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -91,10 +91,25 @@ export class AlfrescoSearchComponent implements OnChanges, OnInit {
|
||||
getMimeTypeIcon(node: any): string {
|
||||
if (node.entry.content && node.entry.content.mimeType) {
|
||||
let icon = this._alfrescoThumbnailService.getMimeTypeIcon(node.entry.content.mimeType);
|
||||
return require(`./../img/${icon}`);
|
||||
return this.resolveIconPath(icon);
|
||||
}
|
||||
}
|
||||
|
||||
private resolveIconPath(icon: string): string {
|
||||
let result = null;
|
||||
try {
|
||||
// webpack
|
||||
result = require(`./../img/${icon}`);
|
||||
} catch (e) {
|
||||
// system.js
|
||||
if (module && module.id) {
|
||||
let baseComponentPath = module.id.replace('/components/alfresco-search.component.js', '');
|
||||
result = `${baseComponentPath}/img/${icon}`;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user