mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 11:02:46 +08:00
FIX: when deleting a tag, the warning modal has the wrong topic count
This commit is contained in:
parent
ad58a1743b
commit
298ee26908
|
@ -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; }
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ class TopicList
|
|||
:for_period,
|
||||
:per_page,
|
||||
:top_tags,
|
||||
:current_user
|
||||
:current_user,
|
||||
:tags
|
||||
|
||||
def initialize(filter, current_user, topics, opts = nil)
|
||||
@filter = filter
|
||||
|
@ -46,6 +47,10 @@ class TopicList
|
|||
if @opts[:category]
|
||||
@category = Category.find_by(id: @opts[:category_id])
|
||||
end
|
||||
|
||||
if @opts[:tags]
|
||||
@tags = Tag.where(id: @opts[:tags]).all
|
||||
end
|
||||
end
|
||||
|
||||
def top_tags
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class TagSerializer < ApplicationSerializer
|
||||
attributes :id, :name
|
||||
attributes :id, :name, :topic_count
|
||||
end
|
||||
|
|
|
@ -7,9 +7,11 @@ class TopicListSerializer < ApplicationSerializer
|
|||
:draft_sequence,
|
||||
:for_period,
|
||||
:per_page,
|
||||
:top_tags
|
||||
:top_tags,
|
||||
:tags
|
||||
|
||||
has_many :topics, serializer: TopicListItemSerializer, embed: :objects
|
||||
has_many :tags, serializer: TagSerializer, embed: :objects
|
||||
|
||||
def can_create_topic
|
||||
scope.can_create?(Topic)
|
||||
|
@ -26,4 +28,8 @@ class TopicListSerializer < ApplicationSerializer
|
|||
def include_top_tags?
|
||||
Tag.include_tags?
|
||||
end
|
||||
|
||||
def include_tags?
|
||||
SiteSetting.tagging_enabled && object.tags.present?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user