From a465d96504e207742b7e719caba765cb77178d34 Mon Sep 17 00:00:00 2001 From: Jesse Vickery Date: Wed, 13 Sep 2023 20:02:17 +0000 Subject: [PATCH 1/3] feat(templates): loading icon for datatables; - Added html loading icon and behavior for datatables. --- .../canada/public/css/canada_datatables.css | 28 +++++++++++++++++ .../public/static/js/canada_datatables.js | 31 +++++++++++++++++++ .../public/datatables/datatables_view.html | 15 +++++++++ 3 files changed, 74 insertions(+) create mode 100644 ckanext/canada/public/css/canada_datatables.css create mode 100644 ckanext/canada/public/static/js/canada_datatables.js diff --git a/ckanext/canada/public/css/canada_datatables.css b/ckanext/canada/public/css/canada_datatables.css new file mode 100644 index 000000000..0e7418643 --- /dev/null +++ b/ckanext/canada/public/css/canada_datatables.css @@ -0,0 +1,28 @@ +/*#################### +## Datatables Views ## +######################*/ +div#dtprv_processing.dataTables_processing{ + z-index: 9999 !important; + top: 0 !important; + left: 0 !important; + width: 100% !important; + height: 100% !important; + margin: 0 !important; + /* see static/js/canada_datatables for dynamic styles */ +} +div#dtprv_processing.dataTables_processing > div:last-child{ + position: absolute !important; + left: 50% !important; + transform: translate(-50%, -50%) !important; + pointer-events: none !important; + /* see static/js/canada_datatables for dynamic styles */ +} +div#dtprv_processing.dataTables_processing > div:last-child > div{ + background-color: #335075 !important; + pointer-events: none !important; +} +/*##################### +## END ## +## Datatables Views ## +## END ## +#######################*/ diff --git a/ckanext/canada/public/static/js/canada_datatables.js b/ckanext/canada/public/static/js/canada_datatables.js new file mode 100644 index 000000000..70591416d --- /dev/null +++ b/ckanext/canada/public/static/js/canada_datatables.js @@ -0,0 +1,31 @@ +window.addEventListener('load', function(){ + + $(document).on('preInit.dt', function(_event, _settings){ + + $('body.dt-view').css('visibility', 'visible'); + $('#dtprv_processing').css({ + 'background-color': 'rgba(255, 255, 255, 1)', + 'display': 'block', + 'pointer-events': 'all', + }); + $('#dtprv_processing > div').css('top', '15%'); + + }); + + $(document).on('init.dt', function(){ + + $('#dtprv_processing').css({ + 'background-color': 'rgba(255, 255, 255, 0.65)', + 'pointer-events': 'none', + }); + $('#dtprv_processing > div').css('top', '50%'); + + }); + + $(document).on('processing.dt', function(_event, _settings, _processing){ + + $('#dtprv_processing').css('display', _processing ? 'block' : 'none'); + + }); + +}); diff --git a/ckanext/canada/templates/public/datatables/datatables_view.html b/ckanext/canada/templates/public/datatables/datatables_view.html index 5b12fb32f..269ed765c 100644 --- a/ckanext/canada/templates/public/datatables/datatables_view.html +++ b/ckanext/canada/templates/public/datatables/datatables_view.html @@ -1,5 +1,14 @@ {% ckan_extends %} +{% block page %} + {{ super() }} +
+
+
+
+
+{% endblock %} + {%- block datatable_column_label -%} {%- set label = 'label_' + h.lang() -%} {%- set description = 'notes_' + h.lang() -%} @@ -61,4 +70,10 @@ {%- endblock -%} {% block google_analytics_footer %}{%- endblock -%} {{ super() }} + {% endblock %} + +{%- block styles %} + {{ super() }} + +{%- endblock -%} From 5e125778ab3816a6ad0fa06887e83773e942c677 Mon Sep 17 00:00:00 2001 From: Jesse Vickery Date: Thu, 14 Sep 2023 20:35:28 +0000 Subject: [PATCH 2/3] feat(templates): use webassets; - Used webassets. --- ckanext/canada/plugins.py | 1 + .../public/{css => datatables}/canada_datatables.css | 0 .../{static/js => datatables}/canada_datatables.js | 0 ckanext/canada/public/datatables/webassets.yml | 9 +++++++++ .../templates/public/datatables/datatables_view.html | 4 ++-- 5 files changed, 12 insertions(+), 2 deletions(-) rename ckanext/canada/public/{css => datatables}/canada_datatables.css (100%) rename ckanext/canada/public/{static/js => datatables}/canada_datatables.js (100%) create mode 100644 ckanext/canada/public/datatables/webassets.yml diff --git a/ckanext/canada/plugins.py b/ckanext/canada/plugins.py index fe3fdb60c..80dc1b089 100755 --- a/ckanext/canada/plugins.py +++ b/ckanext/canada/plugins.py @@ -448,6 +448,7 @@ def update_config(self, config): p.toolkit.add_template_directory(config, 'templates/public') p.toolkit.add_public_directory(config, 'public') p.toolkit.add_resource('public/static/js', 'js') + p.toolkit.add_resource('public/datatables', 'canada_datatables') config['ckan.auth.public_user_details'] = False config['recombinant.definitions'] = """ ckanext.canada:tables/ati.yaml diff --git a/ckanext/canada/public/css/canada_datatables.css b/ckanext/canada/public/datatables/canada_datatables.css similarity index 100% rename from ckanext/canada/public/css/canada_datatables.css rename to ckanext/canada/public/datatables/canada_datatables.css diff --git a/ckanext/canada/public/static/js/canada_datatables.js b/ckanext/canada/public/datatables/canada_datatables.js similarity index 100% rename from ckanext/canada/public/static/js/canada_datatables.js rename to ckanext/canada/public/datatables/canada_datatables.js diff --git a/ckanext/canada/public/datatables/webassets.yml b/ckanext/canada/public/datatables/webassets.yml new file mode 100644 index 000000000..e67a446c0 --- /dev/null +++ b/ckanext/canada/public/datatables/webassets.yml @@ -0,0 +1,9 @@ +css: + contents: + - canada_datatables.css + output: canada_datatables/%(version)s_canada_datatables.css + +js: + contents: + - canada_datatables.js + output: canada_datatables/%(version)s_canada_datatables.js diff --git a/ckanext/canada/templates/public/datatables/datatables_view.html b/ckanext/canada/templates/public/datatables/datatables_view.html index 269ed765c..2ae3d89d7 100644 --- a/ckanext/canada/templates/public/datatables/datatables_view.html +++ b/ckanext/canada/templates/public/datatables/datatables_view.html @@ -70,10 +70,10 @@ {%- endblock -%} {% block google_analytics_footer %}{%- endblock -%} {{ super() }} - + {% asset 'canada_datatables/js' %} {% endblock %} {%- block styles %} {{ super() }} - + {% asset 'canada_datatables/css' %} {%- endblock -%} From 5f1ddfe5fddfe7f8d02c319bb0aed7635e1a6ce3 Mon Sep 17 00:00:00 2001 From: Jesse Vickery Date: Fri, 15 Sep 2023 14:17:39 +0000 Subject: [PATCH 3/3] feat(assets): moved datatables assets out of public; - Moved datatables assets to `assets` directory. --- .../canada/{public => assets}/datatables/canada_datatables.css | 0 .../canada/{public => assets}/datatables/canada_datatables.js | 0 ckanext/canada/{public => assets}/datatables/webassets.yml | 0 ckanext/canada/plugins.py | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) rename ckanext/canada/{public => assets}/datatables/canada_datatables.css (100%) rename ckanext/canada/{public => assets}/datatables/canada_datatables.js (100%) rename ckanext/canada/{public => assets}/datatables/webassets.yml (100%) diff --git a/ckanext/canada/public/datatables/canada_datatables.css b/ckanext/canada/assets/datatables/canada_datatables.css similarity index 100% rename from ckanext/canada/public/datatables/canada_datatables.css rename to ckanext/canada/assets/datatables/canada_datatables.css diff --git a/ckanext/canada/public/datatables/canada_datatables.js b/ckanext/canada/assets/datatables/canada_datatables.js similarity index 100% rename from ckanext/canada/public/datatables/canada_datatables.js rename to ckanext/canada/assets/datatables/canada_datatables.js diff --git a/ckanext/canada/public/datatables/webassets.yml b/ckanext/canada/assets/datatables/webassets.yml similarity index 100% rename from ckanext/canada/public/datatables/webassets.yml rename to ckanext/canada/assets/datatables/webassets.yml diff --git a/ckanext/canada/plugins.py b/ckanext/canada/plugins.py index 80dc1b089..a13443432 100755 --- a/ckanext/canada/plugins.py +++ b/ckanext/canada/plugins.py @@ -448,7 +448,7 @@ def update_config(self, config): p.toolkit.add_template_directory(config, 'templates/public') p.toolkit.add_public_directory(config, 'public') p.toolkit.add_resource('public/static/js', 'js') - p.toolkit.add_resource('public/datatables', 'canada_datatables') + p.toolkit.add_resource('assets/datatables', 'canada_datatables') config['ckan.auth.public_user_details'] = False config['recombinant.definitions'] = """ ckanext.canada:tables/ati.yaml