From c0d4df373ee2a4e00f58ed05df2febadddd45421 Mon Sep 17 00:00:00 2001 From: Serghei MIHAI Date: Thu, 21 Aug 2014 17:52:53 +0200 Subject: [PATCH 2/2] dossiers: remove block not matching date filter criteria while printing page Closes #3109 --- .../dossiers/patientrecord_tab5_actes_passes.html | 2 +- .../dossiers/patientrecord_tab6_next_rdv.html | 2 +- calebasse/static/js/calebasse.dossiers.js | 25 ++++++++++++++-------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/calebasse/dossiers/templates/dossiers/patientrecord_tab5_actes_passes.html b/calebasse/dossiers/templates/dossiers/patientrecord_tab5_actes_passes.html index 4a6e479..835425e 100644 --- a/calebasse/dossiers/templates/dossiers/patientrecord_tab5_actes_passes.html +++ b/calebasse/dossiers/templates/dossiers/patientrecord_tab5_actes_passes.html @@ -43,4 +43,4 @@ {% endfor %} {% endblock %} -{% block print-actions %}filter_date_bounds('#ui-tabs-5', '.frame td span.date');{% endblock %} +{% block print-actions %}filter_date_bounds('#ui-tabs-5', '.frame', 'td span.date');{% endblock %} diff --git a/calebasse/dossiers/templates/dossiers/patientrecord_tab6_next_rdv.html b/calebasse/dossiers/templates/dossiers/patientrecord_tab6_next_rdv.html index 5c1e479..63724ce 100644 --- a/calebasse/dossiers/templates/dossiers/patientrecord_tab6_next_rdv.html +++ b/calebasse/dossiers/templates/dossiers/patientrecord_tab6_next_rdv.html @@ -47,4 +47,4 @@ {% endblock %} -{% block print-actions %}filter_date_bounds('#ui-tabs-6', '.basic td span.date');{% endblock %} +{% block print-actions %}filter_date_bounds('#ui-tabs-6', '.basic', 'td span.date');{% endblock %} diff --git a/calebasse/static/js/calebasse.dossiers.js b/calebasse/static/js/calebasse.dossiers.js index 71bfe44..dc778fc 100644 --- a/calebasse/static/js/calebasse.dossiers.js +++ b/calebasse/static/js/calebasse.dossiers.js @@ -19,21 +19,28 @@ function print_cleanup() { }); } -function filter_date_bounds(tab, selector) { +function filter_date_bounds(tab, container, selector) { var from = $(tab + ' form.filter input[name=from]').datepicker('getDate'); var to = $(tab + ' form.filter input[name=to]').datepicker('getDate'); if (to) { to.setHours(23); to.setMinutes(59); to.setSeconds(59); } - $.each($(tab + ' ' + selector), function(){ - var current = $.datepicker.parseDate('d/m/yy', $(this).text()); - if (current < from || (to && current >= to)) { - $(this).parent().parent().addClass('screen-only'); - } else { - $(this).parent().parent().removeClass('screen-only'); + $.each($(tab + ' ' + container), function(element) { + var block = $(this); + block.addClass('screen-only'); + if ($(selector, $(this)).length) { + $.each($(selector, this), function() { + var current = $.datepicker.parseDate('d/m/yy', $(this).text()); + if (current < from || (to && current >= to)) { + $(this).parent().parent().addClass('screen-only'); + } else { + block.removeClass('screen-only'); + $(this).parent().parent().removeClass('screen-only'); + } + }); } - }); -} + }) +}; function load_add_address_dialog() { var str = $("#contactform").serialize(); -- 2.1.0