diff --git a/doc/conf/LSattribute/LSattr_html/LSattr_html_select_object.docbook b/doc/conf/LSattribute/LSattr_html/LSattr_html_select_object.docbook
index b0cd3c12..0fb33f1b 100644
--- a/doc/conf/LSattribute/LSattr_html/LSattr_html_select_object.docbook
+++ b/doc/conf/LSattribute/LSattr_html/LSattr_html_select_object.docbook
@@ -13,6 +13,7 @@
'display_name_format' => '[LSformat du nom d'affichage des LSobjects]',
'value_attribute' => '[Nom de l'attribut clé des LSobjects]'
),
+ 'ordered' => [Booléen],
'sort' => [Booléen],
'sortDirection' => '[ASC|DESC]'
),]]>
@@ -66,6 +67,18 @@
+
+ ordered
+
+ Booléen définissant si la liste des objets choisis doit être
+ ordonnable ou non (Faux par défaut). Cela aura pour effet d'activer une
+ fonctionnalité dynamique de l'interface permettant de remonter ou descendre
+ dans la liste les objets choisis.
+ Cette fonctionnalité désactive automatiquement le trie des
+ objets à l'affichage.
+
+
+
sort
diff --git a/public_html/images/default/down.png b/public_html/images/default/down.png
new file mode 100644
index 00000000..7f5acc27
Binary files /dev/null and b/public_html/images/default/down.png differ
diff --git a/public_html/images/default/up.png b/public_html/images/default/up.png
new file mode 100644
index 00000000..276836e1
Binary files /dev/null and b/public_html/images/default/up.png differ
diff --git a/public_html/includes/class/class.LSformElement_select_object.php b/public_html/includes/class/class.LSformElement_select_object.php
index 75f3af72..efd880d9 100644
--- a/public_html/includes/class/class.LSformElement_select_object.php
+++ b/public_html/includes/class/class.LSformElement_select_object.php
@@ -67,6 +67,9 @@ class LSformElement_select_object extends LSformElement {
'object_type' => $this -> selectableObject,
'addBtn' => _('Modify'),
'deleteBtns' => _('Delete'),
+ 'up_label' => _('Move up'),
+ 'down_label' => _('Move down'),
+ 'ordered' => (($this -> params['html_options']['ordered'])?1:0),
'multiple' => (($this -> params['multiple'])?1:0),
'filter64' => (($this -> params['html_options']['selectable_object']['filter'])?base64_encode($this -> params['html_options']['selectable_object']['filter']):''),
'noValueLabel' => _('No set value'),
@@ -90,7 +93,7 @@ class LSformElement_select_object extends LSformElement {
}
}
- if (!isset($this -> params['html_options']['sort']) || $this -> params['html_options']['sort']) {
+ if ((!isset($this -> params['html_options']['sort']) || $this -> params['html_options']['sort']) && !$this -> params['html_options']['ordered']) {
uasort($this -> values,array($this,'_sortTwoValues'));
}
diff --git a/public_html/includes/js/LSformElement_select_object_field.js b/public_html/includes/js/LSformElement_select_object_field.js
index 911e98f9..7c98f63c 100644
--- a/public_html/includes/js/LSformElement_select_object_field.js
+++ b/public_html/includes/js/LSformElement_select_object_field.js
@@ -17,6 +17,7 @@ var LSformElement_select_object_field = new Class({
// Delete btns
this.ul.getElements('a.LSformElement_select_object').each(function(a){
+ this.addOrderedBtns(a);
this.addDeleteBtn(a);
},this);
@@ -62,6 +63,45 @@ var LSformElement_select_object_field = new Class({
varLSdefault.addHelpInfo(btn,'LSformElement_select_object','delete');
},
+ addOrderedBtns: function(a) {
+ if (!this.params.ordered) {
+ return true;
+ }
+ var btn_down = new Element('img');
+ btn_down.addClass('btn');
+ btn_down.setProperties({
+ src: varLSdefault.imagePath('down'),
+ alt: this.params.down_label
+ });
+ btn_down.addEvent('click',this.onDownBtnClick.bind(this,btn_down));
+ btn_down.injectAfter(a);
+
+ var btn_up = new Element('img');
+ btn_up.addClass('btn');
+ btn_up.setProperties({
+ src: varLSdefault.imagePath('up'),
+ alt: this.params.up_label
+ });
+ btn_up.addEvent('click',this.onUpBtnClick.bind(this,btn_up));
+ btn_up.injectAfter(a);
+ },
+
+ onUpBtnClick: function(btn) {
+ var li = btn.getParent();
+ var prev = li.getPrevious('li');
+ if ($type(prev) && !prev.hasClass('LSformElement_select_object_addBtn')) {
+ li.inject(prev,'before');
+ }
+ },
+
+ onDownBtnClick: function(btn) {
+ var li = btn.getParent();
+ var next = li.getNext('li');
+ if ($type(next)) {
+ li.inject(next,'after');
+ }
+ },
+
addSingleAddBtn: function(insideEl) {
this.addBtn = new Element('img');
this.addBtn.setProperty('src',varLSdefault.imagePath('modify'));
@@ -190,6 +230,7 @@ var LSformElement_select_object_field = new Class({
input.addClass('LSformElement_select_object');
input.injectAfter(a);
+ this.addOrderedBtns(a);
this.addDeleteBtn(a);
li.injectInside(this.ul);