@@ -50,6 +50,7 @@ function ScreenForm({
5050 const { t } = useTranslation ( "common" , { keyPrefix : "screen-form" } ) ;
5151 const navigate = useNavigate ( ) ;
5252 const dispatch = useDispatch ( ) ;
53+ const [ layoutError , setLayoutError ] = useState ( false ) ;
5354 const [ selectedLayout , setSelectedLayout ] = useState ( ) ;
5455 const [ layoutOptions , setLayoutOptions ] = useState ( ) ;
5556 const [ bindKey , setBindKey ] = useState ( "" ) ;
@@ -59,6 +60,21 @@ function ScreenForm({
5960 order : { createdAt : "desc" } ,
6061 } ) ;
6162
63+ /** Check if published is set */
64+ const checkInputsHandleSubmit = ( ) => {
65+ setLayoutError ( false ) ;
66+ let submit = true ;
67+ if ( ! selectedLayout ) {
68+ displayError ( t ( "remember-layout-error" ) ) ;
69+ setLayoutError ( true ) ;
70+ submit = false ;
71+ }
72+
73+ if ( submit ) {
74+ handleSubmit ( ) ;
75+ }
76+ } ;
77+
6278 useEffect ( ( ) => {
6379 if ( layouts ) {
6480 setLayoutOptions ( layouts [ "hydra:member" ] ) ;
@@ -72,6 +88,11 @@ function ScreenForm({
7288 ) ;
7389 if ( localSelectedLayout ) {
7490 setSelectedLayout ( localSelectedLayout ) ;
91+ // Initialize regions in the formstate object of screenmanager. used to save "empty" playlists, in the situation
92+ // we are deleting all playlists from a screen region
93+ handleInput ( {
94+ target : { id : "regions" , value : localSelectedLayout . regions } ,
95+ } ) ;
7596 }
7697 }
7798 } , [ screen . layout , layoutOptions ] ) ;
@@ -84,6 +105,7 @@ function ScreenForm({
84105 */
85106 const handleAdd = ( { target } ) => {
86107 const { value, id } = target ;
108+
87109 setSelectedLayout ( value ) ;
88110 handleInput ( {
89111 target : { id, value : value . map ( ( item ) => item [ "@id" ] ) . shift ( ) } ,
@@ -250,7 +272,7 @@ function ScreenForm({
250272 noSelectedString = { t ( "nothing-selected-resolution" ) }
251273 handleSelection = { handleInput }
252274 options = { resolutionOptions }
253- selected = { screen . resolution || "" }
275+ selected = { screen . resolution || [ ] }
254276 name = "resolution"
255277 singleSelect
256278 />
@@ -259,7 +281,7 @@ function ScreenForm({
259281 noSelectedString = { t ( "nothing-selected-orientation" ) }
260282 handleSelection = { handleInput }
261283 options = { orientationOptions }
262- selected = { screen . orientation || "" }
284+ selected = { screen . orientation || [ ] }
263285 name = "orientation"
264286 singleSelect
265287 />
@@ -277,6 +299,7 @@ function ScreenForm({
277299 helpText = { t ( "search-to-se-possible-selections" ) }
278300 selected = { selectedLayout ? [ selectedLayout ] : [ ] }
279301 name = "layout"
302+ error = { layoutError }
280303 singleSelect
281304 />
282305 </ div >
@@ -321,7 +344,7 @@ function ScreenForm({
321344 type = "button"
322345 id = "save_screen"
323346 size = "lg"
324- onClick = { handleSubmit }
347+ onClick = { checkInputsHandleSubmit }
325348 >
326349 { t ( "save-button" ) }
327350 </ Button >
@@ -340,7 +363,11 @@ ScreenForm.propTypes = {
340363 enableColorSchemeChange : PropTypes . bool ,
341364 layout : PropTypes . string ,
342365 location : PropTypes . string ,
343- regions : PropTypes . arrayOf ( PropTypes . string ) ,
366+ regions : PropTypes . arrayOf (
367+ PropTypes . shape ( {
368+ "@id" : PropTypes . string ,
369+ } )
370+ ) ,
344371 screenUser : PropTypes . string ,
345372 size : PropTypes . string ,
346373 title : PropTypes . string ,
0 commit comments