Update screen settings to use patches
This commit is contained in:
parent
d5b8ddafaf
commit
e46f64a166
|
@ -309,13 +309,17 @@ export const getFrontendStore = () => {
|
|||
)
|
||||
})
|
||||
if (existingHomeScreen) {
|
||||
const patch = screen => (screen.routing.homeScreen = false)
|
||||
const patch = screen => {
|
||||
screen.routing.homeScreen = false
|
||||
}
|
||||
await store.actions.screens.patch(patch, existingHomeScreen._id)
|
||||
}
|
||||
}
|
||||
|
||||
// Update the passed in screen
|
||||
const patch = screen => (screen.routing.homeScreen = makeHomeScreen)
|
||||
const patch = screen => {
|
||||
screen.routing.homeScreen = makeHomeScreen
|
||||
}
|
||||
await store.actions.screens.patch(patch, screen._id)
|
||||
},
|
||||
removeCustomLayout: async screen => {
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
)
|
||||
}
|
||||
|
||||
const setScreenSetting = (setting, value) => {
|
||||
const setScreenSetting = async (setting, value) => {
|
||||
const { key, parser, validate } = setting
|
||||
|
||||
// Parse value if required
|
||||
|
@ -69,26 +69,16 @@
|
|||
|
||||
// Home screen changes need to be handled manually
|
||||
if (key === "routing.homeScreen") {
|
||||
store.actions.screens.updateHomeScreen(get(selectedScreen), value)
|
||||
console.log(value)
|
||||
await store.actions.screens.updateHomeScreen(get(selectedScreen), value)
|
||||
return
|
||||
}
|
||||
|
||||
// Update screen object in store
|
||||
// If there are 2 home screens after this change, remove this screen as a
|
||||
// home screen
|
||||
const screen = get(selectedScreen)
|
||||
setWith(screen, key.split("."), value, Object)
|
||||
const roleId = screen.routing.roleId
|
||||
const homeScreens = get(store).screens.filter(screen => {
|
||||
return screen.routing.roleId === roleId && screen.routing.homeScreen
|
||||
})
|
||||
if (homeScreens.length > 1) {
|
||||
screen.routing.homeScreen = false
|
||||
}
|
||||
|
||||
// Save new definition
|
||||
// Update screen setting
|
||||
try {
|
||||
store.actions.screens.save(screen)
|
||||
await store.actions.screens.patch(screen => {
|
||||
setWith(screen, key.split("."), value, Object)
|
||||
})
|
||||
} catch (error) {
|
||||
notifications.error("Error saving screen settings")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue