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