FIX: Category badges were missing stripes in some places
This commit is contained in:
parent
a8acbc37a2
commit
8b51176f2e
|
@ -1,22 +1,8 @@
|
|||
// Compile and memoize a template
|
||||
var compiled;
|
||||
function templateFunction() {
|
||||
compiled = compiled || Handlebars.compile("<div class='autocomplete'>" +
|
||||
"<ul>" +
|
||||
"{{#each options}}" +
|
||||
"<li>" +
|
||||
"{{category-link-raw this allowUncategorized=true}}" +
|
||||
"</li>" +
|
||||
"{{/each}}" +
|
||||
"</ul>" +
|
||||
"</div>");
|
||||
return compiled;
|
||||
}
|
||||
|
||||
export default Ember.Component.extend({
|
||||
|
||||
didInsertElement: function(){
|
||||
_initializeAutocomplete: function(){
|
||||
var self = this;
|
||||
var template = this.container.lookup('template:category-group-autocomplete.raw');
|
||||
|
||||
this.$('input').autocomplete({
|
||||
items: this.get('categories'),
|
||||
|
@ -37,10 +23,11 @@ export default Ember.Component.extend({
|
|||
});
|
||||
self.set("categories", categories);
|
||||
},
|
||||
template: templateFunction(),
|
||||
template: template,
|
||||
transformComplete: function(category) {
|
||||
return Discourse.HTML.categoryBadge(category, {allowUncategorized: true});
|
||||
}
|
||||
});
|
||||
}
|
||||
}.on('didInsertElement')
|
||||
|
||||
});
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
import { categoryLinkHTML } from 'discourse/lib/html-builder';
|
||||
|
||||
Ember.Handlebars.helper('bound-category-link', categoryLinkHTML);
|
|
@ -1,4 +1,4 @@
|
|||
import { categoryLinkHTML } from 'discourse/lib/html-builder';
|
||||
import { categoryLinkHTML } from 'discourse/helpers/category-badge';
|
||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
||||
|
||||
registerUnbound('category-badge', function(cat, options) {
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
import { categoryLinkHTML } from 'discourse/lib/html-builder';
|
||||
|
||||
Handlebars.registerHelper('category-link-raw', function(property, options) {
|
||||
return categoryLinkHTML(property, options);
|
||||
});
|
|
@ -1,4 +1,21 @@
|
|||
import { categoryLinkHTML } from 'discourse/lib/html-builder';
|
||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
||||
|
||||
export function categoryLinkHTML(category, options) {
|
||||
var categoryOptions = {};
|
||||
|
||||
// TODO: This is a compatibility layer with the old helper structure.
|
||||
// Can be removed once we migrate to `registerUnbound` fully
|
||||
if (options && options.hash) { options = options.hash; }
|
||||
|
||||
if (options) {
|
||||
if (options.allowUncategorized) { categoryOptions.allowUncategorized = true; }
|
||||
if (options.showParent) { categoryOptions.showParent = true; }
|
||||
if (options.onlyStripe) { categoryOptions.onlyStripe = true; }
|
||||
if (options.link !== undefined) { categoryOptions.link = options.link; }
|
||||
if (options.extraClasses) { categoryOptions.extraClasses = options.extraClasses; }
|
||||
}
|
||||
return new Handlebars.SafeString(Discourse.HTML.categoryBadge(category, categoryOptions));
|
||||
}
|
||||
|
||||
registerUnbound('category-link', categoryLinkHTML);
|
||||
Ember.Handlebars.helper('bound-category-link', categoryLinkHTML);
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
export function categoryLinkHTML(category, options) {
|
||||
var categoryOptions = {};
|
||||
|
||||
// TODO: This is a compatibility layer with the old helper structure.
|
||||
// Can be removed once we migrate to `registerUnbound` fully
|
||||
if (options && options.hash) { options = options.hash; }
|
||||
|
||||
if (options) {
|
||||
if (options.allowUncategorized) { categoryOptions.allowUncategorized = true; }
|
||||
if (options.showParent) { categoryOptions.showParent = true; }
|
||||
if (options.onlyStripe) { categoryOptions.onlyStripe = true; }
|
||||
if (options.link !== undefined) { categoryOptions.link = options.link; }
|
||||
if (options.extraClasses) { categoryOptions.extraClasses = options.extraClasses; }
|
||||
}
|
||||
return new Handlebars.SafeString(Discourse.HTML.categoryBadge(category, categoryOptions));
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<div class='autocomplete'>
|
||||
<ul>
|
||||
{{#each options}}
|
||||
<li>{{category-link this allowUncategorized="true"}}</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
|
@ -32,7 +32,7 @@
|
|||
{{#if c.subcategories}}
|
||||
<div class='subcategories'>
|
||||
{{#each s in c.subcategories}}
|
||||
{{category-link s showParent=true onlyStripe=true}}
|
||||
{{category-link s showParent="true" onlyStripe="true"}}
|
||||
{{#if s.unreadTopics}}
|
||||
<a href={{unbound s.unreadUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.unread_topics' count=s.unreadTopics}}'>{{unbound s.unreadTopics}}</a>
|
||||
{{/if}}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{{#unless hideCategory}}
|
||||
<td class='category'>{{category-link category showParent=true}}</td>
|
||||
<td class='category'>{{category-link category showParent="true"}}</td>
|
||||
{{/unless}}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
</div>
|
||||
{{#unless controller.hideCategory}}
|
||||
<div class='category'>
|
||||
{{category-link t.category showParent=true}}
|
||||
{{category-link t.category showParent="true"}}
|
||||
</div>
|
||||
{{/unless}}
|
||||
{{#if controller.showParticipants}}
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<td>
|
||||
<div class='subcategories'>
|
||||
{{#each subcategory in c.subcategories}}
|
||||
{{category-link subcategory showParent=true}}
|
||||
{{category-link subcategory showParent="true"}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<div class="topic-item-stats clearfix">
|
||||
{{#unless controller.hideCategory}}
|
||||
<div class='category'>
|
||||
{{category-link category showParent=true}}
|
||||
{{category-link category showParent="true"}}
|
||||
</div>
|
||||
{{/unless}}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
{{#each c in categories itemController='site-map-category'}}
|
||||
<li class="category">
|
||||
{{category-link c allowUncategorized=true showParent=true}}
|
||||
{{category-link c allowUncategorized="true" showParent="true"}}
|
||||
|
||||
{{#if c.unreadTotal}}
|
||||
<a href={{unbound c.url}} class='badge badge-notification'>{{c.unreadTotal}}</a>
|
||||
|
|
Loading…
Reference in New Issue