From 2603256a17152d487ea0ecdef8a0ce34009db154 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 24 Apr 2014 14:53:32 +1000 Subject: [PATCH] Extract admin order cycle index row into partial --- app/views/admin/order_cycles/_row.html.haml | 25 ++++++++++++++++++ app/views/admin/order_cycles/index.html.haml | 27 +++----------------- 2 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 app/views/admin/order_cycles/_row.html.haml diff --git a/app/views/admin/order_cycles/_row.html.haml b/app/views/admin/order_cycles/_row.html.haml new file mode 100644 index 0000000000..4396fabcba --- /dev/null +++ b/app/views/admin/order_cycles/_row.html.haml @@ -0,0 +1,25 @@ +- order_cycle = order_cycle_form.object +- klass = "order-cycle-#{order_cycle.id} #{order_cycle_status_class order_cycle}" +%tr{class: klass} + %td= link_to order_cycle.name, main_app.edit_admin_order_cycle_path(order_cycle) + %td= order_cycle_form.text_field :orders_open_at, :class => 'datetimepicker', :value => order_cycle.orders_open_at + %td= order_cycle_form.text_field :orders_close_at, :class => 'datetimepicker', :value => order_cycle.orders_close_at + %td.suppliers + - order_cycle.suppliers.managed_by(spree_current_user).each do |s| + = s.name + %br/ + %td= order_cycle.coordinator.name + %td.distributors + - order_cycle.distributors.managed_by(spree_current_user).each do |d| + = d.name + %br/ + + %td.products + - variant_images = capture do + - order_cycle.variants.each do |v| + = image_tag(v.images.first.attachment.url(:mini)) if v.images.present? + %br/ + %span.with-tip{'data-powertip' => variant_images}= "#{order_cycle.variants.count} variants" + + %td.actions + = link_to '', main_app.clone_admin_order_cycle_path(order_cycle), class: 'clone-order-cycle icon-copy no-text' diff --git a/app/views/admin/order_cycles/index.html.haml b/app/views/admin/order_cycles/index.html.haml index 0e829e025c..c3f4bc0b8f 100644 --- a/app/views/admin/order_cycles/index.html.haml +++ b/app/views/admin/order_cycles/index.html.haml @@ -18,6 +18,7 @@ %col %col %col + %thead %tr %th Name @@ -28,31 +29,9 @@ %th Distributors %th Products %th.actions + %tbody = f.fields_for :collection do |order_cycle_form| - - order_cycle = order_cycle_form.object - - klass = "order-cycle-#{order_cycle.id} #{order_cycle_status_class order_cycle}" - %tr{class: klass} - %td= link_to order_cycle.name, main_app.edit_admin_order_cycle_path(order_cycle) - %td= order_cycle_form.text_field :orders_open_at, :class => 'datetimepicker', :value => order_cycle.orders_open_at - %td= order_cycle_form.text_field :orders_close_at, :class => 'datetimepicker', :value => order_cycle.orders_close_at - %td.suppliers - - order_cycle.suppliers.managed_by(spree_current_user).each do |s| - = s.name - %br/ - %td= order_cycle.coordinator.name - %td.distributors - - order_cycle.distributors.managed_by(spree_current_user).each do |d| - = d.name - %br/ + = render 'admin/order_cycles/row', order_cycle_form: order_cycle_form - %td.products - - variant_images = capture do - - order_cycle.variants.each do |v| - = image_tag(v.images.first.attachment.url(:mini)) if v.images.present? - %br/ - %span.with-tip{'data-powertip' => variant_images}= "#{order_cycle.variants.count} variants" - - %td.actions - = link_to '', main_app.clone_admin_order_cycle_path(order_cycle), class: 'clone-order-cycle icon-copy no-text' = f.submit 'Update'