Add the option to change the confirm and cancel button texts within the confirmation modals (#13966)
* Add button parameters to actions * Add button states to confirmation store * Set text of buttons if values are exist * Pass stored values through to the modal * Add missing duplicate text map * Fix lint issues --------- Co-authored-by: melohagan <101575380+melohagan@users.noreply.github.com>
This commit is contained in:
parent
f42d302f48
commit
9a375d6716
|
@ -53,6 +53,12 @@
|
||||||
placeholder="Are you sure you want to delete?"
|
placeholder="Are you sure you want to delete?"
|
||||||
bind:value={parameters.confirmText}
|
bind:value={parameters.confirmText}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Label small>Confirm Text</Label>
|
||||||
|
<Input placeholder="Confirm" bind:value={parameters.confirmButtonText} />
|
||||||
|
|
||||||
|
<Label small>Cancel Text</Label>
|
||||||
|
<Input placeholder="Cancel" bind:value={parameters.cancelButtonText} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -83,6 +83,12 @@
|
||||||
placeholder="Are you sure you want to duplicate this row?"
|
placeholder="Are you sure you want to duplicate this row?"
|
||||||
bind:value={parameters.confirmText}
|
bind:value={parameters.confirmText}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Label small>Confirm Text</Label>
|
||||||
|
<Input placeholder="Confirm" bind:value={parameters.confirmButtonText} />
|
||||||
|
|
||||||
|
<Label small>Cancel Text</Label>
|
||||||
|
<Input placeholder="Cancel" bind:value={parameters.cancelButtonText} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,18 @@
|
||||||
placeholder="Are you sure you want to execute this query?"
|
placeholder="Are you sure you want to execute this query?"
|
||||||
bind:value={parameters.confirmText}
|
bind:value={parameters.confirmText}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="Confirm Text"
|
||||||
|
placeholder="Confirm"
|
||||||
|
bind:value={parameters.confirmButtonText}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="Cancel Text"
|
||||||
|
placeholder="Cancel"
|
||||||
|
bind:value={parameters.cancelButtonText}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if query?.parameters?.length > 0}
|
{#if query?.parameters?.length > 0}
|
||||||
|
|
|
@ -80,6 +80,12 @@
|
||||||
placeholder="Are you sure you want to save this row?"
|
placeholder="Are you sure you want to save this row?"
|
||||||
bind:value={parameters.confirmText}
|
bind:value={parameters.confirmText}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Label small>Confirm Text</Label>
|
||||||
|
<Input placeholder="Confirm" bind:value={parameters.confirmButtonText} />
|
||||||
|
|
||||||
|
<Label small>Cancel Text</Label>
|
||||||
|
<Input placeholder="Cancel" bind:value={parameters.cancelButtonText} />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title={$confirmationStore.title}
|
title={$confirmationStore.title}
|
||||||
onConfirm={confirmationStore.actions.confirm}
|
onConfirm={confirmationStore.actions.confirm}
|
||||||
|
confirmText={$confirmationStore.confirmButtonText}
|
||||||
|
cancelText={$confirmationStore.cancelButtonText}
|
||||||
>
|
>
|
||||||
{$confirmationStore.text}
|
{$confirmationStore.text}
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
|
@ -4,6 +4,8 @@ const initialState = {
|
||||||
showConfirmation: false,
|
showConfirmation: false,
|
||||||
title: null,
|
title: null,
|
||||||
text: null,
|
text: null,
|
||||||
|
confirmButtonText: null,
|
||||||
|
cancelButtonText: null,
|
||||||
onConfirm: null,
|
onConfirm: null,
|
||||||
onCancel: null,
|
onCancel: null,
|
||||||
}
|
}
|
||||||
|
@ -11,11 +13,20 @@ const initialState = {
|
||||||
const createConfirmationStore = () => {
|
const createConfirmationStore = () => {
|
||||||
const store = writable(initialState)
|
const store = writable(initialState)
|
||||||
|
|
||||||
const showConfirmation = (title, text, onConfirm, onCancel) => {
|
const showConfirmation = (
|
||||||
|
title,
|
||||||
|
text,
|
||||||
|
onConfirm,
|
||||||
|
onCancel,
|
||||||
|
confirmButtonText,
|
||||||
|
cancelButtonText
|
||||||
|
) => {
|
||||||
store.set({
|
store.set({
|
||||||
showConfirmation: true,
|
showConfirmation: true,
|
||||||
title,
|
title,
|
||||||
text,
|
text,
|
||||||
|
confirmButtonText,
|
||||||
|
cancelButtonText,
|
||||||
onConfirm,
|
onConfirm,
|
||||||
onCancel,
|
onCancel,
|
||||||
})
|
})
|
||||||
|
|
|
@ -522,6 +522,7 @@ const confirmTextMap = {
|
||||||
["Execute Query"]: "Are you sure you want to execute this query?",
|
["Execute Query"]: "Are you sure you want to execute this query?",
|
||||||
["Trigger Automation"]: "Are you sure you want to trigger this automation?",
|
["Trigger Automation"]: "Are you sure you want to trigger this automation?",
|
||||||
["Prompt User"]: "Are you sure you want to continue?",
|
["Prompt User"]: "Are you sure you want to continue?",
|
||||||
|
["Duplicate Row"]: "Are you sure you want to duplicate this row?",
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -582,6 +583,11 @@ export const enrichButtonActions = (actions, context) => {
|
||||||
const defaultTitleText = action["##eventHandlerType"]
|
const defaultTitleText = action["##eventHandlerType"]
|
||||||
const customTitleText =
|
const customTitleText =
|
||||||
action.parameters?.customTitleText || defaultTitleText
|
action.parameters?.customTitleText || defaultTitleText
|
||||||
|
const cancelButtonText =
|
||||||
|
action.parameters?.cancelButtonText || "Cancel"
|
||||||
|
const confirmButtonText =
|
||||||
|
action.parameters?.confirmButtonText || "Confirm"
|
||||||
|
|
||||||
confirmationStore.actions.showConfirmation(
|
confirmationStore.actions.showConfirmation(
|
||||||
customTitleText,
|
customTitleText,
|
||||||
confirmText,
|
confirmText,
|
||||||
|
@ -612,7 +618,9 @@ export const enrichButtonActions = (actions, context) => {
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
resolve(false)
|
resolve(false)
|
||||||
}
|
},
|
||||||
|
confirmButtonText,
|
||||||
|
cancelButtonText
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue