Patch #42938 » adds_subitem_icon.patch
| app/assets/stylesheets/application.css | ||
|---|---|---|
|
table.issues td.block_column>span {font-weight: bold; display: block; margin-bottom: 4px;}
|
||
|
table.issues td.block_column>pre {white-space:normal;}
|
||
|
tr.idnt td.subject, tr.idnt td.name {background: url(/chevron-right-idnt.svg) no-repeat 2px 50%;}
|
||
|
tr.idnt-1 td.subject, tr.idnt-1 td.name {padding-left: 24px; background-position: 4px 50%;}
|
||
|
tr.idnt-2 td.subject, tr.idnt-2 td.name {padding-left: 40px; background-position: 20px 50%;}
|
||
|
tr.idnt-3 td.subject, tr.idnt-3 td.name {padding-left: 56px; background-position: 36px 50%;}
|
||
|
tr.idnt-4 td.subject, tr.idnt-4 td.name {padding-left: 72px; background-position: 52px 50%;}
|
||
|
tr.idnt-5 td.subject, tr.idnt-5 td.name {padding-left: 88px; background-position: 68px 50%;}
|
||
|
tr.idnt-6 td.subject, tr.idnt-6 td.name {padding-left: 104px; background-position: 84px 50%;}
|
||
|
tr.idnt-7 td.subject, tr.idnt-7 td.name {padding-left: 120px; background-position: 100px 50%;}
|
||
|
tr.idnt-8 td.subject, tr.idnt-8 td.name {padding-left: 136px; background-position: 116px 50%;}
|
||
|
tr.idnt-9 td.subject, tr.idnt-9 td.name {padding-left: 152px; background-position: 132px 50%;}
|
||
|
tr.idnt-1 td.subject, tr.idnt-1 td.name {padding-left: 0;}
|
||
|
tr.idnt-2 td.subject, tr.idnt-2 td.name {padding-left: 20px;}
|
||
|
tr.idnt-3 td.subject, tr.idnt-3 td.name {padding-left: 36px;}
|
||
|
tr.idnt-4 td.subject, tr.idnt-4 td.name {padding-left: 52px;}
|
||
|
tr.idnt-5 td.subject, tr.idnt-5 td.name {padding-left: 68px;}
|
||
|
tr.idnt-6 td.subject, tr.idnt-6 td.name {padding-left: 84px;}
|
||
|
tr.idnt-7 td.subject, tr.idnt-7 td.name {padding-left: 100px;}
|
||
|
tr.idnt-8 td.subject, tr.idnt-8 td.name {padding-left: 116px;}
|
||
|
tr.idnt-9 td.subject, tr.idnt-9 td.name {padding-left: 132px;}
|
||
|
table.issue-report {table-layout:fixed;}
|
||
|
table.issue-report tr.total, table.issue-report-detailed tr.total { font-weight: bold; border-top:2px solid #d0d7de;}
|
||
| app/helpers/application_helper.rb | ||
|---|---|---|
|
h(project.name)
|
||
|
else
|
||
|
link_to project.name,
|
||
|
project_url(project, {:only_path => true}.merge(options)),
|
||
|
# if it is a Struct it comes from ProjectQueriesHelper#project_with_optional_icon
|
||
|
project_url(project.is_a?(Struct) ? project.item : project, {:only_path => true}.merge(options)),
|
||
|
html_options
|
||
|
end
|
||
|
end
|
||
| app/helpers/projects_queries_helper.rb | ||
|---|---|---|
|
case column.name
|
||
|
when :name
|
||
|
link_to_project(item) +
|
||
|
(tag.span(sprite_icon('user', l(:label_my_projects), icon_only: true), class: 'icon-only icon-user my-project') if User.current.member_of?(item)) +
|
||
|
(tag.span(sprite_icon('bookmarked', l(:label_my_bookmarks), icon_only: true), class: 'icon-only icon-bookmarked-project') if User.current.bookmarked_project_ids.include?(item.id))
|
||
|
user_project_icons(item)
|
||
|
when :short_description
|
||
|
if item.description?
|
||
|
# Sets :inline_attachments to false to avoid performance issues
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def column_content_with_subitem_icon(column, item, value, level)
|
||
|
if item.is_a?(Project)
|
||
|
content =
|
||
|
case column.name
|
||
|
when :name
|
||
|
name = (item.child? && level&.positive?) ? sprite_icon('angle-right', item.name) : item.name
|
||
|
link_to_project(project_with_subitem_icon(item, name)) +
|
||
|
user_project_icons(item)
|
||
|
else
|
||
|
column_value(column, item, value)
|
||
|
end
|
||
|
content
|
||
|
end
|
||
|
end
|
||
|
def csv_value(column, object, value)
|
||
|
if object.is_a?(Project)
|
||
|
case column.name
|
||
| ... | ... | |
|
private
|
||
|
def user_project_icons(item)
|
||
|
content = + ''
|
||
|
content += tag.span(sprite_icon('user', l(:label_my_projects), icon_only: true), class: 'icon-only icon-user my-project') if User.current.member_of?(item)
|
||
|
content += tag.span(sprite_icon('bookmarked', l(:label_my_bookmarks), icon_only: true), class: 'icon-only icon-bookmarked-project') if User.current.bookmarked_project_ids.include?(item.id)
|
||
|
content.html_safe
|
||
|
end
|
||
|
# Struct object that behaves like Project#archived? and Project#name
|
||
|
#
|
||
|
# @param item [Project] Instance of a Project
|
||
|
# @param name [String|ActiveSupport::SafeBuffer] If name is not a String
|
||
|
# the object should hold the angle-right icon
|
||
|
# with the subprojects name
|
||
|
# @return [Struct] Object responding to item, name, and archived?
|
||
|
def project_with_subitem_icon(item, name)
|
||
|
Struct.new(:item, :name) do
|
||
|
def archived?
|
||
|
item.archived?
|
||
|
end
|
||
|
end.new(item, name)
|
||
|
end
|
||
|
def get_project_status_label
|
||
|
{
|
||
|
Project::STATUS_ACTIVE => l(:project_status_active),
|
||
| app/helpers/queries_helper.rb | ||
|---|---|---|
|
content_tag('th', content, :class => column.css_classes)
|
||
|
end
|
||
|
def column_content(column, item)
|
||
|
def column_content(column, item, level = nil)
|
||
|
value = column.value_object(item)
|
||
|
content =
|
||
|
if value.is_a?(Array)
|
||
|
values = value.filter_map {|v| column_value(column, item, v)}
|
||
|
safe_join(values, ', ')
|
||
|
else
|
||
|
column_value(column, item, value)
|
||
|
level ? column_content_with_subitem_icon(column, item, value, level) : column_value(column, item, value)
|
||
|
end
|
||
|
call_hook(:helper_queries_column_content,
|
||
|
{:content => content, :column => column, :item => item})
|
||
|
{:content => content, :column => column, :item => item, :level =>level})
|
||
|
content
|
||
|
end
|
||
|
def column_content_with_subitem_icon(column, item, value, level)
|
||
|
content =
|
||
|
case column.name
|
||
|
when :subject
|
||
|
subject = (item.child? && level&.positive?) ? sprite_icon('angle-right', value) : value
|
||
|
link_to subject, issue_path(item)
|
||
|
else
|
||
|
column_value(column, item, value)
|
||
|
end
|
||
|
call_hook(:helper_queries_column_value,
|
||
|
{:content => content, :column => column, :item => item, :value => value})
|
||
|
content
|
||
|
end
|
||
| app/views/issues/_list.html.erb | ||
|---|---|---|
|
<tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= issue.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
|
||
|
<td class="checkbox hide-when-print"><%= check_box_tag("ids[]", issue.id, false, :id => nil) %></td>
|
||
|
<% query.inline_columns.each do |column| %>
|
||
|
<%= content_tag('td', column_content(column, issue), :class => column.css_classes) %>
|
||
|
<%= content_tag('td', column_content(column, issue, level), :class => column.css_classes) %>
|
||
|
<% end %>
|
||
|
<td class="buttons"><%= link_to_context_menu %></td>
|
||
|
</tr>
|
||
| app/views/projects/_list.html.erb | ||
|---|---|---|
|
<% end %>
|
||
|
<% end %>
|
||
|
<% @query.inline_columns.each do |column| %>
|
||
|
<%= content_tag('td', column_content(column, entry), :class => column.css_classes) %>
|
||
|
<%= content_tag('td', column_content(column, entry, level), :class => column.css_classes) %>
|
||
|
<% end %>
|
||
|
<% if @admin_list %>
|
||
|
<% if !entry.scheduled_for_deletion? %>
|
||
| test/helpers/application_helper_test.rb | ||
|---|---|---|
|
class ApplicationHelperTest < Redmine::HelperTest
|
||
|
include ERB::Util
|
||
|
include AvatarsHelper
|
||
|
include ProjectsQueriesHelper
|
||
|
def setup
|
||
|
super
|
||
| ... | ... | |
|
link_to_project(project, {:only_path => false, :jump => 'blah'})
|
||
|
end
|
||
|
def test_link_to_project_with_subitem_icon
|
||
|
item = Project.find(3)
|
||
|
level = 1
|
||
|
name = (item.child? && level&.positive?) ? sprite_icon('angle-right', item.name) : item.name
|
||
|
# requires ProjectsQueriesHelper
|
||
|
project = project_with_subitem_icon(item, name)
|
||
|
assert_equal %(<a href=\"/projects/subproject1\"><svg class=\"s18 icon-svg\" aria-hidden=\"true\"><use href=\"/assets/icons-1857f271.svg#icon--angle-right\"></use></svg><span class=\"icon-label\">eCookbook Subproject 1</span></a>),
|
||
|
link_to_project(project)
|
||
|
end
|
||
|
def test_link_to_project_settings
|
||
|
project = Project.find(1)
|
||
|
assert_equal '<a href="/projects/ecookbook/settings">eCookbook</a>', link_to_project_settings(project)
|
||
| test/helpers/projects_queries_helper_test.rb | ||
|---|---|---|
|
assert_equal "active", csv_value(c_status, Project.find(1), 1)
|
||
|
assert_equal "eCookbook", csv_value(c_parent_id, Project.find(4), 1)
|
||
|
end
|
||
|
def test_column_content_with_subitem_icon
|
||
|
column = QueryColumn.new(:name)
|
||
|
item = Project.find(3)
|
||
|
value = Project.name
|
||
|
level = 1
|
||
|
content = column_content_with_subitem_icon(column, item, value, level)
|
||
|
name_with_subitem_icon = %(<a href=\"/projects/subproject1\"><svg class=\"s18 icon-svg\" aria-hidden=\"true\"><use href=\"/assets/icons-1857f271.svg#icon--angle-right\"></use></svg><span class=\"icon-label\">eCookbook Subproject 1</span></a>)
|
||
|
assert_equal name_with_subitem_icon, content
|
||
|
end
|
||
|
end
|
||
| test/helpers/queries_helper_test.rb | ||
|---|---|---|
|
assert_select_in options, 'option[value=?]', "cf_#{i_cf.id}.cf_#{u_cf.id}", text: "User's Phone number"
|
||
|
assert_select_in options, 'optgroup[label=?]', 'User', 1
|
||
|
end
|
||
|
def test_column_content_should_use_column_content_with_subitem_icon
|
||
|
item = Issue.generate!(parent_id: 2)
|
||
|
column = QueryColumn.new(:subject)
|
||
|
value = item.subject
|
||
|
level = 1
|
||
|
content = column_content(column, item, level)
|
||
|
assert_equal name_with_subitem_icon(item), content
|
||
|
end
|
||
|
private
|
||
|
def name_with_subitem_icon(item)
|
||
|
%(<a href=\"/issues/#{item.id}\"><svg class=\"s18 icon-svg\" aria-hidden=\"true\"><use href=\"/assets/icons-1857f271.svg#icon--angle-right\"></use></svg><span class=\"icon-label\">Generated</span></a>)
|
||
|
end
|
||
|
end
|
||
- « Previous
- 1
- 2
- 3
- Next »