1
0
Fork 0
mirror of synced 2024-06-02 18:44:54 +12:00

Allow configuring whether notification is automatically dismissed or not

This commit is contained in:
Andrew Kingston 2022-08-22 11:08:52 +01:00
parent ab0d6bd6ed
commit acc71cb0e9
3 changed files with 18 additions and 9 deletions

View file

@ -1,5 +1,5 @@
<script>
import { Select, Label } from "@budibase/bbui"
import { Select, Label, Checkbox } from "@budibase/bbui"
import { onMount } from "svelte"
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
@ -28,17 +28,22 @@
if (!parameters.type) {
parameters.type = "success"
}
if (parameters.autoDismiss == null) {
parameters.autoDismiss = true
}
})
</script>
<div class="root">
<Label small>Type</Label>
<Label>Type</Label>
<Select bind:value={parameters.type} options={types} placeholder={null} />
<Label small>Message</Label>
<Label>Message</Label>
<DrawerBindableInput
value={parameters.message}
on:change={e => (parameters.message = e.detail)}
/>
<Label />
<Checkbox text="Auto dismiss" bind:value={parameters.autoDismiss} />
</div>
<style>

View file

@ -62,10 +62,14 @@ const createNotificationStore = () => {
subscribe: store.subscribe,
actions: {
send,
info: msg => send(msg, "info", "Info"),
success: msg => send(msg, "success", "CheckmarkCircle"),
warning: msg => send(msg, "warning", "Alert"),
error: msg => send(msg, "error", "Alert", false),
info: (msg, autoDismiss) =>
send(msg, "info", "Info", autoDismiss ?? true),
success: (msg, autoDismiss) =>
send(msg, "success", "CheckmarkCircle", autoDismiss ?? true),
warning: (msg, autoDismiss) =>
send(msg, "warning", "Alert", autoDismiss ?? true),
error: (msg, autoDismiss) =>
send(msg, "error", "Alert", autoDismiss ?? false),
blockNotifications,
dismiss,
},

View file

@ -301,11 +301,11 @@ const continueIfHandler = action => {
}
const showNotificationHandler = action => {
const { message, type } = action.parameters
const { message, type, autoDismiss } = action.parameters
if (!message || !type) {
return
}
notificationStore.actions[type]?.(message)
notificationStore.actions[type]?.(message, autoDismiss)
}
const handlerMap = {