Fixed disabling button and dismissing modals (#9805)

This commit is contained in:
Keith Holliday
2018-01-15 09:16:15 -07:00
committed by GitHub
parent c33eba6736
commit d4f634c3d8

View File

@@ -7,8 +7,8 @@
style="width: 400px; height: 140px;") style="width: 400px; height: 140px;")
.modal-footer .modal-footer
.text-center .text-center
.btn.btn-primary(v-if="amazonPaymentsCanCheckout", button.btn.btn-primary(v-if="amazonPaymentsCanCheckout",
@click="amazonCheckOut()") {{ $t('checkout') }} @click="amazonCheckOut()", :disabled='!amazonButtonEnabled') {{ $t('checkout') }}
</template> </template>
<style scoped> <style scoped>
@@ -164,6 +164,7 @@ export default {
onReady: (consent) => { onReady: (consent) => {
let getConsent = consent.getConsentStatus; let getConsent = consent.getConsentStatus;
this.$set(this.amazonPayments, 'recurringConsent', getConsent ? Boolean(getConsent()) : false); this.$set(this.amazonPayments, 'recurringConsent', getConsent ? Boolean(getConsent()) : false);
this.$set(this, 'amazonButtonEnabled', true);
}, },
onConsent: (consent) => { onConsent: (consent) => {
this.$set(this.amazonPayments, 'recurringConsent', Boolean(consent.getConsentStatus())); this.$set(this.amazonPayments, 'recurringConsent', Boolean(consent.getConsentStatus()));
@@ -190,6 +191,7 @@ export default {
}); });
if (response.status < 400) { if (response.status < 400) {
this.$set(this, 'amazonButtonEnabled', true);
this.reset(); this.reset();
// @TODO: What are we syncing? // @TODO: What are we syncing?
window.location.reload(true); window.location.reload(true);
@@ -216,11 +218,14 @@ export default {
let responseStatus = response.status; let responseStatus = response.status;
if (responseStatus >= 400) { if (responseStatus >= 400) {
this.$set(this, 'amazonButtonEnabled', true);
alert(`Error: ${response.message}`); alert(`Error: ${response.message}`);
// @TODO: do we need this? this.amazonPaymentsreset(); // @TODO: do we need this? this.amazonPaymentsreset();
return; return;
} }
this.$root.$emit('bv::hide::modal', 'amazon-payment');
let newGroup = response.data.data; let newGroup = response.data.data;
if (newGroup && newGroup._id) { if (newGroup && newGroup._id) {
// @TODO: Just append? or $emit? // @TODO: Just append? or $emit?