2020-02-19 05:51:28 +13:00
|
|
|
<script>
|
2020-09-05 09:40:25 +12:00
|
|
|
import { Modal, Button, Heading, Spacer } from "@budibase/bbui"
|
2020-02-25 04:00:48 +13:00
|
|
|
|
|
|
|
export let title = ""
|
|
|
|
export let body = ""
|
|
|
|
export let okText = "OK"
|
|
|
|
export let cancelText = "Cancel"
|
|
|
|
export let onOk = () => {}
|
|
|
|
export let onCancel = () => {}
|
|
|
|
|
|
|
|
export const show = () => {
|
2020-09-03 19:44:08 +12:00
|
|
|
theModal.show()
|
2020-02-25 04:00:48 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
export const hide = () => {
|
2020-09-03 19:44:08 +12:00
|
|
|
theModal.hide()
|
2020-02-25 04:00:48 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
let theModal
|
|
|
|
|
|
|
|
const cancel = () => {
|
|
|
|
hide()
|
|
|
|
onCancel()
|
|
|
|
}
|
|
|
|
|
|
|
|
const ok = () => {
|
2020-08-19 07:59:34 +12:00
|
|
|
const result = onOk()
|
2020-08-19 08:04:42 +12:00
|
|
|
// allow caller to return false, to cancel the "ok"
|
2020-08-19 07:59:34 +12:00
|
|
|
if (result === false) return
|
2020-02-25 04:00:48 +13:00
|
|
|
hide()
|
|
|
|
}
|
2020-02-19 05:51:28 +13:00
|
|
|
</script>
|
|
|
|
|
2020-09-03 19:44:08 +12:00
|
|
|
<Modal id={title} bind:this={theModal}>
|
|
|
|
<h2>{title}</h2>
|
2020-09-05 09:40:25 +12:00
|
|
|
<Spacer extraLarge />
|
|
|
|
<slot class="rows">{body}</slot>
|
|
|
|
<Spacer extraLarge />
|
2020-09-03 19:44:08 +12:00
|
|
|
<div class="modal-footer">
|
|
|
|
<Button red wide on:click={ok}>{okText}</Button>
|
|
|
|
<Button secondary wide on:click={cancel}>{cancelText}</Button>
|
2020-02-19 05:51:28 +13:00
|
|
|
</div>
|
2020-09-03 19:44:08 +12:00
|
|
|
</Modal>
|
2020-03-24 23:56:48 +13:00
|
|
|
|
|
|
|
<style>
|
2020-09-03 19:44:08 +12:00
|
|
|
h2 {
|
|
|
|
font-size: var(--font-size-xl);
|
|
|
|
margin: 0;
|
|
|
|
font-family: var(--font-sans);
|
|
|
|
font-weight: 600;
|
|
|
|
}
|
|
|
|
|
|
|
|
.modal-footer {
|
|
|
|
display: grid;
|
|
|
|
grid-gap: var(--spacing-s);
|
2020-03-28 05:58:32 +13:00
|
|
|
}
|
2020-03-24 23:56:48 +13:00
|
|
|
</style>
|