dataviz: automatically refresh cells on filter change (#72465)

This commit is contained in:
Valentin Deniaud 2023-01-04 13:46:01 +01:00 committed by Gitea
parent 3f8536d41e
commit 5f23c06485
2 changed files with 16 additions and 3 deletions

View File

@ -23,11 +23,12 @@
<script>
$(function () {
const form = $('#chart-filters');
var loaded_cell_count = 0;
if (!$('body').data('filters-cell-id')) {
$('body').data('filters-cell-id', Math.random().toString(36).slice(2, 7));
var loaded_cell_count = 0;
function load_filters_cell_last() {
if (++loaded_cell_count == $('div.chartngcell').length) {
combo_load_cell($('.chart-filters-cell'));
@ -54,7 +55,8 @@
end_field.parent().hide();
}
}).change();
$('#chart-filters').submit(function(e) {
form.submit(function(e) {
e.preventDefault();
$(window).trigger('combo:refresh-graphs');
chart_cell = $(this).parents('.cell');
@ -62,6 +64,12 @@
new_url = ajax_cell_url + '?filters_cell_id=' + $('body').data('filters-cell-id') + '&' + $(this).serialize();
chart_cell.data('ajax-cell-url', new_url);
});
form.change(function() {
if(loaded_cell_count == 0) {
form.submit();
}
});
});
</script>
{% endblock %}

View File

@ -29,5 +29,10 @@
end_field_template.parent().hide();
}
}).change();
$('select, input', 'div#panel-dataviz_chartngcell-{{ cell.pk }}-general').change(function() {
$('div#cell-dataviz_chartngcell-{{ cell.pk }} button.save').click();
});
});
</script>