mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Post time query filter not set correctly when loaded from params.
https://meta.discourse.org/t/before-and-after-are-not-implemented-right-in-search/92515
This commit is contained in:
@@ -38,6 +38,7 @@ export default Em.Component.extend({
|
|||||||
{ name: I18n.t("search.advanced.filters.tracking"), value: "tracking" },
|
{ name: I18n.t("search.advanced.filters.tracking"), value: "tracking" },
|
||||||
{ name: I18n.t("search.advanced.filters.bookmarks"), value: "bookmarks" }
|
{ name: I18n.t("search.advanced.filters.bookmarks"), value: "bookmarks" }
|
||||||
],
|
],
|
||||||
|
|
||||||
inOptionsForAll: [
|
inOptionsForAll: [
|
||||||
{ name: I18n.t("search.advanced.filters.first"), value: "first" },
|
{ name: I18n.t("search.advanced.filters.first"), value: "first" },
|
||||||
{ name: I18n.t("search.advanced.filters.pinned"), value: "pinned" },
|
{ name: I18n.t("search.advanced.filters.pinned"), value: "pinned" },
|
||||||
@@ -45,6 +46,7 @@ export default Em.Component.extend({
|
|||||||
{ name: I18n.t("search.advanced.filters.wiki"), value: "wiki" },
|
{ name: I18n.t("search.advanced.filters.wiki"), value: "wiki" },
|
||||||
{ name: I18n.t("search.advanced.filters.images"), value: "images" }
|
{ name: I18n.t("search.advanced.filters.images"), value: "images" }
|
||||||
],
|
],
|
||||||
|
|
||||||
statusOptions: [
|
statusOptions: [
|
||||||
{ name: I18n.t("search.advanced.statuses.open"), value: "open" },
|
{ name: I18n.t("search.advanced.statuses.open"), value: "open" },
|
||||||
{ name: I18n.t("search.advanced.statuses.closed"), value: "closed" },
|
{ name: I18n.t("search.advanced.statuses.closed"), value: "closed" },
|
||||||
@@ -55,6 +57,7 @@ export default Em.Component.extend({
|
|||||||
value: "single_user"
|
value: "single_user"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
postTimeOptions: [
|
postTimeOptions: [
|
||||||
{ name: I18n.t("search.advanced.post.time.before"), value: "before" },
|
{ name: I18n.t("search.advanced.post.time.before"), value: "before" },
|
||||||
{ name: I18n.t("search.advanced.post.time.after"), value: "after" }
|
{ name: I18n.t("search.advanced.post.time.after"), value: "after" }
|
||||||
@@ -116,29 +119,36 @@ export default Em.Component.extend({
|
|||||||
this.setSearchedTermValueForGroup();
|
this.setSearchedTermValueForGroup();
|
||||||
this.setSearchedTermValueForBadge();
|
this.setSearchedTermValueForBadge();
|
||||||
this.setSearchedTermValueForTags();
|
this.setSearchedTermValueForTags();
|
||||||
|
|
||||||
this.setSearchedTermValue(
|
this.setSearchedTermValue(
|
||||||
"searchedTerms.in",
|
"searchedTerms.in",
|
||||||
REGEXP_IN_PREFIX,
|
REGEXP_IN_PREFIX,
|
||||||
REGEXP_IN_MATCH
|
REGEXP_IN_MATCH
|
||||||
);
|
);
|
||||||
|
|
||||||
this.setSearchedTermSpecialInValue(
|
this.setSearchedTermSpecialInValue(
|
||||||
"searchedTerms.special.in.likes",
|
"searchedTerms.special.in.likes",
|
||||||
REGEXP_SPECIAL_IN_LIKES_MATCH
|
REGEXP_SPECIAL_IN_LIKES_MATCH
|
||||||
);
|
);
|
||||||
|
|
||||||
this.setSearchedTermSpecialInValue(
|
this.setSearchedTermSpecialInValue(
|
||||||
"searchedTerms.special.in.title",
|
"searchedTerms.special.in.title",
|
||||||
REGEXP_SPECIAL_IN_TITLE_MATCH
|
REGEXP_SPECIAL_IN_TITLE_MATCH
|
||||||
);
|
);
|
||||||
|
|
||||||
this.setSearchedTermSpecialInValue(
|
this.setSearchedTermSpecialInValue(
|
||||||
"searchedTerms.special.in.private",
|
"searchedTerms.special.in.private",
|
||||||
REGEXP_SPECIAL_IN_PRIVATE_MATCH
|
REGEXP_SPECIAL_IN_PRIVATE_MATCH
|
||||||
);
|
);
|
||||||
|
|
||||||
this.setSearchedTermSpecialInValue(
|
this.setSearchedTermSpecialInValue(
|
||||||
"searchedTerms.special.in.seen",
|
"searchedTerms.special.in.seen",
|
||||||
REGEXP_SPECIAL_IN_SEEN_MATCH
|
REGEXP_SPECIAL_IN_SEEN_MATCH
|
||||||
);
|
);
|
||||||
|
|
||||||
this.setSearchedTermValue("searchedTerms.status", REGEXP_STATUS_PREFIX);
|
this.setSearchedTermValue("searchedTerms.status", REGEXP_STATUS_PREFIX);
|
||||||
this.setSearchedTermValueForPostTime();
|
this.setSearchedTermValueForPostTime();
|
||||||
|
|
||||||
this.setSearchedTermValue(
|
this.setSearchedTermValue(
|
||||||
"searchedTerms.min_post_count",
|
"searchedTerms.min_post_count",
|
||||||
REGEXP_MIN_POST_COUNT_PREFIX
|
REGEXP_MIN_POST_COUNT_PREFIX
|
||||||
@@ -304,14 +314,17 @@ export default Em.Component.extend({
|
|||||||
const userInputWhen = match[0].match(REGEXP_POST_TIME_WHEN)[0];
|
const userInputWhen = match[0].match(REGEXP_POST_TIME_WHEN)[0];
|
||||||
const existingInputDays = this.get("searchedTerms.time.days");
|
const existingInputDays = this.get("searchedTerms.time.days");
|
||||||
const userInputDays = match[0].replace(REGEXP_POST_TIME_PREFIX, "");
|
const userInputDays = match[0].replace(REGEXP_POST_TIME_PREFIX, "");
|
||||||
|
const properties = {};
|
||||||
|
|
||||||
if (existingInputWhen !== userInputWhen) {
|
if (existingInputWhen !== userInputWhen) {
|
||||||
this.set("searchedTerms.time.when", userInputWhen);
|
properties["searchedTerms.time.when"] = userInputWhen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingInputDays !== userInputDays) {
|
if (existingInputDays !== userInputDays) {
|
||||||
this.set("searchedTerms.time.days", userInputDays);
|
properties["searchedTerms.time.days"] = userInputDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setProperties(properties);
|
||||||
} else {
|
} else {
|
||||||
this.set("searchedTerms.time.days", "");
|
this.set("searchedTerms.time.days", "");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -354,6 +354,14 @@ QUnit.test("update status through advanced search ui", async assert => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("update post time through advanced search ui", async assert => {
|
QUnit.test("update post time through advanced search ui", async assert => {
|
||||||
|
await visit("/search?expanded=true&q=after:2018-08-22");
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".search-query").val(),
|
||||||
|
"after:2018-08-22",
|
||||||
|
"it should update the search term correctly"
|
||||||
|
);
|
||||||
|
|
||||||
const postTimeSelector = selectKit(
|
const postTimeSelector = selectKit(
|
||||||
".search-advanced-options .select-kit#postTime"
|
".search-advanced-options .select-kit#postTime"
|
||||||
);
|
);
|
||||||
@@ -369,6 +377,7 @@ QUnit.test("update post time through advanced search ui", async assert => {
|
|||||||
postTimeSelector.rowByName("after").exists(),
|
postTimeSelector.rowByName("after").exists(),
|
||||||
'has "after" populated'
|
'has "after" populated'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".search-query").val(),
|
find(".search-query").val(),
|
||||||
"none after:2016-10-05",
|
"none after:2016-10-05",
|
||||||
|
|||||||
Reference in New Issue
Block a user