64 lines
2.0 KiB
HTML
64 lines
2.0 KiB
HTML
{% load i18n gadjo %}
|
|
|
|
{% block cell-content %}
|
|
<h2>{{ cell.title }}</h2>
|
|
|
|
<div>
|
|
{% if form.fields|length > 1 %}
|
|
<form method='get' enctype='multipart/form-data' id='chart-filters'>
|
|
{{ form|with_template }}
|
|
<div class='buttons'>
|
|
<button class='submit-button'>{% trans 'Refresh' %}</button>
|
|
</div>
|
|
</form>
|
|
{% else %}
|
|
<p>
|
|
{% blocktrans trimmed %}
|
|
No filters are available. Note that only filters that are shared between all chart cells will appear. Furthermore, in case they have a value, it must be the same accross all cells.
|
|
{% endblocktrans %}
|
|
</p>
|
|
{% endif %}
|
|
</div>
|
|
|
|
|
|
<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));
|
|
|
|
function load_filters_cell_last() {
|
|
if (++loaded_cell_count == $('div.chartngcell').length) {
|
|
combo_load_cell($('.chart-filters-cell'));
|
|
loaded_cell_count = 0;
|
|
}
|
|
}
|
|
|
|
document.querySelectorAll('div.dataviz-table').forEach(graph => {
|
|
graph.addEventListener('DOMSubtreeModified', load_filters_cell_last);
|
|
});
|
|
document.querySelectorAll('div.chartngcell embed').forEach(graph => {
|
|
graph.addEventListener('load', load_filters_cell_last)
|
|
});
|
|
}
|
|
|
|
form.submit(function(e) {
|
|
e.preventDefault();
|
|
$(window).trigger('combo:refresh-graphs');
|
|
chart_cell = $(this).parents('.cell');
|
|
ajax_cell_url = "{{ site_base }}{{ cell.get_ajax_url }}";
|
|
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 %}
|