app/views/organizations/_select_project_columns_to_display.html.erb
<%= form_tag({ :controller => 'organizations', :action => 'set_available_inline_columns', :project_id => @project }, :method => :get, :id => 'query_form') do %>
<table id="query-columns">
<tr>
<td><%= I18n.t(:field_column_names) %></td>
<td style="padding-left:0">
<%= label_tag "available_columns", I18n.t(:label_available_columns) %>
<br />
<%= select_tag 'available_columns',
options_for_select(query_available_inline_columns_options(Project)),
:multiple => true, :size => 10, :style => "width:160px",
:ondblclick => "moveOptions(this.form.available_columns, this.form.selected_columns);" %>
</td>
<td class="buttons">
<p><input type="button" value="→"
onclick="moveOptions(this.form.available_columns, this.form.selected_columns);" /></p>
<input type="button" value="←"
onclick="moveOptions(this.form.selected_columns, this.form.available_columns);" />
</td>
<td>
<%= label_tag "selected_columns", I18n.t(:label_selected_columns) %>
<br />
<%= select_tag "tag_name",
options_for_select(query_selected_inline_columns_options(Project)),
:id => 'selected_columns', :multiple => true, :size => 10, :style => "width:160px",
:ondblclick => "moveOptions(this.form.selected_columns, this.form.available_columns);" %>
</td>
<td class="buttons">
<!--<p><input type="button" value="⇈" onclick="moveOptionTop(this.form.selected_columns);" /></p>-->
<p><input type="button" value="↑" onclick="moveOptionUp(this.form.selected_columns);" /></p>
<p><input type="button" value="↓" onclick="moveOptionDown(this.form.selected_columns);" /></p>
<!--<p><input type="button" value="⇊" onclick="moveOptionBottom(this.form.selected_columns);" /></p>-->
</td>
</tr>
</table>
<br>
<% if can? :manage_projects_selected_columns, Organization %>
<span><%= submit_tag I18n.t(:label_save), class: "btn" %></span>
<% end %>
<%= javascript_tag do %>
$(document).ready(function(){
$('#query-columns').closest('form').submit(function(){
$('#selected_columns option').prop('selected', true);
//get the selected value in Array
var selected_columns = new Array();
$('#selected_columns option').each(function(){
selected_columns.push(this.value);
});
//update the data in database
$.ajax({
url:"/update_available_inline_columns",
method: 'GET',
data: {
query_classname: "Project",
selected_inline_columns: selected_columns
}
})
});
});
<% end %>
<% end %>