|
|
@ -48,6 +48,43 @@ Reporting.RestoreQuery = { |
|
|
|
target.options[target.length] = group_option; |
|
|
|
target.options[target.length] = group_option; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This is called the first time the report loads.
|
|
|
|
|
|
|
|
// Params:
|
|
|
|
|
|
|
|
// elements: Array of visible filter-select-boxes that have dependents
|
|
|
|
|
|
|
|
// (and possibly are dependents themselfes)
|
|
|
|
|
|
|
|
initialize_load_dependent_filters: function(elements) { |
|
|
|
|
|
|
|
var filters_to_load, dependent_filters; |
|
|
|
|
|
|
|
dependent_filters = elements.findAll(function (select) { return select.value == '<<inactive>>' }); |
|
|
|
|
|
|
|
filters_to_load = elements.reject( function (select) { return select.value == '<<inactive>>' }); |
|
|
|
|
|
|
|
// Filters which are <<inactive>> are probably dependents themselfes, so remove and forget them for now.
|
|
|
|
|
|
|
|
// This is OK as they get reloaded later
|
|
|
|
|
|
|
|
dependent_filters.each(function(select) { |
|
|
|
|
|
|
|
Reporting.Filters.remove_filter(select.up('tr').getAttribute("data-filter-name")); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// For each dependent filter we reload its dependent chain
|
|
|
|
|
|
|
|
filters_to_load.each(function(selectBox) { |
|
|
|
|
|
|
|
var sources, selected_values; |
|
|
|
|
|
|
|
Reporting.Filters.activate_dependents(selectBox, function() { |
|
|
|
|
|
|
|
sources = Reporting.Filters.get_dependents(selectBox).collect(function(field) { |
|
|
|
|
|
|
|
return $('tr_' + field).select('.filter_values select').first(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
sources.each(function(source) { |
|
|
|
|
|
|
|
if (source.hasAttribute('data-initially-selected')) { |
|
|
|
|
|
|
|
selected_values = source.getAttribute('data-initially-selected').replace(/'/g, '"').evalJSON(true); |
|
|
|
|
|
|
|
Reporting.Filters.select_values(source, selected_values); |
|
|
|
|
|
|
|
Reporting.Filters.value_changed(source.up('tr').getAttribute("data-filter-name")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (sources.reject( function (select) { return select.value == '<<inactive>>' }).size() == 0) { |
|
|
|
|
|
|
|
Reporting.Filters.activate_dependents(selectBox); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
Reporting.RestoreQuery.initialize_load_dependent_filters(sources); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
restore_group_bys: function () { |
|
|
|
restore_group_bys: function () { |
|
|
|
// Activate recent group_bys on loading
|
|
|
|
// Activate recent group_bys on loading
|
|
|
|
$('group_by_container').select("option") |
|
|
|
$('group_by_container').select("option") |
|
|
@ -70,6 +107,10 @@ Reporting.RestoreQuery = { |
|
|
|
rm_box.value = filter_name; |
|
|
|
rm_box.value = filter_name; |
|
|
|
Reporting.Filters.select_option_enabled($("add_filter_select"), filter_name, false); |
|
|
|
Reporting.Filters.select_option_enabled($("add_filter_select"), filter_name, false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// restore values of dependent filters
|
|
|
|
|
|
|
|
Reporting.RestoreQuery.initialize_load_dependent_filters($$('.filters-select[data-dependents]').findAll(function(select) { |
|
|
|
|
|
|
|
return select.up('tr').visible() |
|
|
|
|
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|