Skip to content

Commit

Permalink
removed Radiobuttons, TextInput, TemplateForm and Slider Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
josihoppe committed Jun 24, 2024
1 parent 19c75f8 commit c7e3b28
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 113 deletions.
18 changes: 2 additions & 16 deletions slapp/explorer/forms.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
"""Module containing django forms."""
from django.forms import FloatField, Form, TextInput, renderers
from django.utils.safestring import mark_safe
from django.forms import FloatField, Form, TextInput


class TemplateForm(Form): # noqa: D101
template_name = None
extra_content = {}

def __str__(self) -> str: # noqa: D105
if self.template_name:
renderer = renderers.get_default_renderer()
return mark_safe(renderer.render(self.template_name, {"form": self, **self.extra_content})) # noqa: S308
return super().__str__()


class ParametersSliderForm(TemplateForm): # noqa: D101
template_name = "forms/layer.html"

class ParametersSliderForm(Form): # noqa: D101
def __init__(self, parameters, **kwargs) -> None: # noqa: D107, ANN001
super().__init__(**kwargs)
self.fields = {item["name"]: item["field"] for item in self.generate_fields(parameters)}
Expand Down
9 changes: 0 additions & 9 deletions slapp/explorer/widgets.py

This file was deleted.

84 changes: 10 additions & 74 deletions slapp/templates/pages/parameters.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,42 +83,15 @@ <h2>Parameter für die Energiesystemoptimieung festlegen</h2>
<div class="h-270px table-cell">
<fieldset class="mb-3">
<div class="form-check">
<input class="form-check-input"
type="radio"
name="pv-{{ municipality.id }}-selection"
id="pv-{{ municipality.id }}-noLimitRadio"
checked />
keine Obergrenze angeben
</div>
<div class="form-check">
<input class="form-check-input"
type="radio"
name="pv-{{ municipality.id }}-selection"
id="pv-{{ municipality.id }}-MW" />
<!-- This is the additional input field right next to the second radio button -->
<input type="text"
id="pv-{{ municipality.id }}-MW"
class="js-range-slider"
value=""
data-min="{{ sliders_config.s_w_1.min|stringformat:'s' }}"
data-max="{{ sliders_config.s_w_1.max|stringformat:'s' }}"
data-from="{{ sliders_config.s_w_1.from|stringformat:'s' }}"
data-step="{{ sliders_config.s_w_1.step|stringformat:'s' }}" />
<!-- This is the input slider -->
<span>{{ sliders_form.1_pv }}</span>
<label class="form-check-label d-inline-block" for="maxOutputRadio">
<label class="form-check-label d-inline-block">
MW max. Gesamtleistung <i>(aktuell: 0,12 MW)</i>
</label>
</div>
<div class="form-check">
<input class="form-check-input"
type="radio"
name="pv-{{ municipality.id }}-selection"
id="pv-{{ municipality.id }}-area" />
<!-- This is the additional input field right next to the second radio button -->
<input type="text"
id="maxOutputValue"
class="form-control d-inline-block w-auto form-control-sm"
value="0,27" />
<!-- This is the input slider -->
<span>{{ sliders_form.1_pv }}</span>
<label class="form-check-label d-inline-block"
for="pv-{{ municipality.id }}-area">
km² max. Flächenverbrauch <i>(1,73 km² ausgewiesen, davon derzeit 0,27 km² belegt)</i>
Expand All @@ -130,37 +103,15 @@ <h2>Parameter für die Energiesystemoptimieung festlegen</h2>
<div class="h-270px table-cell">
<fieldset class="mb-3">
<div class="form-check">
<input class="form-check-input"
type="radio"
name="wind-{{ municipality.id }}-selection"
id="wind-{{ municipality.id }}-noLimitRadio"
checked />
keine Obergrenze angeben
</div>
<div class="form-check">
<input class="form-check-input"
type="radio"
name="wind-{{ municipality.id }}-selection"
id="wind-{{ municipality.id }}-MW" />
<!-- This is the additional input field right next to the second radio button -->
<input type="text"
id="wind-{{ municipality.id }}-MW"
class="form-control d-inline-block w-auto form-control-sm"
value="0,12" />
<!-- This is the input slider -->
<span>{{ sliders_form.1_wind }}</span>
<label class="form-check-label d-inline-block" for="maxOutputRadio">
MW max. Gesamtleistung <i>(aktuell: 0,12 MW)</i>
</label>
</div>
<div class="form-check">
<input class="form-check-input"
type="radio"
name="wind-{{ municipality.id }}-selection"
id="wind-{{ municipality.id }}-area" />
<!-- This is the additional input field right next to the second radio button -->
<input type="text"
id="maxOutputValue"
class="form-control d-inline-block w-auto form-control-sm"
value="0,27" />
<!-- This is the input slider -->
{{ sliders_form.1_wind }}
<label class="form-check-label d-inline-block"
for="pv-{{ municipality.id }}-area">
km² max. Flächenverbrauch <i>(1,73 km² ausgewiesen, davon derzeit 0,27 km² belegt)</i>
Expand All @@ -172,23 +123,8 @@ <h2>Parameter für die Energiesystemoptimieung festlegen</h2>
<div class="h-155px table-cell">
<fieldset class="mb-3">
<div class="form-check">
<input class="form-check-input"
type="radio"
name="hydro-{{ municipality.id }}-selection"
id="hydro-{{ municipality.id }}-noLimitRadio"
checked />
keine Obergrenze angeben
</div>
<div class="form-check">
<input class="form-check-input"
type="radio"
name="hydro-{{ municipality.id }}-selection"
id="hydro-{{ municipality.id }}-MW" />
<!-- This is the additional input field right next to the second radio button -->
<input type="text"
id="hydro-{{ municipality.id }}-MW"
class="form-control d-inline-block w-auto form-control-sm"
value="0,12" />
<!-- This is the input slider -->
{{ sliders_form.1_hydro }}
<label class="form-check-label d-inline-block" for="maxOutputRadio">
MW max. Gesamtleistung <i>(aktuell: 0,12 MW)</i>
</label>
Expand Down
14 changes: 0 additions & 14 deletions slapp/templates/widgets/slider.html

This file was deleted.

0 comments on commit c7e3b28

Please sign in to comment.