Clean up additionalTags impl

This commit is contained in:
James Kiesel 2016-08-15 15:36:28 -04:00
parent 037e9bb7b8
commit 5dd9009718
1 changed files with 5 additions and 6 deletions

View File

@ -15,10 +15,9 @@ export default Discourse.Route.extend({
f = ''; f = '';
if (params.additional_tags) { if (params.additional_tags) {
this.set("additionalTags", _.compact(params.additional_tags.split('/')).map((tag) => { this.set("additionalTags", params.additional_tags.split('/').map((tag) => {
return this.store.createRecord("tag", { id: Handlebars.Utils.escapeExpression(tag) }); return this.store.createRecord("tag", { id: Handlebars.Utils.escapeExpression(tag) }).id;
})); }));
this.set("additionalTagIds", _.pluck(this.get("additionalTags"), 'id'));
} }
if (params.category) { if (params.category) {
@ -63,8 +62,8 @@ export default Discourse.Route.extend({
} }
this.set('category', category); this.set('category', category);
} else if (_.any(this.get("additionalTags"))) { } else if (this.get("additionalTags")) {
params.filter = `tags/intersection/${tag_id}/${this.get('additionalTagIds').join('/')}`; params.filter = `tags/intersection/${tag_id}/${this.get('additionalTags').join('/')}`;
this.set('category', null); this.set('category', null);
} else { } else {
params.filter = `tags/${tag_id}/l/${filter}`; params.filter = `tags/${tag_id}/l/${filter}`;
@ -134,7 +133,7 @@ export default Discourse.Route.extend({
// Pre-fill the tags input field // Pre-fill the tags input field
if (controller.get('model.id')) { if (controller.get('model.id')) {
var c = self.controllerFor('composer').get('model'); var c = self.controllerFor('composer').get('model');
c.set('tags', _.flatten([controller.get('model.id')], controller.get('additionalTagIds'))); c.set('tags', _.flatten([controller.get('model.id')], controller.get('additionalTags')));
} }
}); });
}, },