Skip to content

Commit

Permalink
Bug Fixes (openemr#7012)
Browse files Browse the repository at this point in the history
* Bug Fixes
- remove cards max height to prevent scroll on longer lists.

* - refresh issues on dialog close using close promise.

* - toggle cards icon for collapse state

* - persist stats widgets
- show correct initial card stat icon
- toggle cards open/close icons

* - add back card class otherwise will befault to white BG color

* - some restore session refresh
  • Loading branch information
sjpadgett committed Nov 13, 2023
1 parent 33697e0 commit 9c28f17
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 29 deletions.
50 changes: 24 additions & 26 deletions interface/patient_file/summary/demographics.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,11 @@ function load_location(location) {
?>

// load divs
placeHtml("stats.php", "stats_div", true);
placeHtml("stats.php", "stats_div", true).then(() => {
$('[data-toggle="collapse"]').on('click', function (e) {
updateUserVisibilitySetting(e);
});
});
placeHtml("pnotes_fragment.php", 'pnotes_ps_expand').then(() => {
// must be delegated event!
$(this).on("click", ".complete_btn", function() {
Expand Down Expand Up @@ -815,11 +819,6 @@ function openReminderPopup() {
<?php } elseif ($active_reminders || $all_allergy_alerts) { ?>
openReminderPopup();
<?php } ?>

// $(".card-title").on('click', "button", (e) => {
// console.debug("click");
// updateUserVisibilitySetting(e);
// });
});

/**
Expand All @@ -835,30 +834,33 @@ function openReminderPopup() {
const targetID = e.target.getAttribute("data-target");
const target = document.querySelector(targetID);
const targetStr = targetID.substring(1);

// test ensure at least an element we want.
if (target.classList.contains("collapse")) {
// who is icon. Easier to catch BS event than create one specific for this decision..
// Should always be icon target
let iconTarget = e.target.children[0] || e.target;
// toggle
if (iconTarget.classList.contains("fa-expand")) {
iconTarget.classList.remove('fa-expand');
iconTarget.classList.add('fa-compress');
}
else {
iconTarget.classList.remove('fa-compress');
iconTarget.classList.add('fa-expand');
}
}
let formData = new FormData();
formData.append("csrf_token_form", <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>);
formData.append("target", targetStr);
formData.append("mode", (target.classList.contains("show")) ? 0 : 1);

top.restoreSession();
const response = await fetch("../../../library/ajax/user_settings.php", {
method: "POST",
credentials: 'same-origin',
body: formData,
});

const update = await response.text();
return update;
}

// Update the User's visibility setting when the card header is clicked
function cardTitleButtonClickListener() {
const buttons = document.querySelectorAll(".card-title button[data-toggle='collapse']");
buttons.forEach((b) => {
b.addEventListener("click", (e) => {
updateUserVisibilitySetting(e);
});
});
return await response.text();
}

// JavaScript stuff to do when a new patient is set.
Expand Down Expand Up @@ -914,10 +916,6 @@ function setMyPatient() {
$(window).on('load', function() {
setMyPatient();
});

document.addEventListener("DOMContentLoaded", () => {
cardTitleButtonClickListener();
});
</script>

<style>
Expand All @@ -928,11 +926,11 @@ function setMyPatient() {
}

/* Short term fix. This ensures the problem list, allergies, medications, and immunization cards handle long lists without interuppting
the UI. This should be configurable and should go in a more appropriate place */
the UI. This should be configurable and should go in a more appropriate place
.pami-list {
max-height: 200px;
overflow-y: scroll;
}
} */

<?php
if (!empty($GLOBALS['right_justify_labels_demographics']) && ($_SESSION['language_direction'] == 'ltr')) { ?>
Expand Down
11 changes: 10 additions & 1 deletion interface/patient_file/summary/stats_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<script>

// callback from add_edit_issue.php:
// The close logic in add_edit_issue not working so dialog will do refresh
function refreshIssue(issue, title) {
top.restoreSession();
window.location=window.location;
Expand All @@ -67,7 +68,15 @@ function dopclick(id, category) {
top.restoreSession();
category = (category == 0) ? '' : category;
let dlg_url = 'add_edit_issue.php?issue=' + encodeURIComponent(id) + '&thistype=' + encodeURIComponent(category);
dlgopen(dlg_url, '_blank', 1280, 900, '', <?php echo xlj("Add/Edit Issue"); ?>);
// dlgopen will call top.restoreSession
dlgopen(dlg_url, '_blank', 1280, 900, '', <?php echo xlj("Add/Edit Issue"); ?>, {
allowDrag: false,
allowResize: true,
resolvePromiseOn: 'close',
}).then(() => {
top.restoreSession();
location.reload();
});
}

// Process click on number of encounters.
Expand Down
4 changes: 2 additions & 2 deletions templates/patient/card/card_base.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<section class="{{ card_container_class_list|default(['card', 'mb-2'])|join(' ') }} {{ card_bg_color }} {{ card_text_color }}">
<section class="{{ card_container_class_list|default(['card', 'mb-2'])|join(' ') }} card mb-2 {{ card_bg_color }} {{ card_text_color }}">
<div class="card-body p-1">
<h6 class="card-title mb-0 d-flex p-1 justify-content-between">
<button class="btn btn-sm btn-link" href="#" {% if forceAlwaysOpen != true %} data-toggle="collapse" data-target="#{{ id|attr }}" {% endif %} aria-expanded="true" aria-controls="{{ id|attr }}">{{ title|text }}</button>
<a class="text-left font-weight-bolder" href="#" {% if forceAlwaysOpen != true %} data-toggle="collapse" data-target="#{{ id|attr }}" {% endif %} aria-expanded="true" aria-controls="{{ id|attr }}">{{ title|text }}<i class="ml-1 fa fa-fw fa-sm {% if initiallyCollapsed %} fa-expand {% else %} fa-compress {% endif %}" data-target="#{{ id|attr }}"></i></a>
{% if auth %}
<span>
{% if card.canAdd() or btnLabel == "Add" %}
Expand Down

0 comments on commit 9c28f17

Please sign in to comment.