- content_for :page_actions do
  :javascript
    function toggleSettings(){
      if( $('#advanced_settings').is(":visible") ){
        $('button#toggle_settings i').switchClass("icon-chevron-up","icon-chevron-down")
      }
      else {
        $('button#toggle_settings i').switchClass("icon-chevron-down","icon-chevron-up")
      }
      $("#advanced_settings").slideToggle()
    }

  - if can? :notify_producers, @order_cycle
    %li
      = button_to t(:notify_producers), main_app.notify_producers_admin_order_cycle_path, :id => 'admin_notify_producers', :confirm => t(:are_you_sure)
  %li
    %button#toggle_settings{ onClick: 'toggleSettings()' }
      = t('.advanced_settings')
      %i.icon-chevron-down

#advanced_settings{ hidden: true }
  = render partial: "/admin/order_cycles/advanced_settings"

- content_for :page_title do
  = t :edit_order_cycle

- ng_controller = order_cycles_simple_form ? 'AdminSimpleEditOrderCycleCtrl' : 'AdminEditOrderCycleCtrl'
= admin_inject_order_cycle_instance
= form_for [main_app, :admin, @order_cycle], :url => '', :html => {:class => 'ng order_cycle', 'ng-app' => 'admin.orderCycles', 'ng-controller' => ng_controller, name: 'order_cycle_form'} do |f|

  %save-bar{ dirty: "order_cycle_form.$dirty", persist: "true" }
    %input.red{ type: "button", value: t('.save'), ng: { click: "submit($event, null)", disabled: "!order_cycle_form.$dirty || order_cycle_form.$invalid" } }
    - if order_cycles_simple_form
      %input.red{ type: "button", value: t('.save_and_back_to_list'), ng: { click: "submit($event, '#{main_app.admin_order_cycles_path}')", disabled: "!order_cycle_form.$dirty || order_cycle_form.$invalid" } }
    - else
      %input.red{ type: "button", value: t('.save_and_next'), ng: { click: "submit($event, '#{main_app.admin_order_cycle_incoming_path(@order_cycle)}')", disabled: "!order_cycle_form.$dirty || order_cycle_form.$invalid" } }
      %input{ type: "button", value: t('.next'), ng: { click: "cancel('#{main_app.admin_order_cycle_incoming_path(@order_cycle)}')", disabled: "order_cycle_form.$dirty" } }
    %input{ type: "button", ng: { value: "order_cycle_form.$dirty ? '#{t('.cancel')}' : '#{t('.back_to_list')}'", click: "cancel('#{main_app.admin_order_cycles_path}')" } }

  - if order_cycles_simple_form
    = render 'simple_form', f: f
  - else
    = render 'form', f: f
