mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 10:50:26 -06:00
FIX: tag input doesn't show staff-only tags to non-staff
This commit is contained in:
parent
af1c994940
commit
3d5716a2c8
@ -78,7 +78,7 @@ export default Ember.TextField.extend({
|
|||||||
url: Discourse.getURL("/tags/filter/search"),
|
url: Discourse.getURL("/tags/filter/search"),
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: function (term) {
|
data: function (term) {
|
||||||
return { q: term, limit: self.siteSettings.max_tag_search_results };
|
return { q: term, limit: self.siteSettings.max_tag_search_results, filterForInput: true };
|
||||||
},
|
},
|
||||||
results: function (data) {
|
results: function (data) {
|
||||||
if (self.siteSettings.tags_sort_alphabetically) {
|
if (self.siteSettings.tags_sort_alphabetically) {
|
||||||
|
@ -112,6 +112,11 @@ class TagsController < ::ApplicationController
|
|||||||
query = query.where('tags.name like ?', "%#{term}%")
|
query = query.where('tags.name like ?', "%#{term}%")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params[:filterForInput] && !guardian.is_staff?
|
||||||
|
staff_tag_names = SiteSetting.staff_tags.split("|")
|
||||||
|
query = query.where('tags.name NOT IN (?)', staff_tag_names) if staff_tag_names.present?
|
||||||
|
end
|
||||||
|
|
||||||
tags = query.count.map {|t, c| { id: t, text: t, count: c } }
|
tags = query.count.map {|t, c| { id: t, text: t, count: c } }
|
||||||
|
|
||||||
render json: { results: tags }
|
render json: { results: tags }
|
||||||
|
Loading…
Reference in New Issue
Block a user