]> source.dussan.org Git - redmine.git/commitdiff
Custom queries: buttons to move column to top and bottom (#16326).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 21 Mar 2014 02:20:56 +0000 (02:20 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 21 Mar 2014 02:20:56 +0000 (02:20 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12991 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/queries/_columns.html.erb
public/javascripts/select_list_move.js

index 0d624d989a51206277dc4ce21c86eaf190b4c2bc..595a96b146a24719367ef6ddf3cc7743ee50c026 100644 (file)
               :ondblclick => "moveOptions(this.form.selected_columns, this.form.available_columns);" %>
     </td>
     <td class="buttons">
+      <input type="button" value="&#8648;" onclick="moveOptionTop(this.form.selected_columns);" /><br />
       <input type="button" value="&#8593;" onclick="moveOptionUp(this.form.selected_columns);" /><br />
-      <input type="button" value="&#8595;" onclick="moveOptionDown(this.form.selected_columns);" />
+      <input type="button" value="&#8595;" onclick="moveOptionDown(this.form.selected_columns);" /><br />
+      <input type="button" value="&#8650;" onclick="moveOptionBottom(this.form.selected_columns);" />
     </td>
   </tr>
 </table>
index 88496fd2677d817c1e53bfc8c2371205c5746c15..c3a5d0a2b68fa763feb82145a285ce82f22ad7ba 100644 (file)
@@ -51,6 +51,17 @@ function moveOptionUp(theSel) {
   }
 }
 
+function moveOptionTop(theSel) {
+  var index = theSel.selectedIndex;
+
+  if (index > 0) {
+    for (i=index; i>0; i--) {
+      swapOptions(theSel, i-1, i);
+    }
+    theSel.selectedIndex = 0;
+  }
+}
+
 function moveOptionDown(theSel) {
   var index = theSel.selectedIndex;
   if (index < theSel.length - 1) {
@@ -59,6 +70,17 @@ function moveOptionDown(theSel) {
   }
 }
 
+function moveOptionBottom(theSel) {
+  var index = theSel.selectedIndex;
+  var indexTop = theSel.length - 1;
+  if (index < theSel.length - 1) {
+    for (i=index; i<indexTop; i++) {
+      swapOptions(theSel, i+1, i);
+    }
+    theSel.selectedIndex = indexTop;
+  }
+}
+
 // OK
 function selectAllOptions(id) {
   var select = $('#'+id);