arkhitech / redmine_mentions

Allows users to mention team members in their notes/comments.
MIT License
94 stars 88 forks source link

Show firstname and lastname instead of username #54

Open ghost opened 7 years ago

ghost commented 7 years ago

When a user is mentioned within a wiki page or a comment with @user the shown text is generally replaced with the username. Out of social interaktion reasons it would be great if the plugin replaces the text behind the @ with the "@Firstname Lastname". Maybe you can make this an option within the plugin configuration screen to use:

carterb23 commented 6 years ago

Any plans to implement this feature? Would be really helpful!

carterb23 commented 6 years ago

I adapted the code so it works for me. Please review and if fine with it, commit to repo. One thing to mention: @username has to be there from current implementation, otherwise email feature will not work!

File /app/views/hooks/redmine_mentions/_edit_mentionable.html.erb, line 24:

replace: function(mention) {
        var parts = mention.split(' - ');
        var uname = parts[1].substring(parts[1].lastIndexOf("<small>")+7,parts[1].lastIndexOf("</small>"));
        var fullname = parts[0];

        if ('<%=Setting.plugin_redmine_mentions['print_fullname']%>' == 'Y')
        {
            return fullname + '(' + '<%=Setting.plugin_redmine_mentions['trigger']%>' + uname + ')';
        }
        else
        {
            return '<%=Setting.plugin_redmine_mentions['trigger']%>' + uname;
        }
      }

Config option:

File app/views/settings/_mention.erb

<p>
  <label for="settings[trigger]">Trigger</label>
  <%= select_tag('settings[trigger]',
                 options_for_select(['@',':','~','!','#','%'],settings['trigger'])) %>
</p>
<p>
  <label for="settings[print_fullname]">Print fullname</label>
  <%= select_tag('settings[print_fullname]',
                 options_for_select(['Y','N'],settings['print_fullname'])) %> 
</p>

Will insert: Firstname Lastname(@username)

See diff: diff.txt