Skip to content

Commit

Permalink
Merge pull request #615 from NASA-IMPACT/614-solve-the-paging-issue-o…
Browse files Browse the repository at this point in the history
…n-candidate-url-curation-page

stopped ajax reoad every time a change is made which stops the automa…
  • Loading branch information
CarsonDavis authored Mar 27, 2024
2 parents 0133d86 + d1dcb29 commit 5608086
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions sde_indexing_helper/static/js/candidate_url_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ function initializeDataTable() {
"selector": 'td:nth-child(5)'
},
'rowId': 'url',
"stateLoadCallback": function (settings) {
var state = JSON.parse(localStorage.getItem('DataTables_candidate_urls_' + window.location.pathname));
if (!state) {
settings.oInit.pageLength = 1;
}
return state;
},
"ajax": {
"url": `/api/candidate-urls/?format=datatables&collection_id=${collection_id}`,
"data": function (d) {
Expand Down Expand Up @@ -350,8 +357,8 @@ function postDocumentTypePatterns(match_pattern, match_pattern_type, document_ty
csrfmiddlewaretoken: csrftoken
},
success: function (data) {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#document_type_patterns_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
$('#document_type_patterns_table').DataTable().ajax.reload(null, false);
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
Expand All @@ -377,8 +384,8 @@ function postExcludePatterns(match_pattern, match_pattern_type = 0) {
csrfmiddlewaretoken: csrftoken
},
success: function (data) {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#exclude_patterns_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
$('#exclude_patterns_table').DataTable().ajax.reload(null, false);
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
Expand All @@ -403,8 +410,8 @@ function postIncludePatterns(match_pattern, match_pattern_type = 0) {
csrfmiddlewaretoken: csrftoken
},
success: function (data) {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#include_patterns_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
$('#include_patterns_table').DataTable().ajax.reload(null, false);
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
Expand All @@ -430,8 +437,8 @@ function postTitlePatterns(match_pattern, title_pattern, match_pattern_type = 1)
csrfmiddlewaretoken: csrftoken
},
success: function (data) {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#title_patterns_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
$('#title_patterns_table').DataTable().ajax.reload(null, false);
},
error: function (xhr, status, error) {
var errorMessage = xhr.responseText;
Expand Down Expand Up @@ -475,11 +482,11 @@ function deletePattern(url, data_type, url_type = null, candidate_urls_count = n
'X-CSRFToken': csrftoken
},
success: function (data) {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#exclude_patterns_table').DataTable().ajax.reload();
$('#include_patterns_table').DataTable().ajax.reload();
$('#title_patterns_table').DataTable().ajax.reload();
$('#document_type_patterns_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
$('#exclude_patterns_table').DataTable().ajax.reload(null, false);
$('#include_patterns_table').DataTable().ajax.reload(null, false);
$('#title_patterns_table').DataTable().ajax.reload(null, false);
$('#document_type_patterns_table').DataTable().ajax.reload(null, false);
}
});
}
Expand Down Expand Up @@ -645,5 +652,5 @@ $('.document_type_form_select').on('click', function (e) {
});

$('#filter-checkbox').on('change', function () {
$('#candidate_urls_table').DataTable().ajax.reload();
$('#candidate_urls_table').DataTable().ajax.reload(null, false);
});

0 comments on commit 5608086

Please sign in to comment.