PR Feedback updates
This commit is contained in:
parent
ef6f8e2abf
commit
3bdb1ea877
|
@ -6,7 +6,7 @@ import {
|
||||||
findComponentPath,
|
findComponentPath,
|
||||||
getComponentSettings,
|
getComponentSettings,
|
||||||
} from "./componentUtils"
|
} from "./componentUtils"
|
||||||
import { store } from "builderStore"
|
import { store, currentAsset } from "builderStore"
|
||||||
import {
|
import {
|
||||||
queries as queriesStores,
|
queries as queriesStores,
|
||||||
tables as tablesStore,
|
tables as tablesStore,
|
||||||
|
@ -629,24 +629,36 @@ const getRoleBindings = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all bindable properties exposed in an event action flow up until
|
* Gets all bindable event context properties provided in the component
|
||||||
* the specified action ID, as well as context provided for the action
|
* setting
|
||||||
* setting as a whole by the component.
|
|
||||||
*/
|
*/
|
||||||
export const getEventContextBindings = (
|
export const getEventContextBindings = ({
|
||||||
asset,
|
|
||||||
componentId,
|
|
||||||
settingKey,
|
settingKey,
|
||||||
actions,
|
componentInstance,
|
||||||
actionId
|
componentId,
|
||||||
) => {
|
componentDefinition,
|
||||||
|
asset,
|
||||||
|
}) => {
|
||||||
let bindings = []
|
let bindings = []
|
||||||
|
|
||||||
|
const selectedAsset = asset ?? get(currentAsset)
|
||||||
|
|
||||||
// Check if any context bindings are provided by the component for this
|
// Check if any context bindings are provided by the component for this
|
||||||
// setting
|
// setting
|
||||||
const component = findComponent(asset.props, componentId)
|
const component =
|
||||||
const def = store.actions.components.getDefinition(component?._component)
|
componentInstance ?? findComponent(selectedAsset.props, componentId)
|
||||||
|
|
||||||
|
if (!component) {
|
||||||
|
return bindings
|
||||||
|
}
|
||||||
|
|
||||||
|
const definition =
|
||||||
|
componentDefinition ??
|
||||||
|
store.actions.components.getDefinition(component?._component)
|
||||||
|
|
||||||
const settings = getComponentSettings(component?._component)
|
const settings = getComponentSettings(component?._component)
|
||||||
const eventSetting = settings.find(setting => setting.key === settingKey)
|
const eventSetting = settings.find(setting => setting.key === settingKey)
|
||||||
|
|
||||||
if (eventSetting?.context?.length) {
|
if (eventSetting?.context?.length) {
|
||||||
eventSetting.context.forEach(contextEntry => {
|
eventSetting.context.forEach(contextEntry => {
|
||||||
bindings.push({
|
bindings.push({
|
||||||
|
@ -655,14 +667,23 @@ export const getEventContextBindings = (
|
||||||
contextEntry.key
|
contextEntry.key
|
||||||
)}`,
|
)}`,
|
||||||
category: component._instanceName,
|
category: component._instanceName,
|
||||||
icon: def.icon,
|
icon: definition.icon,
|
||||||
display: {
|
display: {
|
||||||
name: contextEntry.label,
|
name: contextEntry.label,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
return bindings
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all bindable properties exposed in an event action flow up until
|
||||||
|
* the specified action ID, as well as context provided for the action
|
||||||
|
* setting as a whole by the component.
|
||||||
|
*/
|
||||||
|
export const getActionBindings = (actions, actionId) => {
|
||||||
|
let bindings = []
|
||||||
// Get the steps leading up to this value
|
// Get the steps leading up to this value
|
||||||
const index = actions?.findIndex(action => action.id === actionId)
|
const index = actions?.findIndex(action => action.id === actionId)
|
||||||
if (index == null || index === -1) {
|
if (index == null || index === -1) {
|
||||||
|
@ -689,7 +710,6 @@ export const getEventContextBindings = (
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return bindings
|
return bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
import { generate } from "shortid"
|
import { generate } from "shortid"
|
||||||
import {
|
import {
|
||||||
getEventContextBindings,
|
getEventContextBindings,
|
||||||
|
getActionBindings,
|
||||||
makeStateBinding,
|
makeStateBinding,
|
||||||
} from "builderStore/dataBinding"
|
} from "builderStore/dataBinding"
|
||||||
import { currentAsset, store } from "builderStore"
|
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
|
||||||
const flipDurationMs = 150
|
const flipDurationMs = 150
|
||||||
|
@ -26,6 +26,7 @@
|
||||||
export let actions
|
export let actions
|
||||||
export let bindings = []
|
export let bindings = []
|
||||||
export let nested
|
export let nested
|
||||||
|
export let componentInstance
|
||||||
|
|
||||||
let actionQuery
|
let actionQuery
|
||||||
let selectedAction = actions?.length ? actions[0] : null
|
let selectedAction = actions?.length ? actions[0] : null
|
||||||
|
@ -68,15 +69,19 @@
|
||||||
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(
|
$: eventContextBindings = getEventContextBindings({
|
||||||
$currentAsset,
|
componentInstance,
|
||||||
$store.selectedComponentId,
|
settingKey: key,
|
||||||
key,
|
})
|
||||||
actions,
|
$: actionContextBindings = getActionBindings(actions, selectedAction?.id)
|
||||||
selectedAction?.id
|
|
||||||
|
$: allBindings = getAllBindings(
|
||||||
|
bindings,
|
||||||
|
[...eventContextBindings, ...actionContextBindings],
|
||||||
|
actions
|
||||||
)
|
)
|
||||||
$: allBindings = getAllBindings(bindings, eventContexBindings, actions)
|
|
||||||
$: {
|
$: {
|
||||||
// Ensure each action has a unique ID
|
// Ensure each action has a unique ID
|
||||||
if (actions) {
|
if (actions) {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
export let name
|
export let name
|
||||||
export let bindings
|
export let bindings
|
||||||
export let nested
|
export let nested
|
||||||
|
export let componentInstance
|
||||||
|
|
||||||
let drawer
|
let drawer
|
||||||
let tmpValue
|
let tmpValue
|
||||||
|
@ -86,6 +87,7 @@
|
||||||
{bindings}
|
{bindings}
|
||||||
{key}
|
{key}
|
||||||
{nested}
|
{nested}
|
||||||
|
{componentInstance}
|
||||||
/>
|
/>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
let popover
|
let popover
|
||||||
let drawers = []
|
let drawers = []
|
||||||
let sudoComponentInstance
|
let pseudoComponentInstance
|
||||||
let open = false
|
let open = false
|
||||||
|
|
||||||
$: if (open && $draggable.selected && $draggable.selected != field._id) {
|
$: if (open && $draggable.selected && $draggable.selected != field._id) {
|
||||||
|
@ -24,10 +24,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (field) {
|
$: if (field) {
|
||||||
sudoComponentInstance = field
|
pseudoComponentInstance = field
|
||||||
}
|
}
|
||||||
$: componentDef = store.actions.components.getDefinition(
|
$: componentDef = store.actions.components.getDefinition(
|
||||||
sudoComponentInstance._component
|
pseudoComponentInstance._component
|
||||||
)
|
)
|
||||||
$: parsedComponentDef = processComponentDefinitionSettings(componentDef)
|
$: parsedComponentDef = processComponentDefinitionSettings(componentDef)
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateSetting = async (setting, value) => {
|
const updateSetting = async (setting, value) => {
|
||||||
const nestedComponentInstance = cloneDeep(sudoComponentInstance)
|
const nestedComponentInstance = cloneDeep(pseudoComponentInstance)
|
||||||
|
|
||||||
const patchFn = store.actions.components.updateComponentSetting(
|
const patchFn = store.actions.components.updateComponentSetting(
|
||||||
setting.key,
|
setting.key,
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
const update = {
|
const update = {
|
||||||
...nestedComponentInstance,
|
...nestedComponentInstance,
|
||||||
active: sudoComponentInstance.active,
|
active: pseudoComponentInstance.active,
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch("change", update)
|
dispatch("change", update)
|
||||||
|
@ -96,7 +96,7 @@
|
||||||
let { left, top } = cfg
|
let { left, top } = cfg
|
||||||
let percentageOffset = 30
|
let percentageOffset = 30
|
||||||
// left-outside
|
// left-outside
|
||||||
left = anchorBounds.left - eleBounds.width - 5
|
left = anchorBounds.left - eleBounds.width - 18
|
||||||
|
|
||||||
// shift up from the anchor, if space allows
|
// shift up from the anchor, if space allows
|
||||||
let offsetPos = Math.floor(eleBounds.height / 100) * percentageOffset
|
let offsetPos = Math.floor(eleBounds.height / 100) * percentageOffset
|
||||||
|
@ -115,10 +115,10 @@
|
||||||
<Layout noPadding noGap>
|
<Layout noPadding noGap>
|
||||||
<div class="type-icon">
|
<div class="type-icon">
|
||||||
<Icon name={parsedComponentDef.icon} />
|
<Icon name={parsedComponentDef.icon} />
|
||||||
<span>{parsedComponentDef.name}</span>
|
<span>{field.field}</span>
|
||||||
</div>
|
</div>
|
||||||
<ComponentSettingsSection
|
<ComponentSettingsSection
|
||||||
componentInstance={sudoComponentInstance}
|
componentInstance={pseudoComponentInstance}
|
||||||
componentDefinition={parsedComponentDef}
|
componentDefinition={parsedComponentDef}
|
||||||
isScreen={false}
|
isScreen={false}
|
||||||
onUpdateSetting={updateSetting}
|
onUpdateSetting={updateSetting}
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.popover-wrap {
|
.popover-wrap {
|
||||||
background-color: var(--spectrum-alias-background-color-secondary);
|
background-color: var(--spectrum-alias-background-color-primary);
|
||||||
}
|
}
|
||||||
.type-icon {
|
.type-icon {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -20,10 +20,7 @@
|
||||||
let sanitisedFields
|
let sanitisedFields
|
||||||
let fieldList
|
let fieldList
|
||||||
let schema
|
let schema
|
||||||
// let assetIdCache
|
|
||||||
let cachedValue
|
let cachedValue
|
||||||
// $: value, console.log("VALUE UPDATED")
|
|
||||||
// $: $currentAsset, console.log("currentAsset updated ", $currentAsset)
|
|
||||||
|
|
||||||
$: bindings = getBindableProperties($selectedScreen, componentInstance._id)
|
$: bindings = getBindableProperties($selectedScreen, componentInstance._id)
|
||||||
$: actionType = componentInstance.actionType
|
$: actionType = componentInstance.actionType
|
||||||
|
@ -46,7 +43,6 @@
|
||||||
$: options = Object.keys(schema || {})
|
$: options = Object.keys(schema || {})
|
||||||
$: sanitisedValue = getValidColumns(convertOldFieldFormat(value), options)
|
$: sanitisedValue = getValidColumns(convertOldFieldFormat(value), options)
|
||||||
$: updateSanitsedFields(sanitisedValue)
|
$: updateSanitsedFields(sanitisedValue)
|
||||||
|
|
||||||
$: unconfigured = buildUnconfiguredOptions(schema, sanitisedFields)
|
$: unconfigured = buildUnconfiguredOptions(schema, sanitisedFields)
|
||||||
|
|
||||||
// Builds unused ones only
|
// Builds unused ones only
|
||||||
|
@ -105,7 +101,7 @@
|
||||||
const type = getComponentForField(instance.field, schema)
|
const type = getComponentForField(instance.field, schema)
|
||||||
instance._component = `@budibase/standard-components/${type}`
|
instance._component = `@budibase/standard-components/${type}`
|
||||||
|
|
||||||
const sudoComponentInstance = store.actions.components.createInstance(
|
const pseudoComponentInstance = store.actions.components.createInstance(
|
||||||
instance._component,
|
instance._component,
|
||||||
{
|
{
|
||||||
_instanceName: instance.field,
|
_instanceName: instance.field,
|
||||||
|
@ -116,7 +112,7 @@
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
|
|
||||||
return { ...instance, ...sudoComponentInstance }
|
return { ...instance, ...pseudoComponentInstance }
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (sanitisedFields) {
|
$: if (sanitisedFields) {
|
||||||
|
|
|
@ -60,4 +60,7 @@
|
||||||
.info :global(a:hover) {
|
.info :global(a:hover) {
|
||||||
color: var(--spectrum-global-color-gray-900);
|
color: var(--spectrum-global-color-gray-900);
|
||||||
}
|
}
|
||||||
|
.info :global(a) {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -211,7 +211,6 @@
|
||||||
{/if}
|
{/if}
|
||||||
</BlockComponent>
|
</BlockComponent>
|
||||||
{/if}
|
{/if}
|
||||||
{#key fields}
|
|
||||||
<BlockComponent type="fieldgroup" props={{ labelPosition }} order={1}>
|
<BlockComponent type="fieldgroup" props={{ labelPosition }} order={1}>
|
||||||
{#each fields as field, idx}
|
{#each fields as field, idx}
|
||||||
{#if getComponentForField(field) && field.active}
|
{#if getComponentForField(field) && field.active}
|
||||||
|
@ -223,7 +222,6 @@
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</BlockComponent>
|
</BlockComponent>
|
||||||
{/key}
|
|
||||||
</BlockComponent>
|
</BlockComponent>
|
||||||
</BlockComponent>
|
</BlockComponent>
|
||||||
{:else}
|
{:else}
|
||||||
|
|
Loading…
Reference in New Issue