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

Fixup/table preference #4411

Merged
merged 2 commits into from
Oct 16, 2024
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
3 changes: 2 additions & 1 deletion portal/static/js/src/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,8 @@ let requestTimerId = 0;
) {
var tnthAjax = this.getDependency("tnthAjax");
tableName = tableName || this.tableIdentifier;
if (!tableName) {
if (!tableName || !document.querySelector("#adminTable")) {
if (callback) callback();
return false;
}
userId = userId || this.userId;
Expand Down
10 changes: 10 additions & 0 deletions portal/static/js/src/modules/TnthAjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ export default { /*global $ */
$.ajax("/api/me").done(
function() {
console.log("user authorized");
if ((typeof CsrfTokenChecker !== "undefined") &&
!CsrfTokenChecker.checkTokenValidity()) {
//if CSRF Token not valid, return error
if (callback) {
callback({"error": DEFAULT_SERVER_DATA_ERROR});
fieldHelper.showError(targetField);
}
return;
}

ajaxCall();
}
).fail(function() {
Expand Down
2 changes: 2 additions & 0 deletions portal/templates/admin/admin_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
// custom ajax request here
function patientDataAjaxRequest(params) {
loadIntervalId = setInterval(() => {
//document DOM not ready, don't make ajax call yet
if (!document.querySelector("#adminTable")) return;
if (typeof window.AdminObj === "undefined") return;
window.AdminObj.getRemotePatientListData(params);
clearInterval(loadIntervalId);
Expand Down