From e52c0e2087e2d794be5e7474af8a5479364bba88 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Mon, 25 Jul 2016 12:12:43 -0400 Subject: [PATCH] FIX: tag filter shows when "no tags" is selected --- .../discourse/components/tag-drop.js.es6 | 35 ++++++++++++------- .../discourse/routes/tags-show.js.es6 | 4 +-- .../templates/components/tag-drop.hbs | 7 ++-- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/discourse/components/tag-drop.js.es6 b/app/assets/javascripts/discourse/components/tag-drop.js.es6 index 75329a5cd05..61e287dc88d 100644 --- a/app/assets/javascripts/discourse/components/tag-drop.js.es6 +++ b/app/assets/javascripts/discourse/components/tag-drop.js.es6 @@ -20,30 +20,39 @@ export default Ember.Component.extend({ } }, - iconClass: function() { + @computed('expanded') + iconClass() { if (this.get('expanded')) { return "fa fa-caret-down"; } return "fa fa-caret-right"; - }.property('expanded'), + }, - tagClass: function() { + @computed('tagId') + tagClass() { if (this.get('tagId')) { return "tag-" + this.get('tagId'); } else { return "tag_all"; } - }.property('tagId'), + }, - allTagsUrl: function() { + @computed('firstCategory', 'secondCategory') + allTagsUrl() { if (this.get('currentCategory')) { return this.get('currentCategory.url') + "?allTags=1"; } else { return "/"; } - }.property('firstCategory', 'secondCategory'), + }, - allTagsLabel: function() { + @computed('tag') + allTagsLabel() { return I18n.t("tagging.selector_all_tags"); - }.property('tag'), + }, + + @computed('tagId') + noTagsSelected() { + return this.get('tagId') === 'none'; + }, @computed('firstCategory', 'secondCategory') noTagsUrl() { @@ -59,17 +68,19 @@ export default Ember.Component.extend({ return I18n.t("tagging.selector_no_tags"); }, - dropdownButtonClass: function() { + @computed('tag') + dropdownButtonClass() { var result = 'badge-category category-dropdown-button'; if (Em.isNone(this.get('tag'))) { result += ' home'; } return result; - }.property('tag'), + }, - clickEventName: function() { + @computed('tag') + clickEventName() { return "click.tag-drop-" + (this.get('tag') || "all"); - }.property('tag'), + }, actions: { expand: function() { diff --git a/app/assets/javascripts/discourse/routes/tags-show.js.es6 b/app/assets/javascripts/discourse/routes/tags-show.js.es6 index a42e7f7e4d1..a828e39c68e 100644 --- a/app/assets/javascripts/discourse/routes/tags-show.js.es6 +++ b/app/assets/javascripts/discourse/routes/tags-show.js.es6 @@ -11,7 +11,7 @@ export default Discourse.Route.extend({ }, model(params) { - var tag = (params.tag_id === 'none' ? null : this.store.createRecord("tag", { id: Handlebars.Utils.escapeExpression(params.tag_id) })), + var tag = this.store.createRecord("tag", { id: Handlebars.Utils.escapeExpression(params.tag_id) }), f = ''; if (params.category) { @@ -25,7 +25,7 @@ export default Discourse.Route.extend({ if (params.category) { this.set('categorySlug', params.category); } if (params.parent_category) { this.set('parentCategorySlug', params.parent_category); } - if (tag && this.get("currentUser")) { + if (tag && tag.get("id") !== "none" && this.get("currentUser")) { // If logged in, we should get the tag's user settings return this.store.find("tagNotification", tag.get("id")).then(tn => { this.set("tagNotification", tn); diff --git a/app/assets/javascripts/discourse/templates/components/tag-drop.hbs b/app/assets/javascripts/discourse/templates/components/tag-drop.hbs index 5d9a6581923..833ab895902 100644 --- a/app/assets/javascripts/discourse/templates/components/tag-drop.hbs +++ b/app/assets/javascripts/discourse/templates/components/tag-drop.hbs @@ -1,8 +1,11 @@ {{#if showTagDropdown}} {{#if tagId}} - {{tagId}} + {{#if noTagsSelected}} + {{noTagsLabel}} + {{else}} + {{tagId}} + {{/if}} {{else}} - {{allTagsLabel}} {{/if}}