From dcc7ecb34a61d55193572ca8bc66c9859f3d6e49 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Thu, 4 Oct 2018 13:20:11 +0000 Subject: Attachments prev/next navigation (#29395). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@17567 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/attachments_controller.rb | 8 ++++++++ app/helpers/attachments_helper.rb | 8 ++++++++ app/views/layouts/_file.html.erb | 4 ++++ 3 files changed, 20 insertions(+) (limited to 'app') diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 1b18662ad..9c0bf15ba 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -32,6 +32,14 @@ class AttachmentsController < ApplicationController def show respond_to do |format| format.html { + if @attachment.container.respond_to?(:attachments) + @attachments = @attachment.container.attachments.to_a + if index = @attachments.index(@attachment) + @paginator = Redmine::Pagination::Paginator.new( + @attachments.size, 1, index+1 + ) + end + end if @attachment.is_diff? @diff = File.read(@attachment.diskfile, :mode => "rb") @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline' diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 36cf0d4fe..385f3b8a4 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -56,6 +56,14 @@ module AttachmentsHelper end end + def render_pagination + pagination_links_each @paginator do |text, parameters, options| + if att = @attachments[parameters[:page] - 1] + link_to text, named_attachment_path(att, att.filename) + end + end if @paginator + end + def render_api_attachment(attachment, api, options={}) api.attachment do render_api_attachment_attributes(attachment, api) diff --git a/app/views/layouts/_file.html.erb b/app/views/layouts/_file.html.erb index 3b225508b..8ffadf703 100644 --- a/app/views/layouts/_file.html.erb +++ b/app/views/layouts/_file.html.erb @@ -12,6 +12,10 @@ <%= yield %> + + <%= render_pagination %> + + <% html_title @attachment.filename %> <% content_for :header_tags do -%> -- cgit v1.2.3