FEATURE: Always show tag dropdown when tagging is enabled (#12209)

This commit is contained in:
Kris
2021-03-10 21:13:15 -05:00
committed by GitHub
parent b81bb2f93b
commit 83519e7f3a
11 changed files with 27 additions and 45 deletions

View File

@ -69,7 +69,7 @@ export default Controller.extend(BulkTopicSelection, FilterModeMixin, {
@discourseComputed("category") @discourseComputed("category")
showTagFilter() { showTagFilter() {
return this.siteSettings.show_filter_by_tag; return true;
}, },
loadMoreTopics() { loadMoreTopics() {

View File

@ -15,23 +15,21 @@
{{/each}} {{/each}}
{{#if siteSettings.tagging_enabled}} {{#if siteSettings.tagging_enabled}}
{{#if siteSettings.show_filter_by_tag}} {{#if additionalTags}}
{{#if additionalTags}} {{tags-intersection-chooser
{{tags-intersection-chooser currentCategory=category
currentCategory=category mainTag=tag.id
mainTag=tag.id additionalTags=additionalTags
additionalTags=additionalTags options=(hash
options=(hash categoryId=category.id
categoryId=category.id )
) }}
}} {{else}}
{{else}} {{tag-drop
{{tag-drop currentCategory=category
currentCategory=category noSubcategories=noSubcategories
noSubcategories=noSubcategories tagId=tag.id
tagId=tag.id }}
}}
{{/if}}
{{/if}} {{/if}}
{{/if}} {{/if}}

View File

@ -1,4 +1,4 @@
{{#d-section tagName="" pageClass="tags" bodyClass=(concat "tag-" tag.id (if category.slug (concat " category-" category.slug)) "")}} {{#d-section tagName="" pageClass="tags" bodyClass=(concat "tag-" tag.id (if category.slug (concat " category-" category.slug)) "" (if additionalTags " tags-intersection"))}}
<div class="container"> <div class="container">
{{discourse-banner user=currentUser banner=site.banner}} {{discourse-banner user=currentUser banner=site.banner}}
</div> </div>

View File

@ -36,7 +36,7 @@ acceptance("Tags intersection", function (needs) {
assert.ok(exists(".mini-tag-chooser"), "The tag selector appears"); assert.ok(exists(".mini-tag-chooser"), "The tag selector appears");
assert.equal( assert.equal(
$(".mini-tag-chooser").text().trim(), $(".composer-fields .mini-tag-chooser").text().trim(),
"first, second", "first, second",
"populates the tags when clicking 'New topic'" "populates the tags when clicking 'New topic'"
); );

View File

@ -4,7 +4,6 @@ import ComboBoxComponent from "select-kit/components/combo-box";
import DiscourseURL, { getCategoryAndTagUrl } from "discourse/lib/url"; import DiscourseURL, { getCategoryAndTagUrl } from "discourse/lib/url";
import TagsMixin from "select-kit/mixins/tags"; import TagsMixin from "select-kit/mixins/tags";
import { computed } from "@ember/object"; import { computed } from "@ember/object";
import { isEmpty } from "@ember/utils";
import { makeArray } from "discourse-common/lib/helpers"; import { makeArray } from "discourse-common/lib/helpers";
export const NO_TAG_ID = "no-tags"; export const NO_TAG_ID = "no-tags";
@ -13,21 +12,13 @@ export const NONE_TAG_ID = "none";
export default ComboBoxComponent.extend(TagsMixin, { export default ComboBoxComponent.extend(TagsMixin, {
pluginApiIdentifiers: ["tag-drop"], pluginApiIdentifiers: ["tag-drop"],
classNameBindings: ["categoryStyle", "tagClass", "shouldHide:hidden"], classNameBindings: ["categoryStyle", "tagClass"],
classNames: ["tag-drop"], classNames: ["tag-drop"],
value: readOnly("tagId"), value: readOnly("tagId"),
tagName: "li", tagName: "li",
showFilterByTag: setting("show_filter_by_tag"),
categoryStyle: setting("category_style"), categoryStyle: setting("category_style"),
maxTagSearchResults: setting("max_tag_search_results"), maxTagSearchResults: setting("max_tag_search_results"),
sortTagsAlphabetically: setting("tags_sort_alphabetically"), sortTagsAlphabetically: setting("tags_sort_alphabetically"),
shouldHide: computed("showFilterByTag", "content.[]", function () {
if (this.showFilterByTag && !isEmpty(this.content)) {
return false;
}
return true;
}),
selectKitOptions: { selectKitOptions: {
allowAny: false, allowAny: false,

View File

@ -308,3 +308,9 @@ section.tag-info {
margin: 0 0.5em 0 0; margin: 0 0.5em 0 0;
} }
} }
body.tags-intersection {
.category-breadcrumb {
margin-right: auto;
}
}

View File

@ -148,7 +148,7 @@ class Tag < ActiveRecord::Base
end end
def self.include_tags? def self.include_tags?
SiteSetting.tagging_enabled && SiteSetting.show_filter_by_tag SiteSetting.tagging_enabled
end end
def full_url def full_url

View File

@ -240,7 +240,7 @@ class TopicTrackingState
end end
def self.include_tags_in_report? def self.include_tags_in_report?
SiteSetting.tagging_enabled && (@include_tags_in_report || SiteSetting.show_filter_by_tag) SiteSetting.tagging_enabled && @include_tags_in_report
end end
def self.include_tags_in_report=(v) def self.include_tags_in_report=(v)

View File

@ -2249,7 +2249,6 @@ en:
max_tags_per_topic: "The maximum tags that can be applied to a topic." max_tags_per_topic: "The maximum tags that can be applied to a topic."
max_tag_length: "The maximum amount of characters that can be used in a tag." max_tag_length: "The maximum amount of characters that can be used in a tag."
max_tag_search_results: "When searching for tags, the maximum number of results to show." max_tag_search_results: "When searching for tags, the maximum number of results to show."
show_filter_by_tag: "Show a dropdown to filter a topic list by tag."
max_tags_in_filter_list: "Maximum number of tags to show in the filter dropdown. The most used tags will be shown." max_tags_in_filter_list: "Maximum number of tags to show in the filter dropdown. The most used tags will be shown."
tags_sort_alphabetically: "Show tags in alphabetical order. Default is to show in order of popularity." tags_sort_alphabetically: "Show tags in alphabetical order. Default is to show in order of popularity."
tags_listed_by_group: "List tags by tag group on the <a href='%{base_path}/tags' target='_blank'>Tags page</a>." tags_listed_by_group: "List tags by tag group on the <a href='%{base_path}/tags' target='_blank'>Tags page</a>."

View File

@ -2379,10 +2379,6 @@ tags:
client: true client: true
default: 5 default: 5
min: 1 min: 1
show_filter_by_tag:
client: true
default: false
refresh: true
max_tags_in_filter_list: max_tags_in_filter_list:
client: true client: true
default: 30 default: 30

View File

@ -636,14 +636,6 @@ describe TopicTrackingState do
expect(row.tags).to contain_exactly("apples", "bananas") expect(row.tags).to contain_exactly("apples", "bananas")
TopicTrackingState.include_tags_in_report = false TopicTrackingState.include_tags_in_report = false
SiteSetting.show_filter_by_tag = true
report = TopicTrackingState.report(user)
expect(report.length).to eq(1)
row = report[0]
expect(row.tags).to contain_exactly("apples", "bananas")
SiteSetting.show_filter_by_tag = false
report = TopicTrackingState.report(user) report = TopicTrackingState.report(user)
expect(report.length).to eq(1) expect(report.length).to eq(1)