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

Batch 1 - fix for vue view list and add team members #7354

Merged
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
120 changes: 65 additions & 55 deletions app/assets/v2/js/grants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ $(document).ready(() => {

Vue.component('grant-sidebar', {
props: [ 'filter_grants', 'grant_types', 'type', 'selected_category', 'keyword', 'following', 'set_type',
'idle_grants', 'show_contributions'
'idle_grants', 'show_contributions', 'query_params'
],
data: function() {
return {
search: this.keyword,
show_filters: true
show_filters: false
};
},
methods: {
Expand All @@ -103,7 +103,21 @@ Vue.component('grant-sidebar', {
toggleContributionView: function(state, event) {
event.preventDefault;
this.filter_grants({show_contributions: state});
},
isMobileDevice: function() {
return window.innerWidth < 576;
},
onResize: function() {
if (!this.isMobileDevice() && this.show_filters !== null) {
this.show_filters = null;
} else if (this.isMobileDevice() && this.show_filters === null) {
this.show_filters = false;
}
console.log(this.show_filters);
}
},
mounted() {
window.addEventListener('resize', this.onResize);
}
});
if (document.getElementById('grants-showcase')) {
Expand All @@ -116,7 +130,7 @@ if (document.getElementById('grants-showcase')) {
page: 1,
limit: 6,
sort: 'weighted_shuffle',
network: 'mainnet',
network: document.network,
keyword: document.keyword,
current_type: document.current_type,
idle_grants: document.idle_grants,
Expand Down Expand Up @@ -149,8 +163,54 @@ if (document.getElementById('grants-showcase')) {
} else {
window.history.pushState('', '', `/grants/${this.current_type}?${q || ''}`);
}

if (this.current_type === 'activity') {
const triggerTS = function() {
const activeElement = $('.infinite-more-link');

if (activeElement.length) {
$('.infinite-more-link').click();
} else {
setTimeout(triggerTS, 1000);
}
};

setTimeout(triggerTS, 1000);
}
},
getQueryParams: function() {
const query_elements = {};

if (this.category && this.current_type !== 'all') {
query_elements['category'] = this.category;
}

if (this.keyword) {
query_elements['keyword'] = this.keyword;
}
if (this.idle_grants) {
query_elements['idle'] = this.idle_grants;
}
if (this.following) {
query_elements['following'] = this.following;
}
if (this.show_contributions) {
query_elements['only_contributions'] = this.show_contributions;
}
if (this.sort !== 'weighted_shuffle') {
query_elements['sort'] = this.sort;
}
if (this.network !== 'mainnet') {
query_elements['network'] = this.network;
}

return $.param(query_elements);
},
filter_grants: function(filters) {
filter_grants: function(filters, event) {
if (event) {
event.preventDefault();
}

if (filters.type !== null && filters.type !== undefined) {
this.current_type = filters.type;
}
Expand All @@ -177,32 +237,7 @@ if (document.getElementById('grants-showcase')) {
}

this.page = 1;
const query_elements = {};

if (this.category && this.current_type !== 'all') {
query_elements['category'] = this.category;
}

if (this.keyword) {
query_elements['keyword'] = this.keyword;
}
if (this.idle_grants) {
query_elements['idle'] = this.idle_grants;
}
if (this.following) {
query_elements['following'] = this.following;
}
if (this.show_contributions) {
query_elements['only_contributions'] = this.show_contributions;
}
if (this.sort !== 'weighted_shuffle') {
query_elements['sort'] = this.sort;
}
if (this.network !== 'mainnet') {
query_elements['network'] = this.network;
}

const q = $.param(query_elements);
const q = this.getQueryParams();

this.setCurrentType(this.current_type, q);
this.fetchGrants(this.page);
Expand Down Expand Up @@ -278,17 +313,6 @@ if (document.getElementById('grants-showcase')) {
vm.grantsHasNext = false;
}
}
// const scrollHeight = $(document).height();
// const scrollPos = $(window).height() + $(window).scrollTop();
// let vm = this;

// if (((scrollHeight - 300) >= scrollPos) / scrollHeight == 0) {
// const grants = await vm.fetchGrants(vm.page + 1, true);

// if (grants && grants.length) {
// vm.page = vm.page++;
// }
// }
}
},
beforeMount() {
Expand Down Expand Up @@ -326,20 +350,6 @@ const etherscanUrlConvert = (elem, network) => {
};


$('.grants_nav a').on('click', function(event) {
event.preventDefault();
if ($(this).attr('href')) {
document.location.href = $(this).attr('href');
return;
}

const typeValue = $(this).data('type');
const categoryValue = $(this).data('category');
const params = { 'type': typeValue, 'category': categoryValue};

updateMultipleParams(params);
});

var glow_skip = function() {
setTimeout(function() {
$('#skip').animate({color: '#999'}, {duration: 1000});
Expand Down
6 changes: 3 additions & 3 deletions app/grants/templates/grants/detail/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ <h1 class="font-title-xl my-4 font-weight-bold">
</p>
</div>
{% endif %}

{% if grant.github_project_url %}
<div class="font-body mb-2">
<i style="width: 14px;" class="fab fa-github-square mr-2 text-center"></i>
<p class="d-inline-block mb-0">
<a href="{{ grant.github_project_url }}" target="_blank" rel="" data-toggle="tooltip" data-html="true" data-placement="top" for="github_project_url"
<a href="{{ grant.github_project_url }}" target="_blank" rel="" data-toggle="tooltip" data-html="true" data-placement="top" for="github_project_url"
title="Project Github URL">
{{ grant.github_project_url }}
</a>
Expand Down Expand Up @@ -202,7 +202,7 @@ <h1 class="font-title-xl my-4 font-weight-bold">
<p class="sub-title {% if is_team_member %} mb-0 {% else %} mb-3 {% endif %}">
TEAM
</p>
{% if is_team_member and not grant.active %}
{% if is_team_member %}
<div>
<div class="form__select2">
<select id="grant-members" class="form__input" name="grant-members" name="members" multiple="multiple" disabled>
Expand Down
6 changes: 2 additions & 4 deletions app/grants/templates/grants/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<script>
document.current_type = "{{ type|default:'all' }}";
document.selected_category = "{{ selected_category }}";
document.network = "{{ network}}";
document.keyword = "{{ keyword }}";
document.following = {{ following|yesno:'true,false' }};
document.idle_grants = {{ idle_grants|yesno:'true,false' }};
Expand All @@ -134,16 +135,13 @@
<script src="{% static "v2/js/grants/funding.js" %}"></script>
<script src="{% static "v2/js/lib/popper.min.js" %}"></script>
<script src="{% static "v2/js/lib/bootstrap.min.js" %}" crossorigin="anonymous"></script>

{% if type == 'activity' %}
{% include 'shared/activity_scripts.html' %}
{% else %}

<script>
var infinite = new Waypoint.Infinite({
element: $('.infinite-container')[0]
});
</script>
{% endif %}


</html>
4 changes: 2 additions & 2 deletions app/grants/templates/grants/shared/landing_subnav.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div class="col-12 col-xl-12 mt-2 mt-xl-0 font-caption text-center text-xl-right font-weight-semibold order_by sort_container">
<div class="mr-4">
<span class="heading mr-2">View</span>
<a href="#" :class="`font-weight-bold ${view == 'list' ? 'gc-text-blue' : 'text-black'}`" @click="setView('list', $event)">List</a> |
<a href="#" :class="`font-weight-bold ${view == 'grid' ? 'gc-text-blue' : 'text-black'}`" @click="setView('grid', $event)">Grid</a>
<a href="#" :class="`font-weight-bold ${view == 'list' ? 'text-black' : 'gc-text-blue' }`" @click="setView('list', $event)">List</a> |
<a href="#" :class="`font-weight-bold ${view == 'grid' ? 'text-black' : 'gc-text-blue' }`" @click="setView('grid', $event)">Grid</a>
</div>
<span class="heading">{% trans "Sort by" %}</span>
<select @change="filter_grants({sort: sort})" v-model="sort" name="sort_option" id="sort_option2">
Expand Down
19 changes: 10 additions & 9 deletions app/grants/templates/grants/shared/sidebar_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<grant-sidebar :grant_types="grant_types" :filter_grants="filter_grants" :type="current_type"
:selected_category="category" :keyword="keyword" :following="following"
:set_type="setCurrentType" :idle_grants="idle_grants" :show_contributions="show_contributions"
:query_params="getQueryParams"
inline-template>
<div class="sidebar_search font-body pr-0 pl-4" >
<div class="search font-caption mb-4" style="width: 110%;">
Expand All @@ -26,11 +27,11 @@
</div>
</div>

<p @click="show_filters = !show_filters" class="d-md-none text-right font-caption font-weight-semibold" v-if="show_filters">
<p @click="show_filters = !show_filters" class="d-md-none text-right font-caption font-weight-semibold" v-if="show_filters === false">
{% trans "Expand Filter" %}
<i class="fas fa-chevron-down"></i>
</p>
<p @click="show_filters = !show_filters" class="d-md-none text-right font-caption font-weight-semibold" v-if="!show_filters">
<p @click="show_filters = !show_filters" class="d-md-none text-right font-caption font-weight-semibold" v-if="show_filters">
{% trans "Minimize Filter" %}
<i class="fas fa-chevron-up"></i>
</p>
Expand Down Expand Up @@ -65,20 +66,20 @@
</li>
<template v-for="grant_type in grant_types">
<li class="mr-1 accordion">
<a :href="`/grants/${grant_type.keyword}`" :data-type="grant_type.keyword" data-category="" :class="`mr-1 ${type == grant_type.keyword ? 'selected' : ''}`">
<a :href="`/grants/${grant_type.keyword}?${query_params()}`" :data-type="grant_type.keyword" data-category="" :class="`mr-1 ${type == grant_type.keyword ? 'selected' : ''}`">
[[grant_type.label]] <sup>([[grant_type.count]])</sup>
</a>
</li>
<div class="panel">
<div class="col-12 options">
<ul class="nav d-inline-block font-body mb-2 grants_nav grants_keyword_nav pl-0 mb-0 pb-1 pt-2 mt-2 mt-xl-0 text-xl-left font-body font-weight-semibold">
<li class="mr-1 ">
<a :href="`/grants/${grant_type.keyword}`" :data-type="grant_type.keyword" data-category="" :class="`mr-3 mr-md-2 mr-lg-3 ${ type == grant_type.keyword && selected_category == '' ? 'selected': ''}`">
<a :href="`/grants/${grant_type.keyword}?${query_params()}`" :data-type="grant_type.keyword" data-category="" :class="`mr-3 mr-md-2 mr-lg-3 ${ type == grant_type.keyword && selected_category == '' ? 'selected': ''}`">
All [[grant_type.label]]
</a>
</li>
<li class="mr-1" v-for="category in grant_type.sub_categories">
<a :href="`/grants/${grant_type.keyword}?category=${category}`" :data-type="grant_type.keyword" data-category="category" :class="`mr-3 mr-md-2 mr-lg-3 ${ type == grant_type.keyword && selected_category == category ? 'selected' : '' }`">
<a :href="`/grants/${grant_type.keyword}?category=${category}&${query_params()}`" :data-type="grant_type.keyword" data-category="category" :class="`mr-3 mr-md-2 mr-lg-3 ${ type == grant_type.keyword && selected_category == category ? 'selected' : '' }`">
[[category]]
</a>
</li>
Expand All @@ -89,23 +90,23 @@

<hr>
<li>
<a @click="set_type('about')" data-type="about" data-category="" :class="`mr-1 px-1 ${ type == 'about'? 'selected':''}`">
<a @click="set_type('about')" data-type="about" data-category="" :class="`mr-1 px-1 ${ type == 'about'? 'selected':''}`">
About
</a>
</li>
<li>
<a @click="set_type('stats')" data-type="stats" data-category="" :class="`mr-1 px-1 ${ type == 'stats'? 'selected':''}`">
<a @click="set_type('stats')" data-type="stats" data-category="" :class="`mr-1 px-1 ${ type == 'stats'? 'selected':''}`">
Stats
</a>
</li>
<li>
<a @click="set_type('activity')" data-type="activity" data-category="" :class="`mr-1 px-1 ${ type == 'activity'? 'selected':''}`">
<a @click="set_type('activity')" data-type="activity" data-category="" :class="`mr-1 px-1 ${ type == 'activity'? 'selected':''}`">
Activity
</a>
</li>
{% if github_handle %}
<li>
<a @click="filter_grants({type: 'me', category: ''})" :class="`mr-1 px-1 ${ type == 'me'? 'selected':''}`">
<a @click="filter_grants({type: 'me', category: ''}, $event)" :class="` ${ type == 'me'? 'selected':''}`">
My Grants
</a>
</li>
Expand Down
13 changes: 8 additions & 5 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def get_grants(request):
contributions_by_grant[grant_id] = group

return JsonResponse({
'grant_types': get_grant_types(network),
'grant_types': get_grant_types(network, _grants),
'current_type': grant_type,
'category': category,
'grants': {
Expand Down Expand Up @@ -377,7 +377,7 @@ def build_grants_by_type(request, grant_type='', sort='weighted_shuffle', networ
_grants.first()

if not idle_grants:
_grants = _grants.filter(last_update__gt=three_months_ago)
_grants = _grants.filter(modified_on__gt=three_months_ago)

if state == 'active':
_grants = _grants.active()
Expand Down Expand Up @@ -416,10 +416,13 @@ def build_grants_by_type(request, grant_type='', sort='weighted_shuffle', networ
return _grants


def get_grant_types(network):
def get_grant_types(network, filtered_grants=None):
all_grants_count = 0
grant_types = []
active_grants = Grant.objects.filter(network=network, hidden=False, active=True)
if filtered_grants:
active_grants = filtered_grants
else:
active_grants = Grant.objects.filter(network=network, hidden=False, active=True)

for _grant_type in GrantType.objects.all():
count = active_grants.filter(grant_type=_grant_type).count()
Expand Down Expand Up @@ -518,7 +521,7 @@ def grants_by_grant_type(request, grant_type):
current_partners_fund += partner.amount

categories = [_category[0] for _category in basic_grant_categories(grant_type)]
grant_types = get_grant_types(network)
grant_types = get_grant_types(network, _grants)

cht = []
chart_list = ''
Expand Down