Sha256: fffb27fa0b1fb59df39dcc94d9a2068c131cf8864d81abd7d26e8f9df30d120d

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

<%
  page = @handler_result.outputs[:page]
  num_accounts = @handler_result.outputs[:num_matching_accounts]
  per_page = @handler_result.outputs[:per_page]
  pages = (num_accounts * 1.0 / per_page).ceil
  accounts = @handler_result.outputs[:accounts]
%>

<div id='search-results-pagination'>
  <%= pluralize(num_accounts, 'user') %> found. 

  <% if pages > 0 %>
    Page: 

    <% 
      linked_page_numbers = [page+1]
      linked_page_numbers.push(1)
      linked_page_numbers.push(pages)
      linked_page_numbers.push(page+1-1, page+1-2, page+1+1, page+1+2)
      linked_page_numbers.reject!{|pp| pp < 1 || pp > pages}
      linked_page_numbers.uniq!
      linked_page_numbers.sort!
    %>

    <% linked_page_numbers.each do |lpn| %>
      <%= link_to_unless lpn == page + 1,
                         lpn, 
                         dev_accounts_path(search: {terms: @handler_result.outputs[:query], page: lpn-1, per_page: per_page}), remote: true %>
    <% end %>
  <% end %>
</div>

<div id='search-results-list'>
  <%= osu.action_list(
      records: accounts,
      list: {
       headings: ['Username', 'Title', 'Name', 'Actions'],
      widths: ['30%', '10%', '40%', '20%'],
      data_procs:
        [
          lambda { |account| account.username },
          lambda { |account| account.title || '---' },
          lambda { |account| account.name || '---' },
          lambda { |account| 
              link_to 'Sign in as',
                      with_interceptor { become_dev_account_path(account) },
                      method: :post
            }
        ]
      }
    ) %>
</div>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openstax_accounts-3.1.1 app/views/openstax/accounts/dev/accounts/_search_results.html.erb
openstax_accounts-3.1.0 app/views/openstax/accounts/dev/accounts/_search_results.html.erb