Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bulk add for collections #9463

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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