dataviz: use |with_template for rendering forms (#74061)
This commit is contained in:
parent
b4845d84af
commit
378f4d6b53
|
@ -1,4 +1,4 @@
|
|||
{% load i18n %}
|
||||
{% load i18n gadjo %}
|
||||
|
||||
{% block cell-content %}
|
||||
<h2>{{ cell.title }}</h2>
|
||||
|
@ -6,7 +6,7 @@
|
|||
<div>
|
||||
{% if form.fields %}
|
||||
<form method='get' enctype='multipart/form-data' id='chart-filters'>
|
||||
{{ form.as_p }}
|
||||
{{ form|with_template }}
|
||||
<div class='buttons'>
|
||||
<button class='submit-button'>{% trans 'Refresh' %}</button>
|
||||
</div>
|
||||
|
@ -44,15 +44,15 @@
|
|||
});
|
||||
}
|
||||
|
||||
start_field = $('#id_filter-time_range_start');
|
||||
end_field = $('#id_filter-time_range_end');
|
||||
start_field = $('#id_filter-time_range_start_p');
|
||||
end_field = $('#id_filter-time_range_end_p');
|
||||
$('#id_filter-time_range').change(function() {
|
||||
if(this.value == 'range') {
|
||||
start_field.parent().show();
|
||||
end_field.parent().show();
|
||||
start_field.show();
|
||||
end_field.show();
|
||||
} else {
|
||||
start_field.parent().hide();
|
||||
end_field.parent().hide();
|
||||
start_field.hide();
|
||||
end_field.hide();
|
||||
}
|
||||
}).change();
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{% load gadjo %}
|
||||
|
||||
<div style="position: relative">
|
||||
{{ form.as_p }}
|
||||
{{ form|with_template }}
|
||||
{% if cell.statistic and cell.chart_type != "table" and cell.chart_type != "table-inverted" %}
|
||||
<div style="position: absolute; right: 0; top: 0; width: 300px; height: 150px">
|
||||
<embed type="image/svg+xml" src="{% url 'combo-dataviz-graph' cell=cell.id %}?width=300&height=150"/>
|
||||
|
@ -9,24 +11,24 @@
|
|||
|
||||
<script>
|
||||
$(function () {
|
||||
start_field = $('#id_cdataviz_chartngcell-{{ cell.pk }}-time_range_start');
|
||||
end_field = $('#id_cdataviz_chartngcell-{{ cell.pk }}-time_range_end');
|
||||
start_field_template = $('#id_cdataviz_chartngcell-{{ cell.pk }}-time_range_start_template');
|
||||
end_field_template = $('#id_cdataviz_chartngcell-{{ cell.pk }}-time_range_end_template');
|
||||
start_field = $('#id_cdataviz_chartngcell-{{ cell.pk }}-time_range_start_p');
|
||||
end_field = $('#id_cdataviz_chartngcell-{{ cell.pk }}-time_range_end_p');
|
||||
start_field_template = $('#id_cdataviz_chartngcell-{{ cell.pk }}-time_range_start_template_p');
|
||||
end_field_template = $('#id_cdataviz_chartngcell-{{ cell.pk }}-time_range_end_template_p');
|
||||
$('#id_cdataviz_chartngcell-{{ cell.pk }}-time_range').change(function() {
|
||||
if(this.value == 'range') {
|
||||
start_field.parent().show();
|
||||
end_field.parent().show();
|
||||
start_field.show();
|
||||
end_field.show();
|
||||
} else {
|
||||
start_field.parent().hide();
|
||||
end_field.parent().hide();
|
||||
start_field.hide();
|
||||
end_field.hide();
|
||||
}
|
||||
if(this.value == 'range-template') {
|
||||
start_field_template.parent().show();
|
||||
end_field_template.parent().show();
|
||||
start_field_template.show();
|
||||
end_field_template.show();
|
||||
} else {
|
||||
start_field_template.parent().hide();
|
||||
end_field_template.parent().hide();
|
||||
start_field_template.hide();
|
||||
end_field_template.hide();
|
||||
}
|
||||
}).change();
|
||||
|
||||
|
|
|
@ -1822,7 +1822,7 @@ def test_chartng_cell_manager_new_api_dynamic_fields(app, admin_user, new_api_st
|
|||
resp.form[field_prefix + 'statistic'] = statistic.pk
|
||||
resp = app.post(resp.form.action, params=resp.form.submit_fields(), xhr=True)
|
||||
assert 'time_interval' in resp.json['tabs']['general']['form']
|
||||
assert 'This field is required.' not in resp.json['tabs']['general']['form']
|
||||
assert '<div class="error">' not in resp.json['tabs']['general']['form']
|
||||
|
||||
|
||||
@with_httmock(new_api_mock)
|
||||
|
|
Loading…
Reference in New Issue