Korjaa monivalintalistat (palveluyksiköt, muut jäsenet)

CheckboxSelectMultiple on RadioSelectin aliluokka, joten valintaruudut
saivat daisyUI:n radio-luokan, ja sama luokka meni myös listan
ympärillä olevalle divillä: lista kutistui pieneksi ympyräksi.

- Widget-luokkien järjestys korjattu (checkbox ennen radiota).
- Valintaryhmät renderöidään fieldset + legend -rakenteena, jokaisella
  vaihtoehdolla oma label; puhelimella yksi sarake, leveämmällä kaksi.
- Testit rakenteelle, virheen liitokselle ja näppäimistövalinnalle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-29 14:53:03 +02:00
co-authored by Claude Opus 5.5
parent 1ca03137fd
commit fe6af96a31
4 changed files with 59 additions and 2 deletions
+17
View File
@@ -126,6 +126,23 @@ class TestCreateAndEdit:
assert "Aili Alihankkija" in detail
assert "Alustava" in detail and "Normaali" in detail
def test_choice_lists_are_checkbox_groups(
self, employee_client: Client, customer: CustomerModel, unit: ServiceUnitModel
) -> None:
html = employee_client.get("/jobs/new/").content.decode()
assert "<legend" in html and html.count('<fieldset class="fieldset"') >= 2
assert f'type="checkbox" name="service_units" value="{unit.pk}" class="checkbox"' in html
assert 'type="checkbox" name="members"' in html
assert 'class="radio"' not in html
assert 'for="id_service_units"' not in html # no label pointing at the wrapper
response = create(employee_client, customer, unit, service_units=[])
assert response.status_code == 422
page = response.content.decode()
assert 'aria-describedby="id_service_units_error"' in page
assert f'name="service_units" value="{unit.pk}" class="checkbox"' in page
assert "Valitse vähintään yksi palveluyksikkö." in page
def test_existing_tag_is_reused_ignoring_case(
self, employee_client: Client, customer: CustomerModel, unit: ServiceUnitModel
) -> None:
+2 -1
View File
@@ -17,10 +17,11 @@ class DaisyFormRenderer(TemplatesSetting):
field_template_name = "components/field.html"
# First isinstance match wins: CheckboxSelectMultiple is a subclass of RadioSelect.
_WIDGET_CLASSES: list[tuple[type[forms.Widget], str]] = [
(forms.CheckboxInput, "checkbox"),
(forms.RadioSelect, "radio"),
(forms.CheckboxSelectMultiple, "checkbox"),
(forms.RadioSelect, "radio"),
(forms.Select, "select w-full"),
(forms.Textarea, "textarea w-full"),
(Input, "input w-full"),