Merge branch 'master' into instrument-couch

This commit is contained in:
Sam Rose 2023-12-19 11:26:13 +00:00 committed by GitHub
commit 5b3ec0b94d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 9 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

@ -164,7 +164,8 @@
// Required constraint
if (
field === dataSourceSchema?.table?.primaryDisplay ||
constraints.presence?.allowEmpty === false
constraints.presence?.allowEmpty === false ||
constraints.presence === true
) {
rules.push({
constraint: "required",

View File

@ -23,7 +23,8 @@ export const createValidatorFromConstraints = (
// Required constraint
if (
field === table?.primaryDisplay ||
schemaConstraints.presence?.allowEmpty === false
schemaConstraints.presence?.allowEmpty === false ||
schemaConstraints.presence === true
) {
rules.push({
type: schemaConstraints.type == "array" ? "array" : "string",

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]
}