Feature #33641 » author-and-assignee-badge-v2.patch
| app/helpers/application_helper.rb | ||
|---|---|---|
|
end
|
||
|
def authoring(created, author, options={})
|
||
|
l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created)).html_safe
|
||
|
l(options[:label] || :label_added_time_by, :author => link_to_user(author), :badge => options[:badge], :age => time_tag(created)).html_safe
|
||
|
end
|
||
|
def time_tag(time)
|
||
| app/helpers/journals_helper.rb | ||
|---|---|---|
|
css_classes = journal.private_notes? ? 'badge badge-private private' : ''
|
||
|
content_tag('span', content.html_safe, :id => "journal-#{journal.id}-private_notes", :class => css_classes)
|
||
|
end
|
||
|
def journal_user_badge(journal)
|
||
|
issue = journal&.journalized
|
||
|
return '' if issue.nil?
|
||
|
# Show only "Author" badge if the user is both an author and an assignee
|
||
|
case journal.user
|
||
|
when issue.author
|
||
|
content_tag('span', l(:label_author), class: 'badge badge-user-author')
|
||
|
when issue.assigned_to
|
||
|
content_tag('span', l(:field_assigned_to), class: 'badge badge-user-assignee')
|
||
|
else
|
||
|
''
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| app/helpers/messages_helper.rb | ||
|---|---|---|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
module MessagesHelper
|
||
|
def message_user_badge(message)
|
||
|
return '' if message&.parent.nil?
|
||
|
if message.parent.author == message.author
|
||
|
content_tag('span', l(:label_author), class: 'badge badge-status-open')
|
||
|
else
|
||
|
''
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| app/helpers/news_helper.rb | ||
|---|---|---|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
module NewsHelper
|
||
|
def news_comment_user_badge(comment)
|
||
|
return '' if comment&.commented.nil?
|
||
|
if comment.commented.author == comment.author
|
||
|
content_tag('span', l(:label_author), class: 'badge badge-status-open')
|
||
|
else
|
||
|
''
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| app/helpers/wiki_helper.rb | ||
|---|---|---|
|
end
|
||
|
def wiki_content_update_info(content)
|
||
|
l(:label_updated_time_by, :author => link_to_user(content.author), :age => time_tag(content.updated_on)).html_safe
|
||
|
l(:label_updated_time_by, :author => link_to_user(content.author), :age => time_tag(content.updated_on), :badge => '').html_safe
|
||
|
end
|
||
|
end
|
||
| app/views/issues/tabs/_history.html.erb | ||
|---|---|---|
|
</div>
|
||
|
<h4 class='note-header'>
|
||
|
<%= avatar(journal.user) %>
|
||
|
<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
|
||
|
<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by, :badge => journal_user_badge(journal) %>
|
||
|
<%= render_private_notes_indicator(journal) %>
|
||
|
</h4>
|
||
| app/views/messages/show.html.erb | ||
|---|---|---|
|
<%= avatar(message.author) %>
|
||
|
<%= link_to message.subject, { :controller => 'messages', :action => 'show', :board_id => @board, :id => @topic, :r => message, :anchor => "message-#{message.id}" } %>
|
||
|
-
|
||
|
<%= authoring message.created_on, message.author %>
|
||
|
<%= authoring message.created_on, message.author, :badge => message_user_badge(message) %>
|
||
|
</h4>
|
||
|
<div class="wiki"><%= textilizable message, :content, :attachments => message.attachments %></div>
|
||
|
<%= link_to_attachments message, :author => false, :thumbnails => true %>
|
||
| app/views/news/show.html.erb | ||
|---|---|---|
|
:title => l(:button_delete),
|
||
|
:class => 'icon-only icon-del' %>
|
||
|
</div>
|
||
|
<h4><%= avatar(comment.author) %><%= authoring comment.created_on, comment.author %></h4>
|
||
|
<h4><%= avatar(comment.author) %><%= authoring comment.created_on, comment.author, :badge => news_comment_user_badge(comment) %></h4>
|
||
|
<div class="wiki">
|
||
|
<%= textilizable(comment.comments) %>
|
||
|
</div>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_missing_feeds_access_key: Missing a Atom access key
|
||
|
label_feeds_access_key_created_on: "Atom access key created %{value} ago"
|
||
|
label_module_plural: Modules
|
||
|
label_added_time_by: "Added by %{author} %{age} ago"
|
||
|
label_updated_time_by: "Updated by %{author} %{age} ago"
|
||
|
label_added_time_by: "Added by %{author} %{badge} %{age} ago"
|
||
|
label_updated_time_by: "Updated by %{author} %{badge} %{age} ago"
|
||
|
label_updated_time: "Updated %{value} ago"
|
||
|
label_jump_to_a_project: Jump to a project...
|
||
|
label_file_plural: Files
|
||
| ... | ... | |
|
label_display_type_board: Board
|
||
|
label_my_bookmarks: My bookmarks
|
||
|
label_assign_to_me: Assign to me
|
||
|
label_author: Author
|
||
|
button_login: Login
|
||
|
button_submit: Submit
|
||
| public/stylesheets/application.css | ||
|---|---|---|
|
color: #1D781D;
|
||
|
border: 1px solid #1D781D;
|
||
|
}
|
||
|
.badge-user-author {
|
||
|
color: #205D86;
|
||
|
border: 1px solid #205D86;
|
||
|
}
|
||
|
.badge-user-assignee {
|
||
|
color: #205D86;
|
||
|
border: 1px solid #205D86;
|
||
|
}
|
||
|
/***** Tooltips *****/
|
||
|
.ui-tooltip {
|
||
|
background: #000;
|
||
| test/helpers/journals_helper_test.rb | ||
|---|---|---|
|
assert_kind_of Attachment, thumbnails.first
|
||
|
assert_equal 'image.png', thumbnails.first.filename
|
||
|
end
|
||
|
def test_journal_user_badge
|
||
|
issue = Issue.generate!(:author_id => 1, :assigned_to_id => 2)
|
||
|
journal = issue.init_journal(User.find(1), "Updated by an author")
|
||
|
assert_equal '<span class="badge badge-user-author">Author</span>', journal_user_badge(journal)
|
||
|
issue.clear_journal
|
||
|
journal = issue.init_journal(User.find(2), "Updated by an assignee")
|
||
|
assert_equal '<span class="badge badge-user-assignee">Assignee</span>', journal_user_badge(journal)
|
||
|
issue.clear_journal
|
||
|
issue.update_attribute(:assigned_to_id, 1)
|
||
|
journal = issue.init_journal(User.find(1), "The user is both an author and an assignee")
|
||
|
assert_equal '<span class="badge badge-user-author">Author</span>', journal_user_badge(journal)
|
||
|
end
|
||
|
end
|
||