From f93d557aa95b55444e7bf8b185684ad45cec636c Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Wed, 15 Mar 2023 11:44:18 +0100 Subject: [PATCH] =?UTF-8?q?Move=20the=20multiselect=20=E2=80=9Ccomponent?= =?UTF-8?q?=E2=80=9D=20to=20the=20select-field=20template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I had in the product edit page only because it was easier to test there while i was developing it, but it is something that should be done for all select[multiple], of course. I removed the whole x-cloak thing because i am not sure what would happen if i do something wrong and Alpine can not initialize the multiselect; probably show nothing to the user. Now it shows the native select a fraction of a second, but if i fuck it up at least the user can still use the app. --- web/static/numerus.css | 5 --- web/template/app.gohtml | 7 ---- web/template/form.gohtml | 40 ++++++++++++++++++++++- web/template/products/edit.gohtml | 53 +------------------------------ 4 files changed, 40 insertions(+), 65 deletions(-) diff --git a/web/static/numerus.css b/web/static/numerus.css index 4f1b572..2db0b16 100644 --- a/web/static/numerus.css +++ b/web/static/numerus.css @@ -588,11 +588,6 @@ main > nav { right: 0; } -/* AlpineJS */ -[x-cloak] { - display: none !important; -} - /* Multiselect */ .multiselect { max-width: 35rem; diff --git a/web/template/app.gohtml b/web/template/app.gohtml index d0ad46a..237a83c 100644 --- a/web/template/app.gohtml +++ b/web/template/app.gohtml @@ -6,13 +6,6 @@ {{ template "title" . }} — Numerus -
diff --git a/web/template/form.gohtml b/web/template/form.gohtml index 6b9eadb..ac56505 100644 --- a/web/template/form.gohtml +++ b/web/template/form.gohtml @@ -40,7 +40,21 @@ {{ define "select-field" -}} {{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.SelectField*/ -}} -
+
+ {{- if .Multiple }} + + {{ end -}} {{- if .Errors }}
    diff --git a/web/template/products/edit.gohtml b/web/template/products/edit.gohtml index 0f04c9f..2fd3085 100644 --- a/web/template/products/edit.gohtml +++ b/web/template/products/edit.gohtml @@ -20,58 +20,7 @@ {{ template "input-field" .Name | addInputAttr "autofocus" }} {{ template "input-field" .Description }} {{ template "input-field" .Price }} -
    -
    - {{ template "select-field" .Tax }} -
    - {{ with .Tax }} - - {{ end }} -
    + {{ template "select-field" .Tax }}