summaryrefslogtreecommitdiffstats
path: root/app/views/queries/_columns.html.erb
blob: 26a46078060df6c99da3bb391d1777fe73e28cc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<% tag_id = tag_name.gsub(/[\[\]]+/, '_').sub(/_+$/, '') %>
<% available_tag_id = "available_#{tag_id}" %>
<% selected_tag_id = "selected_#{tag_id}" %>

<table class="query-columns">
  <tr>
    <td style="padding-left:0">
      <%= label_tag available_tag_id, l(:description_available_columns) %>
      <br />
      <%= select_tag 'available_columns',
              options_for_select(query_available_inline_columns_options(query)),
              :id => available_tag_id,
              :multiple => true, :size => 10, :style => "width:150px",
              :ondblclick => "moveOptions(this.form.#{available_tag_id}, this.form.#{selected_tag_id});" %>
    </td>
    <td class="buttons">
      <input type="button" value="&#8594;"
       onclick="moveOptions(this.form.<%= available_tag_id %>, this.form.<%= selected_tag_id %>);" /><br />
      <input type="button" value="&#8592;"
       onclick="moveOptions(this.form.<%= selected_tag_id %>, this.form.<%= available_tag_id %>);" />
    </td>
    <td>
      <%= label_tag selected_tag_id, l(:description_selected_columns) %>
      <br />
      <%= select_tag tag_name,
              options_for_select(query_selected_inline_columns_options(query)),
              :id => selected_tag_id,
              :multiple => true, :size => 10, :style => "width:150px",
              :ondblclick => "moveOptions(this.form.#{selected_tag_id}, this.form.#{available_tag_id});" %>
    </td>
    <td class="buttons">
      <input type="button" value="&#8648;" onclick="moveOptionTop(this.form.<%= selected_tag_id %>);" /><br />
      <input type="button" value="&#8593;" onclick="moveOptionUp(this.form.<%= selected_tag_id %>);" /><br />
      <input type="button" value="&#8595;" onclick="moveOptionDown(this.form.<%= selected_tag_id %>);" /><br />
      <input type="button" value="&#8650;" onclick="moveOptionBottom(this.form.<%= selected_tag_id %>);" />
    </td>
  </tr>
</table>

<%= javascript_tag do %>
$(document).ready(function(){
  $('.query-columns').closest('form').submit(function(){
    $('#<%= selected_tag_id %> option').prop('selected', true);
  });
});
<% end %>