Show group icon in category badges if the category has restricted access

This commit is contained in:
Neil Lalonde 2014-02-03 15:28:31 -05:00
parent bf951689e8
commit 1b66876c08
3 changed files with 23 additions and 3 deletions

View file

@ -47,7 +47,10 @@ Discourse.HTML = {
var name = Em.get(category, 'name'),
description = Em.get(category, 'description'),
html = "<a href=\"" + Discourse.getURL("/category/") + Discourse.Category.slugFor(category) + "\" class=\"badge-category\" ";
restricted = Em.get(category, 'read_restricted'),
html = "<a href=\"" + Discourse.getURL("/category/") + Discourse.Category.slugFor(category) + "\" ";
html += "class=\"badge-category" + (restricted ? ' restricted' : '' ) + "\" ";
// Add description if we have it
if (description) html += "title=\"" + Handlebars.Utils.escapeExpression(description) + "\" ";
@ -56,7 +59,12 @@ Discourse.HTML = {
if (categoryStyle) {
html += "style=\"" + categoryStyle + "\" ";
}
html += ">" + name + "</a>";
if (restricted) {
html += "><div><i class='fa fa-group'></i> " + name + "</div></a>";
} else {
html += ">" + name + "</a>";
}
return html;
}

View file

@ -1,5 +1,10 @@
{{#if category}}
<a href="#" {{action expand}} class="badge-category" {{bind-attr style="badgeStyle"}}>{{category.name}}</a>
<a href="#" {{action expand}} class="badge-category" {{bind-attr style="badgeStyle"}}>
{{#if category.read_restricted}}
<i class='fa fa-group'></i>
{{/if}}
{{category.name}}
</a>
{{else}}
{{#if noSubcategories}}
<a href='#' {{action expand}} class='badge-category home' {{bind-attr style="badgeStyle"}}>{{i18n categories.no_subcategory}}</i></a>

View file

@ -28,6 +28,13 @@
&[href] {
color: $white;
}
&.restricted {
div {
display: inline-block;
vertical-align: top;
margin: 0;
}
}
}