LSrelation :

-> Revue de la mise en forme
	-> Revue de la structure de <li> (supression des <span>)
	-> Mise en place d'un texte quand plus aucun objet est en relation
This commit is contained in:
Benjamin Renard 2008-10-08 15:34:36 +00:00
parent 9ad151312e
commit 95b3854e46
5 changed files with 52 additions and 18 deletions

View file

@ -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);

View file

@ -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'].= "<li class='LSrelation'><a href='view.php?LSobject=".$relationConf['LSobject']."&amp;dn=".$o -> getDn()."' class='LSrelation'><span id='".$o -> getDn()."'>".$o -> getDisplayValue(NULL,true)."</span></li>\n";
$data['html'].= "<li class='LSrelation'><a href='view.php?LSobject=".$relationConf['LSobject']."&amp;dn=".$o -> getDn()."' class='LSrelation' id='".$o -> getDn()."'>".$o -> getDisplayValue(NULL,true)."</a></li>\n";
}
}
else {
$data['html'] = "<li>"._('Liste vide.')."</li>\n";
if (isset($relationConf['emptyText'])) {
$data['html'] = "<li>".$relationConf['emptyText']."</li>\n";
}
else {
$data['html'] = "<li>"._('Aucun objet en relation.')."</li>\n";
}
}
$data['id'] = $_REQUEST['id'];
}

View file

@ -1,4 +1,4 @@
<h1 id='LSrelation_title_{$item.id}'>{$item.label}</h1>
<h1 id='LSrelation_title_{$item.id}' class='LSrelation'>{$item.label}</h1>
{if $item.actions!=''}
<ul class='LSview-actions'>
{foreach from=$item.actions item=action}
@ -8,6 +8,8 @@
{/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}' class='LSrelation'><span id='{$object.dn}'>{$object.text}</span></a></li>
<li class='LSrelation'><a href='view.php?LSobject={$item.LSobject}&amp;dn={$object.dn}' class='LSrelation' id='{$object.dn}'>{$object.text}</a></li>
{foreachelse}
<li class='LSrelation'>{$item.emptyText}</li>
{/foreach}
</ul>

View file

@ -3,12 +3,16 @@
* LSrelation
***********************
*/
h1.LSrelation {
font-size: 1.4em;
}
img.LSrelation-btn {
margin-left: 0.5em;
}
a.LSrelation {
text-decoration: none;
color: #000;
font-weight: normal;
text-decoration: none;
color: #000;
font-weight: normal;
}

View file

@ -81,6 +81,7 @@ if($LSsession -> startLSsession()) {
// Relations
if (is_array($object -> config['relations'])) {
$LSrelations=array();
$LSrelations_JSparams=array();
foreach($object -> config['relations'] as $relationName => $relationConf) {
if ($GLOBALS['LSsession'] -> relationCanAccess($object -> getValue('dn'),$LSobject,$relationName)) {
$return=array(
@ -88,8 +89,18 @@ if($LSsession -> startLSsession()) {
'LSobject' => $relationConf['LSobject']
);
if (isset($relationConf['emptyText'])) {
$return['emptyText'] = $relationConf['emptyText'];
}
else {
$return['emptyText'] = _('Aucun objet en relation.');
}
$id=rand();
$return['id']=$id;
$LSrelations_JSparams[$id]=array(
'emptyText' => $return['emptyText']
);
$_SESSION['LSrelation'][$id] = array(
'relationName' => $relationName,
'objectType' => $object -> getType(),
@ -137,9 +148,11 @@ if($LSsession -> startLSsession()) {
}
}
}
$GLOBALS['LSsession'] -> addJSscript('LSconfirmBox.js');
$GLOBALS['LSsession'] -> addCssFile('LSconfirmBox.css');
$GLOBALS['Smarty'] -> assign('LSrelations',$LSrelations);
$GLOBALS['LSsession'] -> addJSconfigParam('LSrelations',$LSrelations_JSparams);
}
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);