Add paginate for user dossiers
This commit is contained in:
parent
eb5985efc4
commit
2eb01bdf42
8 changed files with 37 additions and 4 deletions
3
Gemfile
3
Gemfile
|
@ -37,6 +37,9 @@ gem 'haml-rails'
|
|||
#bootstrap saas
|
||||
gem 'bootstrap-sass', '~> 3.3.5'
|
||||
|
||||
# Pagination
|
||||
gem 'will_paginate-bootstrap'
|
||||
|
||||
# Decorators
|
||||
gem 'draper'
|
||||
|
||||
|
|
|
@ -408,6 +408,9 @@ GEM
|
|||
websocket-driver (0.5.3)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.2)
|
||||
will_paginate (3.0.7)
|
||||
will_paginate-bootstrap (1.0.1)
|
||||
will_paginate (>= 3.0.3)
|
||||
xpath (2.0.0)
|
||||
nokogiri (~> 1.3)
|
||||
|
||||
|
@ -465,3 +468,7 @@ DEPENDENCIES
|
|||
unicorn
|
||||
web-console (~> 2.0)
|
||||
webmock
|
||||
will_paginate-bootstrap
|
||||
|
||||
BUNDLED WITH
|
||||
1.10.6
|
||||
|
|
|
@ -89,6 +89,11 @@ input#nom_projet {
|
|||
max-width: 27px;
|
||||
}
|
||||
|
||||
div.pagination{
|
||||
padding-top:20px;
|
||||
display:block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.alert.alert-success.move_up {
|
||||
position: absolute;
|
||||
|
|
|
@ -2,10 +2,16 @@ class Users::DossiersController < UsersController
|
|||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
@dossiers = current_user.dossiers.where("state NOT IN ('draft')").order(updated_at: 'DESC').decorate
|
||||
end
|
||||
def show
|
||||
@dossiers = current_user.dossiers.where("state NOT IN ('draft')").order(updated_at: 'DESC')
|
||||
|
||||
if params[:page].nil?
|
||||
params[:page] = 1
|
||||
end
|
||||
|
||||
@dossiers = @dossiers.paginate(:page => params[:page], :per_page => 12).decorate
|
||||
end
|
||||
|
||||
def show
|
||||
@dossier = current_user_dossier params[:id]
|
||||
|
||||
@etablissement = @dossier.etablissement
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class DossierDecorator < Draper::Decorator
|
||||
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
|
||||
delegate_all
|
||||
|
||||
def date_fr
|
||||
|
|
4
app/decorators/dossiers_decorator.rb
Normal file
4
app/decorators/dossiers_decorator.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class DossiersDecorator < Draper::CollectionDecorator
|
||||
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
|
||||
|
||||
end
|
|
@ -11,4 +11,7 @@
|
|||
%td
|
||||
= link_to(dossier.nom_projet, users_dossier_recapitulatif_path(dossier))
|
||||
%td{id: "dossier_#{dossier.id}_state"}= dossier.state_fr
|
||||
%td= dossier.last_update
|
||||
%td= dossier.last_update
|
||||
|
||||
.pagination
|
||||
= will_paginate @dossiers, renderer: BootstrapPagination::Rails
|
|
@ -20,6 +20,10 @@
|
|||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
fr:
|
||||
will_paginate:
|
||||
next_label: 'Suivant'
|
||||
previous_label: 'Précédent'
|
||||
|
||||
number:
|
||||
currency:
|
||||
format:
|
||||
|
|
Loading…
Reference in a new issue