Files
openfoodnetwork/app/views/admin/enterprises/_admin_index.html.haml
Jean-Baptiste Bellet e18454c55a Add pagination on enterprises page for super admin
Enterprises are stored in `@enterprise_set` variables, and we iterate over to show the list of enterprises to super admin.

Previously, we used to use `Sets::EnterpriseSet.new(collection)` instead of creating set based on `@collection`: this leads to call the `collection` method twice, which was probably very time consuming. This commit fix also that.

+ use paginated enterprises loading on bulk update but without testing if the current user is an admin
2023-02-03 09:15:07 +01:00

43 lines
1.7 KiB
Plaintext

= form_for @enterprise_set, url: main_app.bulk_update_admin_enterprises_path do |f|
%table#listing_enterprises.index
%colgroup
%col{style: "width: 25%;"}/
%col{style: "width: 15%;"}/
%col{style: "width: 5%;"}/
- if spree_current_user.admin?
%col{style: "width: 12%;"}/
- if spree_current_user.admin?
%col{style: "width: 18%;"}/
%col{style: "width: 25%;"}/
%thead
%tr{"data-hook" => "enterprises_header"}
%th= t('.name')
%th= t('.role')
- if spree_current_user.admin?
%th= t('.sells')
%th= t('.visible')
- if spree_current_user.admin?
%th= t('.owner')
%th
%tbody
= f.fields_for :collection do |enterprise_form|
- enterprise = enterprise_form.object
%tr{class: "enterprise-#{enterprise.id}"}
%td= link_to enterprise.name, main_app.edit_admin_enterprise_path(enterprise)
%td
= enterprise_form.check_box :is_primary_producer
= t('.producer')
- if spree_current_user.admin?
%td= enterprise_form.select :sells, Enterprise::SELLS, {}, class: 'select2 fullwidth'
%td= enterprise_form.check_box :visible, {}, 'public', 'hidden'
- if spree_current_user.admin?
%td= enterprise_form.select :owner_id, enterprise.users.map{ |e| [ e.email, e.id ] }, {}, class: "select2 fullwidth"
%td{"data-hook" => "admin_users_index_row_actions"}
= render 'actions', enterprise: enterprise
- if @enterprises.empty?
%tr
%td{colspan: "4"}= t(:none)
= f.submit t(:update)
= render partial: 'admin/shared/pagy_links', locals: { pagy: @pagy }