From 4922ead57a7261be8e3b62d5e5e798b056423727 Mon Sep 17 00:00:00 2001 From: Michael Frister Date: Fri, 23 Aug 2013 18:01:13 +0100 Subject: [PATCH] Add link to XLS formatted issue list to issue index using hook --- .../_view_issues_sidebar_issues_bottom.rhtml | 7 ------- features/step_definitions/format_steps.rb | 3 +++ features/xls_export_link.feature | 7 +++++++ lib/open_project/xls_export/hooks/issue_hook.rb | 7 ++++--- 4 files changed, 14 insertions(+), 10 deletions(-) delete mode 100644 app/views/hooks/different_formats/_view_issues_sidebar_issues_bottom.rhtml create mode 100644 features/step_definitions/format_steps.rb create mode 100644 features/xls_export_link.feature diff --git a/app/views/hooks/different_formats/_view_issues_sidebar_issues_bottom.rhtml b/app/views/hooks/different_formats/_view_issues_sidebar_issues_bottom.rhtml deleted file mode 100644 index 61fa836ef7..0000000000 --- a/app/views/hooks/different_formats/_view_issues_sidebar_issues_bottom.rhtml +++ /dev/null @@ -1,7 +0,0 @@ -

<%= l(:different_formats) %>

-<% if params[:action] == "index" or params[:action] == "all" %> - <%= link_to l(:print_with_description), :controller => 'issues', :action => 'printable', :project_id => @project %>
- <% if User.current.allowed_to? :export_issues, @project, :global => @project.nil? %> - <%= link_to l(:export_to_excel), :controller => 'issues', :action => 'index', :format => 'xls', :project_id => @project %>
- <% end %> -<% end %> diff --git a/features/step_definitions/format_steps.rb b/features/step_definitions/format_steps.rb new file mode 100644 index 0000000000..a5614a6862 --- /dev/null +++ b/features/step_definitions/format_steps.rb @@ -0,0 +1,3 @@ +Then /^there should be a link to the issue list in ([^ ]+) format$/ do |format| + find_link(format)[:href].should == project_issues_path(:project_id => 1, :format => 'xls') +end diff --git a/features/xls_export_link.feature b/features/xls_export_link.feature new file mode 100644 index 0000000000..1f6d7f2842 --- /dev/null +++ b/features/xls_export_link.feature @@ -0,0 +1,7 @@ +Feature: Show link to XLS format below issue list + + Scenario: There is a link to the issue list in XML format + Given there is a project named "Test Project" + And I am already admin + When I go to the issues index page for the project "Test Project" + Then there should be a link to the issue list in XLS format diff --git a/lib/open_project/xls_export/hooks/issue_hook.rb b/lib/open_project/xls_export/hooks/issue_hook.rb index e6b879598f..945d1a10fa 100644 --- a/lib/open_project/xls_export/hooks/issue_hook.rb +++ b/lib/open_project/xls_export/hooks/issue_hook.rb @@ -1,7 +1,8 @@ -# Hooks to attach to the Redmine Issues. module PrintableIssues class IssueHook < Redmine::Hook::ViewListener - # Renders the Cost Object subject and basic costs information - render_on :view_issues_sidebar_issues_bottom, :partial => 'hooks/different_formats/view_issues_sidebar_issues_bottom' + # Add XLS format link below issue list + def view_issues_index_other_formats(context) + context[:link_formatter].link_to 'XLS', :url => { :project_id => context[:project].id } + end end end