Ensure action parameters can never be null and fix display of close screen modal action
This commit is contained in:
parent
c4ecae90ff
commit
e7061647da
2 changed files with 18 additions and 13 deletions
|
@ -23,14 +23,18 @@
|
|||
export let bindings = []
|
||||
export let nested
|
||||
|
||||
$: showAvailableActions = !actions?.length
|
||||
|
||||
let actionQuery
|
||||
$: parsedQuery =
|
||||
typeof actionQuery === "string" ? actionQuery.toLowerCase().trim() : ""
|
||||
|
||||
let selectedAction = actions?.length ? actions[0] : null
|
||||
|
||||
$: {
|
||||
// Ensure parameters object is never null
|
||||
if (selectedAction && !selectedAction.parameters) {
|
||||
selectedAction.parameters = {}
|
||||
}
|
||||
}
|
||||
$: parsedQuery =
|
||||
typeof actionQuery === "string" ? actionQuery.toLowerCase().trim() : ""
|
||||
$: showAvailableActions = !actions?.length
|
||||
$: mappedActionTypes = actionTypes.reduce((acc, action) => {
|
||||
let parsedName = action.name.toLowerCase().trim()
|
||||
if (parsedQuery.length && parsedName.indexOf(parsedQuery) < 0) {
|
||||
|
@ -40,7 +44,6 @@
|
|||
acc[action.type].push(action)
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
// These are ephemeral bindings which only exist while executing actions
|
||||
$: eventContexBindings = getEventContextBindings(
|
||||
$currentAsset,
|
||||
|
@ -50,9 +53,8 @@
|
|||
selectedAction?.id
|
||||
)
|
||||
$: allBindings = eventContexBindings.concat(bindings)
|
||||
|
||||
// Assign a unique ID to each action
|
||||
$: {
|
||||
// Ensure each action has a unique ID
|
||||
if (actions) {
|
||||
actions.forEach(action => {
|
||||
if (!action.id) {
|
||||
|
@ -61,13 +63,11 @@
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
$: selectedActionComponent =
|
||||
selectedAction &&
|
||||
actionTypes.find(t => t.name === selectedAction[EVENT_TYPE_KEY])?.component
|
||||
|
||||
// Select the first action if we delete an action
|
||||
$: {
|
||||
// Select the first action if we delete an action
|
||||
if (selectedAction && !actions?.includes(selectedAction)) {
|
||||
selectedAction = actions?.[0]
|
||||
}
|
||||
|
|
|
@ -6,9 +6,11 @@
|
|||
export let bindings = []
|
||||
</script>
|
||||
|
||||
<Body size="S">Navigate To screen, or leave blank.</Body>
|
||||
<br />
|
||||
<div class="root">
|
||||
<span>
|
||||
You can optionally navigate to another screen after closing the screen
|
||||
modal.
|
||||
</span>
|
||||
<Label small>Screen</Label>
|
||||
<DrawerBindableInput
|
||||
title="Destination URL"
|
||||
|
@ -20,6 +22,9 @@
|
|||
</div>
|
||||
|
||||
<style>
|
||||
span {
|
||||
grid-column: 1 / 3;
|
||||
}
|
||||
.root {
|
||||
display: grid;
|
||||
align-items: center;
|
||||
|
|
Loading…
Reference in a new issue