Added empty box icon to unsolved topics

This commit is contained in:
David Taylor 2017-02-27 15:00:04 +00:00
parent 73e4909615
commit 726b9a460d
4 changed files with 18 additions and 1 deletions

View File

@ -223,6 +223,13 @@ export default {
title: I18n.t('solved.has_accepted_answer'), title: I18n.t('solved.has_accepted_answer'),
icon: 'check-square-o' 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; return results;
}.property() }.property()

View File

@ -3,6 +3,7 @@ en:
solved_enabled: "Enable solved plugin, allow users to select solutions for topics" 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)" 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)" 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: reports:
accepted_solutions: accepted_solutions:
title: "Accepted solutions" title: "Accepted solutions"

View File

@ -8,3 +8,6 @@ plugins:
accept_all_solutions_trust_level: accept_all_solutions_trust_level:
default: 4 default: 4
client: true client: true
empty_box_on_unsolved:
default: false
client: true

View File

@ -340,11 +340,17 @@ SQL
require_dependency 'topic_list_item_serializer' require_dependency 'topic_list_item_serializer'
class ::TopicListItemSerializer class ::TopicListItemSerializer
attributes :has_accepted_answer attributes :has_accepted_answer, :can_have_answer
def has_accepted_answer def has_accepted_answer
object.custom_fields["accepted_answer_post_id"] ? true : false object.custom_fields["accepted_answer_post_id"] ? true : false
end 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 end
TopicList.preloaded_custom_fields << "accepted_answer_post_id" if TopicList.respond_to? :preloaded_custom_fields TopicList.preloaded_custom_fields << "accepted_answer_post_id" if TopicList.respond_to? :preloaded_custom_fields