]> source.dussan.org Git - redmine.git/commitdiff
Adds 2 buttons to easily reorder selected columns (#4272).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 28 Nov 2009 11:59:45 +0000 (11:59 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 28 Nov 2009 11:59:45 +0000 (11:59 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3106 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/queries/_columns.rhtml
public/javascripts/select_list_move.js

index e11b286b62028b10927963bb5149367efe867287..91ee627b271363c47d28b36228e876ec0a597c40 100644 (file)
@@ -5,15 +5,19 @@
                          :multiple => true, :size => 10, :style => "width:150px" %>
                </td>
                <td align="center" valign="middle">
-                       <input type="button" value="--&gt;"
+                       <input type="button" value="&#8594;"
                         onclick="moveOptions(this.form.available_columns, this.form.selected_columns);" /><br />
-                       <input type="button" value="&lt;--"
+                       <input type="button" value="&#8592;"
                         onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" />
                </td>
                <td><%= select_tag 'query[column_names][]',
                          options_for_select(query.columns.collect {|column| [column.caption, column.name]}),
                          :id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %>
                </td>
+               <td align="center" valign="middle">
+                       <input type="button" value="&#8593;" onclick="moveOptionUp(this.form.selected_columns);" /><br />
+                       <input type="button" value="&#8595;" onclick="moveOptionDown(this.form.selected_columns);" />
+               </td>
        </tr>
 </table>
 
index 1ced88232217fb85dd8e3b5f03ec1427480985f5..a9c5bfd36110367b44edeb77172a87db9c34c419 100644 (file)
@@ -7,6 +7,17 @@ function addOption(theSel, theText, theValue)
   theSel.options[selLength] = newOpt;\r
 }\r
 \r
+function swapOptions(theSel, index1, index2)\r
+{\r
+       var text, value;\r
+  text = theSel.options[index1].text;\r
+  value = theSel.options[index1].value;\r
+  theSel.options[index1].text = theSel.options[index2].text;\r
+  theSel.options[index1].value = theSel.options[index2].value;\r
+  theSel.options[index2].text = text;\r
+  theSel.options[index2].value = value;\r
+}\r
+\r
 function deleteOption(theSel, theIndex)\r
 { \r
   var selLength = theSel.length;\r
@@ -45,6 +56,22 @@ function moveOptions(theSelFrom, theSelTo)
   if(NS4) history.go(0);\r
 }\r
 \r
+function moveOptionUp(theSel) {\r
+       var index = theSel.selectedIndex;\r
+       if (index > 0) {\r
+               swapOptions(theSel, index-1, index);\r
+       theSel.selectedIndex = index-1;\r
+       }\r
+}\r
+\r
+function moveOptionDown(theSel) {\r
+       var index = theSel.selectedIndex;\r
+       if (index < theSel.length - 1) {\r
+               swapOptions(theSel, index, index+1);\r
+       theSel.selectedIndex = index+1;\r
+       }\r
+}\r
+\r
 function selectAllOptions(id)\r
 {\r
   var select = $(id);\r