Cillian O'Ruanaidh
db92e9d91c
Fix error from OrderCycle#distributor_shipping methods return ActiveRecord::Relation sometimes and Array other times
...
Now it will return ActiveRecord::Relation consistently.
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
5207dbf8c6
OrderCycle#distributor_shipping_methods should return all attachable ones by default per distributor, not per all distributors
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
7e40ad39cb
Bring back select all checkboxes on order cycle checkout options form.
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
a53a3259a8
Connect DistributorShippingMethods to OrderCycles instead of Spree::ShippingMethods
...
Before if a shipping method was shared between multiple distributors it could only be disabled/enabled on that order cycle for all the distributors which have that shipping method e.g. you couldn't select that shipping method for one distributor but disable it for another.
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
65ee9e1486
Implement new design with shipping and payment methods on different rows instead of same one, the select all checkboxes still need to be added back later
...
This is the new design from https://github.com/openfoodfoundation/openfoodnetwork/pull/9262#issuecomment-1206673689
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
a73b608f8a
Remove 'shared' shipping method sections from order cycle checkout options form, any shared shipping methods are to be displayed for each distributor e.g. if they belong to multiple distributors they will be displayed multiple times
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
4b0b4ad991
Revert "Use a more simple layout on the order cycle checkout options form"
...
This reverts commit 0dddaa6c2b9f1925adca6ff8deac8181691ae119.
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
8e47949260
Check 'Select all' checkboxes on page load if all its checkboxes are checked
...
This means the code to set the initial value in the view template isn't needed.
2022-09-30 13:13:39 +01:00
Maikel Linke
195f1e1237
Make "Select all" translatable
2022-09-30 13:13:39 +01:00
Maikel Linke
26d5ea6cdc
Remove unused input name
2022-09-30 13:13:39 +01:00
Maikel Linke
c5bb2f52e1
Check "Select all" to start with
...
Reflect the state of the shipping method checkboxes.
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
87431c188e
Use ShippingMethod :frontend method and drop :backend to avoid ClassLength Rubocop error
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
0673f9a5ae
Use a more simple layout on the order cycle checkout options form
...
Before there was a row for each distributor and a 'shared' row for shipping methods which were shared among more than one distributor. This layout displays a single list of shipping methods with the distributor or distributors it belongs to beside it as suggested by @lin-d-hop
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
8cb2767f9a
The no shipping/payment method warnings on order cycle checkout options looks better left aligned
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
1a70cc0c4c
Don't display no shipping/payment method warnings on order cycle checkout options if the distributor has some that are shared with other distributors
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
464a9b95a4
On order cycle checkout options shipping methods shared between distributors should be checked by default too
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
8b59b7a796
Use if exclude instead of if !include in OrderCycleForm
...
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
472bd150bb
For consistency with other '<em>' don't strip whitespace.
...
Although both '%em' and '%em>' are rendering the same markup, perhaps because the tag is on it's own new line.
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
af87943fd0
Change 'if !' to 'unless' in OrderCyclesList
...
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
80b7a5d39a
Remove OrderCycleShippingMethod model and use a :has_and_belongs_to_many association instead
...
Before the OrderCycleShippingMethod had a validation which checked the shipping method belonged to the order cycle distributor. Instead of this validation this just ignores shipping methods which don't belong to one of the order cycle's distributors when they are being attached in the OrderCycleForm service. This pattern is already being used in the OrderCycleForm service for ignoring Schedules that the person doesn't own.
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
61bbf0714e
Remove flag argument anti-pattern from Shop::OrderCyclesList
...
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
da3eea6005
Fetch shared shipping/payment methods for order cycle checkout options in single query
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
6453bbcc1c
Fix :selected_shipping_method_ids param for shared shipping methods.
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
541a340dcf
If an OrderCycle or Spree::ShippingMethod is destroyed then remove it's associated OrderCycleShippingMethod records too
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
593da4996f
A shop won't be shown as open if it doesn't have useable shipping method so these shipping method validations are really necessary
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
ed13ee6cbc
Fix association alignment in OrderCycle
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
564e4d802c
Don't use :html_safe with payment method name in checkout options in case it contains something malicious
...
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
747c88fb35
Update the Shop::OrderCyclesList service so it's clearer what kind of order cycles are being fetched
...
Before the Shop::OrderCyclesList service would return order cycles even if they are not ready for checkout and we had a check before calling the service in BaseController which would return OrderCycle.where('false'). It seems like this check should be part of the service too.
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
f4a4f7c9ff
Remove validations checking order cycle has shipping methods
...
Instead we will make sure the order cycle is not available on the shopfront if it is doesn't have valid shipping methods. This will preven the issue where if one distributor deletes their shipping method, we don't want to invalidate the order cycle for all other distributors.
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
81730f725d
Enterprises shouldn't be considered ready for checkout if it only has backend shipping methods
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
7bd56007bd
Don't use :html_safe in case shipping method name contains something malicious in app/views/admin/order_cycles/checkout_options.html.haml
...
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
d9de35799d
Array difference operator is neater than reject in app/views/admin/order_cycles/checkout_options.html.haml
...
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
67d4c38550
Rename :preferred_shipping_methods to :selected_shipping_methods on OrderCycle
...
It's a clearer name because 'preferred' implies there could be other unpreferred shipping methods available as well.
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
f25de984d2
Use .empty? instead of !exists? in app/models/order_cycle_shipping_method.rb
...
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
9a511e9e94
Rubocop adjustments
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
9296686384
Make backend, frontend scopes on Spree::ShippingMethod neater
...
Co-authored-by: Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
f6c754839b
Make OrderCycleShippingMethod inherit from ApplicationRecord
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
fc4f951a1a
Only require OrderCycleShippingMethod records if people want to override the default shipping methods
...
It makes things much simpler if we return all shipping methods by default without needing OrderCycleShippingMethod records to be added to the database.
Co-authored-by: Maikel <maikel@email.org.au >
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
a46b77d10c
Ensure hack for showing products on a shop with closed order cycles also works if an order cycle has no shipping methods
...
If a distributor order cycle has no shipping methods it will be invalid. This is a bit confusing because adding a check for :invalid seems like it would be better if it was done in the Shop::OrderCyclesList service but the hack doesn't work if you put it in there, it seems like something needs a refactor.
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
bff7650b35
Change :available_shipping_methods helper to use new OrderAvailableShippingMethods service.
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
855ec1a708
Add new 'Checkout options' step to the edit order cycle form so people can attach shipping methods
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
1e817af5aa
Validate deleting a shipping method or switching it to backoffice only doesn't invalidate any order cycles
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
48c2e48b24
Update the OrderCycleForm service so it supports attaching shipping methods
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
ca97a7f52d
Add :shipping_methods association to OrderCyle and validations
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
9a6e8a1113
Add an OrderCycleShippingMethod model to handle attaching shipping methods to order cycles
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
94d71b8dce
Remove extra unnecessary :display_on_checkout scope and reuse :frontend scope instead
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
a5daee39e3
Extract out a DISPLAY_ON_OPTIONS constant in Spree::ShippingMethod instead of magic strings
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
37617f63ea
Remove non-functional :backend scope from Spree::ShippingRate
...
It finds shipping methods where 'display_on != front_end' but :front_end values were removed in a1317be19b/db/migrate/20200508101630_convert_frontend_shipping_method_to_both.rb so it will always return true.
2022-09-30 13:13:39 +01:00
Cillian O'Ruanaidh
9b5f743fa5
Extract out a OrderCycle#simple? method so it can be used in models
2022-09-30 13:13:39 +01:00
binarygit
ebe4a3d6ab
Add StimulusReflex
2022-09-29 16:03:45 +02:00