Skip to content

Commit

Permalink
#68 - watch shipping address data
Browse files Browse the repository at this point in the history
  • Loading branch information
szafran89 committed Dec 21, 2018
1 parent 573549e commit e5379a9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
31 changes: 23 additions & 8 deletions view/frontend/web/js/components/ShippingAddressForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,34 @@ export default {
},
ready () {
return !this.$v.address.$invalid
},
addressData () {
if (this.$store.state.shippingAddress !== null) {
return this.$store.getters.addressByType('shippingAddress')
} else {
return null
}
}
},
watch: {
ready (val) {
if (val) {
this.$store.commit(
'setAddress',
{ type: 'shippingAddress', address: this.address }
)
}
this.$emit('ready', val)
},
address: {
handler () {
if (this.ready) {
this.$store.commit(
'setAddress',
{ type: 'shippingAddress', address: this.address }
)
}
},
deep: true
}
},
created () {
if (this.addressData !== null) {
this.address = this.addressData
}
},
methods: {
Expand Down Expand Up @@ -219,4 +235,3 @@ export default {
}
}
</style>

3 changes: 2 additions & 1 deletion view/frontend/web/js/components/steps/TheShippingStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@ready="isReady => customerEmailReadyToSubmit = isReady"
/>
<ShippingAddressForm
v-if="!isCustomerLoggedIn"
ref="shippingsAddressForm"
@ready="isReady => shippingAddressReadyToSubmit = isReady"
/>
Expand Down Expand Up @@ -67,7 +68,7 @@ export default {
if (
!this.shippingAddressReadyToSubmit ||
!this.shippingMethodsReadyToSubmit ||
(!this.isCustomerLoggedIn && !this.shippingMethodsReadyToSubmit) ||
(!this.isCustomerLoggedIn && !this.customerEmailReadyToSubmit)
) {
return
Expand Down

0 comments on commit e5379a9

Please sign in to comment.