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