Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datatables Loading Icon #1406

Merged
merged 3 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions ckanext/canada/assets/datatables/canada_datatables.css
Original file line number Diff line number Diff line change
@@ -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 ##
#######################*/
31 changes: 31 additions & 0 deletions ckanext/canada/assets/datatables/canada_datatables.js
Original file line number Diff line number Diff line change
@@ -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');

});

});
9 changes: 9 additions & 0 deletions ckanext/canada/assets/datatables/webassets.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions ckanext/canada/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('assets/datatables', 'canada_datatables')
config['ckan.auth.public_user_details'] = False
config['recombinant.definitions'] = """
ckanext.canada:tables/ati.yaml
Expand Down
15 changes: 15 additions & 0 deletions ckanext/canada/templates/public/datatables/datatables_view.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{% ckan_extends %}

{% block page %}
{{ super() }}
<div id="dtprv_processing" class="dataTables_processing card">
<div>
<div></div><div></div><div></div><div></div>
</div>
</div>
{% endblock %}

{%- block datatable_column_label -%}
{%- set label = 'label_' + h.lang() -%}
{%- set description = 'notes_' + h.lang() -%}
Expand Down Expand Up @@ -61,4 +70,10 @@
{%- endblock -%}
{% block google_analytics_footer %}{%- endblock -%}
{{ super() }}
{% asset 'canada_datatables/js' %}
{% endblock %}

{%- block styles %}
{{ super() }}
{% asset 'canada_datatables/css' %}
{%- endblock -%}
Loading