diff --git a/CHANGELOG.md b/CHANGELOG.md index 915961c8..23ee3982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,23 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- [#265](https://github.com/os2display/display-admin-client/pull/265) + - Add no-cache directive + - [#263](https://github.com/os2display/display-admin-client/pull/263) - Added prefix to local storage keys. + +- [#262](https://github.com/os2display/display-admin-client/pull/262) + - Add multi select styling for `invalid` state + - Add possibility of sending error via props to multiselect component + - Add validation checking if layout is selected on screen before save + - Add validation checking if template is selected on slide before save + - [#260](https://github.com/os2display/display-admin-client/pull/260) - Bug in multiselect, fixed by removing duplicates by key both `@id`and `id` - [#265](https://github.com/os2display/display-admin-client/pull/265) - Bug in multiselect, fixed by removing duplicates by key both `@id`and `id` + - [#259](https://github.com/os2display/display-admin-client/pull/259) - Add saving of playlists/groups with screen (as opposed to _after_) - Clean up `screen-manager.jsx` diff --git a/e2e/slides.spec.js b/e2e/slides.spec.js index 7895caeb..5507c01c 100644 --- a/e2e/slides.spec.js +++ b/e2e/slides.spec.js @@ -145,11 +145,7 @@ test.describe("Create slide page works", () => { page.locator(".Toastify").locator(".Toastify__toast--error") ).toBeVisible(); await expect( - page - .locator(".Toastify") - .locator(".Toastify__toast--error") - .getByText(/An error occurred/) - .first() + page.locator(".Toastify").locator(".Toastify__toast--error").first() ).toBeVisible(); await expect(page).toHaveURL(/slide\/create/); }); diff --git a/src/components/screen/screen-form.jsx b/src/components/screen/screen-form.jsx index bd17030c..0c702c3b 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,21 @@ function ScreenForm({ order: { createdAt: "desc" }, }); + /** Check if published is set */ + const checkInputsHandleSubmit = () => { + setLayoutError(false); + let submit = true; + if (!selectedLayout) { + displayError(t("remember-layout-error")); + setLayoutError(true); + submit = false; + } + + if (submit) { + handleSubmit(); + } + }; + useEffect(() => { if (layouts) { setLayoutOptions(layouts["hydra:member"]); @@ -283,6 +299,7 @@ function ScreenForm({ helpText={t("search-to-se-possible-selections")} selected={selectedLayout ? [selectedLayout] : []} name="layout" + error={layoutError} singleSelect /> @@ -327,7 +344,7 @@ function ScreenForm({ type="button" id="save_screen" size="lg" - onClick={handleSubmit} + onClick={checkInputsHandleSubmit} > {t("save-button")} diff --git a/src/components/screen/screen-manager.jsx b/src/components/screen/screen-manager.jsx index c9ea4249..6983fb01 100644 --- a/src/components/screen/screen-manager.jsx +++ b/src/components/screen/screen-manager.jsx @@ -257,7 +257,7 @@ function ScreenManager({ regions: mapPlaylistsWithRegion(), }), }; - debugger; + setLoadingMessage(t("loading-messages.saving-screen")); if (saveMethod === "POST") { diff --git a/src/components/slide/slide-form.jsx b/src/components/slide/slide-form.jsx index 2ae24f73..1755b490 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,21 @@ function SlideForm({ order: { createdAt: "desc" }, }); + /** Check if published is set */ + const checkInputsHandleSubmit = () => { + setTemplateError(false); + let submit = true; + if (!selectedTemplate) { + setTemplateError(true); + submit = false; + displayError(t("slide-form.remember-template-error")); + } + + if (submit) { + handleSubmit(); + } + }; + /** * For closing overlay on escape key. * @@ -227,6 +243,7 @@ function SlideForm({ handleSelection={selectTemplate} options={templateOptions} selected={selectedTemplates} + error={templateError} name="templateInfo" filterCallback={onFilterTemplate} singleSelect @@ -484,7 +501,7 @@ function SlideForm({