Allow slug partial-match option
This commit is contained in:
parent
911b973237
commit
26291e62b1
|
@ -1,4 +1,5 @@
|
||||||
<script type="text/discourse-plugin" version="0.8.26">
|
<script type="text/discourse-plugin" version="0.8.26">
|
||||||
|
// modified RCO Jan 2019 to allow partial match on category-slug
|
||||||
let categoryThemeList = settings.category_icon_list.split('|');
|
let categoryThemeList = settings.category_icon_list.split('|');
|
||||||
let lockIcon = settings.category_lock_icon || 'lock';
|
let lockIcon = settings.category_lock_icon || 'lock';
|
||||||
|
|
||||||
|
@ -15,11 +16,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIconItem(categorySlug) {
|
function getIconItem(categorySlug) {
|
||||||
let categoryThemeItem = categoryThemeList.find((str) => str.indexOf(categorySlug) > -1);
|
// return nothing if categorySlug not specified
|
||||||
|
if (!categorySlug) return;
|
||||||
|
let categoryThemeItem = categoryThemeList.find((str) =>
|
||||||
|
str.indexOf(",") > -1 ? categorySlug.indexOf(str.substr(0,str.indexOf(","))) > -1 : '');
|
||||||
if (categoryThemeItem) {
|
if (categoryThemeItem) {
|
||||||
let iconItem = categoryThemeItem.split(',');
|
let iconItem = categoryThemeItem.split(',');
|
||||||
// Ensure exact match
|
// Test partial/exact match
|
||||||
if(iconItem[0] === categorySlug) {
|
if(iconItem[3]=='partial') {
|
||||||
|
return iconItem;
|
||||||
|
} else if(iconItem[0] === categorySlug) {
|
||||||
return iconItem;
|
return iconItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
category_icon_list:
|
category_icon_list:
|
||||||
default: 'help,question-circle,#CC0000|'
|
default: 'help,question-circle,#CC0000,partial|'
|
||||||
type: 'list'
|
type: 'list'
|
||||||
description: 'Enter comma-delimited configuration for categories, in the format "category-slug,icon,color".'
|
description: 'Enter comma-delimited configuration for categories, in the format "slug,icon,colour,match". If match is "partial" then the slug need only partially match the category-slug, otherwise an exact match is required'
|
||||||
svg_icons:
|
svg_icons:
|
||||||
default: 'question-circle'
|
default: 'question-circle'
|
||||||
type: 'list'
|
type: 'list'
|
||||||
|
|
Loading…
Reference in New Issue