mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
Disabling save button on order page until changes are made to the order
This commit is contained in:
@@ -6,7 +6,11 @@ Darkswarm.directive "ofnOnHand", ->
|
||||
# In cases where this field gets its value from the HTML element rather than the model,
|
||||
# initialise the model with the HTML value.
|
||||
if scope.$eval(attr.ngModel) == undefined
|
||||
ngModel.$setViewValue elem.val()
|
||||
# Don't dirty the model when we do this
|
||||
setDirty = ngModel.$setDirty
|
||||
ngModel.$setDirty = angular.noop
|
||||
ngModel.$setViewValue(elem.val())
|
||||
ngModel.$setDirty = setDirty
|
||||
|
||||
ngModel.$parsers.push (viewValue) ->
|
||||
on_hand = parseInt(attr.ofnOnHand)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
%i.ofn-i_009-close
|
||||
= t(:cancel_order)
|
||||
.columns.small-12.medium-3
|
||||
= button_tag :class => 'button primary radius expand', :id => 'update-button' do
|
||||
= button_tag :class => 'button primary radius expand', :id => 'update-button', "ng-disabled" => 'update_order_form.$pristine' do
|
||||
%i.ofn-i_051-check-big
|
||||
= t(:save_changes)
|
||||
%span{ ng: { show: 'update_order_form.$dirty' } }= t(:save_changes)
|
||||
%span{ ng: { hide: 'update_order_form.$dirty' } }= t(:order_saved)
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
%br
|
||||
.row
|
||||
.columns.large-12
|
||||
= form_for order, html: {id: 'update-order'} do |order_form|
|
||||
= form_for order, html: {id: 'update-order', name: 'update_order_form' } do |order_form|
|
||||
- if order.changes_allowed?
|
||||
= render 'spree/orders/form', order_form: order_form
|
||||
-else
|
||||
|
||||
@@ -1332,6 +1332,7 @@ Please follow the instructions there to make your enterprise visible on the Open
|
||||
price: "Price"
|
||||
on_hand: "On hand"
|
||||
save_changes: "Save Changes"
|
||||
order_saved: "Order Saved"
|
||||
spree_admin_overview_enterprises_header: "My Enterprises"
|
||||
spree_admin_overview_enterprises_footer: "MANAGE MY ENTERPRISES"
|
||||
spree_admin_enterprises_hubs_name: "Name"
|
||||
|
||||
@@ -43,12 +43,18 @@ feature "Order Management", js: true do
|
||||
it "allows quantity to be changed, items to be removed and the order to be cancelled" do
|
||||
visit spree.order_path(order)
|
||||
|
||||
expect(page).to have_button I18n.t(:order_saved), disabled: true
|
||||
expect(page).to_not have_button I18n.t(:save_changes)
|
||||
|
||||
# Changing the quantity of an item
|
||||
within "tr.variant-#{item1.variant.id}" do
|
||||
expect(page).to have_content item1.product.name
|
||||
expect(page).to have_field 'order_line_items_attributes_0_quantity'
|
||||
fill_in 'order_line_items_attributes_0_quantity', with: 2
|
||||
end
|
||||
|
||||
expect(page).to have_button I18n.t(:save_changes)
|
||||
|
||||
expect(find("tr.variant-#{item2.variant.id}")).to have_content item2.product.name
|
||||
expect(find("tr.variant-#{item3.variant.id}")).to have_content item3.product.name
|
||||
expect(find("tr.order-adjustment")).to have_content "Shipping"
|
||||
|
||||
Reference in New Issue
Block a user