-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdd857c
commit acdbca2
Showing
8 changed files
with
305 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/ckanext-agra-theme/ckanext/agra_theme/public/base/javascript/filters.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const checkboxes = document.querySelectorAll('.filters input[type="checkbox"]'); | ||
|
||
function get_query() { | ||
var url = window.location.search; | ||
var query = url.substr(1); | ||
if (query === "") { | ||
return {}; | ||
} | ||
var result = {}; | ||
|
||
query.split("&").forEach(function (part) { | ||
var item = part.split("="); | ||
var key = item[0]; | ||
var value = item[1]; | ||
if (result[key]) { | ||
result[key].push(value); | ||
} else { | ||
result[key] = [value]; | ||
} | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
// Loop through each checkbox and add an event listener | ||
checkboxes.forEach((checkbox) => { | ||
checkbox.addEventListener("change", (event) => { | ||
var queryList = get_query(); | ||
const name = event.target.name; | ||
const value = event.target.value; | ||
|
||
if (event.target.checked) { | ||
// Add the value to the query list for the checked key | ||
if (queryList[name]) { | ||
queryList[name].push(value); | ||
} else { | ||
queryList[name] = [value]; | ||
} | ||
} else { | ||
// Remove the unchecked value from the query list | ||
queryList[name] = queryList[name].filter((v) => v !== value); | ||
if (queryList[name].length === 0) { | ||
delete queryList[name]; | ||
} | ||
} | ||
|
||
// Create a new URL by flattening the array for each key | ||
var newUrl = | ||
"?" + | ||
Object.entries(queryList) | ||
.flatMap(([key, values]) => values.map((val) => `${key}=${val}`)) | ||
.join("&"); | ||
|
||
// Push the new URL to the history | ||
window.history.pushState({}, "", newUrl); | ||
// Reload the page | ||
window.location.reload(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/ckanext-agra-theme/ckanext/agra_theme/templates/file_size.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h1>File Sizes for Resources in Dataset</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Resource Name</th> | ||
<th>File Size (bytes)</th> | ||
</tr> | ||
{% for resource in resource_sizes %} | ||
<tr> | ||
<td>{{ resource.name }}</td> | ||
<td>{{ resource.size }}</td> | ||
</tr> | ||
{% endfor %} | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
src/ckanext-agra-theme/ckanext/agra_theme/templates/package/search.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
{% extends "page.html" %} | ||
{% import 'macros/form.html' as form %} | ||
|
||
{% block subtitle %}{{ _(dataset_type.title()) }}{% endblock %} | ||
|
||
{% block breadcrumb_content %} | ||
<li class="active">{{ h.nav_link(_(dataset_type.title() + 's'), named_route='%s.search' % dataset_type, highlight_actions = 'new index') }}</li> | ||
{% endblock %} | ||
|
||
{% block primary_content %} | ||
<section class="module"> | ||
<div class="module-content"> | ||
{% block page_primary_action %} | ||
{% if h.check_access('package_create') %} | ||
<div class="page_primary_action"> | ||
{{ h.snippet ('snippets/add_dataset.html', dataset_type=dataset_type) }} | ||
</div> | ||
{% endif %} | ||
{% endblock %} | ||
{% block form %} | ||
{% set facets = { | ||
'fields': fields_grouped, | ||
'search': search_facets, | ||
'titles': facet_titles, | ||
'translated_fields': translated_fields, | ||
'remove_field': remove_field } | ||
%} | ||
{% set sorting = [ | ||
(_('Relevance'), 'score desc, metadata_modified desc'), | ||
(_('Name Ascending'), 'title_string asc'), | ||
(_('Name Descending'), 'title_string desc'), | ||
(_('Last Modified'), 'metadata_modified desc'), | ||
(_('Popular'), 'views_recent desc') if g.tracking_enabled else (false, false) ] | ||
%} | ||
{% snippet 'snippets/search_form.html', form_id='dataset-search-form', type=dataset_type, query=q, sorting=sorting, sorting_selected=sort_by_selected, count=page.item_count, placeholder=_('Search ' + dataset_type + 's') + '...', facets=facets, show_empty=request.params, error=query_error, fields=fields %} | ||
{% endblock %} | ||
{% block package_search_results_list %} | ||
{{ h.snippet('snippets/package_list.html', packages=page.items) }} | ||
{% endblock %} | ||
</div> | ||
|
||
{% block page_pagination %} | ||
{{ page.pager(q=q) }} | ||
{% endblock %} | ||
</section> | ||
|
||
{% block package_search_results_api %} | ||
<section class="module"> | ||
<div class="module-content"> | ||
{% block package_search_results_api_inner %} | ||
<small> | ||
{% set api_link = h.link_to(_('API'), h.url_for(controller='api', action='get_api', ver=3)) %} | ||
{% set api_doc_link = h.link_to(_('API Docs'), 'http://docs.ckan.org/en/{0}/api/'.format(g.ckan_doc_version)) %} | ||
{% if g.dumps_url -%} | ||
{% set dump_link = h.link_to(_('full {format} dump').format(format=g.dumps_format), g.dumps_url) %} | ||
{% trans %} | ||
You can also access this registry using the {{ api_link }} (see {{ api_doc_link }}) or download a {{ dump_link }}. | ||
{% endtrans %} | ||
{% else %} | ||
{% trans %} | ||
You can also access this registry using the {{ api_link }} (see {{ api_doc_link}}). | ||
{% endtrans %} | ||
{%- endif %} | ||
</small> | ||
{% endblock %} | ||
</div> | ||
</section> | ||
{% endblock %} | ||
{% endblock %} | ||
|
||
|
||
{% block secondary_content %} | ||
<div class="filters"> | ||
<div> | ||
{% for facet, title in facet_titles.items() %} | ||
<div class="facet-category"> | ||
<div class="facet-title">{{ title }}</div> | ||
<div class="facet-items"> | ||
{% for item in search_facets[facet]['items'] %} | ||
<label> | ||
<input type="checkbox" name="{{ facet }}" value="{{ item['name'] }}" {% if item['active'] %}checked{% endif %}> | ||
{{ item['display_name'] }} [{{ item['count'] }}] | ||
</label> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
<!-- Example for Hierarchical Groups --> | ||
{% if search_facets.get('groups') %} | ||
<div class="facet-category"> | ||
<div class="facet-title">{{ facet_titles.get('groups', 'Groups') }}</div> | ||
<ul class="group-hierarchy"> | ||
{% for group in search_facets['groups']['items'] %} | ||
<li> | ||
<label> | ||
<input type="checkbox" name="groups" value="{{ group['id'] }}" {% if group['active'] %}checked{% endif %}> | ||
{{ group['display_name'] }} | ||
</label> | ||
{% if group.get('children') %} | ||
<ul> | ||
{% for child in group['children'] %} | ||
<li> | ||
<label> | ||
<input type="checkbox" name="groups" value="{{ child['id'] }}" {% if child['active'] %}checked{% endif %}> | ||
{{ child['display_name'] }} | ||
</label> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
{% endif %} | ||
<a class="close no-text hide-filters"><i class="fa fa-times-circle"></i><span class="text">close</span></a> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block t_content %} | ||
<div class="filters"> | ||
<div> | ||
{% for facet in facet_titles %} | ||
{{ h.snippet('snippets/facet_list.html', title=facet_titles[facet], name=facet, search_facets=search_facets) }} | ||
{% endfor %} | ||
</div> | ||
<a class="close no-text hide-filters"><i class="fa fa-times-circle"></i><span class="text">close</span></a> | ||
</div> | ||
{% endblock %} |
27 changes: 27 additions & 0 deletions
27
src/ckanext-agra-theme/ckanext/agra_theme/templates/snippets/statistic.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<div class="box stats"> | ||
<div class="inner"> | ||
<ul> | ||
{% block stats_group %} | ||
<li> | ||
<a href="{{ h.url_for('dataset.search') }}"> | ||
<strong>{{ h.SI_number_span(stats.dataset_count) }}</strong> | ||
{{ _('dataset') if stats.dataset_count == 1 else _('datasets') }} | ||
</a> | ||
</li> | ||
<li> | ||
<a href="{{ h.url_for(controller='organization', action='index') }}"> | ||
<strong>{{ h.SI_number_span(stats.organization_count) }}</strong> | ||
{{ _('organization') if stats.organization_count == 1 else | ||
_('organizations') }} | ||
</a> | ||
</li> | ||
<li> | ||
<a href="{{ h.url_for(controller='group', action='index') }}"> | ||
<strong>{{ h.SI_number_span(stats.group_count) }}</strong> | ||
{{ _('group') if stats.group_count == 1 else _('groups') }} | ||
</a> | ||
</li> | ||
{% endblock %} | ||
</ul> | ||
</div> | ||
</div> |