= csrf_meta_tags
- content_for :page_actions do
  - if can?(:fire, @order)
    %li= event_links
  - if can?(:resend, @order)
    %li= button_link_to Spree.t(:resend), resend_admin_order_url(@order), :method => :post, :icon => 'icon-email'
  %li.links-dropdown#links-dropdown{ links: order_links(@order).to_json }
  - if can?(:admin, Spree::Order)
    %li= button_link_to t(:back_to_orders_list), admin_orders_path, :icon => 'icon-arrow-left'

= render :partial => 'spree/admin/shared/order_tabs', :locals => { :current => 'Order Details' }

%div{"data-hook" => "admin_order_edit_header"}
  -# Suppress errors when manually creating a new order - needs to proceed to edit page
  -# without having line items (which otherwise gives a validation error)
  - unless params["suppress_error_msg"]
    = render partial: "spree/shared/error_messages", :locals => { :target => @order }

  = admin_inject_shops(module: 'admin.orders')
  = admin_inject_order_cycles
  %div{"ng-app" => "admin.orders", "ng-controller" => "orderCtrl", "ofn-distributor-id" => @order.distributor_id, "ofn-order-cycle-id" => @order.order_cycle_id}

    = render :partial => 'add_product' if can?(:update, @order)

    - if @order.line_items.empty?
      .no-objects-found
        = Spree.t(:your_order_is_empty_add_product)

    %div{"data-hook" => "admin_order_edit_form"}
      = render :partial => 'form', :locals => { :order => @order }

:coffee
  angular.bootstrap(document.getElementById("links-dropdown"),['admin.dropdown'])
