FIX: Search filters text was not able to be overridden
This is because the translations were being applied when the JS files were parsed, which is before the overrides are loaded. The solution is to return the filters in a function which is executed when they are needed.
This commit is contained in:
parent
435a9913a4
commit
5e110a5770
|
@ -29,23 +29,30 @@ const REGEXP_POST_TIME_WHEN = /^(before|after)/gi;
|
|||
|
||||
const IN_OPTIONS_MAPPING = { images: "with" };
|
||||
|
||||
const inOptionsForUsers = [
|
||||
let _extraOptions = [];
|
||||
|
||||
function inOptionsForUsers() {
|
||||
return [
|
||||
{ name: I18n.t("search.advanced.filters.unseen"), value: "unseen" },
|
||||
{ name: I18n.t("search.advanced.filters.posted"), value: "posted" },
|
||||
{ name: I18n.t("search.advanced.filters.created"), value: "created" },
|
||||
{ name: I18n.t("search.advanced.filters.watching"), value: "watching" },
|
||||
{ name: I18n.t("search.advanced.filters.tracking"), value: "tracking" },
|
||||
{ name: I18n.t("search.advanced.filters.bookmarks"), value: "bookmarks" },
|
||||
];
|
||||
].concat(..._extraOptions.map((eo) => eo.inOptionsForUsers).filter(Boolean));
|
||||
}
|
||||
|
||||
const inOptionsForAll = [
|
||||
function inOptionsForAll() {
|
||||
return [
|
||||
{ name: I18n.t("search.advanced.filters.first"), value: "first" },
|
||||
{ name: I18n.t("search.advanced.filters.pinned"), value: "pinned" },
|
||||
{ name: I18n.t("search.advanced.filters.wiki"), value: "wiki" },
|
||||
{ name: I18n.t("search.advanced.filters.images"), value: "images" },
|
||||
];
|
||||
].concat(..._extraOptions.map((eo) => eo.inOptionsForAll).filter(Boolean));
|
||||
}
|
||||
|
||||
const statusOptions = [
|
||||
function statusOptions() {
|
||||
return [
|
||||
{ name: I18n.t("search.advanced.statuses.open"), value: "open" },
|
||||
{ name: I18n.t("search.advanced.statuses.closed"), value: "closed" },
|
||||
{ name: I18n.t("search.advanced.statuses.public"), value: "public" },
|
||||
|
@ -58,18 +65,18 @@ const statusOptions = [
|
|||
name: I18n.t("search.advanced.statuses.single_user"),
|
||||
value: "single_user",
|
||||
},
|
||||
];
|
||||
].concat(..._extraOptions.map((eo) => eo.statusOptions).filter(Boolean));
|
||||
}
|
||||
|
||||
const postTimeOptions = [
|
||||
function postTimeOptions() {
|
||||
return [
|
||||
{ name: I18n.t("search.advanced.post.time.before"), value: "before" },
|
||||
{ name: I18n.t("search.advanced.post.time.after"), value: "after" },
|
||||
];
|
||||
].concat(..._extraOptions.map((eo) => eo.postTimeOptions).filter(Boolean));
|
||||
}
|
||||
|
||||
function addAdvancedSearchOptions(options) {
|
||||
inOptionsForAll.pushObjects(options.inOptionsForAll);
|
||||
inOptionsForUsers.pushObjects(options.inOptionsForUsers);
|
||||
statusOptions.pushObjects(options.statusOptions);
|
||||
postTimeOptions.pushObjects(options.postTimeOptions);
|
||||
export function addAdvancedSearchOptions(options) {
|
||||
_extraOptions.push(options);
|
||||
}
|
||||
|
||||
export default Component.extend({
|
||||
|
@ -105,10 +112,10 @@ export default Component.extend({
|
|||
},
|
||||
},
|
||||
inOptions: this.currentUser
|
||||
? inOptionsForUsers.concat(inOptionsForAll)
|
||||
: inOptionsForAll,
|
||||
statusOptions: statusOptions,
|
||||
postTimeOptions: postTimeOptions,
|
||||
? inOptionsForUsers().concat(inOptionsForAll())
|
||||
: inOptionsForAll(),
|
||||
statusOptions: statusOptions(),
|
||||
postTimeOptions: postTimeOptions(),
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -736,5 +743,3 @@ export default Component.extend({
|
|||
this.onChangeSearchTerm(searchTerm.trim());
|
||||
},
|
||||
});
|
||||
|
||||
export { addAdvancedSearchOptions };
|
||||
|
|
Loading…
Reference in New Issue