From e176410b54c72b8011d6193039816344e6f486ff Mon Sep 17 00:00:00 2001 From: Ben0it-T Date: Sun, 2 Jan 2022 17:22:56 +0100 Subject: [PATCH 1/3] Fix auto-complete username when creating new cards (addCardForm) --- client/components/lists/listBody.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index 9b54f901e..3a368c344 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -336,7 +336,7 @@ BlazeComponent.extendComponent({ [ // User mentions { - match: /\B@([\w.]*)$/, + match: /\B@([\w.-]*)$/, search(term, callback) { const currentBoard = Boards.findOne(Session.get('currentBoard')); callback( @@ -347,6 +347,9 @@ BlazeComponent.extendComponent({ ); }, template(user) { + if (user.profile && user.profile.fullname) { + return (user.username + " (" + user.profile.fullname + ")"); + } return user.username; }, replace(user) { From a160b662ef8e9a69c0bbc8cffa2811c2f08b7e2c Mon Sep 17 00:00:00 2001 From: Ben0it-T Date: Sun, 2 Jan 2022 18:44:28 +0100 Subject: [PATCH 2/3] User mentions now return @username (full name) --- client/components/main/editor.js | 17 +++++++++++++---- models/activities.js | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/components/main/editor.js b/client/components/main/editor.js index fec040a23..6c9791f62 100644 --- a/client/components/main/editor.js +++ b/client/components/main/editor.js @@ -11,7 +11,7 @@ BlazeComponent.extendComponent({ const mentions = [ // User mentions { - match: /\B@([\w.]*)$/, + match: /\B@([\w.-]*)$/, search(term, callback) { const currentBoard = Boards.findOne(Session.get('currentBoard')); callback( @@ -21,8 +21,17 @@ BlazeComponent.extendComponent({ .map(member => { const user = Users.findOne(member.userId); const username = user.username; - const fullName = user.profile && user.profile !== undefined ? user.profile.fullname : ""; - return username.includes(term) || fullName.includes(term) ? fullName + "(" + username + ")" : null; + const fullName = user.profile && user.profile !== undefined && user.profile.fullname ? user.profile.fullname : ""; + // return username.includes(term) || fullName.includes(term) ? fullName + "(" + username + ")" : null; + if (username.includes(term) || fullName.includes(term)) { + if (fullName) { + return username + " (" + fullName + ")"; + } + else { + return username; + } + } + return null; }) .filter(Boolean), [...specialHandleNames]) ); @@ -355,7 +364,7 @@ Blaze.Template.registerHelper( } return member; }), [...specialHandles]); - const mentionRegex = /\B@([\w.]*)/gi; + const mentionRegex = /\B@([\w.-]*)/gi; let currentMention; while ((currentMention = mentionRegex.exec(content)) !== null) { diff --git a/models/activities.js b/models/activities.js index 9f913a554..c59488a87 100644 --- a/models/activities.js +++ b/models/activities.js @@ -202,7 +202,7 @@ if (Meteor.isServer) { } return member; }); - const mentionRegex = /\B@(?:(?:"([\w.\s]*)")|([\w.]+))/gi; // including space in username + const mentionRegex = /\B@(?:(?:"([\w.\s-]*)")|([\w.-]+))/gi; // including space in username let currentMention; while ((currentMention = mentionRegex.exec(comment)) !== null) { /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "[iI]gnored" }]*/ From 4589c3df15708800cdd1a5dacfcc9bf6b9e838be Mon Sep 17 00:00:00 2001 From: Ben0it-T Date: Sun, 2 Jan 2022 19:35:47 +0100 Subject: [PATCH 3/3] User mentions now return @username (full name) - part 2 --- client/components/main/editor.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/client/components/main/editor.js b/client/components/main/editor.js index 6c9791f62..6c81fe32d 100644 --- a/client/components/main/editor.js +++ b/client/components/main/editor.js @@ -22,25 +22,22 @@ BlazeComponent.extendComponent({ const user = Users.findOne(member.userId); const username = user.username; const fullName = user.profile && user.profile !== undefined && user.profile.fullname ? user.profile.fullname : ""; - // return username.includes(term) || fullName.includes(term) ? fullName + "(" + username + ")" : null; - if (username.includes(term) || fullName.includes(term)) { - if (fullName) { - return username + " (" + fullName + ")"; - } - else { - return username; - } - } - return null; + return username.includes(term) || fullName.includes(term) ? user : null; }) - .filter(Boolean), [...specialHandleNames]) + .filter(Boolean), [...specialHandles]) ); }, - template(value) { - return value; + template(user) { + if (user.profile && user.profile.fullname) { + return (user.profile.fullname + " (" + user.username + ")"); + } + return user.username; }, - replace(username) { - return `@${username} `; + replace(user) { + if (user.profile && user.profile.fullname) { + return `@${user.username} (${user.profile.fullname}) `; + } + return `@${user.username} `; }, index: 1, },