mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-07-04 21:02:20 +00:00
REVERT: 'FEATURE: Add solved icon for topic titles in search results and other topic lists'
This commit is contained in:
parent
b1682574d0
commit
6dbd420c9e
@ -1,19 +0,0 @@
|
|||||||
module TopicAnswerMixin
|
|
||||||
def self.included(klass)
|
|
||||||
klass.attributes :has_accepted_answer, :can_have_answer
|
|
||||||
end
|
|
||||||
|
|
||||||
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 false if object.closed || object.archived
|
|
||||||
return scope.allow_accepted_answers_on_category?(object.category_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
def include_can_have_answer?
|
|
||||||
SiteSetting.empty_box_on_unsolved
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,7 +1,6 @@
|
|||||||
import Topic from "discourse/models/topic";
|
import Topic from "discourse/models/topic";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import TopicStatus from "discourse/raw-views/topic-status";
|
import TopicStatus from "discourse/raw-views/topic-status";
|
||||||
import TopicStatusIcons from "discourse/helpers/topic-status-icons";
|
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
@ -65,12 +64,6 @@ function acceptPost(post) {
|
|||||||
function initializeWithApi(api) {
|
function initializeWithApi(api) {
|
||||||
const currentUser = api.getCurrentUser();
|
const currentUser = api.getCurrentUser();
|
||||||
|
|
||||||
TopicStatusIcons.addObject([
|
|
||||||
"has_accepted_answer",
|
|
||||||
"check-square-o",
|
|
||||||
"solved"
|
|
||||||
]);
|
|
||||||
|
|
||||||
api.includePostAttributes(
|
api.includePostAttributes(
|
||||||
"can_accept_answer",
|
"can_accept_answer",
|
||||||
"can_unaccept_answer",
|
"can_unaccept_answer",
|
||||||
@ -226,7 +219,7 @@ export default {
|
|||||||
results.push({
|
results.push({
|
||||||
openTag: "span",
|
openTag: "span",
|
||||||
closeTag: "span",
|
closeTag: "span",
|
||||||
title: I18n.t("topic_statuses.solved.help"),
|
title: I18n.t("solved.has_accepted_answer"),
|
||||||
icon: "check-square-o"
|
icon: "check-square-o"
|
||||||
});
|
});
|
||||||
} else if (
|
} else if (
|
||||||
|
@ -9,6 +9,7 @@ en:
|
|||||||
title: "Solved"
|
title: "Solved"
|
||||||
allow_accepted_answers: "Allow topic owner and staff to mark a reply as the solution"
|
allow_accepted_answers: "Allow topic owner and staff to mark a reply as the solution"
|
||||||
accept_answer: "Select if this reply solves the problem"
|
accept_answer: "Select if this reply solves the problem"
|
||||||
|
has_accepted_answer: "This topic has a solution"
|
||||||
has_no_accepted_answer: "This topic has no solution"
|
has_no_accepted_answer: "This topic has no solution"
|
||||||
unaccept_answer: "Unselect if this reply no longer solves the problem"
|
unaccept_answer: "Unselect if this reply no longer solves the problem"
|
||||||
accepted_answer: "Solution"
|
accepted_answer: "Solution"
|
||||||
@ -18,7 +19,3 @@ en:
|
|||||||
other: "solutions"
|
other: "solutions"
|
||||||
accepted_html: "{{icon}} Solved <span class='by'>by <a href data-user-card='{{username_lower}}'>{{username}}</a></span> in <a href='{{post_path}}' class='back'>post #{{post_number}}</a>"
|
accepted_html: "{{icon}} Solved <span class='by'>by <a href data-user-card='{{username_lower}}'>{{username}}</a></span> in <a href='{{post_path}}' class='back'>post #{{post_number}}</a>"
|
||||||
accepted_notification: "<p><span>{{username}}</span> {{description}}</p>"
|
accepted_notification: "<p><span>{{username}}</span> {{description}}</p>"
|
||||||
|
|
||||||
topic_statuses:
|
|
||||||
solved:
|
|
||||||
help: "This topic has a solution"
|
|
||||||
|
49
plugin.rb
49
plugin.rb
@ -18,10 +18,6 @@ register_asset 'stylesheets/solutions.scss'
|
|||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
|
|
||||||
[
|
|
||||||
'../app/serializers/concerns/topic_answer_mixin.rb'
|
|
||||||
].each { |path| load File.expand_path(path, __FILE__) }
|
|
||||||
|
|
||||||
# we got to do a one time upgrade
|
# we got to do a one time upgrade
|
||||||
if defined?(UserAction::SOLVED)
|
if defined?(UserAction::SOLVED)
|
||||||
unless $redis.get('solved_already_upgraded')
|
unless $redis.get('solved_already_upgraded')
|
||||||
@ -483,29 +479,42 @@ SQL
|
|||||||
end
|
end
|
||||||
|
|
||||||
require_dependency 'topic_list_item_serializer'
|
require_dependency 'topic_list_item_serializer'
|
||||||
require_dependency 'search_topic_list_item_serializer'
|
require_dependency 'listable_topic_serializer'
|
||||||
require_dependency 'suggested_topic_serializer'
|
|
||||||
require_dependency 'category_detailed_serializer'
|
|
||||||
require_dependency 'user_summary_serializer'
|
|
||||||
|
|
||||||
class ::TopicListItemSerializer
|
class ::TopicListItemSerializer
|
||||||
include TopicAnswerMixin
|
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 false if object.closed || object.archived
|
||||||
|
return scope.allow_accepted_answers_on_category?(object.category_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_can_have_answer?
|
||||||
|
SiteSetting.empty_box_on_unsolved
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class ::SearchTopicListItemSerializer
|
class ::ListableTopicSerializer
|
||||||
include TopicAnswerMixin
|
attributes :has_accepted_answer, :can_have_answer
|
||||||
end
|
|
||||||
|
|
||||||
class ::SuggestedTopicSerializer
|
def has_accepted_answer
|
||||||
include TopicAnswerMixin
|
object.custom_fields["accepted_answer_post_id"] ? true : false
|
||||||
end
|
end
|
||||||
|
|
||||||
class ::CategoryDetailedSerializer
|
def can_have_answer
|
||||||
include TopicAnswerMixin
|
return true if SiteSetting.allow_solved_on_all_topics
|
||||||
end
|
return false if object.closed || object.archived
|
||||||
|
return scope.allow_accepted_answers_on_category?(object.category_id)
|
||||||
|
end
|
||||||
|
|
||||||
class ::UserSummarySerializer::TopicSerializer
|
def include_can_have_answer?
|
||||||
include TopicAnswerMixin
|
SiteSetting.empty_box_on_unsolved
|
||||||
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user