class PolicyManager::PaginatorRenderer
Constants
- ELLIPSIS
Public Instance Methods
container_attributes()
click to toggle source
Calls superclass method
# File lib/policy_manager/exporter/paginator_renderer.rb, line 23 def container_attributes super.except(*[:link_options]) end
to_html()
click to toggle source
# File lib/policy_manager/exporter/paginator_renderer.rb, line 9 def to_html list_items = pagination.map do |item| case item when (1.class == Integer ? Integer : Fixnum) page_number(item) else send(item) end end.join(@options[:link_separator]) list_wrapper = tag :nav, list_items, class: "pagination button-group" tag :nav, list_wrapper end
Protected Instance Methods
gap()
click to toggle source
# File lib/policy_manager/exporter/paginator_renderer.rb, line 60 def gap tag :p, tag(:i, ELLIPSIS, class: 'page-link'), class: 'page-item disabled btn' end
next_page()
click to toggle source
# File lib/policy_manager/exporter/paginator_renderer.rb, line 69 def next_page num = @collection.current_page < @collection.total_pages && @collection.current_page + 1 previous_or_next_page num, @options[:next_label], 'next btn' end
page_number(page)
click to toggle source
# File lib/policy_manager/exporter/paginator_renderer.rb, line 29 def page_number(page) link_options = @options[:link_options] || {} if page == current_page tag(:a, page, class: 'btn page-item active', href: '') else tag(:a, page, href: page_path(page), class: 'page-link btn', rel: rel_value(page)) end end
page_path(page)
click to toggle source
# File lib/policy_manager/exporter/paginator_renderer.rb, line 39 def page_path(page) return "../index.html" if page == 1 if @collection.current_page == 1 return "./#{page}/index.html" if @collection.current_page < page return "../#{page}/index.html" if @collection.current_page > page else return "../#{page}/index.html" end end
previous_or_next_page(page, text, classname)
click to toggle source
# File lib/policy_manager/exporter/paginator_renderer.rb, line 49 def previous_or_next_page(page, text, classname) link_options = @options[:link_options] || {} if page link_wrapper = tag(:a, text || page, href: page_path(page), class: "page-link btn" + classname.to_s) # link_wrapper, class: 'page-item ' else tag(:a, text, href:'', class: 'page-link btn') # span_wrapper, class: 'page-item disabled' end end
previous_page()
click to toggle source
# File lib/policy_manager/exporter/paginator_renderer.rb, line 64 def previous_page num = @collection.current_page > 1 && @collection.current_page - 1 previous_or_next_page num, @options[:previous_label], 'previous btn' end