mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FIX: tags index should show all tags belonging to a category even if they have never been used
This commit is contained in:
parent
5ba8612fa8
commit
3c0df3510a
2 changed files with 10 additions and 2 deletions
|
@ -6,7 +6,11 @@
|
|||
{{/if}}
|
||||
{{#each sortedTags as |tag|}}
|
||||
<div class='tag-box'>
|
||||
{{#if tag.count}}
|
||||
{{discourse-tag tag.id}} <span class='tag-count'>x {{tag.count}}</span>
|
||||
{{else}}
|
||||
{{discourse-tag tag.id}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/each}}
|
||||
<div class="clearfix" />
|
||||
|
|
|
@ -15,7 +15,11 @@ class TagsController < ::ApplicationController
|
|||
categories = Category.where("id in (select category_id from category_tags)")
|
||||
.where("id in (?)", guardian.allowed_category_ids)
|
||||
.preload(:tags)
|
||||
category_tag_counts = categories.map { |c| {id: c.id, tags: self.class.tag_counts_json(Tag.category_tags_by_count_query(c, limit: 300).count)} }
|
||||
category_tag_counts = categories.map do |c|
|
||||
h = Tag.category_tags_by_count_query(c, limit: 300).count
|
||||
h.merge!(c.tags.where.not(name: h.keys).inject({}) { |sum,t| sum[t.name] = 0; sum }) # unused tags
|
||||
{id: c.id, tags: self.class.tag_counts_json(h)}
|
||||
end
|
||||
|
||||
tag_counts = self.class.tags_by_count(guardian, limit: 300).count
|
||||
@tags = self.class.tag_counts_json(tag_counts)
|
||||
|
|
Loading…
Reference in a new issue