Move patient detail page specific js code in a dedicated module.

This commit is contained in:
Mikaël Ates 2015-11-03 18:51:26 +01:00
parent 46c5054c5b
commit c3bc156912
2 changed files with 92 additions and 7 deletions

View File

@ -0,0 +1,88 @@
/*
biomon - Signs monitoring and patient management application
Copyright (C) 2015 Entr'ouvert
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
(function($) {
$(function() {
/*
Last visited tab
*/
$("div#tabs").tabs();
var tab_active;
$('a.patient-tab').click(function() {
$.cookie('patient-last-tab', $(this).attr('id'), { path: location.pathname });
tab_active = $(this).attr('id');
if ( tab_active == 'tab-alert' ) {
ALERTS.refresh_alerts();
} else {
ALERTS.stop_refresh_alerts();
}
if ( tab_active == 'tab-dashboard' ) {
DASHBOARD.refresh(true);
} else {
DASHBOARD.stop_refresh(true);
}
});
if ($.cookie('patient-last-tab')) {
tab_active = $.cookie('patient-last-tab');
$('a#' + $.cookie('patient-last-tab')).click();
};
/*
Open/close patient file
$(this) must be referenced for used in ajax callback
functions : http://bugs.jquery.com/ticket/7624
*/
$('i.patient-enabler').click(function() {
var target = $(this);
var value = '';
if (target.hasClass('disabled')) {value = 'on';}
$.ajax({
type: 'post',
url: target.attr('action'),
data: {enabled: value},
success: function() {
if(value == ''){
target.switchClass("fa-folder-open enabled", "fa-folder disabled", 0);
} else {
target.switchClass("fa-folder disabled", "fa-folder-open enabled", 0);
};
UTILS.show_message(gettext("Patient record updated."));
},
error: function(xhr, ajaxOptions, thrownError) {
UTILS.show_message(gettext("Patient record not updated !"));
}
});
});
/*
Refresh open events figures in identification bar
*/
ALERTS.refresh_alerts_stats(true);
/*
Alert tab
*/
/* At beginning hide titles, if episodes they'll be displayed in fine */
$('div#running-alerts span#running').hide();
$('div#closed-alerts span#closed').hide();
})
})(jQuery);

View File

@ -1,6 +1,10 @@
{% extends "biomon/base.html" %}
{% load i18n %}
{% block extra_scripts %}
<script type="text/javascript" src="{{ STATIC_URL }}biomon/js/biomon.patientdetail.js"></script>
{% endblock %}
{% block content-1-right %}
<div id="identification">
<i class="fa patient-enabler hvr-pulse-shrink {% if not patient.enabled %}disabled fa-folder{% else %}enabled fa-folder-open{% endif %}" action="{% url 'patient_update_enabled_field' pk=patient.pk %}"></i>
@ -175,10 +179,3 @@
</div>
</div>
{% endblock %}
{% block extra_end_scripts %}
<script>
$(document).ready(function(){
patient_detail();
});
</script>
{% endblock %}