cirandas.net

ref: master

plugins/delivery/views/delivery_plugin/_order_select.html.slim


- methods ||= order.delivery_methods
- edition = true if edition.nil?
- readonly = !edition

div.order-delivery-select id='order-#{order.id}'

  div.supplier-delivery-data
    - if order.delivery_methods.size > 0
      - if readonly
        = supplier_delivery_selected_method(methods: methods, selected: order.supplier_delivery_id)
      - else
        = content_tag("div", 
          f.select(:supplier_delivery_id, supplier_delivery_options(methods: methods, selected: order.supplier_delivery_id), {}, class: "form-control", disabled: readonly,
          onchange: 'delivery.order.select.onChange(this)', onkeyup: 'delivery.order.select.onChange(this)') + content_tag('div', '', class: 'help-block instructions'), class: "form-group")
    - elsif (name = consumer_delivery_field_value order, :name).present?
      = labelled_form_field _('Option'),
        f.text_field(:address, value: name, readonly: true)
      .help-block.instructions
        = consumer_delivery_field_value order, :description

  / do not render on confirmation if supplier_delivery is pickup
  - if order.supplier_delivery_data[:delivery_type] != 'pickup'
    div.consumer-delivery-data
      = f.fields_for :consumer_delivery_data do |ff|
        = labelled_form_field _('Address (street and number)'),
          ff.text_field(:address, value: consumer_delivery_field_value(order, :address), readonly: readonly)
        = labelled_form_field _('Address completion'),
          ff.text_field(:address_line2, value: consumer_delivery_field_value(order, :address_line2), readonly: readonly)
        = labelled_form_field _('Address reference'),
          ff.text_field(:address_reference, value: consumer_delivery_field_value(order, :address_reference), readonly: readonly)
        = labelled_form_field _('District'),
          ff.text_field(:district, value: consumer_delivery_field_value(order, :district), readonly: readonly)
        = labelled_form_field _('City'),
          ff.text_field(:city, value: consumer_delivery_field_value(order, :city), readonly: readonly)
        = labelled_form_field _('State'),
          ff.text_field(:state, value: consumer_delivery_field_value(order, :state), readonly: readonly)
        = labelled_form_field _('ZIP code'),
          ff.text_field(:zip_code, value: consumer_delivery_field_value(order, :zip_code), readonly: readonly)

javascript:
  delivery.order.select.onChange($('.order-delivery-select#order-#{order.id} #order_supplier_delivery_id'))