Project

General

Profile

Feature #33641 » author-and-assignee-badge-v2.patch

Go MAEDA, 2020-07-04 10:21

View differences:

app/helpers/application_helper.rb
642 642
  end
643 643

  
644 644
  def authoring(created, author, options={})
645
    l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created)).html_safe
645
    l(options[:label] || :label_added_time_by, :author => link_to_user(author), :badge => options[:badge], :age => time_tag(created)).html_safe
646 646
  end
647 647

  
648 648
  def time_tag(time)
app/helpers/journals_helper.rb
68 68
    css_classes = journal.private_notes? ? 'badge badge-private private' : ''
69 69
    content_tag('span', content.html_safe, :id => "journal-#{journal.id}-private_notes", :class => css_classes)
70 70
  end
71

  
72
  def journal_user_badge(journal)
73
    issue = journal&.journalized
74
    return '' if issue.nil?
75

  
76
    # Show only "Author" badge if the user is both an author and an assignee
77
    case journal.user
78
    when issue.author
79
      content_tag('span', l(:label_author), class: 'badge badge-user-author')
80
    when issue.assigned_to
81
      content_tag('span', l(:field_assigned_to), class: 'badge badge-user-assignee')
82
    else
83
      ''
84
    end
85
  end
71 86
end
app/helpers/messages_helper.rb
18 18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 19

  
20 20
module MessagesHelper
21
  def message_user_badge(message)
22
    return '' if message&.parent.nil?
23

  
24
    if message.parent.author == message.author
25
      content_tag('span', l(:label_author), class: 'badge badge-status-open')
26
    else
27
      ''
28
    end
29
  end
21 30
end
app/helpers/news_helper.rb
18 18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 19

  
20 20
module NewsHelper
21
  def news_comment_user_badge(comment)
22
    return '' if comment&.commented.nil?
23

  
24
    if comment.commented.author == comment.author
25
      content_tag('span', l(:label_author), class: 'badge badge-status-open')
26
    else
27
      ''
28
    end
29
  end
21 30
end
app/helpers/wiki_helper.rb
66 66
  end
67 67

  
68 68
  def wiki_content_update_info(content)
69
    l(:label_updated_time_by, :author => link_to_user(content.author), :age => time_tag(content.updated_on)).html_safe
69
    l(:label_updated_time_by, :author => link_to_user(content.author), :age => time_tag(content.updated_on), :badge => '').html_safe
70 70
  end
71 71
end
app/views/issues/tabs/_history.html.erb
13 13
    </div>
14 14
    <h4 class='note-header'>
15 15
      <%= avatar(journal.user) %>
16
      <%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
16
      <%= authoring journal.created_on, journal.user, :label => :label_updated_time_by, :badge => journal_user_badge(journal) %>
17 17
      <%= render_private_notes_indicator(journal) %>
18 18
    </h4>
19 19

  
app/views/messages/show.html.erb
69 69
    <%= avatar(message.author) %>
70 70
    <%= link_to message.subject, { :controller => 'messages', :action => 'show', :board_id => @board, :id => @topic, :r => message, :anchor => "message-#{message.id}" } %>
71 71
    -
72
    <%= authoring message.created_on, message.author %>
72
    <%= authoring message.created_on, message.author, :badge => message_user_badge(message) %>
73 73
  </h4>
74 74
  <div class="wiki"><%= textilizable message, :content, :attachments => message.attachments %></div>
75 75
  <%= link_to_attachments message, :author => false, :thumbnails => true %>
app/views/news/show.html.erb
42 42
                              :title => l(:button_delete),
43 43
                              :class => 'icon-only icon-del' %>
44 44
    </div>
45
    <h4><%= avatar(comment.author) %><%= authoring comment.created_on, comment.author %></h4>
45
    <h4><%= avatar(comment.author) %><%= authoring comment.created_on, comment.author, :badge => news_comment_user_badge(comment) %></h4>
46 46
    <div class="wiki">
47 47
    <%= textilizable(comment.comments) %>
48 48
    </div>
config/locales/en.yml
895 895
  label_missing_feeds_access_key: Missing a Atom access key
896 896
  label_feeds_access_key_created_on: "Atom access key created %{value} ago"
897 897
  label_module_plural: Modules
898
  label_added_time_by: "Added by %{author} %{age} ago"
899
  label_updated_time_by: "Updated by %{author} %{age} ago"
898
  label_added_time_by: "Added by %{author} %{badge} %{age} ago"
899
  label_updated_time_by: "Updated by %{author} %{badge} %{age} ago"
900 900
  label_updated_time: "Updated %{value} ago"
901 901
  label_jump_to_a_project: Jump to a project...
902 902
  label_file_plural: Files
......
1089 1089
  label_display_type_board: Board
1090 1090
  label_my_bookmarks: My bookmarks
1091 1091
  label_assign_to_me: Assign to me
1092
  label_author: Author
1092 1093

  
1093 1094
  button_login: Login
1094 1095
  button_submit: Submit
public/stylesheets/application.css
1446 1446
  color: #1D781D;
1447 1447
  border: 1px solid #1D781D;
1448 1448
}
1449
.badge-user-author {
1450
  color: #205D86;
1451
  border: 1px solid #205D86;
1452
}
1453
.badge-user-assignee {
1454
  color: #205D86;
1455
  border: 1px solid #205D86;
1456
}
1457

  
1449 1458
/***** Tooltips *****/
1450 1459
.ui-tooltip {
1451 1460
  background: #000;
test/helpers/journals_helper_test.rb
49 49
    assert_kind_of Attachment, thumbnails.first
50 50
    assert_equal 'image.png', thumbnails.first.filename
51 51
  end
52

  
53
  def test_journal_user_badge
54
    issue = Issue.generate!(:author_id => 1, :assigned_to_id => 2)
55

  
56
    journal = issue.init_journal(User.find(1), "Updated by an author")
57
    assert_equal '<span class="badge badge-user-author">Author</span>', journal_user_badge(journal)
58

  
59
    issue.clear_journal
60
    journal = issue.init_journal(User.find(2), "Updated by an assignee")
61
    assert_equal '<span class="badge badge-user-assignee">Assignee</span>', journal_user_badge(journal)
62

  
63
    issue.clear_journal
64
    issue.update_attribute(:assigned_to_id, 1)
65
    journal = issue.init_journal(User.find(1), "The user is both an author and an assignee")
66
    assert_equal '<span class="badge badge-user-author">Author</span>', journal_user_badge(journal)
67
  end
52 68
end
(6-6/9)