From b34d025f5677fc2f1e67f3332af187e488c697aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= <jschneider@entrouvert.com>
Date: Wed, 30 Jul 2014 13:47:20 +0200
Subject: [PATCH] dossiers: render pause facturation comment expandable

Closes #5010
---
 .../dossiers/patientrecord_tab1_general.html       |  7 ++++--
 .../dossiers/patientrecord_tab3_contact.html       |  4 ++--
 calebasse/static/css/dossiers.css                  | 15 +++++++++++-
 calebasse/static/css/style.css                     | 11 ---------
 calebasse/static/js/calebasse.dossiers.js          | 27 ++++++++++++----------
 5 files changed, 36 insertions(+), 28 deletions(-)

diff --git a/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html b/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html
index 7192e12..0b4e7b6 100644
--- a/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html
+++ b/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html
@@ -90,8 +90,11 @@
       {{ form.confidential.label_tag }} : <span class="autosubmit">{{ form.confidential }}</span>
       <p id="pause-msg" style="display: none; font-size: 10px;">Pause facturation mise à jour</p>
       {{ form.pause.label_tag }} : <span class="autosubmit">{{ form.pause }}</span>
-      <br/><label>Commentaire de la pause facturation</label> <button class="save enable-on-change btn-maj">✔</button><br/>
-      {{ form.pause_comment }}
+      <br/><label class="expand-label">Commentaire de la pause facturation {% if object.pause_comment %}<span title="Un commentaire existe" class="icon-comment" style="display: inline"></span>{% endif %} [+]</label>
+      <span class="expand">
+        <button class="save enable-on-change btn-maj">✔</button><br/>
+        {{ form.pause_comment }}
+      </span>
 
     </div>
   </form>
diff --git a/calebasse/dossiers/templates/dossiers/patientrecord_tab3_contact.html b/calebasse/dossiers/templates/dossiers/patientrecord_tab3_contact.html
index 7cf1380..4c432ef 100644
--- a/calebasse/dossiers/templates/dossiers/patientrecord_tab3_contact.html
+++ b/calebasse/dossiers/templates/dossiers/patientrecord_tab3_contact.html
@@ -38,8 +38,8 @@
   </li>
   {% endif %}
   <span class="social-security-contact">
-    <label class="social-security-label">Infos d'assuré [+]</label>
-    <ul>
+    <label class="expand-label">Infos d'assuré [+]</label>
+    <ul class="expand">
       {% if contact.id == object.id %}
       {{ object.first_name }} <span class="lastname">{{ object.last_name }}</span>
       {% endif %}
diff --git a/calebasse/static/css/dossiers.css b/calebasse/static/css/dossiers.css
index dc958cf..392221b 100644
--- a/calebasse/static/css/dossiers.css
+++ b/calebasse/static/css/dossiers.css
@@ -126,4 +126,17 @@ div#tabs-4 div div.buttons {
 
 input[type=checkbox] + button {
     display: none;
-}
\ No newline at end of file
+}
+
+.expand-label {
+    cursor: pointer;
+}
+
+label.expand-label:hover {
+    font-weight: bold;
+}
+
+.expand {
+    display: none;
+}
+
diff --git a/calebasse/static/css/style.css b/calebasse/static/css/style.css
index 9f56490..2971ca8 100644
--- a/calebasse/static/css/style.css
+++ b/calebasse/static/css/style.css
@@ -1379,15 +1379,4 @@ div.statistic {
     list-style-type: none;
 }
 
-.social-security-label {
-    cursor: pointer;
-}
-
-label.social-security-label:hover {
-    font-weight: bold;
-}
-
-.social-security-contact ul {
-    display: none;
-}
 
diff --git a/calebasse/static/js/calebasse.dossiers.js b/calebasse/static/js/calebasse.dossiers.js
index 3ccc4ef..a031dd8 100644
--- a/calebasse/static/js/calebasse.dossiers.js
+++ b/calebasse/static/js/calebasse.dossiers.js
@@ -242,18 +242,6 @@ function load_tab3_addresses() {
               }
           });
       });
-    $('.social-security-label').click(function() {
-      var label = $(this).html();
-      var data = $(this).next();
-      if (($(data).is(':hidden'))) {
-        $(this).html(label.replace('+', '-'));
-        $(this).css("font-weight", "bold");
-      } else {
-        $(this).html(label.replace('-', '+'));
-        $(this).css("font-weight", "");
-      }
-      $(data).toggle();
-    });
     var hashes = location.hash.split('&');
     for (i in hashes) {
       if (hashes[i] == "newcontact") {
@@ -362,6 +350,21 @@ function load_tab8_medical() {
     var $tabs = $('#tabs').tabs({
       load: function(event, ui) {
         var tabid = $(ui.tab).attr('id');
+        $('.expand-label').click(function() {
+          var label = $(this).html();
+          var data = $(this).next();
+          console.log(data[0]);
+          if (($(data).is(':hidden'))) {
+            $(this).html(label.replace("[+]", "[-]"));
+            console.log("hidden");
+            $(this).css("font-weight", "bold");
+          } else {
+            console.log("not hidden");
+            $(this).html(label.replace("[-]", "[+]"));
+            $(this).css("font-weight", "");
+          }
+          $(data).toggle();
+        });
         if (tabid == "ui-id-1")
       load_tab1_general();
         else if (tabid == "ui-id-2")
-- 
2.0.1

