Starting alternative flow for new manual order

This commit is contained in:
stveep
2017-03-19 19:24:31 +00:00
committed by Rob Harrington
parent fcce858ea4
commit 220693f4e3
5 changed files with 72 additions and 36 deletions

View File

@@ -5,6 +5,9 @@ Spree::Admin::OrdersController.class_eval do
helper CheckoutHelper
before_filter :load_spree_api_key, :only => :bulk_management
# Ensure that the distributor is set for an order when
before_filter :ensure_distribution, only: :new
# We need to add expections for collection actions other than :index here
# because spree_auth_devise causes load_order to be called, which results
# in an auth failure as the @order object is nil for collection actions
@@ -131,4 +134,10 @@ Spree::Admin::OrdersController.class_eval do
ocs.closed +
ocs.undated
end
def ensure_distribution
unless @order.distribution_set?
render 'set_distribution'
end
end
end

View File

@@ -186,6 +186,12 @@ Spree::OrdersController.class_eval do
private
def ensure_distributor
unless @order.distributor_id
render 'set_distribution'
end
end
def populate_variant_attributes
order = current_order.reload

View File

@@ -1,38 +1,3 @@
/ insert_before "[data-hook='admin_order_form_buttons']"
%fieldset.no-border-bottom
%legend{align: 'center'} Distribution
- if @order.complete?
.alpha.six.columns
%p
%b Distributor:
= f.object.distributor.andand.name || "None"
= f.hidden_field :distributor_id
.omega.six.columns
%p
%b Order cycle:
= f.object.order_cycle.andand.name || "None"
= f.hidden_field :order_cycle_id
- else
.alpha.six.columns
.field
%label{for: "order_distributor_id"} Distributor
%input.ofn-select2.fullwidth{id: "order_distributor_id",
type: 'number',
name: "order[distributor_id]",
"ng-model" => 'distributor_id',
data: "shops" }
.omega.six.columns
.field
%label{ for: "order_order_cycle_id"} Order Cycle
%input.ofn-select2.fullwidth{id: "order_order_cycle_id",
type: 'number',
name: "order[order_cycle_id]",
"ng-model" => 'order_cycle_id',
"ng-disabled" => "!distributor_id",
data: "orderCycles",
text: "name_and_status",
filter: "validOrderCycle" }
= render partial: 'distribution_fields'

View File

@@ -0,0 +1,36 @@
%fieldset.no-border-bottom
%legend{align: 'center'} Distribution
- if @order.complete?
.alpha.six.columns
%p
%b Distributor:
= f.object.distributor.andand.name || "None"
= f.hidden_field :distributor_id
.omega.six.columns
%p
%b Order cycle:
= f.object.order_cycle.andand.name || "None"
= f.hidden_field :order_cycle_id
- else
.alpha.six.columns
.field
%label{for: "order_distributor_id"} Distributor
%input.ofn-select2.fullwidth{id: "order_distributor_id",
type: 'number',
name: "order[distributor_id]",
"ng-model" => 'distributor_id',
data: "shops" }
.omega.six.columns
.field
%label{ for: "order_order_cycle_id"} Order Cycle
%input.ofn-select2.fullwidth{id: "order_order_cycle_id",
type: 'number',
name: "order[order_cycle_id]",
"ng-model" => 'order_cycle_id',
"ng-disabled" => "!distributor_id",
data: "orderCycles",
text: "name_and_status",
filter: "validOrderCycle" }

View File

@@ -0,0 +1,20 @@
- content_for :page_title do
= t(:new)
- content_for :page_actions do
%li= button_link_to t(:back_to_orders_list), spree.admin_orders_path, :icon => 'icon-arrow-left'
= admin_inject_shops 'admin.orders'
= admin_inject_order_cycles
= render 'spree/admin/shared/order_tabs', :current => 'Order Details'
= csrf_meta_tags
%div{"data-hook" => "admin_order_new_header"}
= render 'spree/shared/error_messages', :target => @order
%div{"ng-app" => "admin.orders", "ng-controller" => "ordersCtrl"}
= form_for @order, url: admin_order_url(@order), method: :put do |f|
= render '_form/_distribution_fields.html.haml'
# ......