FIX: Selecting a user was clearing search terms (#252)
Regressed in #211?
This commit is contained in:
parent
3d2a9d1e87
commit
f56037cdf0
|
@ -2,7 +2,7 @@ import { action } from "@ember/object";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
shouldRender(args, component) {
|
shouldRender(args, component) {
|
||||||
return component.currentUser && component.currentUser.can_assign;
|
return component.currentUser?.can_assign;
|
||||||
},
|
},
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
@ -12,6 +12,5 @@ export default {
|
||||||
"updateSearchTermForAssignedUsername",
|
"updateSearchTermForAssignedUsername",
|
||||||
value
|
value
|
||||||
);
|
);
|
||||||
this.onChangeSearchedTermField("assigned", "updateInRegex", value);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@ import SearchAdvancedOptions from "discourse/components/search-advanced-options"
|
||||||
import TopicButtonAction, {
|
import TopicButtonAction, {
|
||||||
addBulkButton,
|
addBulkButton,
|
||||||
} from "discourse/controllers/topic-bulk-actions";
|
} from "discourse/controllers/topic-bulk-actions";
|
||||||
import { inject } from "@ember/controller";
|
import { inject as controller } from "@ember/controller";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import { registerTopicFooterDropdown } from "discourse/lib/register-topic-footer-dropdown";
|
import { registerTopicFooterDropdown } from "discourse/lib/register-topic-footer-dropdown";
|
||||||
|
@ -835,20 +835,23 @@ const REGEXP_USERNAME_PREFIX = /^(assigned:)/gi;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "extend-for-assign",
|
name: "extend-for-assign",
|
||||||
|
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
const siteSettings = container.lookup("site-settings:main");
|
const siteSettings = container.lookup("site-settings:main");
|
||||||
if (!siteSettings.assign_enabled) {
|
if (!siteSettings.assign_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentUser = container.lookup("current-user:main");
|
const currentUser = container.lookup("current-user:main");
|
||||||
if (currentUser && currentUser.can_assign) {
|
if (currentUser?.can_assign) {
|
||||||
SearchAdvancedOptions.reopen({
|
SearchAdvancedOptions.reopen({
|
||||||
updateSearchTermForAssignedUsername() {
|
updateSearchTermForAssignedUsername() {
|
||||||
const match = this.filterBlocks(REGEXP_USERNAME_PREFIX);
|
const match = this.filterBlocks(REGEXP_USERNAME_PREFIX);
|
||||||
const userFilter = this.get("searchedTerms.assigned");
|
const userFilter = this.get("searchedTerms.assigned");
|
||||||
let searchTerm = this.searchTerm || "";
|
let searchTerm = this.searchTerm || "";
|
||||||
let keyword = "assigned";
|
let keyword = "assigned";
|
||||||
if (userFilter && userFilter.length !== 0) {
|
|
||||||
|
if (userFilter?.length !== 0) {
|
||||||
if (match.length !== 0) {
|
if (match.length !== 0) {
|
||||||
searchTerm = searchTerm.replace(
|
searchTerm = searchTerm.replace(
|
||||||
match[0],
|
match[0],
|
||||||
|
@ -858,16 +861,16 @@ export default {
|
||||||
searchTerm += ` ${keyword}:${userFilter}`;
|
searchTerm += ` ${keyword}:${userFilter}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set("searchTerm", searchTerm.trim());
|
this._updateSearchTerm(searchTerm);
|
||||||
} else if (match.length !== 0) {
|
} else if (match.length !== 0) {
|
||||||
searchTerm = searchTerm.replace(match[0], "");
|
searchTerm = searchTerm.replace(match[0], "");
|
||||||
this.set("searchTerm", searchTerm.trim());
|
this._updateSearchTerm(searchTerm);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
TopicButtonAction.reopen({
|
TopicButtonAction.reopen({
|
||||||
assignUser: inject("assign-user"),
|
assignUser: controller("assign-user"),
|
||||||
actions: {
|
actions: {
|
||||||
showReAssign() {
|
showReAssign() {
|
||||||
this.set("assignUser.isBulkAction", true);
|
this.set("assignUser.isBulkAction", true);
|
||||||
|
|
Loading…
Reference in New Issue