Update remaining usage of API in client library
This commit is contained in:
parent
b970c315f1
commit
71cf06e6f4
|
@ -9,7 +9,7 @@
|
|||
import Router from "./Router.svelte"
|
||||
import { enrichProps, propsAreSame } from "utils/componentProps"
|
||||
import { builderStore } from "stores"
|
||||
import { hashString } from "utils/helpers"
|
||||
import { Helpers } from "@budibase/frontend-core"
|
||||
import Manifest from "manifest.json"
|
||||
import { getActiveConditions, reduceConditionActions } from "utils/conditions"
|
||||
import Placeholder from "components/app/Placeholder.svelte"
|
||||
|
@ -106,7 +106,7 @@
|
|||
|
||||
// Raw settings are all settings excluding internal props and children
|
||||
$: rawSettings = getRawSettings(instance)
|
||||
$: instanceKey = hashString(JSON.stringify(rawSettings))
|
||||
$: instanceKey = Helpers.hashString(JSON.stringify(rawSettings))
|
||||
|
||||
// Update and enrich component settings
|
||||
$: updateSettings(rawSettings, instanceKey, settingsDefinition, $context)
|
||||
|
@ -300,7 +300,7 @@
|
|||
// Generates a key used to determine when components need to fully remount.
|
||||
// Currently only toggling editing requires remounting.
|
||||
const getRenderKey = (id, editing) => {
|
||||
return hashString(`${id}-${editing}`)
|
||||
return Helpers.hashString(`${id}-${editing}`)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -29,10 +29,14 @@
|
|||
for (let i = 0; i < fileList.length; i++) {
|
||||
data.append("file", fileList[i])
|
||||
}
|
||||
return await API.uploadAttachment({
|
||||
data,
|
||||
tableId: formContext?.dataSource?.tableId,
|
||||
})
|
||||
try {
|
||||
return await API.uploadAttachment({
|
||||
data,
|
||||
tableId: formContext?.dataSource?.tableId,
|
||||
})
|
||||
} catch (error) {
|
||||
return []
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script>
|
||||
import { getContext } from "svelte"
|
||||
import InnerForm from "./InnerForm.svelte"
|
||||
import { hashString } from "utils/helpers"
|
||||
import { Helpers } from "@budibase/frontend-core"
|
||||
|
||||
export let dataSource
|
||||
export let theme
|
||||
|
@ -50,13 +50,17 @@
|
|||
dataSource._id &&
|
||||
actionType === "Create"
|
||||
) {
|
||||
const query = await API.fetchQueryDefinition(dataSource._id)
|
||||
let paramSchema = {}
|
||||
const params = query.parameters || []
|
||||
params.forEach(param => {
|
||||
paramSchema[param.name] = { ...param, type: "string" }
|
||||
})
|
||||
schema = paramSchema
|
||||
try {
|
||||
const query = await API.fetchQueryDefinition(dataSource._id)
|
||||
let paramSchema = {}
|
||||
const params = query.parameters || []
|
||||
params.forEach(param => {
|
||||
paramSchema[param.name] = { ...param, type: "string" }
|
||||
})
|
||||
schema = paramSchema
|
||||
} catch (error) {
|
||||
schema = {}
|
||||
}
|
||||
}
|
||||
|
||||
// For all other cases, just grab the normal schema
|
||||
|
@ -71,7 +75,7 @@
|
|||
}
|
||||
|
||||
$: initialValues = getInitialValues(actionType, dataSource, $context)
|
||||
$: resetKey = hashString(
|
||||
$: resetKey = Helpers.hashString(
|
||||
JSON.stringify(initialValues) + JSON.stringify(schema)
|
||||
)
|
||||
</script>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { setContext, getContext } from "svelte"
|
||||
import { derived, get, writable } from "svelte/store"
|
||||
import { createValidatorFromConstraints } from "./validation"
|
||||
import { generateID } from "utils/helpers"
|
||||
import { Helpers } from "@budibase/frontend-core"
|
||||
import { deepGet, deepSet } from "@budibase/bbui"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
|
||||
|
@ -153,7 +153,7 @@
|
|||
// If we've already registered this field then keep some existing state
|
||||
let initialValue = deepGet(initialValues, field) ?? defaultValue
|
||||
let initialError = null
|
||||
let fieldId = `id-${generateID()}`
|
||||
let fieldId = `id-${Helpers.uuid()}`
|
||||
const existingField = getField(field)
|
||||
if (existingField) {
|
||||
const { fieldState } = get(existingField)
|
||||
|
|
|
@ -30,17 +30,21 @@
|
|||
|
||||
const fetchTable = async id => {
|
||||
if (id) {
|
||||
const result = await API.fetchTableDefinition(id)
|
||||
if (!result.error) {
|
||||
tableDefinition = result
|
||||
try {
|
||||
tableDefinition = await API.fetchTableDefinition(id)
|
||||
} catch (error) {
|
||||
tableDefinition = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fetchRows = async id => {
|
||||
if (id) {
|
||||
const rows = await API.fetchTableData(id)
|
||||
options = rows && !rows.error ? rows : []
|
||||
try {
|
||||
options = await API.fetchTableData(id)
|
||||
} catch (error) {
|
||||
options = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue