Matt-Yorkley
dd23e3d38a
Simplify payment method controller
2021-12-20 18:47:22 +00:00
Matt-Yorkley
b4dab46cf8
Remove unused code for changing required attributes
2021-12-20 18:36:28 +00:00
Matt-Yorkley
723d6489cd
Extract initSelectedCard()
2021-12-20 18:36:26 +00:00
Matt-Yorkley
9525e353a3
Don't try to select a card if there is no select element
...
This error was being thrown when the user had no cards saved:
```
TypeError: stripeCardsController is null
```
2021-12-20 18:36:09 +00:00
Matt-Yorkley
a64f654697
Don't try to select a card if there is no selectTarget
...
This error was being thrown when the user had no cards saved:
```
Error: Missing target element "stripe-cards.select"
```
2021-12-20 15:41:22 +00:00
Matt-Yorkley
f18fc3c2f3
Implement disconnect() to tidy up (remove) event listeners from the DOM when finished
2021-12-20 15:29:52 +00:00
Matt-Yorkley
d58f5aa25d
Move initialization to initialize()
2021-12-20 15:29:52 +00:00
Matt-Yorkley
33c156bb55
Extract (arrow) functions for callbacks used by event listeners and reduce variable assignments
2021-12-20 15:29:52 +00:00
Matt-Yorkley
24c051bad3
Simplify stripe selected check
2021-12-20 15:21:13 +00:00
Jean-Baptiste Bellet
2c5667ef56
Initialize stripe-cards controller when selecting a payment method
2021-12-20 15:34:58 +01:00
Jean-Baptiste Bellet
d4ec075dfc
Disabled stripe-cards input if a already registred card is select
...
And then re-enabled it, if use decide to register a new card
2021-12-20 15:34:58 +01:00
Jean-Baptiste Bellet
7b6aa99de2
Handle when input is already checked
...
ie. user hasn't click on anything
2021-12-20 15:34:58 +01:00
Jean-Baptiste Bellet
6ef7256295
Only submit handle form submit if stripeElementsForm is visible
2021-12-20 15:34:58 +01:00
Matt-Yorkley
2fe96c5f63
Update Stripe controller hidden fields
2021-12-07 16:29:25 +00:00
Matt-Yorkley
720d147421
Bring in stimulus controller for stripe elements
2021-12-07 16:29:25 +00:00
Matt-Yorkley
d85597fe4c
Rename stripe cards controller
2021-12-07 16:29:25 +00:00
Jean-Baptiste Bellet
fd5ad7566a
Disabled all form elements that should not be sent to the controller
2021-12-07 16:27:22 +00:00
Jean-Baptiste Bellet
f7662947dc
Extract to a method that handle all the form elements
2021-12-07 16:27:22 +00:00
Jean-Baptiste Bellet
7437c6a6d7
Add a stripe controller that show/hide stripe form if saved cards or not
2021-12-07 16:27:22 +00:00
Jean-Baptiste Bellet
5f3ea6accb
Do not init by hidden all the container
...
that allow to init the content without clicking on anything
2021-12-07 16:27:22 +00:00
Jean-Baptiste Bellet
7159cc3ff1
Handle required attribute on input for PaymentMethod controller
...
This is done for one reason : do not submit form with required attribute on input that are actually hidden ; this is not handle correctly by browsers.
This idea here is to add/remove the required attribute on each input if the form is visible or not.
2021-12-07 16:27:22 +00:00
Jean-Baptiste Bellet
3063b041d1
Change the paymentmethod controller to handle both desc and form
...
Add tests as well
Update _payment.html.haml
Update _payment.html.haml
2021-12-07 16:23:39 +00:00
Jean-Baptiste Bellet
786b198f4d
Create an updateinput controller
...
- that update the targets input value to the value stored in data attribute
- Add tests
2021-10-06 15:06:56 +05:30
Matt-Yorkley
5ef34347a3
Implement optional non-Angular flash messages
2021-09-08 10:34:34 +01:00
Jean-Baptiste Bellet
1ecfeca88c
Populate view with both shipping_method_id & ship_address_same_as_billing
...
... and then handle correctly the display of the form
2021-08-23 15:23:53 +02:00
Jean-Baptiste Bellet
402bfdac30
Show/Hide shipping address form depending on the checkbox/radio state
2021-08-19 10:34:07 +02:00
Jean-Baptiste Bellet
57d7191332
Add new step, second one: payment method
...
Add payment method form
- select the right form depending on the path
2021-07-26 15:47:36 +02:00
Jean-Baptiste Bellet
151a6fd16b
Add first stimulus controllers to display elements
...
1. Introduce a stimulus toggle_controller
- controller: { "data-controller": "toggle" }
- action: { "data-action": "toggle#toggle" }
- show or not: { "data-toggle-show": true || false }
- targets: { "data-toggle-target": "content", style: "display: none" }
Display payment method price
2. States are populated via a new dependant_select_controller by stimulus.
Usage:
- controller : { "data-controller": "dependant-select", "data-dependant-select-options-value": [ [1: ["option", "for", "1"], [2: ["option", "for", "2"] ] }
- target (on the populating target): { "data-dependant-select-target": "select" }
- source and action (on the input that leads the dependant select): {"data-dependant-select-target": "source", "data-action": "dependant-select#handleSelectChange"}
Some improvements on readability
3. Populate ShippingMethod description thanks to "shippingmethod_controller"
+
- Add countries and states
2021-07-26 15:47:36 +02:00
Matt-Yorkley
6882201533
Add StimulusJS and example controller
2021-07-20 15:22:16 +01:00