A platform for community discussion. Free, open, simple.
FIX: when deleting a tag, the warning modal has the wrong topic count
Neil Lalonde298ee2690898
diff --git a/app/assets/javascripts/discourse/controllers/tags-show.js.es6 b/app/assets/javascripts/discourse/controllers/tags-show.js.es6index d1a292c2e88..dbf92517366 100644--- a/app/assets/javascripts/discourse/controllers/tags-show.js.es6+++ b/app/assets/javascripts/discourse/controllers/tags-show.js.es6@@ -119,8 +119,8 @@ export default Ember.Controller.extend(BulkTopicSelection, {deleteTag() {const self = this;- const topicsLength = this.get('list.topic_list.topics.length');- const confirmText = topicsLength === 0 ? I18n.t("tagging.delete_confirm_no_topics") : I18n.t("tagging.delete_confirm", {count: topicsLength});+ const numTopics = this.get('list.topic_list.tags.firstObject.topic_count') || 0;+ const confirmText = numTopics === 0 ? I18n.t("tagging.delete_confirm_no_topics") : I18n.t("tagging.delete_confirm", {count: numTopics});bootbox.confirm(confirmText, function(result) {if (!result) { return; }diff --git a/app/models/topic_list.rb b/app/models/topic_list.rbindex 0e02b74fe15..dbb468cb489 100644--- a/app/models/topic_list.rb+++ b/app/models/topic_list.rb@@ -35,7 +35,8 @@ class TopicList:for_period,:per_page,:top_tags,- :current_user+ :current_user,+ :tagsdef initialize(filter, current_user, topics, opts = nil)@filter = filter@@ -46,6 +47,10 @@ class TopicListif @opts[:category]@category = Category.find_by(id: @opts[:category_id])end++ if @opts[:tags]+ @tags = Tag.where(id: @opts[:tags]).all+ endenddef top_tagsdiff --git a/app/serializers/tag_serializer.rb b/app/serializers/tag_serializer.rbindex 206a0256fa7..9f050800295 100644--- a/app/serializers/tag_serializer.rb+++ b/app/serializers/tag_serializer.rb@@ -1,3 +1,3 @@class TagSerializer < ApplicationSerializer- attributes :id, :name+ attributes :id, :name, :topic_countenddiff --git a/app/serializers/topic_list_serializer.rb b/app/serializers/topic_list_serializer.rbindex 0a9300790f2..994ea84950c 100644--- a/app/serializers/topic_list_serializer.rb+++ b/app/serializers/topic_list_serializer.rb@@ -7,9 +7,11 @@ class TopicListSerializer < ApplicationSerializer:draft_sequence,:for_period,:per_page,- :top_tags+ :top_tags,+ :tagshas_many :topics, serializer: TopicListItemSerializer, embed: :objects+ has_many :tags, serializer: TagSerializer, embed: :objectsdef can_create_topicscope.can_create?(Topic)@@ -26,4 +28,8 @@ class TopicListSerializer < ApplicationSerializerdef include_top_tags?Tag.include_tags?end++ def include_tags?+ SiteSetting.tagging_enabled && object.tags.present?+ endend