Skip to content

Commit

Permalink
fix frontend error handing of patient list ajax error (#4415)
Browse files Browse the repository at this point in the history
accidentally merged
[this](#4413) into Master,
reverted that. Will merge this into the `develop` branch.

Co-authored-by: Amy Chen <[email protected]>
  • Loading branch information
achen2401 and Amy Chen authored Oct 22, 2024
1 parent d16a766 commit 94843e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
20 changes: 18 additions & 2 deletions portal/static/js/src/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ let requestTimerId = 0;
errorElement.innerHTML = errorMessage;
}
},
clearError: function() {
var errorElement = document.getElementById("admin-table-error-message");
if (errorElement) {
errorElement.innerHTML = "";
}
},
injectDependencies: function () {
var self = this;
window.portalModules =
Expand Down Expand Up @@ -200,6 +206,8 @@ let requestTimerId = 0;
);
return;
}
//reset error
this.clearError();
this.patientDataAjaxRequest(params);
},
patientDataAjaxRequest: function (params) {
Expand All @@ -219,6 +227,12 @@ let requestTimerId = 0;
}
self.accessed = true;
params.success(results);
}).fail(function(xhr, status) {
console.log("Error ", xhr);
console.log("status", status);
self.setError("Error occurred loading data.");
params.success([]);
self.accessed = true;
});
},
handleCurrentUser: function () {
Expand Down Expand Up @@ -1229,11 +1243,12 @@ let requestTimerId = 0;
sync: true,
},
function (data) {
prefData = data || self.getDefaultTablePreference();
self.currentTablePreference = prefData;

if (!data || data.error) {
return false;
}
prefData = data || self.getDefaultTablePreference();
self.currentTablePreference = prefData;

if (setFilter) {
//set filter values
Expand Down Expand Up @@ -1303,6 +1318,7 @@ let requestTimerId = 0;
for (var item in prefData.filters) {
fname = "#adminTable .bootstrap-table-filter-control-" + item;
if ($(fname).length === 0) {
prefData.filters[item] = null;
continue;
}
//note this is based on the trigger event for filtering specify in the plugin
Expand Down
3 changes: 2 additions & 1 deletion portal/templates/admin/patients_by_org.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ <h4 class="tnth-headline">{{_("Patient List")}}</h4>
</thead>
</table>
</div>
<div id="admin-table-error-message" class="text-danger smaller-text"></div>
<br/>
<div id="admin-table-error-message" class="text-danger"></div>
{{ExportPopover()}}
</div>
{{ajaxDataScript(research_study_id=0)}}
Expand Down

0 comments on commit 94843e6

Please sign in to comment.