Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit c8ebd97

Browse files
committed
two fixes
- if the purchase_contract api call fails, reset the buttons so they can try again - call setTotalPrice when the address next button is clicked, sometimes it doesn't get the change event from the model - clean up query
1 parent e0d86b5 commit c8ebd97

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

js/views/buyDetailsVw.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ module.exports = Backbone.View.extend({
9797
moderatorPriceString = this.model.get('userCurrencyCode') == 'BTC' ?
9898
moderatorPriceBTC.toFixed(8) + " BTC" : moderatorPriceBTC.toFixed(8) + " BTC (" + newDisplayModeratorPrice + ")";
9999

100-
this.$el.find('.js-buyWizardBTCPrice').html(newBTCDisplayPrice+"BTC");
101-
this.$el.find('.js-buyWizardBTCShippingPrice').html(newBTCShippingDisplayPrice+"BTC");
100+
this.$('.js-buyWizardBTCPrice').html(newBTCDisplayPrice+"BTC");
101+
this.$('.js-buyWizardBTCShippingPrice').html(newBTCShippingDisplayPrice+"BTC");
102102

103103
if(userCurrency != 'BTC'){
104-
this.$el.find('.js-buyWizardPrice').html("("+newDisplayPrice+")");
105-
this.$el.find('.js-buyWizardShippingPrice').html("("+newDisplayShippingPrice+")");
104+
this.$('.js-buyWizardPrice').html("("+newDisplayPrice+")");
105+
this.$('.js-buyWizardShippingPrice').html("("+newDisplayShippingPrice+")");
106106
}
107107
this.$('.js-buyWizardModeratorPrice').attr('data-tooltip', moderatorPriceString);
108108
newAttributes.quantity = quantity;
@@ -113,8 +113,8 @@ module.exports = Backbone.View.extend({
113113

114114
lockForm: function(){
115115
"use strict";
116-
this.$el.find('.js-buyWizardQuantity').prop('disabled', true);
117-
this.$el.find('#buyWizardQuantity .numberSpinnerUp, #buyWizardQuantity .numberSpinnerDown').addClass('hide');
116+
this.$('.js-buyWizardQuantity').prop('disabled', true);
117+
this.$('#buyWizardQuantity .numberSpinnerUp, #buyWizardQuantity .numberSpinnerDown').addClass('hide');
118118
},
119119

120120
goToPurchases: function(){

js/views/buyWizardVw.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ module.exports = baseVw.extend({
437437
"use strict";
438438
this.accNext();
439439
this.hideMaps();
440+
this.setTotalPrice(); //in case it isn't set yet
440441
},
441442

442443
sendPurchase: function(){
@@ -445,16 +446,16 @@ module.exports = baseVw.extend({
445446
formData = new FormData(),
446447
moderatorID = this.model.get('selectedModerator').guid || "",
447448
selectedAddress = this.model.get('selectedAddress'),
448-
bitCoinReturnAddr = this.$el.find('#buyWizardBitcoinAddressInput').val();
449+
bitCoinReturnAddr = this.$('#buyWizardBitcoinAddressInput').val();
449450

450-
if (!this.$el.find('#buyWizardQuantity')[0].checkValidity()){
451+
if (!this.$('#buyWizardQuantity')[0].checkValidity()){
451452
messageModal.show(window.polyglot.t('errorMessages.saveError'), window.polyglot.t('errorMessages.missingError'));
452453
return;
453454
}
454455

455-
this.$el.find('.js-buyWizardSendPurchase').addClass('hide');
456-
this.$el.find('.js-buyWizardPendingMsg').removeClass('hide');
457-
this.$el.find('.js-buyWizardPurchaseBack').addClass('disabled');
456+
this.$('.js-buyWizardSendPurchase').addClass('hide');
457+
this.$('.js-buyWizardPendingMsg').removeClass('hide');
458+
this.$('.js-buyWizardPurchaseBack').addClass('disabled');
458459

459460
formData.append("id", this.model.get('id'));
460461

@@ -472,7 +473,7 @@ module.exports = baseVw.extend({
472473
formData.append("moderator", moderatorID);
473474
}
474475

475-
this.$el.find('.js-buyWizardSpinner').removeClass('hide');
476+
this.$('.js-buyWizardSpinner').removeClass('hide');
476477

477478
formData.append("refund_address", bitCoinReturnAddr);
478479

@@ -494,7 +495,11 @@ module.exports = baseVw.extend({
494495
} else {
495496
messageModal.show(window.polyglot.t('errorMessages.contractError'), window.polyglot.t('errorMessages.sellerError') +" " +
496497
window.polyglot.t('errorMessages.checkPurchaseData') + "\n\n Reason: " + data.reason);
497-
self.$el.find('.js-buyWizardSpinner').addClass('hide');
498+
self.$('.js-buyWizardSpinner').addClass('hide');
499+
//re-enable form so they can try again
500+
self.$('.js-buyWizardSendPurchase').removeClass('hide');
501+
self.$('.js-buyWizardPendingMsg').addClass('hide');
502+
self.$('.js-buyWizardPurchaseBack').removeClass('disabled');
498503
}
499504
},
500505
error: function (jqXHR, status, errorThrown) {
@@ -562,8 +567,8 @@ module.exports = baseVw.extend({
562567
maximumFractionDigits: 2,
563568
currency: userCurrency
564569
}).format(totalPrice);
565-
this.$el.find('.js-buyWizardDetailsTotal').text(totalDisplayPrice);
566-
this.$el.find('.js-buyWizardDetailsBTCTotal').text(Number(totalBTCPrice.toFixed(8)));
570+
this.$('.js-buyWizardDetailsTotal').text(totalDisplayPrice);
571+
this.$('.js-buyWizardDetailsBTCTotal').text(Number(totalBTCPrice.toFixed(8)));
567572
},
568573

569574
copyPayAddress: function(){

0 commit comments

Comments
 (0)