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
33
34
35
36
37
|
module PaginationHelper
def paginated_content(models, default_partial_name = nil, options = {})
default_options = {:delete => true, :edit => true}
options = default_options.merge(options)
# return "" if models.blank?
html = ""
models.each_slice(3) do |row_models|
html += '<div class="row">'
row_models.each do |model|
partial_name = default_partial_name || model.class.name.underscore.gsub("chouette/", "")
html += '<div class="col-md-4">' + (render :partial => partial_name, :object => model, :locals => options).to_s + '</div>'
end
html += '</div>'
end
return html.html_safe unless models.blank?
end
def new_pagination collection, cls = nil
# k = collection.first.class unless collection.empty?
pinfos = page_entries_info collection, html: false
if collection.total_pages > 1
links = content_tag :div, '', class: 'page_links' do
will_paginate collection, container: false, page_links: false, previous_label: '', next_label: ''
end
content_tag :div, pinfos.concat(links).html_safe, class: "pagination #{cls}"
else
content_tag :div, pinfos, class: "pagination #{cls}"
end
end
end
|