FIX: `category-group` didn't work with subdirectories
This commit is contained in:
parent
26a9c35293
commit
49978d02c2
|
@ -2,31 +2,32 @@ import { categoryBadgeHTML } from 'discourse/helpers/category-link';
|
|||
|
||||
export default Ember.Component.extend({
|
||||
|
||||
_initializeAutocomplete: function(){
|
||||
var self = this;
|
||||
var template = this.container.lookup('template:category-group-autocomplete.raw');
|
||||
_initializeAutocomplete: function() {
|
||||
const self = this,
|
||||
template = this.container.lookup('template:category-group-autocomplete.raw'),
|
||||
regexp = new RegExp("href=['\"]" + Discourse.getURL('/c/') + "([^'\"]+)");
|
||||
|
||||
this.$('input').autocomplete({
|
||||
items: this.get('categories'),
|
||||
single: false,
|
||||
allowAny: false,
|
||||
dataSource: function(term){
|
||||
dataSource(term){
|
||||
return Discourse.Category.list().filter(function(category){
|
||||
var regex = new RegExp(term, "i");
|
||||
const regex = new RegExp(term, "i");
|
||||
return category.get("name").match(regex) &&
|
||||
!_.contains(self.get('blacklist') || [], category) &&
|
||||
!_.contains(self.get('categories'), category) ;
|
||||
});
|
||||
},
|
||||
onChangeItems: function(items) {
|
||||
var categories = _.map(items, function(link) {
|
||||
var slug = link.match(/href=['"]\/c\/([^'"]+)/)[1];
|
||||
onChangeItems(items) {
|
||||
const categories = _.map(items, function(link) {
|
||||
const slug = link.match(regexp)[1];
|
||||
return Discourse.Category.findSingleBySlug(slug);
|
||||
});
|
||||
self.set("categories", categories);
|
||||
},
|
||||
template: template,
|
||||
transformComplete: function(category) {
|
||||
template,
|
||||
transformComplete(category) {
|
||||
return categoryBadgeHTML(category, {allowUncategorized: true});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue