shortcuts-for-trello icon indicating copy to clipboard operation
shortcuts-for-trello copied to clipboard

Shortcut to mention all members

Open chelder86 opened this issue 10 years ago • 5 comments

For example: @abm for all board members @atm for all task members

chelder86 avatar Nov 19 '14 00:11 chelder86

Pull requests are welcome :)

bulkan avatar Nov 19 '14 01:11 bulkan

I'll try to do it in a few month (no time now, promise). But I love this simple but effective code. I have written the possible pseudocode thought:

  1. By default, detect keyboard shortcut Ctrl+m (m from members)

1.5) If we are within a task...

  1. Click on (find by class js-new-comment-input): <--textarea class="new-comment-input js-new-comment-input" placeholder="Write a comment…" tabindex="1" style="overflow: hidden; word-wrap: break-word; height: 36px;">

  2. Click on (find by class js-comment-mention-member): <--a href="#" class="quiet-button left js-comment-mention-member" title="Make sure a member gets a notification about this comment.">Mention a member…-->

  3. Click on (find by class js-select-all-board-members): <--a href="#" class="js-select-all-board-members"> Mention All Board Members (6)

chelder86 avatar Nov 19 '14 01:11 chelder86

@chelder86 I investigated this briefly and here are my thoughts.

The DOM elements in the members popover look something like this:

<div>
  <li class="item js-member-item">
  <a class="name js-select-member " href="#" idmember="" title="Tony Tamplin (tonytamplin)">
    <span class="member js-member">
      <img class="member-avatar" title="Tony Tamplin (tonytamplin)">
    </span>
    <span class="full-name" name="Tony Tamplin (tonytamplin)">
      Tony Tamplin (<span class="username">tonytamplin</span>)
    </span>
  </a>
  </li>
</div>

I had a fiddle and there seems to be an event handler attached to the a.js-select-member When it is clicked, the value of .js-select-member .username is prepended with an @ and placed into the appropriate place.

So as a test I did this:

1 - Get all members for the board stored in allMembers-

$.get('/1/boards/<board_id>/members/all', function(members) {
  allMembers = members.reduce(function(accum, member){
    accum += (accum ? '' : ' @') + member.username); 
    return accum;
  });
});

2 - Make a HTML element that represents what you want (just like the previous one):

<div>
  <li class="item js-member-item">
  <a class="name js-select-member " href="#" idmember="" title="All Board Members">
    <span class="member js-member">
      <img class="member-avatar" title="All Board Members">
    </span>
    <span class="full-name" name="All Board Members">
      All Board Members (<span class="username">allMembers</span>)
    </span>
  </a>
  </li>
</div>

3 - Add your custom element to the Members popover:

//When the members popover is displayed, execute this code
$.parseHTML(htmlStringFromStep2).prependTo('.pop-over-member-list')

4 - Clicking the newly added element will cause Trello to take the 'username' string, add an @ to the front of it and place it in the location it was initiated from.

It's jsut rough but its a start.

tonytamps avatar May 25 '15 09:05 tonytamps

Yes, it is... Good job!

chelder86 avatar May 25 '15 21:05 chelder86

Now it is possible in Trello to mention all members of the board or tasks by using native @board or @card mentions. Note: it does not expand the mention to all users.

tdalon avatar Sep 20 '16 06:09 tdalon