diff --git a/ckanext/ontario_theme/fanstatic/common.css b/ckanext/ontario_theme/fanstatic/common.css index 9df8d3c5e..c67903d69 100644 --- a/ckanext/ontario_theme/fanstatic/common.css +++ b/ckanext/ontario_theme/fanstatic/common.css @@ -408,19 +408,14 @@ input[type="reset"].ontario-search-reset:focus { .search-form .control-order-by { justify-content: end; - padding-top: 33px; - margin-bottom: 0; background-color: #fff; padding-right: 1rem; - margin-left: -20px; - margin-right: -1rem; - padding-bottom: 16px; } #group-datasets-search-form.search-form .control-order-by, #organization-datasets-search-form.search-form .control-order-by { - margin-right: -20px; + margin-left: unset; padding-right: 20px; } @@ -440,10 +435,6 @@ input[type="reset"].ontario-search-reset:focus { } } -/* child div 2: shows Order By dropdown menu. - Note: clearance for menu below the gray box controlled by - bottom margin in external/ontario_theme.css LINE 759 - */ .search-form .control-order-by { display: flex; } @@ -471,12 +462,6 @@ input[type="reset"].ontario-search-reset:focus { /* used to centre label beside menu box */ } -.search-form .control-order-by .form-control { - font-size: 16px; - height: unset; - /* increase height to accommodate larger font size */ -} - .filter-list { display: inline-grid; padding-bottom: 10px; @@ -488,6 +473,49 @@ input[type="reset"].ontario-search-reset:focus { display: none; } +.search-form .control-order-by .form-control { + font-size: 16px; + height: unset; +} + +.checkbox-status { + order: 2; + background-color: white; + margin: 0 -16px; + display: flex; + align-items: center; + justify-content: flex-start; + padding-top: 16px; +} + +.checkbox-status .search-page-select { + margin-top: 2rem; +} + +.checkbox-status:has(.search-page-select) { + justify-content: flex-end; +} + +.checkbox-status:has(> .ontario-callout) .search-page-select { + margin-top: 0; +} + +form[id*='dataset-search-form'] .checkbox-status, +form[id*='datasets-search-form'] .checkbox-status { + padding-top: unset; +} + +@media screen and (min-width: 767px) { + .checkox-status:has(.control-order-by) { + justify-content: end; + } +} + +#group-datasets-search-form .checkbox-status, +#organization-datasets-search-form .checkbox-status { + margin: 0 -20px; +} + @media (max-width: 767px) { .search-form .control-order-by { display: none; @@ -497,6 +525,12 @@ input[type="reset"].ontario-search-reset:focus { display: block; } + .checkbox-status { + order: 6; + margin: 0 -16px; + padding: 0 16px; + } + .sort-by-modal-div { display: none; position: fixed; @@ -538,6 +572,7 @@ input[type="reset"].ontario-search-reset:focus { .search-form .filter-list { margin: unset; color: #000; + margin-top: 0; flex-wrap: wrap; order: 5; } @@ -588,9 +623,20 @@ a.pill { .search-form .filter-list { font-size: 20px; - margin: 0 -20px; - padding: 10px 20px; background-color: #fff; + padding: 0 20px; + } + + #dataset-search-form .filter-list { + margin: 0 -16px; + } + + form[id*='datasets-search-form'] .filter-list { + margin: 0 -20px; + } + + #dataset-search-form .access-level { + padding: 4px; } /* child div 4: shows filters just below sort by dropdown */ @@ -2327,6 +2373,7 @@ screen and (min-width: 96em) { border-color: #2b8737 !important } + /* ======================================================================== Search Page - Package Items ======================================================================== */ @@ -3223,10 +3270,6 @@ label::after { padding-right: unset; } -.group-packages .filters .module-narrow .module-footer { - padding-left: 12px; -} - @media screen and (min-width: 64em) { .filters .module-narrow .nav-item > a { padding-left: 46px; @@ -3257,8 +3300,8 @@ label::after { padding-right: unset; } -.filters .module-footer { - border-top: none; +.facet-fieldset .show-more-div { + margin: 10px 20px; } .fa.fa-filter { @@ -3270,7 +3313,7 @@ label::after { font-size: 16px; } -.nav > li.show-more-items { +.show-more-items { display: none; } @@ -3607,4 +3650,225 @@ label::after { .popular-datasets-404 li { padding-bottom: 8px; +} + +/* ======================================================================== + Checkboxes - Design System + ======================================================================== */ + +.ontario-checkboxes { + margin-bottom: 2.5rem; + max-width: 48rem +} + +.ontario-checkboxes__item { + position: relative; + margin: 0 0 1rem; + padding: 0 0 0 2rem; + min-height: 28px; + box-sizing: content-box +} + +.ontario-checkboxes__item:last-of-type { + margin: 0 +} + +@media screen and (max-width: 40em) { + .ontario-checkboxes__item { + padding: 0 0 0 2.5rem; + min-height: 32px + } +} + +.ontario-checkboxes__input { + cursor: pointer; + margin: 0; + position: absolute; + top: -2px; + left: -2px; + opacity: 0; + width: 36px; + height: 36px; + z-index: 1; + -webkit-tap-highlight-color: transparent +} + +@media screen and (max-width: 40em) { + .ontario-checkboxes__input { + width: 40px; + height: 40px + } +} + +.ontario-checkboxes__label { + display: inline-block; + cursor: pointer; + line-height: 1.5; + margin: .25rem 0; + padding: 0 1rem; + width: auto; + white-space: normal +} + +@media screen and (max-width: 40em) { + .ontario-checkboxes__label { + margin: .33rem 0 + } +} + +.ontario-checkboxes__label:before { + content: ""; + border: 2px solid #1a1a1a; + background-color: #fff; + border-radius: 4px; + position: absolute; + top: 0; + left: 0; + width: 32px; + height: 32px; + transition: border .1s ease-in-out; + display: block +} + +@media screen and (max-width: 40em) { + .ontario-checkboxes__label:before { + width: 36px; + height: 36px + } +} + +.ontario-checkboxes__label:after { + content: ""; + background-image: url("/images/ontario-checkbox-background-no-width.svg"); + background-repeat: no-repeat; + height: 30px; + width: 30px; + position: absolute; + top: 1px; + left: 1px; + right: 0; + bottom: 0; + opacity: 0; + display: block +} + +@media screen and (max-width: 40em) { + .ontario-checkboxes__label:after { + height: 34px; + width: 34px + } +} + +.ontario-checkboxes__input:focus + .ontario-checkboxes__label:before { + box-shadow: 0 0 0 4px #009adb; + outline: 4px solid transparent; + transition: all .1s ease-in-out +} + +.ontario-checkboxes__input:checked + .ontario-checkboxes__label:after { + opacity: 1 +} + +.ontario-checkboxes__input:checked + .ontario-checkboxes__label:before { + background-color: #1a1a1a +} + +/* ======================================================================== + Checkboxes - Overrides + ======================================================================== */ +.facet-fieldset .ontario-checkboxes, +.facet-fieldset .ontario-fieldset__legend { + padding-left: 20px; +} + +.facet-fieldset label { + font-weight: unset; + font-size: 16px; +} + +.facet-fieldset .ontario-checkboxes { + margin-bottom: unset; +} + +/* ======================================================================== + Fieldsets - Design System + ======================================================================== */ + +@media screen and (max-width: 40em) { + .ontario-fieldset__legend { + font-size: 1.125rem; + line-height: 1.56 + } +} + +.ontario-fieldset__legend { + color: #1a1a1a; + font-family: Raleway, "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 1.1875rem; + font-weight: 700; + line-height: 1.5; + margin: 0 0 1rem 0; + max-width: 38.75em; + white-space: normal; + width: 100% +} + +/* ======================================================================== + Access level - Customizations + ======================================================================== */ +#access-level-checkboxes { + margin-bottom: unset; +} + +.ontario-fieldset legend { + border-bottom: unset; +} + +.access-level .ontario-checkboxes { + display: inline-flex; + margin-bottom: unset; + max-width: unset; +} + +.access-level .ontario-checkboxes__item { + margin: 0 1.25rem 1rem 0; +} + +@media screen and (max-width: 40em) { + .access-level .ontario-checkboxes { + display: inline-block; + margin-bottom: 25px; + } +} + +@media screen and (min-width: 40.0625em) { + .access-level .ontario-fieldset__legend { + float: left; + width: unset; + margin-right: 1.5rem; + } +} + +.access-level .ontario-label.ontario-checkboxes__label { + font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 16px; + font-weight: unset; +} + +.access-level .ontario-checkboxes__input:checked + .ontario-checkboxes__label, +#access-level-sentence-value { + font-weight: 700; +} + +/* custom colors */ +.ontario-border-highlight--dark-blue { + border-color: #0369ac; +} + +.ontario-border-highlight--dark-taupe { + border-color: #7B725C; +} + +.wrapper { + min-height: unset; } \ No newline at end of file diff --git a/ckanext/ontario_theme/fanstatic/scripts/odc-access-level.js b/ckanext/ontario_theme/fanstatic/scripts/odc-access-level.js new file mode 100644 index 000000000..229120237 --- /dev/null +++ b/ckanext/ontario_theme/fanstatic/scripts/odc-access-level.js @@ -0,0 +1,70 @@ +// 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. + +/* + * CKAN module function for submitting form on checkbox selection and + * updating callout + * + * accessLevelBoxes + * All the access level checkboxes in the search bar + * openCheckbox + * The checkbox with value open + */ +"use strict"; + +ckan.module('access_level_checkboxes', function ($) { + return { + options: { + accessLevelBoxes: null, + openCheckbox: null, + }, + initialize: function () { + this.accessLevelBoxes = $('input[name="access_level"][type="checkbox"]'); + const params = new URLSearchParams(document.location.search); + this.openCheckbox = $("#checkbox-option-open"); + // "Open" checkbox checked by default + // else get access_level params and check the appropriate boxes + if (!params.has("access_level") && this.openCheckbox) { + this.openCheckbox.prop('checked', true); + } else if (params.has("access_level")) { + var selected_levels = params.getAll("access_level"); + selected_levels.forEach(function(e) { + $(`#checkbox-option-${e}`).prop('checked', true); + }); + } + // Update checkboxes and callout + $(this.accessLevelBoxes).on('change', jQuery.proxy(this._onChange, this)); + $(document).ready(jQuery.proxy(this._updateAccessLevelSentence, this)); + }, + _onChange: function () { + let form = $('form.search-form'); + form.submit(); + }, + _updateAccessLevelSentence: function () { + const selectedBoxes = $('input[name="access_level"]:checked'); + const calloutElement = $('#access-level-sentence-value'); + const and = this._(' and '); + const all_levels = this._('All levels'); + + var displayName = ""; + + // Update callout based on number of checkboxes checked and the value + if (selectedBoxes.length === this.accessLevelBoxes.length) { + displayName = all_levels; + } else if (selectedBoxes.length === 1) { + displayName = selectedBoxes.first().data('display-name'); + } else { + selectedBoxes.each(function(index) { + displayName += $(this).data('display-name'); + if (index < selectedBoxes.length - 1) { + displayName += and + } + }); + } + if (calloutElement) { + calloutElement.text(displayName); + } + } + } +}); diff --git a/ckanext/ontario_theme/fanstatic/scripts/odc-clear-filters.js b/ckanext/ontario_theme/fanstatic/scripts/odc-clear-filters.js index bd460c156..118644cf8 100644 --- a/ckanext/ontario_theme/fanstatic/scripts/odc-clear-filters.js +++ b/ckanext/ontario_theme/fanstatic/scripts/odc-clear-filters.js @@ -1,21 +1,27 @@ -(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')) { - params.delete(key); - } - } - window.location.href = `${url}?${params}`; +/* + * CKAN module function for submitting form with empty facets once the clear + * filters button is clicked + */ + +"use strict"; + +ckan.module('clear_filters', function ($) { + return { + initialize: function () { + const facetsSelected = $(".filtered.pill"); + if (facetsSelected.length >= 2) { + this.el.css({ display: "inline-block" }); + this.el.on('click', jQuery.proxy(this._onClick, this)); + } + }, + _onClick: function (event) { + $('#fields').empty(); + let 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/odc-facet-checkboxes.js b/ckanext/ontario_theme/fanstatic/scripts/odc-facet-checkboxes.js new file mode 100644 index 000000000..cb1b74d0e --- /dev/null +++ b/ckanext/ontario_theme/fanstatic/scripts/odc-facet-checkboxes.js @@ -0,0 +1,32 @@ +// 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. + +/* + * CKAN module function for submitting form on facet checkbox selection with + * CKAN's hidden form inputs + */ + +"use strict"; + +ckan.module('facet_checkboxes', function ($) { + return { + initialize: function () { + $(".facet-fieldset :checkbox").on('click', jQuery.proxy(this._onChange, this)); + }, + _onChange: function (event) { + const hiddenFields = $('#fields'); + 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(); + } + let form = $('form.search-form'); + form.submit(); + } + } +}); \ No newline at end of file diff --git a/ckanext/ontario_theme/fanstatic/scripts/odc-search.js b/ckanext/ontario_theme/fanstatic/scripts/odc-search.js index eb46383dc..342050787 100644 --- a/ckanext/ontario_theme/fanstatic/scripts/odc-search.js +++ b/ckanext/ontario_theme/fanstatic/scripts/odc-search.js @@ -35,10 +35,20 @@ const inputIds = [{ inputIds.forEach(input => { const textId = document.getElementById(input.textId); const resetId = document.getElementById(input.resetId); - if(textId && textId.value != ""){ - searchReset(resetId,textId); - } - if(textId){ + var typedText = ""; + + if (textId && resetId) { + textId.addEventListener("input", function(e) { + typedText = e.target.value; // Update typedText with current input value + }); + + resetId.addEventListener("click", function (e) { + e.preventDefault(); + textId.value = ""; + typedText = ""; + textId.focus(); + }); + textId.addEventListener("keyup", function (e) { if (e.key === "Escape" || e.keyCode === KEYCODE.ESCAPE) { resetId.click(); @@ -46,11 +56,4 @@ inputIds.forEach(input => { }); } }); - -function searchReset(resetId, textId) { - resetId.addEventListener("click", () => { - textId.defaultValue = ""; - textId.focus(); - }); -} })(); \ 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 10d4ff42a..5cfb1665a 100644 --- a/ckanext/ontario_theme/fanstatic/scripts/webassets.yml +++ b/ckanext/ontario_theme/fanstatic/scripts/webassets.yml @@ -8,13 +8,32 @@ ontario_theme_js: - odc-active-page.js - odc-active-tab.js - odc-search-modal.js - - odc-clear-filters.js - odc-toc-smooth-scroll.js ontario_theme_form_validators_js: filters: rjsmin contents: odc-dataset-form-validators.js output: ontario_theme_scripts/%(version)s_odc-dataset-form-validators.js + extra: + preload: + - vendor/jquery + - base/main + +ontario_theme_facet_checkboxes_js: + filters: rjsmin + contents: + - odc-facet-checkboxes.js + - odc-clear-filters.js + output: ontario_theme_scripts/%(version)s_odc-facet-checkboxes.js + extra: + preload: + - vendor/jquery + - base/main + +ontario_theme_access_level_js: + filters: rjsmin + contents: odc-access-level.js + output: ontario_theme_scripts/%(version)s_odc-access-level.js extra: preload: - vendor/jquery diff --git a/ckanext/ontario_theme/i18n/ckanext-ontario_theme.pot b/ckanext/ontario_theme/i18n/ckanext-ontario_theme.pot index e32b07b00..502dbc405 100644 --- a/ckanext/ontario_theme/i18n/ckanext-ontario_theme.pot +++ b/ckanext/ontario_theme/i18n/ckanext-ontario_theme.pot @@ -1319,19 +1319,19 @@ msgid "Please try another search or reach msgstr "" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:15 -msgid "{number} dataset found with the keyword(s) \"{query}\"" -msgid_plural "{number} datasets found with the keyword(s) \"{query}\"" +msgid "{number} total dataset found with the search term \"{query}\"" +msgid_plural "{number} total datasets found with the search term \"{query}\"" msgstr[0] "" msgstr[1] "" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:17 -msgid "{number} dataset found" -msgid_plural "{number} datasets found" +msgid "{number} total dataset found" +msgid_plural "{number} total datasets found" msgstr[0] "" msgstr[1] "" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:16 -msgid "No datasets found with the keyword(s) \"{query}\"" +msgid "No datasets found with the search term \"{query}\"" msgstr "" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:18 @@ -1339,13 +1339,13 @@ msgid "No datasets found" msgstr "" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:21 -msgid "{number} group found with the keyword(s) \"{query}\"" -msgid_plural "{number} groups found with the keyword(s) \"{query}\"" +msgid "{number} group found with the search term \"{query}\"" +msgid_plural "{number} groups found with the search term \"{query}\"" msgstr[0] "" msgstr[1] "" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:22 -msgid "No groups found with the keyword(s) \"{query}\"" +msgid "No groups found with the search term \"{query}\"" msgstr "" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:23 @@ -1360,12 +1360,12 @@ msgstr "" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:27 msgid "{number} ministry found for \"{query}\"" -msgid_plural "{number} ministries found with the keyword(s) \"{query}\"" +msgid_plural "{number} ministries found with the search term \"{query}\"" msgstr[0] "" msgstr[1] "" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:28 -msgid "No ministries found with the keyword(s) \"{query}\"" +msgid "No ministries found with the search term \"{query}\"" msgstr "" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:29 @@ -1378,6 +1378,16 @@ msgstr[1] "" msgid "No ministries found" msgstr "" +#: ckanext/ontario_theme/templates/internal/snippets/access_level_checkboxes.html:26 +msgid "{level_count} dataset with access level" +msgid_plural "{level_count} datasets with access level" +msgstr[0] "" +msgstr[1] "" + +#: ckanext/ontario_theme/templates/internal/snippets/search_form.html:242 +msgid "We also found" +msgstr "Nous avons également trouvé" + #: ckanext/ontario_theme/templates/internal/user/dashboard.html:6 msgid "Edit settings" msgstr "" @@ -1472,6 +1482,31 @@ msgstr "" msgid "Sort by" msgstr "" +#: ckanext/ontario_theme/fanstatic/scripts/odc-access.js:72 +msgid " and " +msgstr "" + +#: ckanext/ontario_theme/fanstatic/scripts/odc-access.js:73 +msgid "All levels" +msgstr "" + +#: ckanext/ontario_theme/templates/internal/snippets/search_form.html:83 +msgid "Showing datasets with access level" +msgstr "" + +#: ckanext/ontario_theme/templates/internal/snippets/search_form.html:199 +msgid "No datasets with access level" +msgstr "" + +#: ckanext/ontario_theme/templates/internal/snippets/search_form.html:195 +msgid "No datasets found with search term \"{query}\" and access level" +msgstr "" + +#: ckanext/ontario_theme/templates/internal/snippets/search_form.html:193 +msgid "Showing datasets found with search term \"{query}\" and access level" +msgstr "" + + #: ckanext/ontario_theme/templates/internal/snippets/search_form.html:111 msgid "Clear filters" msgstr "" 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 935af4308..4d19539ab 100644 Binary files a/ckanext/ontario_theme/i18n/fr/LC_MESSAGES/ckanext-ontario_theme.mo and b/ckanext/ontario_theme/i18n/fr/LC_MESSAGES/ckanext-ontario_theme.mo differ diff --git a/ckanext/ontario_theme/i18n/fr/LC_MESSAGES/ckanext-ontario_theme.po b/ckanext/ontario_theme/i18n/fr/LC_MESSAGES/ckanext-ontario_theme.po index a2406d130..f109527c2 100644 --- a/ckanext/ontario_theme/i18n/fr/LC_MESSAGES/ckanext-ontario_theme.po +++ b/ckanext/ontario_theme/i18n/fr/LC_MESSAGES/ckanext-ontario_theme.po @@ -108,10 +108,10 @@ msgstr[1] "{number} jeux de données" #: OVERRIDE: ckan/templates/snippets/search_result_text.html #: Datasets -msgid "{number} dataset found with the keyword(s) \"{query}\"" -msgid_plural "{number} datasets found with the keyword(s) \"{query}\"" -msgstr[0] "{number} jeu de données trouvé avec le(s) mot(s) clé(s) « {query} »" -msgstr[1] "{number} jeux de données trouvés avec le(s) mot(s) clé(s) « {query} »" +msgid "{number} total dataset found with the search term \"{query}\"" +msgid_plural "{number} total datasets found with the search term \"{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 msgid "Learn more about " @@ -120,8 +120,8 @@ msgid "accessing data using different formats." msgstr "l’accès aux données à l’aide de différents types de formats." #: ckan/templates/snippets/search_result_text.html:16 -msgid "No datasets found with the keyword(s) \"{query}\"" -msgstr "Aucun jeu de données trouvé avec le(s) mot(s) clé(s) « {query} »" +msgid "No datasets found with the search term \"{query}\"" +msgstr "Aucun jeu de données trouvé avec le terme de recherche « {query} »" #: ckanext/ontario_theme/templates/internal/snippets/facet_list.html:54 msgid "Show more" @@ -132,20 +132,20 @@ msgid "Show less" msgstr "Afficher moins" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:17 -msgid "{number} dataset found" -msgid_plural "{number} datasets found" -msgstr[0] "{number} jeu de données trouvé" -msgstr[1] "{number} jeux de données trouvés" +msgid "{number} total dataset found" +msgid_plural "{number} total datasets found" +msgstr[0] "{number} jeu de données total trouvé" +msgstr[1] "{number} total des jeux de données trouvés" #: Ministries msgid "{number} ministry found for \"{query}\"" -msgid_plural "{number} ministries found with the keyword(s) \"{query}\"" -msgstr[0] "{number} ministère trouvé avec le(s) mot(s) clé(s) « {query} »" -msgstr[1] "{number} ministères trouvés avec le(s) mot(s) clé(s) « {query} »" +msgid_plural "{number} ministries found with the search term \"{query}\"" +msgstr[0] "{number} ministère trouvé avec le terme de recherche « {query} »" +msgstr[1] "{number} ministères trouvés avec le terme de recherche « {query} »" #: OVERRIDE: ckan/templates/snippets/search_result_text.html:28 -msgid "No ministries found with the keyword(s) \"{query}\"" -msgstr "Aucun ministère trouvé avec le(s) mot(s) clé(s) « {query} »" +msgid "No ministries found with the search term \"{query}\"" +msgstr "Aucun ministère trouvé avec le terme de recherche « {query} »" #: OVERRIDE: ckan/templates/snippets/search_result_text.html:29 msgid "{number} ministry found" @@ -158,14 +158,14 @@ msgid "No ministries found" msgstr "Aucun ministère trouvé" #: Groups -msgid "{number} group found with the keyword(s) \"{query}\"" -msgid_plural "{number} groups found with the keyword(s) \"{query}\"" -msgstr[0] "{number} groupe trouvé avec le(s) mot(s) clé(s) « {query} »" -msgstr[1] "{number} groupes trouvés avec le(s) mot(s) clé(s) « {query} »" +msgid "{number} group found with the search term \"{query}\"" +msgid_plural "{number} groups found with the search term \"{query}\"" +msgstr[0] "{number} groupe trouvé avec le terme de recherche « {query} »" +msgstr[1] "{number} groupes trouvés avec le terme de recherche « {query} »" #: ckan/templates/snippets/search_result_text.html:22 -msgid "No groups found with the keyword(s) \"{query}\"" -msgstr "Aucun groupe trouvé avec le(s) mot(s) clé(s) « {query} »" +msgid "No groups found with the search term \"{query}\"" +msgstr "Aucun groupe trouvé avec le terme de recherche « {query} »" #: ckanext/ontario_theme/templates/internal/snippets/search_result_text.html:23 msgid "{number} group found" @@ -645,7 +645,7 @@ msgstr "\n" " Dans cette page\n" "\n" "Sauter les liens de navigation de cette page\n" -" + {% if not error %} +
+ {% snippet 'snippets/search_result_text.html', query=query, count=total_count, type=type %} +
+ {% else %} +
Error
+ {% endif %} {% endblock search_input %} {% block search_search_fields %} - {% if fields -%}{{ form.hidden_from_list(fields=fields) }}{%- endif %} - {% endblock search_search_fields %} + {%- asset "ontario_theme_scripts/ontario_theme_facet_checkboxes_js" -%} + + {% if fields -%} + {{ form.hidden_from_list(fields=fields, except_names=['access_level']) }} + {%- endif -%} + + {% endblock search_search_fields %} - {% block search_title %} - {% if not error %} -
- {% snippet 'snippets/search_result_text.html', query=query, count=count, type=type %} -
- {% else %} -
Error
- {% endif %} - {% endblock search_title %} + {% block search_title %} + {% if facets %} +
+
+ {{ _('Access level') }}{{ _(':') }} +
+ {% snippet 'snippets/access_level_checkboxes.html', checkboxes=true %} +
+
+
+ {% endif %} + {% endblock search_title %} - - {% block search_facets %} - {% if facets %} -

- {% if query %} - {# - Groups/Organizations don't have facets set or the - remove_field() function in their index() action. - Only show when facets and a query are available to avoid - missing attribute error. - #} - {% endif %} - {% if facets %} - {% for field in facets.fields %} - - {% set search_facets_items = facets.search.get(field)['items'] %} - - - {% if (not query and not loop.index0==0) or query %}and{% endif %} - {{ facets.titles.get(field) + _(':') if facets.titles.get(field) is not none }} - {% for field_value in facets.fields[field] %} - {% set dict = h.get_facet_items_dict(field)|selectattr("name", "equalto", field_value)|list if h.get_facet_items_dict(field) %} - {% set item = dict[0] if dict else ({'name': field_value, 'display_name': field_value }) %} - {{ h.snippet('snippets/translate_facets.html', fields=schema_dict, name=field, item=item) }} - {% set item_count = h.localised_number(item['count']) if item['count'] else 0 %} - - - {{ item.display_name }} ({{ item_count }}) - - - - - - {%- if loop.index == 1 -%}{%- endif -%} + + {% block search_facets %} + {% if facets %} +

+ {% for field in facets.fields %} + {% if field != 'access_level' %} + + {% set search_facets_items = facets.search.get(field)['items'] %} + + + {% if (not query and not loop.index0==0) or query %}and{% endif %} + {{ facets.titles.get(field) + _(':') if facets.titles.get(field) is not none }} + {% for field_value in facets.fields[field] %} + {% set dict = h.get_facet_items_dict(field, limit=limit)|selectattr("name", "equalto", field_value)|list if h.get_facet_items_dict(field, limit=limit) %} + {% set item = dict[0] if dict else ({'name': field_value, 'display_name': field_value }) %} + {{ h.snippet('snippets/translate_facets.html', fields=schema_dict, name=field, item=item) }} + {% set item_count = h.localised_number(item['count']) if item['count'] else 0 %} + + + {{ item.display_name }} ({{ item_count }}) + + + + + + {%- if loop.index == 1 -%}{%- endif -%} {% endfor %} + - + {% endif %} {% endfor %} - {% if c.fields|length >= 2 %} - + +

+ {% endif %} + {% endblock search_facets %} + + {% block search_sortby %} + {% if count != 0 %} + +
+
+
+ + + + + {{ _('Sort') }} + + + + + +
+ +
+
+ {% endif %} +
+ {% if facets %} + {% set border_highlight = "ontario-border-highlight--dark-blue" if count !=0 else "ontario-border-highlight--dark-taupe" %} + {% if count and query %} + {% set callout_text = _('Showing datasets found with search term "{query}" and access level') %} + {% elif not count and query %} + {% set callout_text = _('No datasets found with search term "{query}" and access level') %} + {% elif count %} + {% set callout_text = _("Showing datasets with access level") %} + {% else %} + {% set callout_text = _("No datasets with access level") %} {% endif %} +
+

+ {{ callout_text.format(query=query|escape)|safe }}{{ _(':') }} +

+
{% endif %} -

- {% endif %} - {% endblock search_facets %} - - {% block search_sortby %} - {% if count != 0 %} -
+ {% endblock search_sortby %} + {% if facets and count != 0 %} + -
- - -
-
-
-
- - - - - {{ _('Sort by') }} - - - - - -
- -
-
{% endif %} - {% endblock search_sortby %} - {% if facets and count != 0 %} - - {% endif %} - + - {% if show_empty and count == 0 and not error %} -

- {{ _('Please try another search or reach out to us if you think data is missing.') }} -

- {% endif %} - - {% if error %} - {% trans %} -

- There was an error while searching. Please try again. + {% if count == 0 and not error %} + {% if total_count != 0 %} +

+ {{ _('We also found') }}{{ _(":") }} +

+

+ {% endif %} +

+ {{ _('Please try another search or reach out to us if you think data is missing.') }}

- {% endtrans %} - {% endif %} + {% endif %} + + {% if error %} + {% trans %} +

+ There was an error while searching. Please try again. +

+ {% endtrans %} + {% endif %} 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 ecac14b45..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,18 +12,18 @@ #} {% if type == 'dataset' %} - {% set text_query = ungettext('{number} dataset found with the keyword(s) "{query}"', '{number} datasets found with the keyword(s) "{query}"', count) %} - {% set text_query_none = _('No datasets found with the keyword(s) "{query}"') %} - {% set text_no_query = ungettext('{number} dataset found', '{number} datasets found', 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} 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 keyword(s) "{query}"', '{number} groups found with the keyword(s) "{query}"', count) %} - {% set text_query_none = _('No groups found with the keyword(s) "{query}"') %} + {% set text_query = ungettext('{number} group found with the search term "{query}"', '{number} groups found with the search term "{query}"', count) %} + {% set text_query_none = _('No groups found with the search term "{query}"') %} {% set text_no_query = ungettext('{number} group found', '{number} groups found', count) %} {% set text_no_query_none = _('No groups found') %} {% elif type == 'ministry' %} - {% set text_query = ungettext('{number} ministry found for "{query}"', '{number} ministries found with the keyword(s) "{query}"', count) %} - {% set text_query_none = _('No ministries found with the keyword(s) "{query}"') %} + {% set text_query = ungettext('{number} ministry found for "{query}"', '{number} ministries found with the search term "{query}"', count) %} + {% set text_query_none = _('No ministries found with the search term "{query}"') %} {% set text_no_query = ungettext('{number} ministry found', '{number} ministries found', count) %} {% set text_no_query_none = _('No ministries found') %} {% else %} @@ -40,9 +40,9 @@ {%- endif -%} {% if query %} {%- if count -%} - {{ text_query.format(number=h.localised_number(count), query=query, type=type)|safe }} + {{ text_query.format(number=h.localised_number(count), query=query|escape, type=type)|safe }} {%- else -%} - {{ text_query_none.format(query=query, type=type)|safe }} + {{ text_query_none.format(query=query|escape, type=type)|safe }} {%- endif -%} {%- else -%} {%- if count -%}