Skip to content

Commit

Permalink
fix deleted account rows
Browse files Browse the repository at this point in the history
  • Loading branch information
Amy Chen committed Oct 2, 2024
1 parent 25d2532 commit 6ca5b98
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
30 changes: 19 additions & 11 deletions portal/static/js/src/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,23 +478,27 @@ import {EPROMS_MAIN_STUDY_ID, EPROMS_SUBSTUDY_ID} from "./data/common/consts.js"
$("#include_test_role").on("click", function() {
// self.showLoader();
// $("#frmTestUsers").submit();
$("#adminTable").bootstrapTable('refresh');
$("#adminTable").bootstrapTable("refresh");
});
}
},
initRowEvent: function() {
handleDeletedAccountRows: function(tableData) {
const rows = tableData && tableData.rows ? tableData.rows : [];
$("#adminTable tbody tr").each(function() {
$(this).off("click").on("click", (e) => {
e.stopPropagation();
window.location = "/patients/patient_profile/" + $(this).attr("data-uniqueid");
})
const rowId = $(this).attr("data-uniqueid");
const isDeleted = rows.find(o => parseInt(o.id) === parseInt(rowId) && o.deleted);
if (!!isDeleted) {
$(this).addClass("deleted-user-row");
}
})
},
initTableEvents: function () {
var self = this;
$("#adminTable").on("post-body.bs.table", function() {
self.setContainerVis();
self.initRowEvent();
});
$("#adminTable").on("load-success.bs.table", function(e, data) {
self.handleDeletedAccountRows(data);
});
$("#adminTable").on("reset-view.bs.table", function () {
self.addFilterPlaceHolders();
Expand All @@ -505,6 +509,11 @@ import {EPROMS_MAIN_STUDY_ID, EPROMS_SUBSTUDY_ID} from "./data/common/consts.js"
self.resetRowVisByActivationStatus();
self.setRowItemEvent();
});
$("#adminTable").on("click-row.bs.table", function(e, row, $element, field) {
e.stopPropagation();
if (row.deleted) return;
window.location = "/patients/patient_profile/" + $element.attr("data-uniqueid");
});
$(window).bind("scroll mousedown mousewheel keyup", function () {
if ($("html, body").is(":animated")) {
$("html, body").stop(true, true);
Expand Down Expand Up @@ -758,8 +767,6 @@ import {EPROMS_MAIN_STUDY_ID, EPROMS_SUBSTUDY_ID} from "./data/common/consts.js"
var orgFields = $("#userOrgs input[name='organization']");
var fi = this.currentTablePreference ? this.currentTablePreference.filters : {};
var fa = this.siteFilterApplied() ? fi.orgs_filter_control : [];
let ot = this.getOrgTool();
let isSubStudyPatientView = this.isSubStudyPatientView();
orgFields.each(function () {
$(this).prop("checked", false);
var oself = $(this),
Expand Down Expand Up @@ -907,8 +914,9 @@ import {EPROMS_MAIN_STUDY_ID, EPROMS_SUBSTUDY_ID} from "./data/common/consts.js"
// this ensures that the table filter preference is saved before reloading the page
// so the backend can present patient list based on that saved preference
setTimeout(function () {
this.showLoader();
location.reload();
// this.showLoader();
// location.reload();
$("#adminTable").bootstrapTable("refresh");
}.bind(this), 350);
}.bind(this));
},
Expand Down
4 changes: 2 additions & 2 deletions portal/templates/admin/admin_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<caption id="frmTestUsersContainer" class="tnth-hide">
<form id="frmTestUsers" method="GET" action="{{postUrl}}">
<label class="text-normal text-warning">
<input type="checkbox" name="include_test_role" id="include_test_role" value="True" checked/>
<input type="checkbox" name="include_test_role" id="include_test_role" value="True" />
{{_("include test accounts")}}
</label>
</form>
Expand Down Expand Up @@ -92,7 +92,7 @@
{%- macro ajaxDataScript() -%}
<script>
// custom ajax request here
function ajaxRequest(params) {
function patientDataAjaxRequest(params) {
console.log("param data ? ", $.param(params.data));
var includeTestUsers = $("#include_test_role").is(":checked");
//search=&sort=userid&order=desc&offset=0&limit=10
Expand Down
2 changes: 1 addition & 1 deletion portal/templates/admin/patients_by_org.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h4 class="tnth-headline">{{_("Patient List")}}</h4>
data-id-field="id"
data-filter-control="true"
data-side-pagination="server"
data-ajax="ajaxRequest"
data-ajax="patientDataAjaxRequest"
{%- if not isResearcher -%} data-show-export="true" {%- endif -%}
data-export-data-type="all"
>
Expand Down
2 changes: 1 addition & 1 deletion portal/templates/admin/patients_substudy.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h2>{{list_title}}</h2>
data-id-field="id"
data-filter-control="true"
data-side-pagination="server"
data-ajax="ajaxRequest"
data-ajax="patientDataAjaxRequest"
{%- if not isResearcher -%} data-show-export="true" {%- endif -%}
data-export-data-type="all"
>
Expand Down

0 comments on commit 6ca5b98

Please sign in to comment.