2021-11-10 17:04:27 +01:00
|
|
|
<script>
|
2021-11-23 21:14:28 +01:00
|
|
|
import { ModalContent, Input, ProgressCircle } from "@budibase/bbui"
|
2021-11-15 12:03:09 +01:00
|
|
|
import sanitizeUrl from "builderStore/store/screenTemplates/utils/sanitizeUrl"
|
|
|
|
import { selectedAccessRole, allScreens } from "builderStore"
|
2021-11-29 12:53:46 +01:00
|
|
|
import { onDestroy } from "svelte"
|
2021-11-10 17:04:27 +01:00
|
|
|
|
2021-11-11 13:09:36 +01:00
|
|
|
export let screenName
|
2021-11-15 12:03:09 +01:00
|
|
|
export let url
|
2021-11-17 11:24:14 +01:00
|
|
|
export let chooseModal
|
2021-11-23 10:01:12 +01:00
|
|
|
export let save
|
2021-11-23 21:14:28 +01:00
|
|
|
export let showProgressCircle = false
|
|
|
|
|
2021-11-15 12:03:09 +01:00
|
|
|
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
|
|
|
|
)
|
|
|
|
}
|
2021-11-29 12:53:46 +01:00
|
|
|
|
|
|
|
onDestroy(() => {
|
|
|
|
screenName = ""
|
|
|
|
url = ""
|
|
|
|
})
|
2021-11-10 17:04:27 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<ModalContent
|
|
|
|
size="M"
|
2021-11-16 13:18:13 +01:00
|
|
|
title={"Enter details"}
|
2021-11-10 17:04:27 +01:00
|
|
|
confirmText={"Continue"}
|
2021-11-17 11:24:14 +01:00
|
|
|
onCancel={() => chooseModal(0)}
|
2021-11-23 10:01:12 +01:00
|
|
|
onConfirm={() => save()}
|
2021-11-10 17:04:27 +01:00
|
|
|
cancelText={"Back"}
|
2021-11-15 12:03:09 +01:00
|
|
|
disabled={!screenName || !url || routeError}
|
2021-11-10 17:04:27 +01:00
|
|
|
>
|
2021-11-11 13:09:36 +01:00
|
|
|
<Input label="Name" bind:value={screenName} />
|
2021-11-15 12:03:09 +01:00
|
|
|
<Input
|
|
|
|
label="URL"
|
|
|
|
error={routeError}
|
|
|
|
bind:value={url}
|
|
|
|
on:change={routeChanged}
|
|
|
|
/>
|
2021-11-23 21:14:28 +01:00
|
|
|
<div slot="footer">
|
|
|
|
{#if showProgressCircle}
|
|
|
|
<div class="footer-progress"><ProgressCircle size="S" /></div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2021-11-10 17:04:27 +01:00
|
|
|
</ModalContent>
|
2021-11-23 21:14:28 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.footer-progress {
|
|
|
|
margin-top: var(--spacing-s);
|
|
|
|
}
|
|
|
|
</style>
|