<%= error_messages_for 'query' %>
<%= hidden_field_tag 'gantt', '1' if params[:gantt] %> <%= hidden_field_tag 'calendar', '1' if params[:calendar] %> <%= hidden_field_tag 'admin_projects', '1' if params[:admin_projects] %>

<%= text_field 'query', 'name', :size => 80 %>

<% if User.current.admin? || User.current.allowed_to?(:manage_public_queries, @query.project) %>

<% unless @query.type == 'ProjectQuery' %> <% Role.givable.sorted.each do |role| %> <% end %> <%= hidden_field_tag 'query[role_ids][]', '' %> <% end %>

<% end %> <% unless @query.type == 'ProjectQuery' %>

<%= check_box_tag 'query_is_for_all', 1, @query.project.nil?, :class => (User.current.admin? ? '' : 'disable-unless-private') %>

<% end %> <% unless params[:calendar] %>
<%= l(:label_options) %> <% if @query.available_display_types.size > 1 %>

<%= available_display_types_tags(@query) %>

<% elsif @query.available_display_types.size == 1 %> <%= hidden_field_tag 'query[display_type]', @query.available_display_types.first %> <% end %>

<%= check_box_tag 'default_columns', 1, @query.has_default_columns?, :id => 'query_default_columns', :data => {:disables => "#columns, .block_columns input"} %>

<% unless params[:gantt] %>

<%= select 'query', 'group_by', @query.groupable_columns.collect {|c| [c.caption, c.name.to_s]}, :include_blank => true %>

<% unless @query.available_block_columns.empty? %>

<%= available_block_columns_tags(@query) %>

<% end %> <% unless @query.available_totalable_columns.empty? %>

<%= available_totalable_columns_tags(@query) %>

<% end %> <% else %>

<%= hidden_field_tag 'query[draw_relations]', '0' %> <%= hidden_field_tag 'query[draw_progress_line]', '0' %> <%= hidden_field_tag 'query[draw_selected_columns]', '0' %>

<% end %>
<% end %>
<%= l(:label_filter_plural) %> <%= render :partial => 'queries/filters', :locals => {:query => query}%>
<% if params[:calendar].nil? && params[:gantt].nil? %>
<%= l(:label_sort) %> <% 3.times do |i| %> <%= content_tag(:span, "#{i+1}:", :class => 'query_sort_criteria_count')%> <%= label_tag "query_sort_criteria_attribute_" + i.to_s, l(:description_query_sort_criteria_attribute), :class => "hidden-for-sighted" %> <%= select_tag("query[sort_criteria][#{i}][]", options_for_select([[]] + query.available_columns.select(&:sortable?).collect {|column| [column.caption, column.name.to_s]}, @query.sort_criteria_key(i)), :id => "query_sort_criteria_attribute_" + i.to_s)%> <%= label_tag "query_sort_criteria_direction_" + i.to_s, l(:description_query_sort_criteria_direction), :class => "hidden-for-sighted" %> <%= select_tag("query[sort_criteria][#{i}][]", options_for_select([[], [l(:label_ascending), 'asc'], [l(:label_descending), 'desc']], @query.sort_criteria_order(i)), :id => "query_sort_criteria_direction_" + i.to_s) %>
<% end %>
<% end %> <% unless params[:calendar] %> <%= content_tag 'fieldset', :id => 'columns' do %> <%= l(:field_column_names) %> <%= render_query_columns_selection(query) %> <% end %> <% end %>
<%= javascript_tag do %> $(document).ready(function(){ $("input[name='query[visibility]']").change(function(){ var roles_checked = $('#query_visibility_1').is(':checked'); var private_checked = $('#query_visibility_0').is(':checked'); $("input[name='query[role_ids][]'][type=checkbox]").attr('disabled', !roles_checked); if (!private_checked) $("input.disable-unless-private").attr('checked', false); $("input.disable-unless-private").attr('disabled', !private_checked); }).trigger('change'); }); $(function ($) { $('input[name=display_type]').change(function () { var option = $('input[name=display_type]:checked').val(); if (option == 'board') { $('fieldset#columns, fieldset#sort, p#default_columns, p#group_by').hide(); } else { $('fieldset#columns, fieldset#sort, p#default_columns, p#group_by').show(); } }).change(); }); <% end %>