Through row 116

This commit is contained in:
2018-11-24 18:30:58 +00:00
parent 857634d1f1
commit 2fb4f8771c
4 changed files with 43 additions and 45 deletions

View File

@ -301,16 +301,10 @@ dd ul { padding-left: 0; margin-left: 0; }
{{ case_study.energy_storage_capacity }} TODO UNITS?
{% endif %}
{% if case_study.maximum_power_output %}
<dt>{% trans "Maximum power output" %}:
<dd id="maximum_power_output">
{{ case_study.maximum_power_output | intcomma }} W
{% endif %}
{% if case_study.discharge_time %}
<dt>{% trans "Time for discharge from full capacity" %}:
<dd id="discharge_time">
{{ case_study.discharge_time | intcomma }} {% trans "seconds" %}
{% if case_study.energy_transmission_capacity %}
<dt>{% trans "Energy transmission capacity" %}:
<dd id="energy_transmission_capacity">
{{ case_study.energy_transmission_capacity }} TODO UNITS?
{% endif %}
{% if case_study.contractor_or_supplier_of_technology %}

View File

@ -40,6 +40,14 @@
<!-- Conditional logic for hiding and un-hiding fields. -->
<script>
function showIf(thingToShow, whetherToShowIt) {
if (whetherToShowIt) {
$(thingToShow).show()
} else {
$(thingToShow).hide()
}
}
// Here we define the fields we need to conditionally toggle.
// TODO: Move this knowledge out of the template
var conditionalFields = [
@ -102,13 +110,25 @@
name: "power_technology",
redraw: function() {
const other = document.getElementById('id_id_power_technology_0_4')
const showHide = document.getElementById('div_id_power_technology_other')
const panel = document.getElementById('div_id_power_technology_other')
if (other.checked) {
$(showHide).show();
} else {
$(showHide).hide();
}
showIf(panel, other.checked)
}
},
{
name: "power_technology",
redraw: function() {
const group = document.forms['case-study-form'].power_technology
// Storage / other
let showStorage = ['ES', 'OT'].includes(group.value)
// Transmission / heat / other
let showTransmission = ['PT', 'HN', 'OT'].includes(group.value)
showIf('#div_id_energy_storage_capacity', showStorage)
showIf('#div_id_energy_transmission_capacity', showTransmission)
}
},
@ -134,11 +154,7 @@
const input = document.getElementById(option.input)
const section = document.getElementById(option.section)
if (input.checked) {
$(section).show();
} else {
$(section).hide();
}
showIf(section, input.checked)
}
}
}