UX: Add "solved" status filter in advanced search page.

And rename `in:solved` to `status:solved`.
This commit is contained in:
Vinoth Kannan 2020-03-06 08:57:38 +05:30
parent 5591056fe3
commit f4aea44db8
3 changed files with 18 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import PostCooked from "discourse/widgets/post-cooked";
import { formatUsername } from "discourse/lib/utilities"; import { formatUsername } from "discourse/lib/utilities";
import { iconHTML } from "discourse-common/lib/icon-library"; import { iconHTML } from "discourse-common/lib/icon-library";
import { iconNode } from "discourse-common/lib/icon-library"; import { iconNode } from "discourse-common/lib/icon-library";
import SearchAdvancedOptions from "discourse/components/search-advanced-options";
function clearAccepted(topic) { function clearAccepted(topic) {
const posts = topic.get("postStream.posts"); const posts = topic.get("postStream.posts");
@ -262,6 +263,16 @@ export default {
}) })
}); });
SearchAdvancedOptions.reopen({
didInsertElement() {
this._super();
this.statusOptions.push({
name: I18n.t("search.advanced.statuses.solved"),
value: "solved"
});
}
});
withPluginApi("0.1", initializeWithApi); withPluginApi("0.1", initializeWithApi);
withPluginApi("0.8.10", api => { withPluginApi("0.8.10", api => {

View File

@ -27,3 +27,8 @@ en:
topic_statuses: topic_statuses:
solved: solved:
help: "This topic has a solution" help: "This topic has a solution"
search:
advanced:
statuses:
solved: "are solved"

View File

@ -465,7 +465,7 @@ SQL
#TODO Remove when plugin is 1.0 #TODO Remove when plugin is 1.0
if Search.respond_to? :advanced_filter if Search.respond_to? :advanced_filter
Search.advanced_filter(/in:solved/) do |posts| Search.advanced_filter(/status:solved/) do |posts|
posts.where("topics.id IN ( posts.where("topics.id IN (
SELECT tc.topic_id SELECT tc.topic_id
FROM topic_custom_fields tc FROM topic_custom_fields tc
@ -475,7 +475,7 @@ SQL
end end
Search.advanced_filter(/in:unsolved/) do |posts| Search.advanced_filter(/status:unsolved/) do |posts|
posts.where("topics.id NOT IN ( posts.where("topics.id NOT IN (
SELECT tc.topic_id SELECT tc.topic_id
FROM topic_custom_fields tc FROM topic_custom_fields tc