2006-12-16 16:37:32 +03:00
|
|
|
<%= error_messages_for 'query' %>
|
|
|
|
|
|
|
|
<div class="box">
|
|
|
|
<div class="tabular">
|
|
|
|
<p><label for="query_name"><%=l(:field_name)%></label>
|
|
|
|
<%= text_field 'query', 'name', :size => 80 %></p>
|
2007-06-23 17:49:29 +04:00
|
|
|
|
2009-05-10 14:54:31 +04:00
|
|
|
<% if User.current.admin? || User.current.allowed_to?(:manage_public_queries, @project) %>
|
2013-07-11 21:45:10 +04:00
|
|
|
<p><label><%=l(:field_visible)%></label>
|
|
|
|
<label class="block"><%= radio_button 'query', 'visibility', Query::VISIBILITY_PRIVATE %> <%= l(:label_visibility_private) %></label>
|
|
|
|
<label class="block"><%= radio_button 'query', 'visibility', Query::VISIBILITY_ROLES %> <%= l(:label_visibility_roles) %>:</label>
|
|
|
|
<% Role.givable.sorted.each do |role| %>
|
|
|
|
<label class="block role-visibility"><%= check_box_tag 'query[role_ids][]', role.id, @query.roles.include?(role), :id => nil %> <%= role.name %></label>
|
|
|
|
<% end %>
|
|
|
|
<label class="block"><%= radio_button 'query', 'visibility', Query::VISIBILITY_PUBLIC %> <%= l(:label_visibility_public) %></label>
|
|
|
|
<%= hidden_field_tag 'query[role_ids][]', '' %>
|
|
|
|
</p>
|
2007-06-23 17:49:29 +04:00
|
|
|
<% end %>
|
2007-10-01 12:44:17 +04:00
|
|
|
|
2008-03-30 16:29:07 +04:00
|
|
|
<p><label for="query_is_for_all"><%=l(:field_is_for_all)%></label>
|
|
|
|
<%= check_box_tag 'query_is_for_all', 1, @query.project.nil?,
|
|
|
|
:disabled => (!@query.new_record? && (@query.project.nil? || (@query.is_public? && !User.current.admin?))) %></p>
|
|
|
|
|
2013-07-11 21:45:10 +04:00
|
|
|
<fieldset><legend><%= l(:label_options) %></legend>
|
2007-10-01 14:44:45 +04:00
|
|
|
<p><label for="query_default_columns"><%=l(:label_default_columns)%></label>
|
|
|
|
<%= check_box_tag 'default_columns', 1, @query.has_default_columns?, :id => 'query_default_columns',
|
2012-07-22 17:29:26 +04:00
|
|
|
:onclick => 'if (this.checked) {$("#columns").hide();} else {$("#columns").show();}' %></p>
|
2009-04-26 17:09:14 +04:00
|
|
|
|
|
|
|
<p><label for="query_group_by"><%= l(:field_group_by) %></label>
|
|
|
|
<%= select 'query', 'group_by', @query.groupable_columns.collect {|c| [c.caption, c.name.to_s]}, :include_blank => true %></p>
|
2012-12-06 21:48:19 +04:00
|
|
|
|
|
|
|
<p><label><%= l(:button_show) %></label>
|
|
|
|
<%= available_block_columns_tags(@query) %></p>
|
2013-07-11 21:45:10 +04:00
|
|
|
</fieldset>
|
2006-12-16 16:37:32 +03:00
|
|
|
</div>
|
|
|
|
|
2012-08-07 20:41:46 +04:00
|
|
|
<fieldset id="filters"><legend><%= l(:label_filter_plural) %></legend>
|
2006-12-16 16:37:32 +03:00
|
|
|
<%= render :partial => 'queries/filters', :locals => {:query => query}%>
|
2008-03-16 17:31:17 +03:00
|
|
|
</fieldset>
|
|
|
|
|
2009-03-12 21:06:54 +03:00
|
|
|
<fieldset><legend><%= l(:label_sort) %></legend>
|
|
|
|
<% 3.times do |i| %>
|
2011-10-29 05:14:10 +04:00
|
|
|
<%= 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.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) %>
|
|
|
|
<br />
|
2009-03-12 21:06:54 +03:00
|
|
|
<% end %>
|
|
|
|
</fieldset>
|
|
|
|
|
2012-05-21 20:55:48 +04:00
|
|
|
<%= content_tag 'fieldset', :id => 'columns', :style => (query.has_default_columns? ? 'display:none;' : nil) do %>
|
2009-11-28 14:34:12 +03:00
|
|
|
<legend><%= l(:field_column_names) %></legend>
|
2013-02-23 17:53:47 +04:00
|
|
|
<%= render_query_columns_selection(query) %>
|
2009-11-28 14:34:12 +03:00
|
|
|
<% end %>
|
|
|
|
|
2006-12-16 16:37:32 +03:00
|
|
|
</div>
|
2013-07-11 21:45:10 +04:00
|
|
|
|
|
|
|
<%= javascript_tag do %>
|
|
|
|
$(document).ready(function(){
|
|
|
|
$("input[name='query[visibility]']").change(function(){
|
|
|
|
var checked = $('#query_visibility_1').is(':checked');
|
|
|
|
$("input[name='query[role_ids][]'][type=checkbox]").attr('disabled', !checked);
|
|
|
|
}).trigger('change');
|
|
|
|
});
|
|
|
|
<% end %>
|