Pagination fixed
This commit is contained in:
parent
3ad1dc605b
commit
6ddf9ff48c
2 changed files with 10 additions and 25 deletions
|
|
@ -24,14 +24,7 @@ class PackagesController < ApplicationController
|
|||
# first image twice as large. So the first page contains 5 images while
|
||||
# the second and further page contain 6 images.
|
||||
@page = params[:page]
|
||||
# BUG: having page 1 with 5 and other with 6 items does not compute correctly
|
||||
@images_per_page = if @page.to_i < 2
|
||||
5
|
||||
else
|
||||
6
|
||||
end
|
||||
# raise
|
||||
@screenshots = screenshots_visible_to_user(@package).paginate(page: @page, per_page: @images_per_page)
|
||||
@screenshots = screenshots_visible_to_user(@package).paginate(page: @page, per_page: 6)
|
||||
end
|
||||
|
||||
# Show upload form for new images
|
||||
|
|
|
|||
|
|
@ -17,24 +17,16 @@
|
|||
.grid-x.grid-margin-y.grid-margin-x.align-middle
|
||||
|
||||
- @screenshots.each_with_index do |screenshot, idx|
|
||||
/ Display the first screenshot as a large image (on the first page only)
|
||||
- if idx==0 && @page.to_i<2
|
||||
.small-12.medium-12.cell
|
||||
.margin-bottom-3
|
||||
= render(partial:'medium_image', locals: {screenshot: screenshot})
|
||||
.small-12.medium-6.cell
|
||||
.margin-bottom-3
|
||||
= render(partial:'small_image', locals: {screenshot: screenshot})
|
||||
|
||||
/ Display further screenshots as smaller images
|
||||
- else
|
||||
.small-12.medium-6.cell
|
||||
.margin-bottom-3
|
||||
= render(partial:'medium_image', locals: {screenshot: screenshot})
|
||||
|
||||
// Has the unmoderated screenshot been uploaded by the current user?
|
||||
- if screenshot_uploaded_by_current_user?(screenshot)
|
||||
span.label.warning
|
||||
| Uploaded by you
|
||||
- unless screenshot.approved
|
||||
| (but not public yet)
|
||||
// Has the unmoderated screenshot been uploaded by the current user?
|
||||
- if screenshot_uploaded_by_current_user?(screenshot)
|
||||
span.label.warning
|
||||
| Uploaded by you
|
||||
- unless screenshot.approved
|
||||
| (but not moderated yet)
|
||||
|
||||
// Second paginator at the bottom so the user does not have to scroll up again
|
||||
= render(partial: 'packages/paginator', locals: {items: @screenshots})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue