From 7e993a86b377bc87021c6cd4ed396e94692753c8 Mon Sep 17 00:00:00 2001 From: Sine Jespersen Date: Wed, 23 Oct 2024 13:25:00 +0200 Subject: [PATCH 01/12] 2807: add invalid styling for multiselect component --- .../util/forms/multiselect-dropdown/multi-dropdown.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/util/forms/multiselect-dropdown/multi-dropdown.scss b/src/components/util/forms/multiselect-dropdown/multi-dropdown.scss index e301580d..a42030dd 100644 --- a/src/components/util/forms/multiselect-dropdown/multi-dropdown.scss +++ b/src/components/util/forms/multiselect-dropdown/multi-dropdown.scss @@ -1,4 +1,10 @@ +@import "bootstrap/scss/bootstrap"; + .rmsc { + &.invalid { + border: 1px solid $red; + } + &.single-select { input[type="checkbox"] { opacity: 0; From 959c61f592adf443546f63b93705e9f3c60d54b4 Mon Sep 17 00:00:00 2001 From: Sine Jespersen Date: Wed, 23 Oct 2024 13:25:17 +0200 Subject: [PATCH 02/12] 2807: add screen layout validation --- src/components/screen/screen-form.jsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/components/screen/screen-form.jsx b/src/components/screen/screen-form.jsx index bd17030c..3286224e 100644 --- a/src/components/screen/screen-form.jsx +++ b/src/components/screen/screen-form.jsx @@ -50,6 +50,7 @@ function ScreenForm({ const { t } = useTranslation("common", { keyPrefix: "screen-form" }); const navigate = useNavigate(); const dispatch = useDispatch(); + const [layoutError, setLayoutError] = useState(false); const [selectedLayout, setSelectedLayout] = useState(); const [layoutOptions, setLayoutOptions] = useState(); const [bindKey, setBindKey] = useState(""); @@ -59,6 +60,20 @@ function ScreenForm({ order: { createdAt: "desc" }, }); + /** Check if published is set */ + const checkInputsHandleSubmit = () => { + setLayoutError(false); + let submit = true; + if (!selectedLayout) { + setLayoutError(true); + submit = false; + } + + if (submit) { + handleSubmit(); + } + }; + useEffect(() => { if (layouts) { setLayoutOptions(layouts["hydra:member"]); @@ -283,6 +298,7 @@ function ScreenForm({ helpText={t("search-to-se-possible-selections")} selected={selectedLayout ? [selectedLayout] : []} name="layout" + error={layoutError} singleSelect /> @@ -327,7 +343,7 @@ function ScreenForm({ type="button" id="save_screen" size="lg" - onClick={handleSubmit} + onClick={checkInputsHandleSubmit} > {t("save-button")} From 6559727a5afb8f72ebde00afb8e4f5ba11e6bc72 Mon Sep 17 00:00:00 2001 From: Sine Jespersen Date: Wed, 23 Oct 2024 13:25:33 +0200 Subject: [PATCH 03/12] 2807: add slide template validation --- src/components/slide/slide-form.jsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/components/slide/slide-form.jsx b/src/components/slide/slide-form.jsx index 2ae24f73..7dc763f9 100644 --- a/src/components/slide/slide-form.jsx +++ b/src/components/slide/slide-form.jsx @@ -72,6 +72,7 @@ function SlideForm({ const [searchTextTheme, setSearchTextTheme] = useState(""); const [selectedTemplates, setSelectedTemplates] = useState([]); const [themesOptions, setThemesOptions] = useState(); + const [templateError, setTemplateError] = useState(false); // Load templates. const { data: templates, isLoading: loadingTemplates } = @@ -87,6 +88,20 @@ function SlideForm({ order: { createdAt: "desc" }, }); + /** Check if published is set */ + const checkInputsHandleSubmit = () => { + setTemplateError(false); + let submit = true; + if (!selectedTemplate) { + setTemplateError(true); + submit = false; + } + + if (submit) { + handleSubmit(); + } + }; + /** * For closing overlay on escape key. * @@ -227,6 +242,7 @@ function SlideForm({ handleSelection={selectTemplate} options={templateOptions} selected={selectedTemplates} + error={templateError} name="templateInfo" filterCallback={onFilterTemplate} singleSelect @@ -484,7 +500,7 @@ function SlideForm({