|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
/*jslint white: false, nomen: true, devel: true, on: true, debug: false, evil: true, onevar: false, browser: true, white: false, indent: 2 */ |
|
|
|
|
/*global window, $, $$, Reporting, Effect, Ajax */ |
|
|
|
|
/*global window, $, $$, Reporting, Effect, Ajax, Element */ |
|
|
|
|
|
|
|
|
|
Reporting.Filters = { |
|
|
|
|
load_available_values_for_filter: function (filter_name, callback_func) { |
|
|
|
@ -26,32 +26,47 @@ Reporting.Filters = { |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
show_filter: function (field, slowly, callback_func) { |
|
|
|
|
if (callback_func === undefined) { |
|
|
|
|
callback_func = function () {}; |
|
|
|
|
show_filter: function (field, options) { |
|
|
|
|
if (options.callback_func === undefined) { |
|
|
|
|
options.callback_func = function () {}; |
|
|
|
|
} |
|
|
|
|
if (slowly === undefined) { |
|
|
|
|
slowly = true; |
|
|
|
|
if (options.slowly === undefined) { |
|
|
|
|
options.slowly = true; |
|
|
|
|
} |
|
|
|
|
if (options.show_filter === undefined) { |
|
|
|
|
options.show_filter = true; |
|
|
|
|
} |
|
|
|
|
var field_el = $('tr_' + field); |
|
|
|
|
if (field_el !== null) { |
|
|
|
|
Reporting.Filters.load_available_values_for_filter(field, callback_func); |
|
|
|
|
Reporting.Filters.load_available_values_for_filter(field, options.callback_func); |
|
|
|
|
// the following command might be included into the callback_function (which is called after the ajax request) later
|
|
|
|
|
$('rm_' + field).value = field; |
|
|
|
|
if (slowly) { |
|
|
|
|
Effect.Appear(field_el); |
|
|
|
|
var display_functor; |
|
|
|
|
if (options.show_filter) { |
|
|
|
|
display_functor = options.slowly ? Effect.Appear : Element.show; |
|
|
|
|
} else { |
|
|
|
|
field_el.show(); |
|
|
|
|
display_functor = options.slowly ? Effect.Fade : Element.hide; |
|
|
|
|
} |
|
|
|
|
display_functor(field_el); |
|
|
|
|
Reporting.Filters.operator_changed(field, $("operators_" + field)); |
|
|
|
|
Reporting.Filters.display_category(field_el); |
|
|
|
|
Reporting.Filters.display_category(field_el, options.show_filter); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
display_category: function (tr_field) { |
|
|
|
|
display_category: function (tr_field, show) { |
|
|
|
|
if (show === undefined) { |
|
|
|
|
show = true; |
|
|
|
|
} |
|
|
|
|
var label = $(tr_field.getAttribute("data-label")); |
|
|
|
|
if (label !== null) { |
|
|
|
|
label.show(); |
|
|
|
|
var filters = $$('.filter'); |
|
|
|
|
for (var i = 0; i < filters.length; i += 1) { |
|
|
|
|
if (filters[i].visible() === show && filters[i].getAttribute("data-label") === label) { |
|
|
|
|
return; // No need to show/hide
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
var display_functor = show ? Element.show : Element.hide; |
|
|
|
|
display_functor(label); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -105,6 +120,11 @@ Reporting.Filters = { |
|
|
|
|
|
|
|
|
|
toggle_multi_select: function (select) { |
|
|
|
|
Reporting.Filters.multi_select(select, !select.multiple); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
remove_filter: function (field) { |
|
|
|
|
Reporting.Filters.show_filter(field, { show_filter: false }); |
|
|
|
|
Reporting.Filters.select_option_enabled($("add_filter_select"), field, true); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|