forked from tsai/budibase
4 changed files with 84 additions and 19 deletions
@ -1,19 +1,52 @@ |
|||||
<script> |
<script> |
||||
import { ModalContent, Input } from "@budibase/bbui" |
import { ModalContent, Input } from "@budibase/bbui" |
||||
|
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl" |
||||
|
import { selectedAccessRole, allScreens } from "builderStore" |
||||
|
|
||||
export let modal |
export let modal |
||||
export let navigationSelectionModal |
export let navigationSelectionModal |
||||
export let screenName |
export let screenName |
||||
|
export let url |
||||
|
|
||||
|
let routeError |
||||
|
let roleId = $selectedAccessRole || "BASIC" |
||||
|
|
||||
|
const routeChanged = event => { |
||||
|
if (!event.detail.startsWith("/")) { |
||||
|
url = "/" + event.detail |
||||
|
} |
||||
|
url = sanitizeUrl(url) |
||||
|
|
||||
|
if (routeExists(url, roleId)) { |
||||
|
routeError = "This URL is already taken for this access role" |
||||
|
} else { |
||||
|
routeError = "" |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const routeExists = (url, roleId) => { |
||||
|
return $allScreens.some( |
||||
|
screen => |
||||
|
screen.routing.route.toLowerCase() === url.toLowerCase() && |
||||
|
screen.routing.roleId === roleId |
||||
|
) |
||||
|
} |
||||
</script> |
</script> |
||||
|
|
||||
<ModalContent |
<ModalContent |
||||
size="M" |
size="M" |
||||
title={"Enter name"} |
title={"Enter Details"} |
||||
confirmText={"Continue"} |
confirmText={"Continue"} |
||||
onCancel={() => modal.show()} |
onCancel={() => modal.show()} |
||||
onConfirm={() => navigationSelectionModal.show()} |
onConfirm={() => navigationSelectionModal.show()} |
||||
cancelText={"Back"} |
cancelText={"Back"} |
||||
disabled={!screenName} |
disabled={!screenName || !url || routeError} |
||||
> |
> |
||||
<Input label="Name" bind:value={screenName} /> |
<Input label="Name" bind:value={screenName} /> |
||||
|
<Input |
||||
|
label="URL" |
||||
|
error={routeError} |
||||
|
bind:value={url} |
||||
|
on:change={routeChanged} |
||||
|
/> |
||||
</ModalContent> |
</ModalContent> |
||||
|
|||||
Loading…
Reference in new issue