1
0
Fork 0
mirror of synced 2024-07-06 15:00:49 +12:00

Allow multiple screens to have the same URL as long as role is different

This commit is contained in:
Andrew Kingston 2020-12-09 18:39:49 +00:00
parent e5a34871c7
commit 7768b9ace8

View file

@ -48,10 +48,10 @@
const save = async () => { const save = async () => {
if (!route) { if (!route) {
routeError = "Url is required" routeError = "URL is required"
} else { } else {
if (routeNameExists(route)) { if (routeExists(route, roleId)) {
routeError = "This url is already taken" routeError = "This URL is already taken for this access role"
} else { } else {
routeError = "" routeError = ""
} }
@ -79,9 +79,11 @@
$goto(`./${createdScreen._id}`) $goto(`./${createdScreen._id}`)
} }
const routeNameExists = route => { const routeExists = (route, roleId) => {
return $allScreens.some( return $allScreens.some(
screen => screen.routing.route.toLowerCase() === route.toLowerCase() screen =>
screen.routing.route.toLowerCase() === route.toLowerCase() &&
screen.routing.roleId === roleId
) )
} }