LSrelation : fixed refresh bug when multiple relations content the same object
authorBenjamin Renard <brenard@easter-eggs.com>
Thu, 28 Nov 2013 19:51:43 +0000 (20:51 +0100)
committerBenjamin Renard <brenard@easter-eggs.com>
Thu, 28 Nov 2013 19:51:43 +0000 (20:51 +0100)
public_html/includes/class/class.LSrelation.php
public_html/includes/js/LSrelation.js
public_html/templates/default/LSrelations.tpl

index 6eaa9f4..8ea449b 100644 (file)
@@ -205,7 +205,7 @@ class LSrelation {
                             else {
                               $class=' LSrelation_editable';
                             }
-                            $data['html'].= "<li class='LSrelation'><a href='view.php?LSobject=".$relationConf['LSobject']."&amp;dn=".urlencode($o -> getDn())."' class='LSrelation$class' id='".$o -> getDn()."'>".$o -> getDisplayName(NULL,true)."</a></li>\n";
+                            $data['html'].= "<li class='LSrelation'><a href='view.php?LSobject=".$relationConf['LSobject']."&amp;dn=".urlencode($o -> getDn())."' class='LSrelation$class' id='LSrelation_".$_REQUEST['id']."_".$o -> getDn()."'>".$o -> getDisplayName(NULL,true)."</a></li>\n";
                           }
                         }
                         else {
@@ -288,7 +288,8 @@ class LSrelation {
                     }
                     else {
                       $data=array(
-                        'dn' => $_REQUEST['dn']
+                        'dn' => $_REQUEST['dn'],
+                        'id' => $_REQUEST['id']
                       );
                     }
                   }
index 1e88275..110d349 100644 (file)
@@ -69,7 +69,7 @@ var LSrelation = new Class({
         template:   'LSrelation',
         action:     'deleteByDn',
         id:         id,
-        dn:         a.id
+        dn:         this.a2dn(a)
       };
       data.imgload=varLSdefault.loadingImgDisplay(li,'inside');
       new Request({url: 'index_ajax.php', data: data, onSuccess: this.deleteFromImgComplete.bind(this)}).send();
@@ -79,8 +79,8 @@ var LSrelation = new Class({
       var data = JSON.decode(responseText);
       if ( varLSdefault.checkAjaxReturn(data) ) {
         try  {
-          var li = $(data.dn).getParent();
-          var ul=$(data.dn).getParent().getParent();
+          var ul=$('LSrelation_ul_'+data.id);
+          var li = $('LSrelation_'+data.id+'_'+data.dn).getParent();
           li.destroy();
           if (!$type(ul.getFirst())) {
             var getId = /LSrelation_ul_([0-9]*)/
@@ -141,6 +141,11 @@ var LSrelation = new Class({
         $('LSrelation_ul_'+this.refreshRelation).set('html',data.html);
         this.initializeBtn();
       }
+    },
+
+    a2dn: function(a) {
+      var getId = /LSrelation_[0-9]*_(.*)$/
+      return getId.exec(a.id)[1];
     }
 
 });
index 8f8628b..c16b3b6 100644 (file)
@@ -8,7 +8,7 @@
 {/if}
 <ul id='LSrelation_ul_{$item.id}' class='LSrelation'>
 {foreach from=$item.objectList item=object}
-  <li class='LSrelation'><a href='view.php?LSobject={$item.LSobject}&amp;dn={$object.dn|escape:'url'}' class='LSrelation{if $object.canEdit} LSrelation_editable{/if}' id='{$object.dn}'>{$object.text}</a></li>
+  <li class='LSrelation'><a href='view.php?LSobject={$item.LSobject}&amp;dn={$object.dn|escape:'url'}' class='LSrelation{if $object.canEdit} LSrelation_editable{/if}' id='LSrelation_{$item.id}_{$object.dn}'>{$object.text}</a></li>
 {foreachelse}
   <li class='LSrelation'>{$item.emptyText}</li>
 {/foreach}