fix filters on calendar view

pull/5320/head
Jens Ulferts 8 years ago
parent 33545b9e39
commit 7c810e731c
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 13
      app/helpers/queries_helper.rb
  2. 26
      app/views/queries/_filters.html.erb

@ -29,7 +29,18 @@
module QueriesHelper
def operators_for_select(filter)
filter.available_operators.map { |o| [o.human_name, o.to_sym] }
# We do not support OnDate(Time) and BetweenDate(Time)
# for rails based filters
operators = filter
.available_operators
.reject do |o|
[Queries::Operators::OnDate,
Queries::Operators::OnDateTime,
Queries::Operators::BetweenDate,
Queries::Operators::BetweenDateTime].include?(o)
end
operators.map { |o| [o.human_name, o.to_sym] }
end
def entries_for_filter_select_sorted(query)

@ -52,7 +52,7 @@ See doc/COPYRIGHT.rdoc for more details.
if (check_box.prop('checked')) {
operator.show().prop('disabled', false);
values.show().prop('disabled', false);
toggle_operator(field, operator);
toggle_operator(field);
} else {
operator.hide();
filter.hide();
@ -61,8 +61,9 @@ See doc/COPYRIGHT.rdoc for more details.
}
}
function toggle_operator(field, operator) {
switch (operator.value) {
function toggle_operator(field) {
var operator = jQuery("#operators_" + field);
switch (operator.val()) {
case "!*":
case "*":
case "t":
@ -84,8 +85,8 @@ See doc/COPYRIGHT.rdoc for more details.
}
function apply_filters_observer() {
jQuery('#query_form input[type=text]').each(function (a) {
jQuery(a).on('keypress', function (e) {
jQuery('#query_form input[type=text]').each(function (index, filter) {
jQuery(filter).on('keypress', function (e) {
if ((e.keyCode || e.which) == 13) {
selectAllOptions("selected_columns");
jQuery.ajax({
@ -118,20 +119,19 @@ See doc/COPYRIGHT.rdoc for more details.
query.filter_for(field).try(:operator)),
id: "operators_#{field}",
onchange: "toggle_operator('#{field}');",
class: "advanced-filters--select",
style: "vertical-align: top;" %>
class: "advanced-filters--select" %>
</div>
<div id="div_values_<%= field %>" style="display:none;" class="advanced-filters--filter-value">
<% field_values = query.filter_for(field).try(:values) || []
case filter.type
when :list, :list_optional, :list_status, :list_subprojects %>
<% field_values = query.filter_for(field).try(:values) || [] %>
<% case filter.type
when :list, :list_optional %>
<span class="inline-label">
<select <%= "multiple=true" if field_values and field_values.length > 1 %>
name="v[<%= field %>][]"
id="values_<%= field %>"
class="form--select -small"
style="vertical-align: top;">
class="form--select -small">
<%= options_for_select filter.allowed_values, field_values %>
@ -181,5 +181,3 @@ See doc/COPYRIGHT.rdoc for more details.
</div>
</li>
</ul>
<%= hidden_field_tag 'f[]', '' %>

Loading…
Cancel
Save