1
0
Fork 0
mirror of synced 2024-07-11 01:06:04 +12:00

Fix issue where changing the role of a screen did not correctly update screen list

This commit is contained in:
Andrew Kingston 2022-04-01 18:02:34 +01:00
parent cf7900564a
commit a846c701ef

View file

@ -3,13 +3,14 @@
import PathTree from "./PathTree.svelte"
let routes = {}
$: paths = Object.keys(routes || {}).sort()
let paths = []
$: {
const allRoutes = $store.routes
$: allRoutes = $store.routes
$: selectedScreenId = $store.selectedScreenId
$: updatePaths(allRoutes, $selectedAccessRole, selectedScreenId)
const updatePaths = (allRoutes, selectedRoleId, selectedScreenId) => {
const sortedPaths = Object.keys(allRoutes || {}).sort()
const selectedRoleId = $selectedAccessRole
const selectedScreenId = $store.selectedScreenId
let found = false
let firstValidScreenId
@ -41,11 +42,15 @@
})
})
})
routes = filteredRoutes
routes = { ...filteredRoutes }
paths = Object.keys(routes || {}).sort()
// Select the correct role for the current screen ID
if (!found && screenRoleId) {
selectedAccessRole.set(screenRoleId)
if (screenRoleId !== selectedRoleId) {
updatePaths(allRoutes, screenRoleId, selectedScreenId)
}
}
// If the selected screen isn't in this filtered list, select the first one