Skip to content

Commit

Permalink
Merge pull request #2394 from ITK-Leantime/issue-2380
Browse files Browse the repository at this point in the history
Fixed user mentions
  • Loading branch information
marcelfolaron authored Mar 12, 2024
2 parents f584343 + 4ed8b56 commit 7a0856d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions app/Domain/Api/Controllers/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ public function get(array $params): Response

$users = $this->userService->getUsersWithProjectAccess($_SESSION['userdata']['id'], $projectId);

if (isset($params['query'])) {
$query = $params['query'];
// Perform a simple filter by query and create a list of the result.
$users = array_values(
array_filter($users, static fn (array $user) => false !== stripos(implode(' ', $user), $query))
);
}

return $this->tpl->displayJson($users);
}

Expand Down
9 changes: 7 additions & 2 deletions public/assets/js/app/core/editors.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ leantime.editorController = (function () {
// Do your ajax call
// When using multiple delimiters you can alter the query depending on the delimiter used
if (delimiter === '@') {
jQuery.getJSON(leantime.appUrl + '/api/users?projectUsersAccess=current', function (data) {
jQuery.getJSON(leantime.appUrl + '/api/users', {
projectUsersAccess: 'current',
query: query
}, function (data) {
//call process to show the result
let users = [];
for (let i = 0; i < data.length; i++) {
Expand All @@ -72,7 +75,9 @@ leantime.editorController = (function () {
},
insert: function (item) {
return '<a class="userMention" data-tagged-user-id="' + item.id + '" href="javascript:void(0)"><img src="' + leantime.appUrl + '/api/users?profileImage=' + item.id + '" alt="' + item.name + ' Image"/>' + item.name.trim() + '</a>&nbsp;';
}
},
// The default value is 10 (cf. https://github.com/StevenDevooght/tinyMCE-mention?tab=readme-ov-file#items)
items: 10
};

var imageUploadHandler = function(blobInfo, success, failure) {
Expand Down
4 changes: 2 additions & 2 deletions public/assets/js/libs/tinymce-plugins/mention/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
renderInput: function () {
var rawHtml = '<span id="autocomplete">' +
'<span id="autocomplete-delimiter">' + this.options.delimiter + '</span>' +
'<span id="autocomplete-searchtext"><span class="dummy">\uFEFF</span></span>' +
'<span id="autocomplete-searchtext"><span class="dummy">\u200b</span></span>' +
'</span>';

this.editor.execCommand('mceInsertContent', false, rawHtml);
Expand Down Expand Up @@ -181,7 +181,7 @@
},

lookup: function () {
this.query = $.trim($(this.editor.getBody()).find('#autocomplete-searchtext').text()).replace('\ufeff', '');
this.query = $.trim($(this.editor.getBody()).find('#autocomplete-searchtext').text()).replace('\u200b', '');

if (this.$dropdown === undefined) {
this.show();
Expand Down

0 comments on commit 7a0856d

Please sign in to comment.