From 726b9a460d60872f317eaa310cc3cc4fe24ab1ef Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 27 Feb 2017 15:00:04 +0000 Subject: [PATCH] Added empty box icon to unsolved topics --- .../initializers/extend-for-solved-button.js.es6 | 7 +++++++ config/locales/server.en.yml | 1 + config/settings.yml | 3 +++ plugin.rb | 8 +++++++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 b/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 index 375471b..0f3fcc8 100644 --- a/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 +++ b/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6 @@ -223,6 +223,13 @@ export default { title: I18n.t('solved.has_accepted_answer'), icon: 'check-square-o' }); + }else if(this.topic.can_have_answer && this.siteSettings.solved_enabled && this.siteSettings.empty_box_on_unsolved){ + results.push({ + openTag: 'span', + closeTag: 'span', + title: I18n.t('solved.no_accepted_answer'), + icon: 'square-o' + }); } return results; }.property() diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 2ac8d35..3ea8b27 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -3,6 +3,7 @@ en: solved_enabled: "Enable solved plugin, allow users to select solutions for topics" allow_solved_on_all_topics: "Allow users to select solutions on all topics (by default you control this by editing categories)" accept_all_solutions_trust_level: "Minimum trust level required to accept solutions on any topic (even when not OP)" + empty_box_on_unsolved: "Display an empty box next to unsolved topics" reports: accepted_solutions: title: "Accepted solutions" diff --git a/config/settings.yml b/config/settings.yml index 20e2d68..fb42003 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -8,3 +8,6 @@ plugins: accept_all_solutions_trust_level: default: 4 client: true + empty_box_on_unsolved: + default: false + client: true diff --git a/plugin.rb b/plugin.rb index 65dd583..5c1bcda 100644 --- a/plugin.rb +++ b/plugin.rb @@ -340,11 +340,17 @@ SQL require_dependency 'topic_list_item_serializer' class ::TopicListItemSerializer - attributes :has_accepted_answer + attributes :has_accepted_answer, :can_have_answer def has_accepted_answer object.custom_fields["accepted_answer_post_id"] ? true : false end + + def can_have_answer + return true if SiteSetting.allow_solved_on_all_topics + + return scope.allow_accepted_answers_on_category?(object.category_id) + end end TopicList.preloaded_custom_fields << "accepted_answer_post_id" if TopicList.respond_to? :preloaded_custom_fields