Support Barcode, BigInt and User column types in automations (#12610)

* Support barcode and bigint in automations

* Support users in LinkedRowSelector

* Fix clear relationships if empty

* Make sure clearRelationships is initialised to false

* Revert yarn lock

* Refactor

* Refactor
This commit is contained in:
melohagan 2023-12-19 10:26:28 +00:00 committed by GitHub
parent cc9ac15fd3
commit 3697ff3efc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 7 deletions

View File

@ -69,7 +69,15 @@
on:change={e => onChange(e, field)}
useLabel={false}
/>
{:else if schema.type === "string" || schema.type === "number"}
{:else if schema.type === "bb_reference"}
<LinkedRowSelector
linkedRows={value[field]}
{schema}
linkedTableId={"ta_users"}
on:change={e => onChange(e, field)}
useLabel={false}
/>
{:else if ["string", "number", "bigint", "barcodeqr"].includes(schema.type)}
<svelte:component
this={isTestModal ? ModalBindableInput : DrawerBindableInput}
panel={AutomationBindingPanel}

View File

@ -8,6 +8,8 @@
export let schema
export let linkedRows = []
export let useLabel = true
export let linkedTableId
export let label
const dispatch = createEventDispatcher()
let rows = []
@ -16,8 +18,8 @@
$: linkedIds = (Array.isArray(linkedRows) ? linkedRows : [])?.map(
row => row?._id || row
)
$: label = capitalise(schema.name)
$: linkedTableId = schema.tableId
$: label = label || capitalise(schema.name)
$: linkedTableId = linkedTableId || schema.tableId
$: linkedTable = $tables.list.find(table => table._id === linkedTableId)
$: fetchRows(linkedTableId)
@ -57,7 +59,7 @@
{:else}
<Multiselect
value={linkedIds}
{label}
label={useLabel ? label : null}
options={rows}
getOptionLabel={getPrettyName}
getOptionValue={row => row._id}

View File

@ -113,7 +113,7 @@
if (type === "json" && !isJSBinding(value)) {
return "json-slot-icon"
}
if (type !== "string" && type !== "number") {
if (!["string", "number", "bigint", "barcodeqr"].includes(type)) {
return "slot-icon"
}
return ""

View File

@ -84,9 +84,11 @@ export async function run({ inputs, appId, emitter }: AutomationStepInput) {
// clear any undefined, null or empty string properties so that they aren't updated
for (let propKey of Object.keys(inputs.row)) {
const clearRelationships =
inputs.meta?.fields?.[propKey]?.clearRelationships
if (
(inputs.row[propKey] == null || inputs.row[propKey] === "") &&
!inputs.meta?.fields?.[propKey]?.clearRelationships
(inputs.row[propKey] == null || inputs.row[propKey]?.length === 0) &&
!clearRelationships
) {
delete inputs.row[propKey]
}