Skip to content

Commit

Permalink
Merge pull request #7900 from JVickery-TBS/feature/datatables-processing
Browse files Browse the repository at this point in the history
Datatables Processing Visuals
  • Loading branch information
amercader committed Nov 24, 2023
2 parents dcdb7e7 + 4b5b23a commit ae30274
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/7900.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added processing and pre-processing indicators to Datatables Views.
13 changes: 13 additions & 0 deletions ckanext/datatablesview/assets/datatables_view.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ div.dataTables_scroll{
/* processing message should hover over table and be visible */
#dtprv_processing {
z-index: 100;
display: block;
}

#dtprv_processing.pre-init::after{
content: '';
display: block;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: white;
z-index: -1;
}

/* for table header, don't wrap */
Expand Down
11 changes: 10 additions & 1 deletion ckanext/datatablesview/assets/datatablesview.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,16 @@ this.ckan.module('datatables_view', function (jQuery) {
})

// init the datatable
$('#dtprv').on('preInit.dt', function (_event, _settings) {
// show loading indicator when first painting data into the table.
// useful with very large resources that take long to load
$('body.dt-view').css('visibility', 'visible');
$('#dtprv_processing').addClass('pre-init');
});
datatable = $('#dtprv').DataTable({
paging: true,
serverSide: true,
processing: false,
processing: true,
stateSave: statesaveflag,
stateDuration: stateduration,
colReorder: {
Expand Down Expand Up @@ -592,6 +598,9 @@ this.ckan.module('datatables_view', function (jQuery) {
api.page(gsavedPage)
}

// hide the pre-loading indicator background so the table is interactive when loading
$('#dtprv_processing').removeClass('pre-init');

// restore selected rows from state
if (typeof gsavedSelected !== 'undefined') {
api.rows(gsavedSelected).select()
Expand Down

0 comments on commit ae30274

Please sign in to comment.