1
0
Fork 0
mirror of synced 2024-09-20 19:33:10 +12:00

Merge branch 'master' into posthog-feature-flags

This commit is contained in:
Sam Rose 2024-08-09 09:25:48 +01:00 committed by GitHub
commit 858bb77c00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 49 additions and 14 deletions

View file

@ -102,7 +102,9 @@
{onOptionMouseenter} {onOptionMouseenter}
{onOptionMouseleave} {onOptionMouseleave}
isPlaceholder={value == null || value === ""} isPlaceholder={value == null || value === ""}
placeholderOption={placeholder === false ? null : placeholder} placeholderOption={placeholder === false
? null
: placeholder || "Choose an option"}
isOptionSelected={option => compareOptionAndValue(option, value)} isOptionSelected={option => compareOptionAndValue(option, value)}
onSelectOption={selectOption} onSelectOption={selectOption}
{loading} {loading}

View file

@ -157,7 +157,7 @@
</span> </span>
{:else if schema.type === "link"} {:else if schema.type === "link"}
<LinkedRowSelector <LinkedRowSelector
linkedRows={fieldData} linkedData={fieldData}
{schema} {schema}
on:change={e => on:change={e =>
onChange({ onChange({
@ -169,7 +169,7 @@
/> />
{:else if schema.type === "bb_reference" || schema.type === "bb_reference_single"} {:else if schema.type === "bb_reference" || schema.type === "bb_reference_single"}
<LinkedRowSelector <LinkedRowSelector
linkedRows={fieldData} linkedData={fieldData}
{schema} {schema}
linkedTableId={"ta_users"} linkedTableId={"ta_users"}
on:change={e => on:change={e =>

View file

@ -146,7 +146,7 @@
{:else if type === "link"} {:else if type === "link"}
<LinkedRowSelector <LinkedRowSelector
{error} {error}
linkedRows={value} linkedData={value}
schema={meta} schema={meta}
on:change={e => (value = e.detail)} on:change={e => (value = e.detail)}
/> />

View file

@ -6,7 +6,7 @@
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
export let schema export let schema
export let linkedRows = [] export let linkedData
export let useLabel = true export let useLabel = true
export let linkedTableId export let linkedTableId
export let label export let label
@ -15,14 +15,26 @@
let rows = [] let rows = []
let linkedIds = [] let linkedIds = []
$: linkedIds = (Array.isArray(linkedRows) ? linkedRows : [])?.map( $: fieldValue = getFieldValue(linkedData, schema)
row => row?._id || row
)
$: label = label || capitalise(schema.name) $: label = label || capitalise(schema.name)
$: linkedTableId = linkedTableId || schema.tableId $: linkedTableId = linkedTableId || schema.tableId
$: linkedTable = $tables.list.find(table => table._id === linkedTableId) $: linkedTable = $tables.list.find(table => table._id === linkedTableId)
$: fetchRows(linkedTableId) $: fetchRows(linkedTableId)
const getFieldValue = val => {
const linkedIds = (Array.isArray(val) ? val : [])?.map(
row => row?._id || row
)
if (
schema.relationshipType === "one-to-many" ||
schema.type === "bb_reference_single"
) {
return linkedIds[0]
} else {
return linkedIds
}
}
async function fetchRows(linkedTableId) { async function fetchRows(linkedTableId) {
try { try {
rows = await API.fetchTableData(linkedTableId) rows = await API.fetchTableData(linkedTableId)
@ -45,7 +57,7 @@
</Label> </Label>
{:else if schema.relationshipType === "one-to-many" || schema.type === "bb_reference_single"} {:else if schema.relationshipType === "one-to-many" || schema.type === "bb_reference_single"}
<Select <Select
value={linkedIds?.[0]} value={fieldValue}
options={rows} options={rows}
getOptionLabel={getPrettyName} getOptionLabel={getPrettyName}
getOptionValue={row => row._id} getOptionValue={row => row._id}
@ -58,7 +70,7 @@
/> />
{:else} {:else}
<Multiselect <Multiselect
value={linkedIds} value={fieldValue}
label={useLabel ? label : null} label={useLabel ? label : null}
options={rows} options={rows}
getOptionLabel={getPrettyName} getOptionLabel={getPrettyName}

View file

@ -8,7 +8,7 @@
import ClientBindingPanel from "components/common/bindings/ClientBindingPanel.svelte" import ClientBindingPanel from "components/common/bindings/ClientBindingPanel.svelte"
import { createEventDispatcher, setContext } from "svelte" import { createEventDispatcher, setContext } from "svelte"
import { isJSBinding } from "@budibase/string-templates" import { isJSBinding, findHBSBlocks } from "@budibase/string-templates"
export let panel = ClientBindingPanel export let panel = ClientBindingPanel
export let value = "" export let value = ""
@ -105,9 +105,11 @@
datetime: isValidDate, datetime: isValidDate,
link: hasValidLinks, link: hasValidLinks,
bb_reference: hasValidLinks, bb_reference: hasValidLinks,
bb_reference_single: hasValidLinks,
array: hasValidOptions, array: hasValidOptions,
longform: value => !isJSBinding(value), longform: value => !isJSBinding(value),
json: value => !isJSBinding(value), json: value => !isJSBinding(value),
options: value => !isJSBinding(value) && !findHBSBlocks(value)?.length,
boolean: isValidBoolean, boolean: isValidBoolean,
attachment: false, attachment: false,
attachment_single: false, attachment_single: false,

View file

@ -80,6 +80,7 @@ const componentMap = {
"field/barcodeqr": FormFieldSelect, "field/barcodeqr": FormFieldSelect,
"field/signature_single": FormFieldSelect, "field/signature_single": FormFieldSelect,
"field/bb_reference": FormFieldSelect, "field/bb_reference": FormFieldSelect,
"field/bb_reference_single": FormFieldSelect,
// Some validation types are the same as others, so not all types are // Some validation types are the same as others, so not all types are
// explicitly listed here. e.g. options uses string validation // explicitly listed here. e.g. options uses string validation
"validation/string": ValidationEditor, "validation/string": ValidationEditor,

View file

@ -129,6 +129,11 @@
width: 100%; width: 100%;
min-width: unset; min-width: unset;
} }
.signature-cell img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
.signature-cell.light img { .signature-cell.light img {
-webkit-filter: invert(100%); -webkit-filter: invert(100%);
filter: invert(100%); filter: invert(100%);

View file

@ -566,7 +566,13 @@ class GoogleSheetsIntegration implements DatasourcePlus {
query.filters.equal[`_${GOOGLE_SHEETS_PRIMARY_KEY}`] = id query.filters.equal[`_${GOOGLE_SHEETS_PRIMARY_KEY}`] = id
} }
} }
let filtered = dataFilters.runQuery(rows, query.filters || {}) let filtered = dataFilters.runQuery(
rows,
query.filters || {},
(row: GoogleSpreadsheetRow, headerKey: string) => {
return row.get(headerKey)
}
)
if (hasFilters && query.paginate) { if (hasFilters && query.paginate) {
filtered = filtered.slice(offset, offset + limit) filtered = filtered.slice(offset, offset + limit)
} }

View file

@ -436,8 +436,15 @@ export const search = (
* Performs a client-side search on an array of data * Performs a client-side search on an array of data
* @param docs the data * @param docs the data
* @param query the JSON query * @param query the JSON query
* @param findInDoc optional fn when trying to extract a value
* from custom doc type e.g. Google Sheets
*
*/ */
export const runQuery = (docs: Record<string, any>[], query: SearchFilters) => { export const runQuery = (
docs: Record<string, any>[],
query: SearchFilters,
findInDoc: Function = deepGet
) => {
if (!docs || !Array.isArray(docs)) { if (!docs || !Array.isArray(docs)) {
return [] return []
} }
@ -464,7 +471,7 @@ export const runQuery = (docs: Record<string, any>[], query: SearchFilters) => {
for (const [key, testValue] of Object.entries(query[type] || {})) { for (const [key, testValue] of Object.entries(query[type] || {})) {
const valueToCheck = isLogicalSearchOperator(type) const valueToCheck = isLogicalSearchOperator(type)
? doc ? doc
: deepGet(doc, removeKeyNumbering(key)) : findInDoc(doc, removeKeyNumbering(key))
const result = test(valueToCheck, testValue) const result = test(valueToCheck, testValue)
if (query.allOr && result) { if (query.allOr && result) {
return true return true