mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Replace Spree::ShippingMethods form partial by our own and apply overrides
This commit is contained in:
@@ -1 +0,0 @@
|
||||
remove "div[data-hook='admin_shipping_method_form_availability_fields']"
|
||||
@@ -1 +0,0 @@
|
||||
remove "div[data-hook='admin_shipping_method_form_calculator_fields']"
|
||||
@@ -1,61 +0,0 @@
|
||||
/ replace "div[data-hook='admin_shipping_method_form_fields']"
|
||||
|
||||
=admin_inject_shipping_method
|
||||
.alpha.eleven.columns{ "data-hook" => "admin_shipping_method_form_fields",
|
||||
"ng-app" => "admin.shippingMethods",
|
||||
"ng-controller" => "shippingMethodCtrl" }
|
||||
.row
|
||||
.alpha.three.columns
|
||||
= f.label :name, t(:name)
|
||||
.omega.eight.columns
|
||||
= f.text_field :name, :class => 'fullwidth', placeholder: t(:spree_admin_eg_pickup_from_school)
|
||||
= error_message_on :shipping_method, :name
|
||||
.row
|
||||
.alpha.three.columns
|
||||
= f.label :description, t(:description)
|
||||
.omega.eight.columns
|
||||
= f.text_area :description, class: 'fullwidth', rows: 2, placeholder: t(:spree_admin_eg_collect_your_order)
|
||||
= error_message_on :shipping_method, :description
|
||||
- if @available_zones.length == 1
|
||||
= f.hidden_field :zone_id, value: @available_zones.first.id
|
||||
- else
|
||||
.row
|
||||
.alpha.three.columns
|
||||
= f.label :zone_id, t(:zone)
|
||||
.omega.eight.columns
|
||||
= f.collection_select(:zone_id, @available_zones, :id, :name, {}, {:class => 'select2 fullwidth'})
|
||||
= error_message_on :shipping_method, :zone_id
|
||||
- if spree_current_user.admin?
|
||||
.row
|
||||
.alpha.three.columns
|
||||
= f.label :display_on, t(:display)
|
||||
.omega.eight.columns
|
||||
= select(:shipping_method, :display_on, Spree::ShippingMethod::DISPLAY.collect { |display| [t(display), display == :both ? nil : display.to_s] }, {}, {:class => 'select2 fullwidth'})
|
||||
= error_message_on :shipping_method, :display_on
|
||||
|
||||
.row
|
||||
-# Shipping Category is not really used, so set to nil
|
||||
= f.hidden_field :shipping_category_id, value: nil
|
||||
.alpha.three.columns
|
||||
-# The 'Category' label here is just a logical descriptor for the data we are trying to collect for 'requires_ship_address'
|
||||
-# and does not relate to shipping categories in any way.
|
||||
= f.label :require_ship_address, t(:category)
|
||||
.two.columns
|
||||
= f.radio_button :require_ship_address, true
|
||||
|
||||
= f.label :delivery, t(:delivery)
|
||||
.omega.six.columns
|
||||
= f.radio_button :require_ship_address, false
|
||||
|
||||
= f.label :pick_up, t(:pick_up)
|
||||
|
||||
.row
|
||||
.alpha.three.columns
|
||||
= f.label :tags, t(:tags)
|
||||
.omega.eight.columns
|
||||
= f.hidden_field :tag_list, "ng-value" => "shippingMethod.tag_list"
|
||||
%tags-with-translation#something{ object: "shippingMethod", 'find-tags' => 'findTags(query)' }
|
||||
|
||||
.row
|
||||
.alpha.eleven.columns
|
||||
= render :partial => 'spree/admin/shared/calculator_fields', :locals => { :f => f }
|
||||
57
app/views/spree/admin/shipping_methods/_form.html.haml
Normal file
57
app/views/spree/admin/shipping_methods/_form.html.haml
Normal file
@@ -0,0 +1,57 @@
|
||||
=admin_inject_shipping_method
|
||||
.alpha.eleven.columns{ "ng-app" => "admin.shippingMethods",
|
||||
"ng-controller" => "shippingMethodCtrl" }
|
||||
.row
|
||||
.alpha.three.columns
|
||||
= f.label :name, t(:name)
|
||||
.omega.eight.columns
|
||||
= f.text_field :name, class: 'fullwidth', placeholder: t(:spree_admin_eg_pickup_from_school)
|
||||
= error_message_on :shipping_method, :name
|
||||
.row
|
||||
.alpha.three.columns
|
||||
= f.label :description, t(:description)
|
||||
.omega.eight.columns
|
||||
= f.text_area :description, class: 'fullwidth', rows: 2, placeholder: t(:spree_admin_eg_collect_your_order)
|
||||
= error_message_on :shipping_method, :description
|
||||
- if spree_current_user.admin?
|
||||
.row
|
||||
.alpha.three.columns
|
||||
= f.label :display_on, t(:display)
|
||||
.omega.eight.columns
|
||||
= select(:shipping_method, :display_on, Spree::ShippingMethod::DISPLAY.collect { |display| [t(display), display == :both ? nil : display.to_s] }, {}, {class: 'select2 fullwidth'})
|
||||
= error_message_on :shipping_method, :display_on
|
||||
|
||||
.row
|
||||
.alpha.three.columns
|
||||
= f.label :tags, t(:tags)
|
||||
.omega.eight.columns
|
||||
= f.hidden_field :tag_list, "ng-value" => "shippingMethod.tag_list"
|
||||
%tags-with-translation#something{ object: "shippingMethod", 'find-tags' => 'findTags(query)' }
|
||||
|
||||
.row
|
||||
.alpha.eleven.columns
|
||||
= render partial: 'spree/admin/shared/calculator_fields', locals: { f: f }
|
||||
|
||||
.alpha.six.columns
|
||||
.alpha.six.columns
|
||||
%fieldset.categories.no-border-bottom
|
||||
%legend{align: "center"}= Spree.t(:categories)
|
||||
= f.field_container :categories do
|
||||
- Spree::ShippingCategory.all.each do |category|
|
||||
= label_tag do
|
||||
= check_box_tag('shipping_method[shipping_categories][]', category.id, @shipping_method.shipping_categories.include?(category))
|
||||
= category.name
|
||||
%br/
|
||||
= error_message_on :shipping_method, :shipping_category_id
|
||||
|
||||
.alpha.six.columns
|
||||
%fieldset.no-border-bottom
|
||||
%legend{align: "center"}= Spree.t(:zones)
|
||||
= f.field_container :zones do
|
||||
- shipping_method_zones = @shipping_method.zones.to_a
|
||||
- Spree::Zone.all.each do |zone|
|
||||
= label_tag do
|
||||
= check_box_tag('shipping_method[zones][]', zone.id, shipping_method_zones.include?(zone))
|
||||
= zone.name
|
||||
%br/
|
||||
= error_message_on :shipping_method, :zone_id
|
||||
Reference in New Issue
Block a user