summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2018-10-04 13:20:11 +0000
committerGo MAEDA <maeda@farend.jp>2018-10-04 13:20:11 +0000
commitdcc7ecb34a61d55193572ca8bc66c9859f3d6e49 (patch)
tree8f6e5c9e422a9c4fc2e2a7c46bfd054e54e2441c
parent28c231473f98a4b184204dd53cbeee1e0d655853 (diff)
downloadredmine-dcc7ecb34a61d55193572ca8bc66c9859f3d6e49.tar.gz
redmine-dcc7ecb34a61d55193572ca8bc66c9859f3d6e49.zip
Attachments prev/next navigation (#29395).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@17567 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/attachments_controller.rb8
-rw-r--r--app/helpers/attachments_helper.rb8
-rw-r--r--app/views/layouts/_file.html.erb4
-rw-r--r--public/stylesheets/application.css4
-rw-r--r--test/functional/attachments_controller_test.rb10
5 files changed, 34 insertions, 0 deletions
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 @@
</div>
<%= yield %>
+<span class="pagination">
+ <%= render_pagination %>
+</span>
+
<% html_title @attachment.filename %>
<% content_for :header_tags do -%>
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 1ff1dbd8a..8a33fda3a 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -666,6 +666,10 @@ span.pagination {margin-left:3px; color:#888; display:block;}
font-weight: bold;
}
span.pagination>span {white-space:nowrap;}
+.controller-attachments.action-show span.pagination{
+ display: block;
+ margin-top: 1.2em;
+}
#search-form fieldset p {margin:0.2em 0;}
diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb
index 016ed28fa..a5d4c1705 100644
--- a/test/functional/attachments_controller_test.rb
+++ b/test/functional/attachments_controller_test.rb
@@ -287,6 +287,16 @@ class AttachmentsControllerTest < Redmine::ControllerTest
assert_response 404
end
+ def test_show_renders_pagination
+ get :show, :params => { :id => 5, :type => 'inline' }
+ assert_response :success
+
+ assert_select 'ul.pages li.next', :text => /next/i
+ assert_select 'ul.pages li.previous', :text => /previous/i
+
+ set_tmp_attachments_directory
+ end
+
def test_download_text_file
get :download, :params => {
:id => 4
ort/47649/stable28 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/l10n/hy/gallery.po
blob: c1a1f43fe7df97afff04f391aa3af8fbf6992607 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32