Finish the addresses page
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 30 Aug 2007 20:16:41 +0000 (22:16 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 30 Aug 2007 20:16:41 +0000 (22:16 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
htdocs/css/keynote.css
modules/profile/addresses.inc.php
templates/profile/adresses.address.tpl
templates/profile/adresses.tpl

index 3c1a22c..8261843 100644 (file)
@@ -216,6 +216,11 @@ td.action {
 }
 td.action a { padding: 0px 2px 0px 2px; }
 
+th.grayed {
+    background: url('../images/skins/keynote_bg_lighter.png') #848495 top left repeat-x fixed;
+    font-style: italic;
+}
+
 /*******************************************************************************
     4   Tableau de choix de skins
         [ Styles pour les tableaux de types de ceux des skins ]
index c94e119..4243527 100644 (file)
@@ -93,7 +93,17 @@ class ProfileAddress
                 unset($value[$key]);
             }
         }
-        $success = true;
+        $current = 0;
+        foreach ($value as $key=>&$adr) {
+            if (@$adr['current']) {
+                $current++;
+            }
+        }
+        if (!$init && $current != 1 && count($value) > 0) {
+            $success = false;
+        } else {
+            $success = true;
+        }
         foreach ($value as $key=>&$adr) {
             $this->geolocAddress($adr, $s);
             $this->cleanAddress($page, $adr);
index 949ac66..5b49c91 100644 (file)
 {assign var=adid value="addresses_$i"}
 <input type="hidden" name="{$adpref}[removed]" value="0"/>
 <input type="hidden" name="{$adpref}[datemaj]" value="{$adr.datemaj}"/>
-<table class="bicol" style="margin-bottom: 1em">
+<table class="bicol" style="display: none; margin-bottom: 1em" id="{$adid}_grayed">
+  <tr>
+    <th class="grayed">
+      <div style="float: right">
+        <a href="javascript:restoreAddress('{$adid}', '{$adpref}')">{icon name=arrow_refresh title="Restaurer l'adresse"}</a>
+      </div>
+      Restaurer l'adresse n°{$i+1}
+    </th>
+  </tr>
+</table>
+<table class="bicol" style="margin-bottom: 1em" id="{$adid}">
   <tr>
     <th>
       <div style="float: left">
index 237ba56..833d716 100644 (file)
@@ -28,6 +28,12 @@ function removeObject(id, pref)
   document.forms.prof_annu[pref + "[removed]"].value = "1";
 }
 
+function restoreObject(id, pref)
+{
+  document.getElementById(id).style.display = '';
+  document.forms.prof_annu[pref + "[removed]"].value = "0";
+}
+
 function getAddressElement(adrid, adelement)
 {
   return document.forms.prof_annu["addresses[" + adrid + "][" + adelement + "]"];
@@ -67,6 +73,16 @@ function removeAddress(id, pref)
 {
   removeObject(id, pref);
   checkCurrentAddress(null);
+  if (document.forms.prof_annu[pref + '[datemaj]'].value != '') {
+    document.getElementById(id + '_grayed').style.display = '';
+  }
+}
+
+function restoreAddress(id, pref)
+{
+  document.getElementById(id +  '_grayed').style.display = 'none';
+  checkCurrentAddress(null);
+  restoreObject(id, pref);
 }
 
 function addAddress()
@@ -75,8 +91,8 @@ function addAddress()
   while (getAddressElement(i, 'pub') != null) {
     i++;
   }
-  $("#add_adr").before('<div id="addresses_' + i + '"></div>');
-  Ajax.update_html('addresses_' + i, 'profile/ajax/address/' + i, checkCurrentAddress);
+  $("#add_adr").before('<div id="addresses_' + i + '_cont"></div>');
+  Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress);
 }
 
 function addTel(id)
@@ -95,7 +111,7 @@ function addTel(id)
 //]]></script>
 
 {foreach key=i item=adr from=$addresses}
-<div id="{"addresses_$i"}">
+<div id="{"addresses_`$i`_cont"}">
 {include file="profile/adresses.address.tpl" i=$i adr=$adr}
 </div>
 {/foreach}