mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Import Spree views for orders#edit in our codebase and integrate deface modifications
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
/ insert_before "[data-hook='admin_order_form_buttons']"
|
||||
|
||||
= render partial: 'spree/admin/orders/_form/distribution_fields'
|
||||
@@ -1,2 +0,0 @@
|
||||
add_to_attributes "table.index, [data-hook='admin_order_form_buttons']"
|
||||
attributes "ng-show" => "distributionChosen()"
|
||||
@@ -1,3 +0,0 @@
|
||||
/ replace "code[erb-loud]:contains('button t(:update)')"
|
||||
|
||||
= button t(:update_and_recalculate_fees), 'icon-refresh'
|
||||
@@ -1,3 +0,0 @@
|
||||
/ replace 'code[erb-loud]:contains(\'"(#{f.object.variant.options_text})"\')'
|
||||
|
||||
= "(#{f.object.full_name})"
|
||||
@@ -1,3 +0,0 @@
|
||||
/ replace 'code[erb-loud]:contains(\'f.object.variant.display_amount\')'
|
||||
|
||||
= f.object.single_money
|
||||
@@ -1,6 +0,0 @@
|
||||
/ insert_after "code[erb-loud]:contains('button_link_to t(:resend)')"
|
||||
|
||||
%li.links-dropdown#links-dropdown{ links: order_links(@order).to_json }
|
||||
|
||||
:coffee
|
||||
angular.bootstrap(document.getElementById("links-dropdown"),['admin.dropdown'])
|
||||
@@ -1,6 +0,0 @@
|
||||
/ replace "code[erb-loud]:contains(\'error_messages\')"
|
||||
|
||||
-# 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 }
|
||||
17
app/views/spree/admin/orders/_add_product.html.haml
Normal file
17
app/views/spree/admin/orders/_add_product.html.haml
Normal file
@@ -0,0 +1,17 @@
|
||||
= render partial: "spree/admin/variants/autocomplete", formats: :js
|
||||
#add-line-item{"data-hook" => ""}
|
||||
%fieldset
|
||||
%legend{align: "center"}
|
||||
= t(:add_product)
|
||||
.field.eight.columns.alpha{"data-hook" => "add_product_name"}
|
||||
= label_tag :add_product_name, t(:name_or_sku)
|
||||
= hidden_field_tag :add_variant_id, "", class: "variant_autocomplete fullwidth"
|
||||
.field.two.columns{"data-hook" => "add_quantity"}
|
||||
= label_tag :add_quantity, t(:qty)
|
||||
= number_field_tag :add_quantity, 1, min: 0
|
||||
.actions.two.columns.omega{"data-hook" => "add_button"}
|
||||
= link_to_with_icon 'icon-plus', t(:add), admin_order_line_items_url(@order),
|
||||
method: :post,
|
||||
id: 'add_line_item_to_order',
|
||||
class: 'button fullwidth',
|
||||
'data-update' => 'order-form-wrapper'
|
||||
68
app/views/spree/admin/orders/_form.html.haml
Normal file
68
app/views/spree/admin/orders/_form.html.haml
Normal file
@@ -0,0 +1,68 @@
|
||||
%div{"data-hook" => "admin_order_form_fields"}
|
||||
- if @line_item.try(:errors).present?
|
||||
= render partial: 'spree/shared/error_messages', locals: { target: @line_item }
|
||||
= form_for @order, url: admin_order_url(@order), method: :put do |f|
|
||||
%fieldset.no-border-top
|
||||
= f.hidden_field :number
|
||||
%table.index{"ng-show" => "distributionChosen()"}
|
||||
%colgroup
|
||||
%col{style: "width: 49%;"}/
|
||||
%col{style: "width: 14%;"}/
|
||||
%col{style: "width: 10%;"}/
|
||||
%col{style: "width: 14%;"}/
|
||||
%col{style: "width: 8%;"}/
|
||||
%thead#line-items
|
||||
%tr{"data-hook" => "admin_order_form_line_items_headers"}
|
||||
%th
|
||||
= t(:item_description)
|
||||
%th.price
|
||||
= t(:price)
|
||||
%th.qty
|
||||
= t(:qty)
|
||||
%th.total
|
||||
%span
|
||||
= t(:total)
|
||||
%th.orders-actions.actions{"data-hook" => "admin_order_form_line_items_header_actions"}
|
||||
%tbody{"data-hook" => "admin_order_form_line_items"}
|
||||
= f.fields_for :line_items do |li_form|
|
||||
= render partial: 'spree/admin/orders/line_item', locals: { f: li_form }
|
||||
%tbody#subtotal.no-border-top{"data-hook" => "admin_order_form_subtotal"}
|
||||
%tr#subtotal-row
|
||||
%td{colspan: "3"}
|
||||
%b
|
||||
= t(:subtotal)
|
||||
\:
|
||||
%td.total.align-center
|
||||
%span
|
||||
= @order.display_item_total.to_html
|
||||
%td.actions
|
||||
%tbody#order-charges.no-border-top{"data-hook" => "admin_order_form_adjustments"}
|
||||
- @order.adjustments.eligible.each do |adjustment|
|
||||
%tr
|
||||
%td{colspan: "3"}
|
||||
%strong
|
||||
= adjustment.label
|
||||
\:
|
||||
%td.total.align-center
|
||||
%span= adjustment.display_amount.to_html
|
||||
%td.actions
|
||||
%tbody#order-total.grand-total.no-border-top{"data-hook" => "admin_order_form_total"}
|
||||
%tr
|
||||
%td{colspan: "3"}
|
||||
%b
|
||||
= t(:order_total)
|
||||
\:
|
||||
%td.total.align-center
|
||||
%span#order_total
|
||||
= @order.display_total.to_html
|
||||
%td.actions
|
||||
|
||||
= render partial: 'spree/admin/orders/_form/distribution_fields'
|
||||
|
||||
.filter-actions.actions{"data-hook" => "admin_order_form_buttons", "ng-show" => "distributionChosen()"}
|
||||
= button t(:update_and_recalculate_fees), 'icon-refresh'
|
||||
%span.or
|
||||
= t(:or)
|
||||
= link_to_with_icon 'button icon-arrow-left', t(:back), admin_orders_url
|
||||
= javascript_tag do
|
||||
= render partial: 'spree/admin/shared/update_order_state', handlers: [:js]
|
||||
12
app/views/spree/admin/orders/_line_item.html.haml
Normal file
12
app/views/spree/admin/orders/_line_item.html.haml
Normal file
@@ -0,0 +1,12 @@
|
||||
%tr{"data-hook" => "admin_order_form_line_item_row", id: "#{spree_dom_id(f.object)}", class: "#{cycle('odd', 'even')}"}
|
||||
%td
|
||||
= f.object.variant.product.name
|
||||
= "(#{f.object.full_name})" unless f.object.variant.option_values.empty?
|
||||
%td.price.align-center
|
||||
= f.object.variant.display_amount
|
||||
%td.qty
|
||||
= f.number_field :quantity, min: 0, class: "qty"
|
||||
%td.total.align-center
|
||||
= f.object.single_money
|
||||
%td.actions{"data-hook" => "admin_order_form_line_item_actions"}
|
||||
= link_to_delete f.object, {url: admin_order_line_item_url(@order.number, f.object), no_text: true}
|
||||
@@ -3,6 +3,8 @@
|
||||
- content_for :page_actions do
|
||||
%li= event_links
|
||||
%li= button_link_to t(:resend), resend_admin_order_url(@order), method: :post, icon: 'icon-email'
|
||||
%li.links-dropdown#links-dropdown{ links: order_links(@order).to_json }
|
||||
|
||||
%li= button_link_to t(:back_to_orders_list), admin_orders_path, icon: 'icon-arrow-left'
|
||||
|
||||
= admin_inject_shops(module: 'admin.orders')
|
||||
@@ -11,7 +13,8 @@
|
||||
= render 'spree/admin/shared/order_tabs', current: 'Order Details'
|
||||
|
||||
%div{"data-hook" => "admin_order_edit_header"}
|
||||
= render 'spree/shared/error_messages', target: @order
|
||||
- unless params["suppress_error_msg"]
|
||||
= render partial: "spree/shared/error_messages", :locals => { :target => @order }
|
||||
|
||||
%div{"ng-app" => "admin.orders", "ng-controller" => "orderCtrl", "ofn-distributor-id" => @order.distributor_id, "ofn-order-cycle-id" => @order.order_cycle_id}
|
||||
= render 'add_product'
|
||||
@@ -22,3 +25,6 @@
|
||||
|
||||
- content_for :head do
|
||||
= javascript_tag 'var expand_variants = true;'
|
||||
|
||||
:coffee
|
||||
angular.bootstrap(document.getElementById("links-dropdown"),['admin.dropdown'])
|
||||
|
||||
65
app/views/spree/admin/shared/_order_tabs.html.haml
Normal file
65
app/views/spree/admin/shared/_order_tabs.html.haml
Normal file
@@ -0,0 +1,65 @@
|
||||
- content_for :page_title do
|
||||
= t(:order)
|
||||
\#
|
||||
= @order.number
|
||||
|
||||
- if @order.bill_address.present?
|
||||
= @order.bill_address.firstname
|
||||
= @order.bill_address.lastname
|
||||
\-
|
||||
|
||||
- content_for :sidebar_title do
|
||||
= t(:order_information)
|
||||
|
||||
- content_for :sidebar do
|
||||
%header#order_tab_summary
|
||||
%dl.additional-info
|
||||
%dt#order_status
|
||||
= t(:status)
|
||||
%dd
|
||||
%span{:class => "state #{@order.state}"}
|
||||
= t(@order.state, scope: :order_state)
|
||||
%dt
|
||||
= t(:total)
|
||||
\:
|
||||
%dd#order_total
|
||||
= @order.display_total.to_html
|
||||
|
||||
- if @order.completed?
|
||||
%dt
|
||||
= t(:shipment)
|
||||
\:
|
||||
%dd#shipment_status
|
||||
%span.state
|
||||
= @order.shipment_state
|
||||
= t(@order.shipment_state, scope: :shipment_states, default: [:missing, none])
|
||||
%dt
|
||||
= t(:payment)
|
||||
\:
|
||||
%dd#payment_status
|
||||
%span.state
|
||||
= @order.payment_state
|
||||
= t(@order.payment_state, scope: :payment_states, default: [:missing, none])
|
||||
%dt
|
||||
= t(:date_completed)
|
||||
\:
|
||||
%dd#date_complete
|
||||
= pretty_time(@order.completed_at)
|
||||
|
||||
%nav.menu
|
||||
%ul{"data-hook" => "admin_order_tabs"}
|
||||
%li{ class: "#{'active' if true}" }
|
||||
= link_to_with_icon 'icon-edit', t(:order_details), edit_admin_order_url(@order)
|
||||
%li{"#{'class=active' if current == 'Customer Details'}"}
|
||||
= link_to_with_icon 'icon-user', t(:customer_details), admin_order_customer_url(@order)
|
||||
%li{"#{'class=active' if current == 'Adjustments Details'}"}
|
||||
= link_to_with_icon 'icon-cogs', t(:adjustments), admin_order_adjustments_url(@order)
|
||||
|
||||
%li{"#{'class=active' if current == 'Payments'}"}
|
||||
= link_to_with_icon 'icon-credit-card', t(:payments), admin_order_payments_url(@order)
|
||||
|
||||
%li{"#{'class=active' if current == 'Shipments'}"}
|
||||
= link_to_with_icon 'icon-road', t(:shipments), admin_order_shipments_url(@order)
|
||||
- if @order.completed?
|
||||
%li{"#{'class=active' if current == 'Return Authorizations'}"}
|
||||
= link_to_with_icon 'icon-share-alt', t(:return_authorizations), admin_order_return_authorizations_url(@order)
|
||||
Reference in New Issue
Block a user