Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show firstname and lastname instead of username #54

Open
ghost opened this issue Oct 26, 2016 · 2 comments
Open

Show firstname and lastname instead of username #54

ghost opened this issue Oct 26, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 26, 2016

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
Copy link

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

@carterb23
Copy link

carterb23 commented Aug 23, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant