<%#-- copyright OpenProject is a project management system. Copyright (C) 2012-2014 the OpenProject Foundation (OPF) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3. OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: Copyright (C) 2006-2013 Jean-Philippe Lang Copyright (C) 2010-2013 the ChiliProject Team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. See doc/COPYRIGHT.rdoc for more details. ++#%> <%# expects the following locals: - @query and query: a Query object %> <%= error_messages_for 'query' %> <%= hidden_field_tag 'confirm', 1 %>

<%= label :query, :name, required_field_name(Query.human_attribute_name(:name)) %> <%= text_field 'query', 'name', size: 80 %>

<% if query.any_summable_columns? %>

<%= label :query, :display_sums %> <%= check_box 'query', 'display_sums' %>

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

<%= label :query, :is_public %> <%= check_box :query, :is_public, onchange: (User.current.admin? ? nil : 'if (this.checked) {$("query_is_for_all").checked = false; $("query_is_for_all").disabled = true;} else {$("query_is_for_all").disabled = false;}') %>

<% end %>

<%= label :query, :is_for_all %> <%= check_box_tag 'query_is_for_all', 1, @query.project.nil?, disabled: (!@query.new_record? && (@query.project.nil? || (@query.is_public? && !User.current.admin?))) %>

<%= label :query, :default_columns %> <%= check_box_tag 'default_columns', 1, @query.has_default_columns?, id: 'query_default_columns', onclick: 'if (this.checked) {Element.hide("columns")} else {Element.show("columns")}' %>

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

<%= l(:label_filter_plural) %> <%= render partial: 'queries/filters', locals: {query: query}%>
<%= l(:label_sort) %> <% 3.times do |i| %> <%= i+1 %>: <%= 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}")%> <%= 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}") %>
<% end %>
<%= content_tag 'fieldset', id: 'columns', style: (query.has_default_columns? ? 'display:none;' : nil) do %> <%= Query.human_attribute_name(:column_names) %> <%= render partial: 'queries/columns', locals: {query: query}%> <% end %>