Skip to content

Commit

Permalink
add bulk add for collections (#9463)
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu authored Sep 27, 2021
1 parent bed2a26 commit 91a8284
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
8 changes: 8 additions & 0 deletions app/assets/v2/js/grants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,14 @@ if (document.getElementById('grants-showcase')) {
});
});
},
addCollectionToCart: async function(collection_id) {
const collectionDetailsURL = `/grants/v1/api/collections/${collection_id}`;
const collection = await fetchData(collectionDetailsURL, 'GET');

(collection.grants || []).forEach((grant) => {
CartData.addToCart(grant);
});
},
updateCartData: function(e) {
const grants_in_cart = (e && e.detail && e.detail.list && e.detail.list) || [];
const grant_ids_in_cart = grants_in_cart.map((grant) => grant.grant_id);
Expand Down
8 changes: 2 additions & 6 deletions app/grants/templates/grants/components/collection.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,8 @@ <h2 class="h5 gc-font-base">
<input type="hidden" :id="`collection-${collection.id}`" :value="`https://gitcoin.co/grants/explorer/?collection_id=${collection.id}`">
</button>

<template v-if="$parent.activeCollection">
<button @click.stop="addToCart()" class="btn btn-primary ml-1" style="flex: 1 1 0px;">
<i class="fas fa-fw fa-cart-plus" aria-hidden="true"></i> Add to Cart
</button>
</template>
<template v-else>

<template>
<a class="btn btn-primary ml-1" :href="`/grants/explorer/?collection_id=${collection.id}`" style="flex: 1 1 0px;" v-if="$parent.isLandingPage">
<i class="fas fa-fw fa-arrow-right"></i> View
</a>
Expand Down
14 changes: 9 additions & 5 deletions app/grants/templates/grants/explorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
class="far fa-fw fa-search font-smaller-3 position-absolute text-grey-300"
:style="(searchVisible ? 'top: 10px;margin-left: 7px;left: 34px;' : 'top: 19px; margin-left: 7px;')"
></i>
<input class="form-control form-control-sm rounded-pill pl-4" placeholder="Search..." type="search" @click="searchVisible=!searchVisible" v-model="params.keyword" @input="changeQuery({page: 1})">
<input class="form-control form-control-sm rounded-pill pl-4" placeholder="Search..." type="search" @click="searchVisible=!searchVisible" v-model="params.keyword" @input="changeQuery({page: 1})" @keyup.enter="changeQuery({page: 1})">
<div class="navCart dropdown gc-cart" v-if="!searchVisible && sticky_active">
<a href="" class="gc-cart__icon d-block" role="button" @click="$refs.navCart.init()"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="padding: 0.3rem 1rem;">
Expand Down Expand Up @@ -281,10 +281,14 @@

{% include 'grants/shared/top-filters.html' %}

<template v-if="isGrantExplorer && !isGrantCollectionExplorer">
<!-- {% include 'grants/shared/active_clr_round.html'%} -->
</template>
<button class="btn btn-outline-gc-grey btn-sm mb-2" v-if="grantsHasPrev" @click="unshiftGrants(lowestPage-1)">Load previous page</button>
<div class="d-flex">
<button class="btn btn-outline-gc-grey btn-sm mb-2" v-if="grantsHasPrev" @click="unshiftGrants(lowestPage-1)">Load previous page</button>
<template v-if="params.collection_id">
<button @click.stop="addCollectionToCart(params.collection_id)" class="btn btn-sm btn-primary mb-2 ml-auto">
<i class="fas fa-fw fa-cart-plus" aria-hidden="true"></i> Add Collection to Cart
</button>
</template>
</div>
<div class="infinite-container row" v-if="grants">
<div :class="`col-12 ${view == 'grid' ? 'col-md-6 col-xl-4' : ''} mb-4 infinite-item grant-card`" v-for="(grant, id) in grants">
<a class="text-decoration-none" :href="grant.details_url">
Expand Down

0 comments on commit 91a8284

Please sign in to comment.