Date: Mon, 22 Jul 2024 16:23:00 +0000
Subject: [PATCH 28/48] readding item_name
---
.../ontario_theme/templates/internal/snippets/facet_list.html | 1 +
1 file changed, 1 insertion(+)
diff --git a/ckanext/ontario_theme/templates/internal/snippets/facet_list.html b/ckanext/ontario_theme/templates/internal/snippets/facet_list.html
index 5f6459931..2efc45a2f 100644
--- a/ckanext/ontario_theme/templates/internal/snippets/facet_list.html
+++ b/ckanext/ontario_theme/templates/internal/snippets/facet_list.html
@@ -50,6 +50,7 @@
{% endif -%}
{% set label = label_function(translate, "title") if (label_function and translate) else item.display_name %}
{% set count = count_label(item['count']) if count_label else ('(%d)' % item['count']) %}
+ {% set item_name = item.name|replace(' ', '-') %}
Date: Mon, 22 Jul 2024 19:10:18 +0000
Subject: [PATCH 29/48] clear filters resubmits form
---
.../fanstatic/scripts/odc-clear-filters.js | 41 ++++++++++---------
.../fanstatic/scripts/webassets.yml | 5 ++-
.../internal/snippets/search_form.html | 1 +
3 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/ckanext/ontario_theme/fanstatic/scripts/odc-clear-filters.js b/ckanext/ontario_theme/fanstatic/scripts/odc-clear-filters.js
index ad1947936..76daacf64 100644
--- a/ckanext/ontario_theme/fanstatic/scripts/odc-clear-filters.js
+++ b/ckanext/ontario_theme/fanstatic/scripts/odc-clear-filters.js
@@ -1,21 +1,24 @@
-(function () {
- var clearFiltersButton = document.getElementById("clear-filters-button");
- var facetsSelected = document.querySelectorAll(".filtered.pill");
+// Enable JavaScript's strict mode. Strict mode catches some common
+// programming errors and throws exceptions, prevents some unsafe actions from
+// being taken, and disables some confusing and bad JavaScript features.
- if (facetsSelected.length >= 2) {
- clearFiltersButton.style.display = "inline-block";
- clearFiltersButton.addEventListener('click', clearFilters);
- }
- function clearFilters() {
- const url = window.location.href.split('?')[0];
- let params = new URLSearchParams(document.location.search);
- let array = Array.from(params);
- for (const field of array) {
- const [key, value] = field;
- if ((key != 'q') && (key != 'access_level')) {
- params.delete(key);
- }
- }
- window.location.href = `${url}?${params}`;
+"use strict";
+
+ckan.module('clear_filters', function ($) {
+ return {
+ initialize: function () {
+ var clearFiltersButton = $("#clear-filters-button");
+ var facetsSelected = $(".filtered.pill");
+ if (facetsSelected.length >= 2) {
+ clearFiltersButton.css({ display: "inline-block" });
+ clearFiltersButton.on('click', jQuery.proxy(this._onChange, this));
+ }
+ },
+ _onChange: function (event) {
+ $(('#fields')).empty();
+
+ var form = $('form.search-form');
+ form.submit();
}
-})();
\ No newline at end of file
+ }
+});
\ No newline at end of file
diff --git a/ckanext/ontario_theme/fanstatic/scripts/webassets.yml b/ckanext/ontario_theme/fanstatic/scripts/webassets.yml
index d20625f61..f195041a7 100644
--- a/ckanext/ontario_theme/fanstatic/scripts/webassets.yml
+++ b/ckanext/ontario_theme/fanstatic/scripts/webassets.yml
@@ -7,7 +7,6 @@ ontario_theme_js:
- odc-show-more.js
- odc-active-page.js
- odc-search-modal.js
- - odc-clear-filters.js
- odc-toc-smooth-scroll.js
ontario_theme_form_validators_js:
@@ -21,7 +20,9 @@ ontario_theme_form_validators_js:
ontario_theme_facet_checkboxes_js:
filters: rjsmin
- contents: odc-facet-checkboxes.js
+ contents:
+ - odc-facet-checkboxes.js
+ - odc-clear-filters.js
output: ontario_theme_scripts/%(version)s_odc-facet-checkboxes.js
extra:
preload:
diff --git a/ckanext/ontario_theme/templates/internal/snippets/search_form.html b/ckanext/ontario_theme/templates/internal/snippets/search_form.html
index 748271bbe..107e8bdab 100644
--- a/ckanext/ontario_theme/templates/internal/snippets/search_form.html
+++ b/ckanext/ontario_theme/templates/internal/snippets/search_form.html
@@ -127,6 +127,7 @@
{% else %}
{% if count %}
- {% set href = h.add_url_param(new_params={'access_level': value}, extras=extras) %}
+ {% set href = h.remove_url_param('access_level', replace=value, extras=extras) %}
{% set level_count = h.localised_number(count[0])|int %}
{% set alt_results = ungettext('{level_count} dataset with access level', '{level_count} datasets with access level', level_count) %}
{{ alt_results.format(level_count=level_count) }} {{ display_name }}
diff --git a/ckanext/ontario_theme/templates/internal/snippets/search_form.html b/ckanext/ontario_theme/templates/internal/snippets/search_form.html
index 107e8bdab..939eb270d 100644
--- a/ckanext/ontario_theme/templates/internal/snippets/search_form.html
+++ b/ckanext/ontario_theme/templates/internal/snippets/search_form.html
@@ -238,10 +238,12 @@
{% if count == 0 and not error %}
{% if total_count != 0 %}
-
We also found{{ _(":") }}
-
- {% snippet 'snippets/access_level_checkboxes.html', extras=extras %}
-
+
+ {{ _('We also found') }}{{ _(":") }}
+
+ {% snippet 'snippets/access_level_checkboxes.html', extras=extras %}
+
+
{% endif %}
{{ _('Please try another search or reach out to us if you think data is missing.') }}
diff --git a/ckanext/ontario_theme/templates/internal/snippets/search_result_text.html b/ckanext/ontario_theme/templates/internal/snippets/search_result_text.html
index 894131361..5cb168af3 100644
--- a/ckanext/ontario_theme/templates/internal/snippets/search_result_text.html
+++ b/ckanext/ontario_theme/templates/internal/snippets/search_result_text.html
@@ -12,9 +12,9 @@
#}
{% if type == 'dataset' %}
- {% set text_query = ungettext('{number} dataset found with the search term "{query}"', '{number} datasets found with the search term "{query}"', count) %}
+ {% set text_query = ungettext('{number} total dataset found with the search term "{query}"', '{number} total datasets found with the search term "{query}"', count) %}
{% set text_query_none = _('No datasets found with the search term "{query}"') %}
- {% set text_no_query = ungettext('{number} dataset found', '{number} datasets found', count) %}
+ {% set text_no_query = ungettext('{number} total dataset found', '{number} total datasets found', count) %}
{% set text_no_query_none = _('No datasets found') %}
{% elif type == 'group' %}
{% set text_query = ungettext('{number} group found with the search term "{query}"', '{number} groups found with the search term "{query}"', count) %}
From cdd68c557e67f9b56a301870791aaee8b5eedb9f Mon Sep 17 00:00:00 2001
From: Alex Green
Date: Mon, 19 Aug 2024 20:21:47 +0000
Subject: [PATCH 32/48] minor translation fixes
---
.../fr/LC_MESSAGES/ckanext-ontario_theme.mo | Bin 97556 -> 97550 bytes
.../fr/LC_MESSAGES/ckanext-ontario_theme.po | 8 ++++----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/ckanext/ontario_theme/i18n/fr/LC_MESSAGES/ckanext-ontario_theme.mo b/ckanext/ontario_theme/i18n/fr/LC_MESSAGES/ckanext-ontario_theme.mo
index 233b72f9e1b54886d346c6d46037f509805f1292..40bd46e4e504a9907e4cbbbd8bbf69dbd91d5a25 100644
GIT binary patch
delta 1756
zcmY+^e@K;A9LMo<^4BVNb8VK{ted&E>RK+-GAhe{Y}MRK^G9ix<-Mh8n%(S|@lg4P
zj2Q*SC8&fUgBV-F2G$ta+S*{a!JsiD=7vhg~p68tBe81mw
zx}PMRev;5PnB=t?W3F$u<}b`Evt|tj%dIKG2&Up?d$Z
z@DTCe)8q*T(2lQRH@<*h
zpuYbaH{;K!(9YRrO%j&lTUdiF_z@~1lWSZgyi6K;F&`DO<+u`eqH@)XQ}7p52>-?m
z9JAf+B#6p=0j|X|`~)wcQnr4Fdw&yZzGhTJK16=RGXpdfitlj_4xuKDueD}822r64
z;RM`(+CddoVFXv;O;pI^c3RVcX;_IDu>eO=5zEy((-?309+?UqOxE!W7mw!!$I(eVky8
z$%wcdX76?(+=4TBz5{hCPU3m&L`|5v$E9X5&Z55#$6^brXpf?5qzhli9-M^Vp{E@W
z(@?0NqH>*7?;fEkUhChAcO9>G5B#BMBTazFMXenbBr
z4&$f$tQp0wX3zaeM~l1Ju3h6<`yoa{{Wlt%>%B8dQer~i;Bd@Sc^AN
z5y^^La{>!d7u8p&WBdoI#{TtaP?#qDpf!069B*^y`!iJNhHy3hiCQRh$W?JJDpgCd
z7|U@x_Tt+Zf7qH?3F2bottf@no2KoyF_RQMY)pnbb7>qVY
zYa3%-C3a?Ppv;D1Bc*oYbC2$p*lqnhS{8`a*V&x@d3CliE-?}b?}{GmzqH%7rTz~g
C#sX{r
delta 1771
zcmYk+VQ7_A9LMoCu!zl-*n=4y#Cz}u
zT!1$)hGpBWS%zz|1k%{bqa`3T<(RHFx6@T#OH)LZ1rFqBeLLEAcHX
z!b#NoU*lH%5f$1sPgxVe4txwf+>aljB2vD?MZ#Z6Llf7dLe_wfVizh`6L=^7gbLv`
zEXSgq?j&(k?i08P+wo(350$blyWIRVYQ26`L_S15#5ZSXC=}mf6;7cREXi0i7vreV
z)nF+;i8?_B+cAq9@Ej`S#k;LJgcZ0A-^Y5KMMbRcX=@5Ffpgj4G|h7Z!Xi&0@twA
z8dLd<%VF&v7s3oK<#`wCRvg9vM^Ou|>~g7j1mpCZu^0zXMf)PEM#gXjj^iS{fWA)r
z8x4ipKI?Kl4;7IWsG_VvMW7|@AHYuf0cxQesG?oa?KZAPrL-RPA810QFoikn$NTZm
zZtlN|s-nl8pc+-J8&D^B6<6WwsC$13Q+OUX{number} total dataset found with the search term \"{query}\""
msgid_plural "{number} total datasets found with the search term \"{query}\""
-msgstr[0] "{number} total de jeu de données trouvé avec le terme de recherche « {query} »"
+msgstr[0] "{number} jeu de données total trouvé avec le terme de recherche « {query} »"
msgstr[1] "{number} total des jeux de données trouvés avec le terme de recherche « {query} »"
#: ckanext/ontario_theme/templates/internal/package/snippets/resources_list.html
@@ -134,7 +134,7 @@ msgstr "Afficher moins"
#: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:17
msgid "{number} total dataset found"
msgid_plural "{number} total datasets found"
-msgstr[0] "{number} total de jeu de données trouvé"
+msgstr[0] "{number} jeu de données total trouvé"
msgstr[1] "{number} total des jeux de données trouvés"
#: Ministries
@@ -2027,7 +2027,7 @@ msgstr "Aucun jeux de données avec niveau d’accès"
#: ckanext/ontario_theme/templates/internal/snippets/search_form.html:195
msgid "No datasets found with search term \"{query}\" and access level"
-msgstr "Aucun jeux de données trouvés avec le terme de recherche «{query}» et niveau d’accès"
+msgstr "Aucun jeu de données trouvé avec le terme de recherche «{query}» et niveau d’accès"
#: ckanext/ontario_theme/templates/internal/snippets/search_form.html:193
msgid "Showing datasets found with search term \"{query}\" and access level"
@@ -2222,7 +2222,7 @@ msgstr "Effacer les filtres"
#: ckanext/ontario_theme/templates/internal/snippets/search_form.html:123
msgid "Please try another search or reach out to us if you think data is missing."
-msgstr "Veuillez essayer une autre recherche ou communiquer avec nous si vous pensez que des données sont manquantes."
+msgstr "Veuillez effectuer une autre recherche ou communiquer avec nous si vous pensez que des données sont manquantes."
#: ckanext/ontario_theme/plugin.py:729
msgid "{bytes} B"
From 3ef3e3428ec18a69f569323af1961c309428f087 Mon Sep 17 00:00:00 2001
From: Alex Green
Date: Tue, 20 Aug 2024 19:43:50 +0000
Subject: [PATCH 33/48] remove facet when checked checkbox is unchecked
---
.../fanstatic/scripts/odc-facet-checkboxes.js | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/ckanext/ontario_theme/fanstatic/scripts/odc-facet-checkboxes.js b/ckanext/ontario_theme/fanstatic/scripts/odc-facet-checkboxes.js
index 14479fa4e..42cda6419 100644
--- a/ckanext/ontario_theme/fanstatic/scripts/odc-facet-checkboxes.js
+++ b/ckanext/ontario_theme/fanstatic/scripts/odc-facet-checkboxes.js
@@ -12,16 +12,19 @@
ckan.module('facet_checkboxes', function ($) {
return {
initialize: function () {
- $(".facet-fieldset :checkbox").on('click', jQuery.proxy(this._onChange, this));
+ $(".facet-fieldset :checkbox").on('click', jQuery.proxy(this._onChange, this));
},
_onChange: function (event) {
const hiddenFields = $(('#fields'));
- $('').attr({
- type: 'hidden',
- name: event.target.name,
- value: event.target.value
- }).appendTo(hiddenFields);
-
+ if (event.target.checked) {
+ $('').attr({
+ type: 'hidden',
+ name: event.target.name,
+ value: event.target.value
+ }).appendTo(hiddenFields);
+ } else {
+ $(`input[name='${event.target.name}'][value='${event.target.value}']`).remove();
+ }
var form = $('form.search-form');
form.submit();
}
From bbd4179898234994692dec0b7f20202734a15efb Mon Sep 17 00:00:00 2001
From: Alex Green
Date: Tue, 20 Aug 2024 20:30:58 +0000
Subject: [PATCH 34/48] Issue with count displaying 0 instead of correct amount
resolved
---
.../internal/snippets/search_form.html | 44 ++++++++++---------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/ckanext/ontario_theme/templates/internal/snippets/search_form.html b/ckanext/ontario_theme/templates/internal/snippets/search_form.html
index 939eb270d..d22cefafe 100644
--- a/ckanext/ontario_theme/templates/internal/snippets/search_form.html
+++ b/ckanext/ontario_theme/templates/internal/snippets/search_form.html
@@ -5,6 +5,7 @@
{% set schema_dict = h.scheming_get_dataset_schema('dataset')['dataset_fields'] %}
{% set extras = extras if extras else none %}
{% set total_count = h.get_facet_items_dict('access_level')|sum(attribute='count') if facets else count %}
+{% set limit = h.ontario_theme_get_facet_options()['limit']|int %}