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
1 changed files with 7 additions and 5 deletions

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
) )
} }