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