Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions assets/javascripts/discourse/initializers/extend-for-assigns.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { htmlSafe } from "@ember/template";
import { isEmpty } from "@ember/utils";
import { hbs } from "ember-cli-htmlbars";
import { h } from "virtual-dom";
import SearchAdvancedOptions from "discourse/components/search-advanced-options";
import { renderAvatar } from "discourse/helpers/user-avatar";
import { withPluginApi } from "discourse/lib/plugin-api";
import { registerTopicFooterDropdown } from "discourse/lib/register-topic-footer-dropdown";
Expand Down Expand Up @@ -816,35 +815,39 @@ export default {
return;
}

const currentUser = container.lookup("service:current-user");
if (currentUser?.can_assign) {
SearchAdvancedOptions.reopen({
updateSearchTermForAssignedUsername() {
const match = this.filterBlocks(REGEXP_USERNAME_PREFIX);
const userFilter = this.searchedTerms?.assigned;
let searchTerm = this.searchTerm || "";
let keyword = "assigned";

if (userFilter?.length !== 0) {
if (match.length !== 0) {
searchTerm = searchTerm.replace(
match[0],
`${keyword}:${userFilter}`
);
} else {
searchTerm += ` ${keyword}:${userFilter}`;
withPluginApi("1.34.0", (api) => {
const currentUser = container.lookup("service:current-user");
if (currentUser?.can_assign) {
api.modifyClass(
"component:search-advanced-options",
(Superclass) =>
class extends Superclass {
updateSearchTermForAssignedUsername() {
const match = this.filterBlocks(REGEXP_USERNAME_PREFIX);
const userFilter = this.searchedTerms?.assigned;
let searchTerm = this.searchTerm || "";
let keyword = "assigned";

if (userFilter?.length !== 0) {
if (match.length !== 0) {
searchTerm = searchTerm.replace(
match[0],
`${keyword}:${userFilter}`
);
} else {
searchTerm += ` ${keyword}:${userFilter}`;
}

this._updateSearchTerm(searchTerm);
} else if (match.length !== 0) {
searchTerm = searchTerm.replace(match[0], "");
this._updateSearchTerm(searchTerm);
}
}
}
);
}

this._updateSearchTerm(searchTerm);
} else if (match.length !== 0) {
searchTerm = searchTerm.replace(match[0], "");
this._updateSearchTerm(searchTerm);
}
},
});
}

withPluginApi("1.34.0", (api) => {
extendTopicModel(api);
initialize(api);
registerTopicFooterButtons(api);
Expand Down
Loading