EagerELK/ditty

View on GitHub
views/partials/pager.haml

Summary

Maintainability
Test Coverage
%nav{"aria-label" => "Page navigation"}
  .row
    .col-sm-12.col-md-6
      %p.my-2
        - if list.pagination_record_count > 0
          Showing #{list.current_page_record_range} of #{list.pagination_record_count} records
        - else
          %p.text-center No records to show
    .col-sm-12.col-md-6
      - if list.pagination_record_count > 0
        %ul.pagination.justify-content-end
          - if list.first_page?
            %li.page-item.disabled
              %span.page-link First
            %li.page-item.disabled
              %span.page-link Previous
          - else
            %li.page-item
              %a.page-link{ href: first_link } First
            %li.page-item
              %a.page-link{ href: prev_link } Previous
          %li.page-item
            .dropdown
              %button.page-link.dropdown-toggle{ type: 'button', id: 'dropdownMenuButton', 'data-toggle':  'dropdown', 'aria-haspopup': 'true', 'aria-expanded': 'false' }
                = params[:count] || 10
              .dropdown-menu
                %a.dropdown-item{ href: "#{base_path}?#{query_string(count: 10)}" } 10
                %a.dropdown-item{ href: "#{base_path}?#{query_string(count: 25)}" } 25
                %a.dropdown-item{ href: "#{base_path}?#{query_string(count: 50)}" } 50
                %a.dropdown-item{ href: "#{base_path}?#{query_string(count: 100)}" } 100
          - if list.last_page?
            %li.page-item.disabled
              %span.page-link Next
            %li.page-item.disabled
              %span.page-link Last
          - else
            %li.page-item
              %a.page-link{ href: next_link } Next
            %li.page-item
              %a.page-link{ href: last_link } Last
          %li
             
          %li
            %a.page-link{ href: "#{base_path}/.csv?#{URI.encode_www_form(params.merge(count: 'all'))}" }
              Export