@mikezimm/fps-core-v7
Version:
Library of reusable core interfaces, types and constants migrated from fps-library-v2
48 lines • 1.87 kB
JavaScript
/**
* getEasySystemIcon: Pass in an array of ISystemEasyIcon and it will try to get the imageUrl based on
* the titles ( exact match )
* the urls ( partial match )
* @param EasySysIcons constants: AllEasySystemIcons, EasyCCSPageIcons, EasySystemListIcons, EasySystemLibraryIcons
* @param item
* @returns
*/
export function getEasySystemIcon(EasySysIcons, item) {
let foundIcon = '';
EasySysIcons.map((SysIcon) => {
if (!foundIcon) {
SysIcon.titles.map((title) => {
if (!foundIcon) {
if (item.title && item.title.toLowerCase() === title) {
foundIcon = SysIcon.imageUrl;
}
else if (item.Title && item.Title.toLowerCase() === title) {
foundIcon = SysIcon.imageUrl;
}
else if (item.description && item.description.toLowerCase() === title) {
foundIcon = SysIcon.imageUrl;
}
else if (item.Description && item.Description.toLowerCase() === title) {
foundIcon = SysIcon.imageUrl;
}
}
;
});
}
;
if (!foundIcon) {
SysIcon.urls.map((url) => {
if (!foundIcon) {
if (item.href && item.href.toLowerCase().indexOf(url) > -1) {
foundIcon = SysIcon.imageUrl;
}
else if (item.url && item.url.toLowerCase().indexOf(url) > -1) {
foundIcon = SysIcon.imageUrl;
}
}
;
});
}
});
return foundIcon;
}
//# sourceMappingURL=getEasySystemIcon.js.map