From 23b1c051b07706130ab7c76841c7a0403260017b Mon Sep 17 00:00:00 2001 From: Aaron Contreras Date: Wed, 22 Nov 2023 09:54:13 -0500 Subject: [PATCH] Allow WorkPackage memberships to be included in user mention autocompletion NOTE: There's de-duplication work to be done at this layer until signaling can de-duplicate at the database layer. There's already planned discussions on how to solve this but in the meantime, we need to de-duplicate Principals at our CKEditor level. --- src/mentions/user-mentions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mentions/user-mentions.js b/src/mentions/user-mentions.js index 08f2547..0772fcb 100644 --- a/src/mentions/user-mentions.js +++ b/src/mentions/user-mentions.js @@ -18,14 +18,14 @@ export function userMentions(queryText) { return []; } - const project_id = getOPHelper(editor, 'idFromLink')(resource.project.href); - const url = getOPPath(editor).api.v3.principals(project_id, queryText) + '&select=elements/_type,elements/id,elements/name'; + const workPackageId = getOPHelper(editor, 'idFromLink')(resource.href); + const url = getOPPath(editor).api.v3.principals(workPackageId, queryText) + '&select=elements/_type,elements/id,elements/name'; const pluginContext = getPluginContext(editor); const base = window.OpenProject.urlRoot; return new Promise((resolve, reject) => { jQuery.getJSON(url, collection => { - resolve(collection._embedded.elements.map(mention => { + resolve(_.uniqBy(collection._embedded.elements, (el) => el.id).map(mention => { const type = mention._type.toLowerCase(); const text = `@${mention.name}`; const id = `@${mention.id}`;