From 95b3854e461fd80e8f3b97ff7394fec92d92b9d0 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 8 Oct 2008 15:34:36 +0000 Subject: [PATCH] LSrelation : -> Revue de la mise en forme -> Revue de la structure de
  • (supression des ) -> Mise en place d'un texte quand plus aucun objet est en relation --- trunk/includes/js/LSrelation.js | 30 ++++++++++++++++++++---------- trunk/index_ajax.php | 11 ++++++++--- trunk/templates/LSrelations.tpl | 6 ++++-- trunk/templates/css/LSrelation.css | 10 +++++++--- trunk/view.php | 13 +++++++++++++ 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/trunk/includes/js/LSrelation.js b/trunk/includes/js/LSrelation.js index 55f1af8a..dc2a38d8 100644 --- a/trunk/includes/js/LSrelation.js +++ b/trunk/includes/js/LSrelation.js @@ -19,24 +19,23 @@ var LSrelation = new Class({ el.destroy(); }, this); this.deleteBtnId = 0; - $$('li.LSrelation').each(function(li) { + $$('a.LSrelation').each(function(a) { this.deleteBtn[this.deleteBtnId] = new Element('img'); this.deleteBtn[this.deleteBtnId].src = 'templates/images/delete.png'; this.deleteBtn[this.deleteBtnId].setStyle('cursor','pointer'); this.deleteBtn[this.deleteBtnId].addClass('LSrelation-btn'); this.deleteBtn[this.deleteBtnId].addEvent('click',this.onDeleteBtnClick.bind(this,this.deleteBtn[this.deleteBtnId])); - this.deleteBtn[this.deleteBtnId].injectInside(li); - li.id=this.deleteBtnId; + this.deleteBtn[this.deleteBtnId].injectAfter(a); + a.getParent().id=this.deleteBtnId; this.deleteBtnId++; }, this); }, onDeleteBtnClick: function(img) { if (this._confirmDelete) { - var li = img.getParent(); - var span = li.getFirst().getFirst('span'); + var a = img.getPrevious('a'); this.confirmBox = new LSconfirmBox({ - text: 'Etês-vous sur de vouloir supprimer "'+span.innerHTML+'" ?', + text: 'Etês-vous sur de vouloir supprimer "'+a.innerHTML+'" ?', startElement: img, onConfirm: this.deleteFromImg.bind(this,img) }); @@ -48,7 +47,7 @@ var LSrelation = new Class({ deleteFromImg: function(img) { var li = img.getParent(); - var span = li.getFirst().getFirst('span'); + var a = img.getPrevious('a'); var ul = li.getParent(); img.destroy(); LSdebug(ul.id); @@ -59,9 +58,9 @@ var LSrelation = new Class({ template: 'LSrelation', action: 'deleteByDn', id: id, - dn: span.id + dn: a.id }; - data.imgload=varLSdefault.loadingImgDisplay(li.id,'inside'); + data.imgload=varLSdefault.loadingImgDisplay(li,'inside'); new Request({url: 'index_ajax.php', data: data, onSuccess: this.deleteFromImgComplete.bind(this)}).send(); }, @@ -69,7 +68,18 @@ var LSrelation = new Class({ var data = JSON.decode(responseText); if ( varLSdefault.checkAjaxReturn(data) ) { try { - $(data.dn).getParent().getParent().destroy(); + var li = $(data.dn).getParent(); + var ul=$(data.dn).getParent().getParent(); + li.destroy(); + if (!$type(ul.getFirst())) { + var getId = /LSrelation_ul_([0-9]*)/ + var id = getId.exec(ul.id)[1]; + + var newli = new Element('li'); + newli.addClass('LSrelation'); + newli.set('html',varLSdefault.LSjsConfig['LSrelations'][id]['emptyText']); + newli.injectInside(ul); + } } catch(e) { LSdebug('Erreur durant la suppression du li du DN : '+data.dn); diff --git a/trunk/index_ajax.php b/trunk/index_ajax.php index 02d4832f..60b92f14 100644 --- a/trunk/index_ajax.php +++ b/trunk/index_ajax.php @@ -180,13 +180,18 @@ if (!isset($_ERRORS)) { if($objRel -> $relationConf['update_function']($object,$_SESSION['LSselect'][$relationConf['LSobject']])) { if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) { $list = $objRel -> $relationConf['list_function']($object); - if (is_array($list)) { + if (is_array($list)&&(!empty($list))) { foreach($list as $o) { - $data['html'].= "
  • ".$o -> getDisplayValue(NULL,true)."
  • \n"; + $data['html'].= "
  • ".$o -> getDisplayValue(NULL,true)."
  • \n"; } } else { - $data['html'] = "
  • "._('Liste vide.')."
  • \n"; + if (isset($relationConf['emptyText'])) { + $data['html'] = "
  • ".$relationConf['emptyText']."
  • \n"; + } + else { + $data['html'] = "
  • "._('Aucun objet en relation.')."
  • \n"; + } } $data['id'] = $_REQUEST['id']; } diff --git a/trunk/templates/LSrelations.tpl b/trunk/templates/LSrelations.tpl index f1318009..4adbe81e 100644 --- a/trunk/templates/LSrelations.tpl +++ b/trunk/templates/LSrelations.tpl @@ -1,4 +1,4 @@ -

    {$item.label}

    +

    {$item.label}

    {if $item.actions!=''}