Skip to content

Commit

Permalink
Fix bugs in #7458 that happen when items are removed from cart (#7573)
Browse files Browse the repository at this point in the history
  • Loading branch information
mds1 authored Oct 1, 2020
1 parent 2e65741 commit a6b15d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion app/assets/v2/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,19 @@ Vue.component('grants-cart', {
});

// Read array of grants in cart from localStorage
this.grantData = CartData.loadCart();
const grantData = CartData.loadCart();

// Make sure none have empty currencies, and if they do default to 0.001 ETH. This is done
// to prevent the cart from getting stuck loading if a currency is empty
grantData.forEach((grant, index) => {
if (!grant.grant_donation_currency) {
grantData[index].grant_donation_currency = 'ETH';
grantData[index].grant_donation_amount = '0.001';
}
});
CartData.setCart(grantData);
this.grantData = grantData;

// Initialize array of empty comments
this.comments = this.grantData.map(grant => undefined);

Expand Down
4 changes: 2 additions & 2 deletions app/grants/templates/grants/cart-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ <h1 class="col-auto text-left font-bigger-2 black" style="font-weight: bold; mar
v-model="grant.grant_donation_amount" type="number" placeholder="Amount">
<select2 v-model="grant.grant_donation_currency" class="col-6 form-control"
style="margin-right:0.5rem" placeholder="Select token">
<option v-for="option in currencies[index]" v-bind:value="option" :disabled="!option">
<option v-for="(option, index) in currencies[index]" v-bind:value="option" :disabled="!option" :key="`currency-${index}`">
<span v-if="!option" style="height:1px; font-size:1px">&mdash;&mdash;&mdash;&mdash;</span>
<span v-else>[[ option ]]</span>
</option>
Expand Down Expand Up @@ -212,7 +212,7 @@ <h1 class="col-auto text-left font-bigger-2 black" style="font-weight: bold; mar
</div>
</div>
{% comment %} Cart Contents: NOT MOBILE {% endcomment %}
<div v-if="!isMobileDevice" v-for="(grant, index) in grantData" class="grant-row">
<div v-if="!isMobileDevice" v-for="(grant, index) in grantData" class="grant-row" :key="grant.grant_id">
<div class="grant-row-style">
<div class="row align-items-center justify-content-between" style="margin-left:0.5rem">
{% comment %} Title and logo {% endcomment %}
Expand Down

0 comments on commit a6b15d2

Please sign in to comment.