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}
{onOptionMouseleave}
isPlaceholder={value == null || value === ""}
placeholderOption={placeholder === false ? null : placeholder}
placeholderOption={placeholder === false
? null
: placeholder || "Choose an option"}
isOptionSelected={option => compareOptionAndValue(option, value)}
onSelectOption={selectOption}
{loading}

View file

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

View file

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

View file

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

View file

@ -8,7 +8,7 @@
import ClientBindingPanel from "components/common/bindings/ClientBindingPanel.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 value = ""
@ -105,9 +105,11 @@
datetime: isValidDate,
link: hasValidLinks,
bb_reference: hasValidLinks,
bb_reference_single: hasValidLinks,
array: hasValidOptions,
longform: value => !isJSBinding(value),
json: value => !isJSBinding(value),
options: value => !isJSBinding(value) && !findHBSBlocks(value)?.length,
boolean: isValidBoolean,
attachment: false,
attachment_single: false,

View file

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

View file

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

View file

@ -566,7 +566,13 @@ class GoogleSheetsIntegration implements DatasourcePlus {
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) {
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
* @param docs the data
* @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)) {
return []
}
@ -464,7 +471,7 @@ export const runQuery = (docs: Record<string, any>[], query: SearchFilters) => {
for (const [key, testValue] of Object.entries(query[type] || {})) {
const valueToCheck = isLogicalSearchOperator(type)
? doc
: deepGet(doc, removeKeyNumbering(key))
: findInDoc(doc, removeKeyNumbering(key))
const result = test(valueToCheck, testValue)
if (query.allOr && result) {
return true