From 8ffdbb8c1b24961f533c855c18362181f4f4e919 Mon Sep 17 00:00:00 2001 From: Felix Gliesche Date: Wed, 4 Apr 2018 11:20:21 +0200 Subject: [PATCH] Use button as additional option for contextmenu --- app/helpers/application_helper.rb | 4 ++++ app/helpers/issues_helper.rb | 10 ++++++---- app/views/issues/_list.html.erb | 6 ++++-- app/views/my/blocks/_timelog.html.erb | 3 +++ app/views/timelog/_list.html.erb | 1 + app/views/versions/index.html.erb | 1 + app/views/versions/show.html.erb | 1 + config/locales/de.yml | 1 + config/locales/en.yml | 1 + public/images/3_bullets.png | Bin 0 -> 1250 bytes public/javascripts/context_menu.js | 3 ++- public/stylesheets/application.css | 4 +++- public/stylesheets/responsive.css | 5 ++++- test/functional/issues_controller_test.rb | 21 +++++++++++---------- test/functional/my_controller_test.rb | 6 +++--- test/test_helper.rb | 2 +- 16 files changed, 46 insertions(+), 23 deletions(-) create mode 100644 public/images/3_bullets.png diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9da044c04..cd10c9a40 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1223,6 +1223,10 @@ module ApplicationHelper content_tag(:a, name, {:href => '#', :onclick => "#{function}; return false;"}.merge(html_options)) end + def link_to_context_menu + link_to l(:button_actions), '#', title: l(:button_actions), class: 'icon-only icon-actions js-contextmenu' + end + # Helper to render JSON in views def raw_json(arg) arg.to_json.to_s.gsub('/', '\/').html_safe diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 972e6b9cb..1c2fd1b5d 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -99,7 +99,8 @@ module IssuesHelper content_tag('td', link_to_issue(child, :project => (issue.project_id != child.project_id)), :class => 'subject', :style => 'width: 50%') + content_tag('td', h(child.status), :class => 'status') + content_tag('td', link_to_user(child.assigned_to), :class => 'assigned_to') + - content_tag('td', child.disabled_core_fields.include?('done_ratio') ? '' : progress_bar(child.done_ratio), :class=> 'done_ratio'), + content_tag('td', child.disabled_core_fields.include?('done_ratio') ? '' : progress_bar(child.done_ratio), :class=> 'done_ratio') + + content_tag('td', link_to_context_menu, :class => 'buttons'), :class => css) end s << '' @@ -114,14 +115,15 @@ module IssuesHelper relations.each do |relation| other_issue = relation.other_issue(issue) css = "issue hascontextmenu #{other_issue.css_classes}" - link = manage_relations ? link_to(l(:label_relation_delete), + buttons = manage_relations ? link_to(l(:label_relation_delete), relation_path(relation), :remote => true, :method => :delete, :data => {:confirm => l(:text_are_you_sure)}, :title => l(:label_relation_delete), :class => 'icon-only icon-link-break' - ) : nil + ) :"".html_safe + buttons << link_to_context_menu s << content_tag('tr', content_tag('td', check_box_tag("ids[]", other_issue.id, false, :id => nil), :class => 'checkbox') + @@ -130,7 +132,7 @@ module IssuesHelper content_tag('td', other_issue.start_date, :class => 'start_date') + content_tag('td', other_issue.due_date, :class => 'due_date') + content_tag('td', other_issue.disabled_core_fields.include?('done_ratio') ? '' : progress_bar(other_issue.done_ratio), :class=> 'done_ratio') + - content_tag('td', link, :class => 'buttons'), + content_tag('td', buttons, :class => 'buttons'), :id => "relation-#{relation.id}", :class => css) end diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index 8024a6948..d704a58bb 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -14,6 +14,7 @@ <% query.inline_columns.each do |column| %> <%= column_header(query, column, query_options) %> <% end %> + @@ -21,7 +22,7 @@ <% if group_name %> <% reset_cycle %> - +   <%= group_name %> <%= group_count %> <%= group_totals %> <%= link_to_function("#{l(:button_collapse_all)}/#{l(:button_expand_all)}", @@ -34,11 +35,12 @@ <% query.inline_columns.each do |column| %> <%= content_tag('td', column_content(column, issue), :class => column.css_classes) %> <% end %> + <%= link_to_context_menu %> <% query.block_columns.each do |column| if (text = column_content(column, issue)) && text.present? -%> - + <% if query.block_columns.count > 1 %> <%= column.caption %> <% end %> diff --git a/app/views/my/blocks/_timelog.html.erb b/app/views/my/blocks/_timelog.html.erb index f96ee6c2e..7354c757d 100644 --- a/app/views/my/blocks/_timelog.html.erb +++ b/app/views/my/blocks/_timelog.html.erb @@ -35,6 +35,7 @@ <%= l(:label_project) %> <%= l(:field_comments) %> <%= l(:field_hours) %> + <% entries_by_day.keys.sort.reverse_each do |day| %> @@ -42,6 +43,7 @@ <%= day == User.current.today ? l(:label_today).titleize : format_date(day) %> <%= html_hours(format_hours(entries_by_day[day].sum(&:hours))) %> + <% entries_by_day[day].each do |entry| -%> @@ -52,6 +54,7 @@ <%= entry.project %> <%= h(' - ') + link_to_issue(entry.issue, :truncate => 50) if entry.issue %> <%= entry.comments %> <%= html_hours(format_hours(entry.hours)) %> + <%= link_to_context_menu %> <% end -%> <% end -%> diff --git a/app/views/timelog/_list.html.erb b/app/views/timelog/_list.html.erb index 6f126b0f7..019ddbb53 100644 --- a/app/views/timelog/_list.html.erb +++ b/app/views/timelog/_list.html.erb @@ -47,6 +47,7 @@ :title => l(:button_delete), :class => 'icon-only icon-del' %> <% end -%> + <%= link_to_context_menu %> <% @query.block_columns.each do |column| diff --git a/app/views/versions/index.html.erb b/app/views/versions/index.html.erb index 2914a6dbc..eeb9f3f06 100644 --- a/app/views/versions/index.html.erb +++ b/app/views/versions/index.html.erb @@ -30,6 +30,7 @@ <%= check_box_tag 'ids[]', issue.id, false, :id => nil %> <%= link_to_issue(issue, :project => (@project != issue.project)) %> + <%= link_to_context_menu %> <% end -%> diff --git a/app/views/versions/show.html.erb b/app/views/versions/show.html.erb index a62b0a1d0..677cc1410 100644 --- a/app/views/versions/show.html.erb +++ b/app/views/versions/show.html.erb @@ -44,6 +44,7 @@ <%= check_box_tag 'ids[]', issue.id, false, :id => nil %> <%= link_to_issue(issue, :project => (@project != issue.project)) %> + <%= link_to_context_menu %> <% end %> diff --git a/config/locales/de.yml b/config/locales/de.yml index 62def24c4..7d4a4582d 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -203,6 +203,7 @@ de: button_update: Aktualisieren button_view: Anzeigen button_watch: Beobachten + button_actions: Aktionen default_activity_design: Design default_activity_development: Entwicklung diff --git a/config/locales/en.yml b/config/locales/en.yml index d9095432b..618ff3f2a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1079,6 +1079,7 @@ en: button_reopen: Reopen button_import: Import button_filter: Filter + button_actions: Actions status_active: active status_registered: registered diff --git a/public/images/3_bullets.png b/public/images/3_bullets.png new file mode 100644 index 0000000000000000000000000000000000000000..616593b2aaf1a63c3a571ca8bef73f864db7c1c7 GIT binary patch literal 1250 zcmZ`(L1@!Z7=D|ZXl1bBVPh9VJb74N(mK06(m-vTE7)1KxpgO(rf)Nvl1A{+vUV-lzIrlMx!A$G7|BZp)x)`4&^jVr$-oKBv^5&5stXQ z>DD28=jb>veaoX3aRq*^Q6+Vn6Gbkx|7+Drt)&AcH)z{p1|iQtMUr7B8V;>PXgqT$ zt!D1K^6I`Fd8(NZ+t|S_4H!@9D93ucPyDaQ(C}JfQ4?F95XbXz5HOlH+NQ)~Nqpr%M$7JL#Dht~W#3{>4PKX~v<2d^Bz~cjKs*>D z@YbWU6=J)hTdbjx3+0>&J0_CE0j?QTQUuYENKd74S^K#|9<- zEFrcQxp4Sa$VjYF$$XotLOw;YscMaE6lF83r5JN>{f6oD-@7|sUk(-r%legend { padding-left: 16px; background: url(../images/arrow_expanded.png) no-repeat 0% 40%; cursor:pointer; } @@ -1308,6 +1309,7 @@ div.wiki img {vertical-align:middle; max-width:100%;} .icon-project { background-image: url(../images/projects.png); } .icon-add-bullet { background-image: url(../images/bullet_add.png); } .icon-shared { background-image: url(../images/link.png); } +.icon-actions { background-image: url(../images/3_bullets.png); } .icon-file { background-image: url(../images/files/default.png); } .icon-file.text-plain { background-image: url(../images/files/text.png); } diff --git a/public/stylesheets/responsive.css b/public/stylesheets/responsive.css index 76e2d5945..fb156863a 100644 --- a/public/stylesheets/responsive.css +++ b/public/stylesheets/responsive.css @@ -793,11 +793,13 @@ width: 33.33%; /* three columns for all cells that are not subject */ } + #issue_tree .issues, #issue_tree .issue, #relations .issues, #relations .issue { position: relative; /* needed for .buttons positioning */ } /* positioniong of unline button */ + #issue_tree .issue > td.buttons, #relations .issue > td.buttons { text-align: right; position: absolute; @@ -806,11 +808,12 @@ padding-right: 0; } + #issue_tree .issue .buttons a, #relations .issue .buttons a { vertical-align: middle; - padding-right: 5px; } + #issue_tree .issue > td.subject, #relations .issue > td.subject { padding-right: 25px; /* this is the spaces that .buttons uses next to subject */ } diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 9f62758e4..fc5b03576 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -1004,7 +1004,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_index_with_columns - columns = ['tracker', 'subject', 'assigned_to'] + columns = ['tracker', 'subject', 'assigned_to', 'buttons'] get :index, :params => { :set_filter => 1, :c => columns @@ -1017,6 +1017,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'th.tracker' assert_select 'th.subject' assert_select 'th.assigned_to' + assert_select 'th.buttons' end # columns should be stored in session @@ -1245,8 +1246,8 @@ class IssuesControllerTest < Redmine::ControllerTest :c => %w(subject description) } - assert_select 'table.issues thead th', 3 # columns: chekbox + id + subject - assert_select 'td.description[colspan="3"]', :text => 'Unable to print recipes' + assert_select 'table.issues thead th', 4 # columns: chekbox + id + subject + assert_select 'td.description[colspan="4"]', :text => 'Unable to print recipes' get :index, :params => { :set_filter => 1, @@ -1264,10 +1265,10 @@ class IssuesControllerTest < Redmine::ControllerTest } assert_response :success - assert_select 'table.issues thead th', 3 # columns: chekbox + id + subject + assert_select 'table.issues thead th', 4 # columns: chekbox + id + subject - assert_select 'td.last_notes[colspan="3"]', :text => 'Some notes with Redmine links: #2, r2.' - assert_select 'td.last_notes[colspan="3"]', :text => 'A comment with inline image: and a reference to #1 and r2.' + assert_select 'td.last_notes[colspan="4"]', :text => 'Some notes with Redmine links: #2, r2.' + assert_select 'td.last_notes[colspan="4"]', :text => 'A comment with inline image: and a reference to #1 and r2.' get :index, :params => { :set_filter => 1, @@ -1288,7 +1289,7 @@ class IssuesControllerTest < Redmine::ControllerTest :c => %w(subject last_notes) } assert_response :success - assert_select 'td.last_notes[colspan="3"]', :text => 'Privates notes' + assert_select 'td.last_notes[colspan="4"]', :text => 'Privates notes' Role.find(1).remove_permission! :view_private_notes @@ -1297,7 +1298,7 @@ class IssuesControllerTest < Redmine::ControllerTest :c => %w(subject last_notes) } assert_response :success - assert_select 'td.last_notes[colspan="3"]', :text => 'Public notes' + assert_select 'td.last_notes[colspan="4"]', :text => 'Public notes' end def test_index_with_description_and_last_notes_columns_should_display_column_name @@ -1307,8 +1308,8 @@ class IssuesControllerTest < Redmine::ControllerTest } assert_response :success - assert_select 'td.last_notes[colspan="3"] span', :text => 'Last notes' - assert_select 'td.description[colspan="3"] span', :text => 'Description' + assert_select 'td.last_notes[colspan="4"] span', :text => 'Last notes' + assert_select 'td.description[colspan="4"] span', :text => 'Description' end def test_index_with_parent_column diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb index 206bba4cf..6a618c4a3 100644 --- a/test/functional/my_controller_test.rb +++ b/test/functional/my_controller_test.rb @@ -125,7 +125,7 @@ class MyControllerTest < Redmine::ControllerTest assert_select '#block-issuequery' do assert_select 'a[href=?]', "/issues?query_id=#{query.id}" # assert number of columns (columns from query + id column + checkbox column) - assert_select 'table.issues th', 6 + assert_select 'table.issues th', 7 # assert results limit assert_select 'table.issues tr.issue', 10 assert_select 'table.issues td.assigned_to' @@ -145,7 +145,7 @@ class MyControllerTest < Redmine::ControllerTest assert_select '#block-issuequery' do assert_select 'a[href=?]', "/projects/ecookbook/issues?query_id=#{query.id}" # assert number of columns (columns from query + id column + checkbox column) - assert_select 'table.issues th', 6 + assert_select 'table.issues th', 7 # assert results limit assert_select 'table.issues tr.issue', 10 assert_select 'table.issues td.assigned_to' @@ -164,7 +164,7 @@ class MyControllerTest < Redmine::ControllerTest assert_select '#block-issuequery' do # assert number of columns (columns from query + id column + checkbox column) - assert_select 'table.issues th', 4 + assert_select 'table.issues th', 5 assert_select 'table.issues th', :text => 'Due date' end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 34aebd4d2..6dcdb7a7c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -305,7 +305,7 @@ module Redmine # Return the columns that are displayed in the issue list def columns_in_issues_list - css_select('table.issues thead th:not(.checkbox)').map(&:text) + css_select('table.issues thead th:not(.checkbox)').map(&:text).select(&:present?) end # Return the columns that are displayed in the list -- 2.15.1