Skip to content

Commit

Permalink
Merge pull request #208 from sumandari/stylehub-patch
Browse files Browse the repository at this point in the history
Fix detail layout and desc order as default on list view
  • Loading branch information
sumandari authored Oct 29, 2021
2 parents c13ec81 + 61ab32a commit e07461f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
10 changes: 5 additions & 5 deletions qgis-app/base/views/processing_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def get_context_data(self, **kwargs):
context['count'] = self.get_queryset().count()
context['order_by'] = self.request.GET.get('order_by', None)
context['queries'] = self.request.GET.get('q', None)
context['is_galery'] = self.request.GET.get('is_galery', None)
context['is_gallery'] = self.request.GET.get('is_gallery', None)
return context

def get_queryset(self):
Expand All @@ -325,16 +325,16 @@ def get_queryset(self):

def get_template_names(self):
context = self.get_context_data()
is_galery = context['is_galery']
if is_galery:
is_gallery = context['is_gallery']
if is_gallery:
self.paginate_by = settings.PAGINATION_DEFAULT_PAGINATION
return 'base/list_galery.html'
else:
return 'base/list.html'

def get_paginate_by(self, queryset):
is_galery = self.request.GET.get('is_galery', None)
if is_galery:
is_gallery = self.request.GET.get('is_gallery', None)
if is_gallery:
return settings.PAGINATION_DEFAULT_PAGINATION_HUB
return settings.PAGINATION_DEFAULT_PAGINATION

Expand Down
3 changes: 3 additions & 0 deletions qgis-app/templates/base/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ <h2 xmlns="http://www.w3.org/1999/html">QGIS {{ resource_name }}</h2>
div.style-polaroid, div.span12.license {
margin-left: 1em;
}
div.span12.license {
margin-bottom: 5em;
}
.style-title {
margin-bottom: 0;
padding-bottom: 0;
Expand Down
2 changes: 1 addition & 1 deletion qgis-app/templates/base/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h3 class="style-title">{{ object_detail.name }}</h3>
</div>

</div>
<div class="span8">
<div class="span6">
<dl class="dl-horizontal">
<dd></dd>
<dt>Name</dt>
Expand Down
4 changes: 2 additions & 2 deletions qgis-app/templates/base/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ <h2>{% if title %}{{title}}{% else %}{% trans "All" %} {{ resource_name }}s{% en

// galery or list view
const url = window.location.href.split('?')[0];
const isGalery = new URLSearchParams(window.location.search).get("is_galery");
const isGalery = new URLSearchParams(window.location.search).get("is_gallery");
console.log(isGalery)
if (isGalery && isGalery === 'true') {
$('.list-grid').find('.is-galery').addClass('disabled')
Expand All @@ -154,7 +154,7 @@ <h2>{% if title %}{{title}}{% else %}{% trans "All" %} {{ resource_name }}s{% en
this.href = url;
})
$('.list-grid a.is-galery').each(function(){
this.href = url + '?is_galery=true';
this.href = url + '?is_gallery=true';
})

// change color for sorted head
Expand Down
16 changes: 8 additions & 8 deletions qgis-app/templates/base/list_galery.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,26 @@ <h5>
// Add arguments in pagination
const orderBy = new URLSearchParams(window.location.search).get("order_by");
const queries = new URLSearchParams(window.location.search).get("q");
const is_galery = 'is_galery=true'
const is_gallery = 'is_gallery=true'
if (orderBy){
$(".pagination li a").each(function(){
this.href += 'order_by=' + orderBy +'&&' + is_galery + '&&';
this.href += 'order_by=' + orderBy +'&&' + is_gallery + '&&';
})
}
if (queries){
$(".pagination li a").each(function(){
this.href += 'q=' + queries +'&&' + is_galery + '&&';
this.href += 'q=' + queries +'&&' + is_gallery + '&&';
})
}
if (!orderBy && !queries){
$(".pagination li a").each(function(){
this.href += is_galery + '&&';
this.href += is_gallery + '&&';
})
}

// galery or list view
const url = window.location.href.split('?')[0];
const isGalery = new URLSearchParams(window.location.search).get("is_galery");
const isGalery = new URLSearchParams(window.location.search).get("is_gallery");
if (isGalery && isGalery === 'true') {
$('.list-grid').find('.is-galery').addClass('disabled')
} else {
Expand All @@ -170,7 +170,7 @@ <h5>
this.href = url;
})
$('.list-grid a.is-galery').each(function(){
this.href = url + '?is_galery=true';
this.href = url + '?is_gallery=true';
})

// edit search input from base template, in order to use it for styles
Expand Down Expand Up @@ -207,10 +207,10 @@ <h5>
const order = $('div.filter-sort').find('a').attr('data')
const sort_by = $('div.filter-sort').find('select').val()
let current_query = new URLSearchParams(window.location.search).get("q");
let is_galery = new URLSearchParams(window.location.search).get("is_galery");
let is_gallery = new URLSearchParams(window.location.search).get("is_gallery");
if (current_query === null) current_query = '';

location.href = location.protocol + '//' + location.host + location.pathname + `?order_by=${order}${sort_by}&&is_galery=${is_galery}`
location.href = location.protocol + '//' + location.host + location.pathname + `?order_by=${order}${sort_by}&&is_gallery=${is_gallery}`
}
</script>
{% endblock %}
Expand Down
6 changes: 3 additions & 3 deletions qgis-app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@
'/planet/',
# '/community-map/',
'/plugins/',
'/styles/?is_galery=true',
'/geopackages/?is_galery=true',
'/models/?is_galery=true',
'/styles/?order_by=-upload_date&&is_gallery=true',
'/geopackages/?order_by=-upload_date&&is_gallery=true',
'/models/?order_by=-upload_date&&is_gallery=true',
FlatPage.objects.all(),
simplemenu.models.URLItem.objects.all(),
)

0 comments on commit e07461f

Please sign in to comment.