mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Upgrade views to Spree 2 and apply overrides
This commit is contained in:
@@ -1,17 +1,11 @@
|
||||
= render partial: "spree/admin/variants/autocomplete", formats: :js
|
||||
#add-line-item
|
||||
%fieldset
|
||||
%legend{align: "center"}
|
||||
= t(:add_product)
|
||||
.field.eight.columns.alpha
|
||||
= label_tag :add_product_name, t(:name_or_sku)
|
||||
= hidden_field_tag :add_variant_id, "", class: "variant_autocomplete fullwidth"
|
||||
.field.two.columns
|
||||
= label_tag :add_quantity, t(:qty)
|
||||
= number_field_tag :add_quantity, 1, min: 0
|
||||
.actions.two.columns.omega
|
||||
= 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'
|
||||
= render :partial => "spree/admin/variants/autocomplete", :formats => :js
|
||||
|
||||
#add-line-item{"data-hook" => ""}
|
||||
%fieldset.no-border-bottom
|
||||
%legend{:align => "center"}= Spree.t(:add_product)
|
||||
|
||||
.field.twelve.columns.alpha{"data-hook" => "add_product_name"}
|
||||
= label_tag :add_variant_id, Spree.t(:name_or_sku)
|
||||
= hidden_field_tag :add_variant_id, "", :class => "variant_autocomplete fullwidth"
|
||||
|
||||
#stock_details
|
||||
|
||||
@@ -1,68 +1,35 @@
|
||||
%div
|
||||
%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
|
||||
%th
|
||||
= t(:item_description)
|
||||
%th.price
|
||||
= t(:price)
|
||||
%th.qty
|
||||
= t(:qty)
|
||||
%th.total
|
||||
%span
|
||||
= t(:total)
|
||||
%th.orders-actions.actions
|
||||
%tbody
|
||||
= f.fields_for :line_items do |li_form|
|
||||
= render partial: 'spree/admin/orders/line_item', locals: { f: li_form }
|
||||
%tbody#subtotal.no-border-top
|
||||
%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
|
||||
- @order.adjustments.eligible.each do |adjustment|
|
||||
%tr
|
||||
%td{colspan: "3"}
|
||||
= render :partial => 'spree/shared/error_messages', :locals => { :target => @line_item }
|
||||
|
||||
= render :partial => "spree/admin/orders/shipment", :collection => @order.shipments, :locals => { :order => order }
|
||||
|
||||
- if order.adjustments.eligible.exists?
|
||||
%fieldset.no-border-bottom
|
||||
%legend= Spree.t('adjustments')
|
||||
%table
|
||||
%thead
|
||||
%th= Spree.t('name')
|
||||
%th= Spree.t('amount')
|
||||
%tbody#order-charges.with-border{"data-hook" => "order_details_adjustments"}
|
||||
- order.adjustments.eligible.each do |adjustment|
|
||||
- next if ((adjustment.originator_type == 'Spree::TaxRate') and (adjustment.amount == 0)) || adjustment.originator_type == 'Spree::ShippingMethod'
|
||||
%tr.total
|
||||
%td
|
||||
%strong
|
||||
= adjustment.label
|
||||
\:
|
||||
%td.total.align-center
|
||||
%span= adjustment.display_amount.to_html
|
||||
%td.actions
|
||||
%tbody#order-total.grand-total.no-border-top
|
||||
%tr
|
||||
%td{colspan: "3"}
|
||||
%b
|
||||
= t(:order_total)
|
||||
\:
|
||||
%td.total.align-center
|
||||
%span#order_total
|
||||
= @order.display_total.to_html
|
||||
%td.actions
|
||||
%span= adjustment.display_amount
|
||||
|
||||
= render partial: 'spree/admin/orders/_form/distribution_fields'
|
||||
- if order.line_items.exists?
|
||||
%fieldset#order-total.no-border-bottom{"data-hook" => "order_details_total"}
|
||||
%legend= Spree.t(:order_total)
|
||||
%span.order-total= order.display_total
|
||||
|
||||
.filter-actions.actions{"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]
|
||||
var order_number = '#{@order.number}';
|
||||
var shipments = [];
|
||||
- @order.shipments.each do |shipment|
|
||||
shipments.push(#{shipment.to_json(:root => false, :include => [:inventory_units, :stock_location]).html_safe});
|
||||
= render :partial => 'spree/admin/shared/update_order_state', :handlers => [:js]
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
= csrf_meta_tags
|
||||
|
||||
- content_for :page_actions do
|
||||
%li= event_links
|
||||
%li= button_link_to t(:resend), resend_admin_order_url(@order), method: :post, icon: 'icon-email'
|
||||
- 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 Spree.t(:back_to_orders_list), admin_orders_path, :icon => 'icon-arrow-left'
|
||||
|
||||
%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' }
|
||||
|
||||
= admin_inject_shops(module: 'admin.orders')
|
||||
= admin_inject_order_cycles
|
||||
|
||||
= render 'spree/admin/shared/order_tabs', current: 'Order Details'
|
||||
|
||||
%div
|
||||
%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 }
|
||||
|
||||
%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'
|
||||
= render :partial => 'add_product' if can?(:update, @order)
|
||||
|
||||
%div
|
||||
#order-form-wrapper
|
||||
= render 'form', order: @order
|
||||
- if @order.line_items.empty?
|
||||
.no-objects-found
|
||||
= Spree.t(:your_order_is_empty_add_product)
|
||||
|
||||
%div{"data-hook" => "admin_order_edit_form"}
|
||||
#order-form-wrapper
|
||||
= render :partial => 'form', :locals => { :order => @order }
|
||||
|
||||
- content_for :head do
|
||||
= javascript_tag 'var expand_variants = true;'
|
||||
|
||||
@@ -29,3 +29,43 @@
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type='text/template' id='variant_autocomplete_stock_template'>
|
||||
<fieldset>
|
||||
<legend align="center"><%= Spree.t(:select_stock) %></legend>
|
||||
<table class="stock-levels" data-hook="stock-levels">
|
||||
<colgroup>
|
||||
<col style="width: 30%;" />
|
||||
<col style="width: 40%;" />
|
||||
<col style="width: 20%;" />
|
||||
<col style="width: 10%;" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<th><%= Spree.t(:location) %></th>
|
||||
<th><%= Spree.t(:count_on_hand) %></th>
|
||||
<th><%= Spree.t(:quantity) %></th>
|
||||
<th class="actions"></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each variant.stock_items}}
|
||||
<tr>
|
||||
<td>{{this.stock_location_name}}</td>
|
||||
{{#if this.available}}
|
||||
<td>
|
||||
{{this.count_on_hand}}
|
||||
{{#if this.backorderable}} (backorders allowed) {{/if}}
|
||||
</td>
|
||||
<td>
|
||||
<input class="quantity" id="stock_item_quantity" data-stock-location-id="{{this.stock_location_id}}" type="number" min="1" value="1">
|
||||
</td>
|
||||
<td class="actions">
|
||||
<button class="add_variant no-text icon-plus icon_link with-tip" data-stock-location-id="{{this.stock_location_id}}" title="Add" data-action="add"></button>
|
||||
</td>
|
||||
{{else}}
|
||||
<td><%= Spree.t(:out_of_stock) %></td>
|
||||
<td>0</td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</fieldset>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user