From f6e635466bbcd7c228ed7b455a56d58de0a3cbac Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 8 Apr 2015 14:31:18 +1000 Subject: [PATCH] Rearranging elements on the order cycle form a little bit --- app/views/admin/order_cycles/_form.html.haml | 11 ++--------- .../order_cycles/_name_and_timing_form.html.haml | 14 +++++++++----- spec/features/admin/order_cycles_spec.rb | 13 ++++--------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/app/views/admin/order_cycles/_form.html.haml b/app/views/admin/order_cycles/_form.html.haml index 6d24e149f8..a5f7ec1518 100644 --- a/app/views/admin/order_cycles/_form.html.haml +++ b/app/views/admin/order_cycles/_form.html.haml @@ -1,5 +1,7 @@ = render 'name_and_timing_form', f: f +-if Enterprise.managed_by(spree_current_user).include? @order_cycle.coordinator + = render 'coordinator_fees', f: f %h2 Incoming %table.exchanges @@ -20,15 +22,6 @@ = f.submit 'Add supplier', 'ng-click' => 'addSupplier($event)' - -%h2 Coordinator --if Enterprise.managed_by(spree_current_user).include? @order_cycle.coordinator - = f.label :coordinator_id, 'Coordinator' - = f.select :coordinator_id, permitted_coordinating_enterprise_options_for(@order_cycle), { include_blank: true }, {'ng-model' => 'order_cycle.coordinator_id', 'ofn-on-change' => 'order_cycle.coordinator_fees = []', 'required' => true} - = render 'coordinator_fees', f: f -- else - = @order_cycle.coordinator.name - %h2 Outgoing %table.exchanges %thead diff --git a/app/views/admin/order_cycles/_name_and_timing_form.html.haml b/app/views/admin/order_cycles/_name_and_timing_form.html.haml index be11d45372..1bb60e784e 100644 --- a/app/views/admin/order_cycles/_name_and_timing_form.html.haml +++ b/app/views/admin/order_cycles/_name_and_timing_form.html.haml @@ -2,20 +2,24 @@ .row .alpha.two.columns = f.label :name - .fourteen.columns.omega + .six.columns.omega - if as_coordinator = f.text_field :name, 'ng-model' => 'order_cycle.name', 'required' => true - else {{ order_cycle.name }} - -.row - .alpha.two.columns + .two.columns = f.label :orders_open_at, 'Orders open' - .six.columns + .omega.six.columns - if as_coordinator = f.text_field :orders_open_at, 'datetimepicker' => 'order_cycle.orders_open_at', 'ng-model' => 'order_cycle.orders_open_at' - else {{ order_cycle.orders_open_at }} + +.row + .alpha.two.columns + = f.label :coordinator + .six.columns.omega + = @order_cycle.coordinator.name .two.columns = f.label :orders_close_at, 'Orders close' .six.columns.omega diff --git a/spec/features/admin/order_cycles_spec.rb b/spec/features/admin/order_cycles_spec.rb index 2d6a854d5c..cb96799fbb 100644 --- a/spec/features/admin/order_cycles_spec.rb +++ b/spec/features/admin/order_cycles_spec.rb @@ -90,7 +90,6 @@ feature %q{ fill_in 'order_cycle_name', with: 'Plums & Avos' fill_in 'order_cycle_orders_open_at', with: '2040-11-06 06:00:00' fill_in 'order_cycle_orders_close_at', with: '2040-11-13 17:00:00' - select 'My coordinator', from: 'order_cycle_coordinator_id' # And I add a coordinator fee click_button 'Add coordinator fee' @@ -170,8 +169,7 @@ feature %q{ page.find('#order_cycle_name').value.should == oc.name page.find('#order_cycle_orders_open_at').value.should == oc.orders_open_at.to_s page.find('#order_cycle_orders_close_at').value.should == oc.orders_close_at.to_s - page.find('#order_cycle_coordinator_id').value.to_i.should == oc.coordinator_id - page.should have_selector "select[name='order_cycle_coordinator_fee_0_id']" + page.should have_content "COORDINATOR #{oc.coordinator.name}" # And I should see the suppliers page.should have_selector 'td.supplier_name', :text => oc.suppliers.first.name @@ -524,13 +522,11 @@ feature %q{ page.should have_content oc_user_coordinating.name page.should_not have_content oc_for_other_user.name - # The order cycle should show enterprises that I manage + # The order cycle should show all enterprises in the order cycle page.should have_selector 'td.suppliers', text: supplier_managed.name page.should have_selector 'td.distributors', text: distributor_managed.name - - # The order cycle should not show enterprises that I don't manage - page.should_not have_selector 'td.suppliers', text: supplier_unmanaged.name - page.should_not have_selector 'td.distributors', text: distributor_unmanaged.name + page.should have_selector 'td.suppliers', text: supplier_unmanaged.name + page.should have_selector 'td.distributors', text: distributor_unmanaged.name end scenario "creating a new order cycle" do @@ -551,7 +547,6 @@ feature %q{ select_incoming_variant supplier_managed, 0, product_managed.master select_incoming_variant supplier_permitted, 1, product_permitted.master - select 'Managed distributor', from: 'order_cycle_coordinator_id' click_button 'Add coordinator fee' select 'Managed distributor fee', from: 'order_cycle_coordinator_fee_0_id'