chore: resolved merge conflicts from develop branch

This commit is contained in:
Vinoth Kirubakaran 2022-04-22 15:30:43 +05:30
commit e2ea748ce6
39 changed files with 630 additions and 165 deletions

View File

@ -1,5 +1,5 @@
{
"version": "1.0.105-alpha.29",
"version": "1.0.105-alpha.30",
"npmClient": "yarn",
"packages": [
"packages/*"

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/backend-core",
"version": "1.0.105-alpha.29",
"version": "1.0.105-alpha.30",
"description": "Budibase backend core libraries used in server and worker",
"main": "src/index.js",
"author": "Budibase",

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/bbui",
"description": "A UI solution used in the different Budibase projects.",
"version": "1.0.105-alpha.29",
"version": "1.0.105-alpha.30",
"license": "MPL-2.0",
"svelte": "src/index.js",
"module": "dist/bbui.es.js",
@ -38,7 +38,7 @@
],
"dependencies": {
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
"@budibase/string-templates": "^1.0.105-alpha.29",
"@budibase/string-templates": "^1.0.105-alpha.30",
"@spectrum-css/actionbutton": "^1.0.1",
"@spectrum-css/actiongroup": "^1.0.1",
"@spectrum-css/avatar": "^3.0.2",

View File

@ -80,8 +80,4 @@
.active svg {
color: var(--spectrum-global-color-blue-600);
}
.spectrum-ActionButton-label {
padding-bottom: 2px;
}
</style>

View File

@ -36,6 +36,7 @@
export let disableSorting = false
export let autoSortColumns = true
export let compact = false
export let customPlaceholder = false
const dispatch = createEventDispatcher()
@ -387,13 +388,24 @@
</div>
{/each}
{:else}
<div class="placeholder" class:placeholder--no-fields={!fields?.length}>
<div
class="placeholder"
class:placeholder--custom={customPlaceholder}
class:placeholder--no-fields={!fields?.length}
>
{#if customPlaceholder}
<slot name="placeholder" />
{:else}
<div class="placeholder-content">
<svg class="spectrum-Icon spectrum-Icon--sizeXXL" focusable="false">
<svg
class="spectrum-Icon spectrum-Icon--sizeXXL"
focusable="false"
>
<use xlink:href="#spectrum-icon-18-Table" />
</svg>
<div>No rows found</div>
</div>
{/if}
</div>
{/if}
</div>
@ -458,6 +470,13 @@
justify-content: flex-start;
align-items: center;
user-select: none;
border-top: var(--table-border);
}
.spectrum-Table-headCell:first-of-type {
border-left: var(--table-border);
}
.spectrum-Table-headCell:last-of-type {
border-right: var(--table-border);
}
.spectrum-Table-headCell--alignCenter {
justify-content: center;
@ -576,16 +595,19 @@
border-top: none;
grid-column: 1 / -1;
background-color: var(--table-bg);
padding: 40px;
}
.placeholder--no-fields {
border-top: var(--table-border);
}
.placeholder--custom {
justify-content: flex-start;
}
.wrapper--quiet .placeholder {
border-left: none;
border-right: none;
}
.placeholder-content {
padding: 40px;
display: flex;
flex-direction: column;
justify-content: center;

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/builder",
"version": "1.0.105-alpha.29",
"version": "1.0.105-alpha.30",
"license": "GPL-3.0",
"private": true,
"scripts": {
@ -65,10 +65,10 @@
}
},
"dependencies": {
"@budibase/bbui": "^1.0.105-alpha.29",
"@budibase/client": "^1.0.105-alpha.29",
"@budibase/frontend-core": "^1.0.105-alpha.29",
"@budibase/string-templates": "^1.0.105-alpha.29",
"@budibase/bbui": "^1.0.105-alpha.30",
"@budibase/client": "^1.0.105-alpha.30",
"@budibase/frontend-core": "^1.0.105-alpha.30",
"@budibase/string-templates": "^1.0.105-alpha.30",
"@sentry/browser": "5.19.1",
"@spectrum-css/page": "^3.0.1",
"@spectrum-css/vars": "^3.0.1",

View File

@ -654,7 +654,7 @@ export const getSchemaForDatasource = (asset, datasource, options) => {
* Builds a form schema given a form component.
* A form schema is a schema of all the fields nested anywhere within a form.
*/
const buildFormSchema = component => {
export const buildFormSchema = component => {
let schema = {}
if (!component) {
return schema

View File

@ -14,7 +14,7 @@
import Table from "./Table.svelte"
import { TableNames } from "constants"
import CreateEditRow from "./modals/CreateEditRow.svelte"
import { Pagination } from "@budibase/bbui"
import { Pagination, Heading, Body, Layout } from "@budibase/bbui"
import { fetchData } from "@budibase/frontend-core"
import { API } from "api"
@ -27,6 +27,8 @@
$: enrichedSchema = enrichSchema($tables.selected?.schema)
$: id = $tables.selected?._id
$: fetch = createFetch(id)
$: hasCols = checkHasCols(schema)
$: hasRows = !!$fetch.rows?.length
const enrichSchema = schema => {
let tempSchema = { ...schema }
@ -47,6 +49,20 @@
return tempSchema
}
const checkHasCols = schema => {
if (!schema || Object.keys(schema).length === 0) {
return false
}
let fields = Object.values(schema)
for (let field of fields) {
if (!field.autocolumn) {
return true
}
}
return false
}
// Fetches new data whenever the table changes
const createFetch = tableId => {
return fetchData({
@ -104,19 +120,28 @@
disableSorting
on:updatecolumns={onUpdateColumns}
on:updaterows={onUpdateRows}
customPlaceholder
>
<CreateColumnButton on:updatecolumns={onUpdateColumns} />
{#if schema && Object.keys(schema).length > 0}
<div class="buttons">
<div class="left-buttons">
<CreateColumnButton
highlighted={$fetch.loaded && (!hasCols || !hasRows)}
on:updatecolumns={onUpdateColumns}
/>
{#if !isUsersTable}
<CreateRowButton
on:updaterows={onUpdateRows}
title={"Create row"}
modalContentComponent={CreateEditRow}
disabled={!hasCols}
highlighted={$fetch.loaded && hasCols && !hasRows}
/>
{/if}
{#if isInternal}
<CreateViewButton />
<CreateViewButton disabled={!hasCols || !hasRows} />
{/if}
</div>
<div class="right-buttons">
<ManageAccessButton resourceId={$tables.selected?._id} />
{#if isUsersTable}
<EditRolesButton />
@ -128,16 +153,40 @@
/>
{/if}
<HideAutocolumnButton bind:hideAutocolumns />
<!-- always have the export last -->
<ExportButton view={$tables.selected?._id} />
<ImportButton
tableId={$tables.selected?._id}
on:updaterows={onUpdateRows}
/>
<ExportButton
disabled={!hasRows || !hasCols}
view={$tables.selected?._id}
/>
{#key id}
<TableFilterButton {schema} on:change={onFilter} />
<TableFilterButton
{schema}
on:change={onFilter}
disabled={!hasCols || !hasRows}
/>
{/key}
</div>
</div>
<div slot="placeholder">
<Layout gap="S">
{#if !hasCols}
<Heading>Let's create some columns</Heading>
<Body>
Start building out your table structure<br />
by adding some columns
</Body>
{:else}
<Heading>Now let's add a row</Heading>
<Body>
Add some data to your table<br />
by adding some rows
</Body>
{/if}
</Layout>
</div>
</Table>
{#key id}
<div in:fade={{ delay: 200, duration: 100 }}>
@ -162,4 +211,20 @@
align-items: center;
margin-top: var(--spacing-xl);
}
.buttons {
flex: 1 1 auto;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
}
.left-buttons,
.right-buttons {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
gap: var(--spacing-m);
}
</style>

View File

@ -25,6 +25,7 @@
export let rowCount
export let type
export let disableSorting = false
export let customPlaceholder = false
let selectedRows = []
let editableColumn
@ -117,10 +118,10 @@
</script>
<Layout noPadding gap="S">
<div>
<Layout noPadding gap="XS">
{#if title}
<div class="table-title">
<Heading size="S">{title}</Heading>
<Heading size="M">{title}</Heading>
{#if loading}
<div transition:fade|local>
<Spinner size="10" />
@ -134,7 +135,7 @@
<DeleteRowsButton on:updaterows {selectedRows} {deleteRows} />
{/if}
</div>
</div>
</Layout>
{#key tableId}
<div class="table-wrapper">
<Table
@ -144,6 +145,7 @@
{customRenderers}
{rowCount}
{disableSorting}
{customPlaceholder}
bind:selectedRows
allowSelectRows={allowEditing && !isUsersTable}
allowEditRows={allowEditing}
@ -153,7 +155,9 @@
on:editrow={e => editRow(e.detail)}
on:clickrelationship={e => selectRelationship(e.detail)}
on:sort
/>
>
<slot slot="placeholder" name="placeholder" />
</Table>
</div>
{/key}
</Layout>
@ -176,6 +180,7 @@
flex-direction: row;
justify-content: flex-start;
align-items: center;
margin-top: var(--spacing-m);
}
.table-title > div {
margin-left: var(--spacing-xs);

View File

@ -2,10 +2,21 @@
import { ActionButton, Modal } from "@budibase/bbui"
import CreateEditColumn from "../modals/CreateEditColumn.svelte"
export let highlighted = false
export let disabled = false
let modal
</script>
<ActionButton icon="TableColumnAddRight" quiet size="S" on:click={modal.show}>
<ActionButton
{disabled}
selected={highlighted}
emphasized={highlighted}
icon="TableColumnAddRight"
quiet
size="S"
on:click={modal.show}
>
Create column
</ActionButton>
<Modal bind:this={modal}>

View File

@ -4,11 +4,21 @@
export let modalContentComponent = CreateEditRow
export let title = "Create row"
export let disabled = false
export let highlighted = false
let modal
</script>
<ActionButton icon="TableRowAddBottom" size="S" quiet on:click={modal.show}>
<ActionButton
{disabled}
emphasized={highlighted}
selected={highlighted}
icon="TableRowAddBottom"
size="S"
quiet
on:click={modal.show}
>
{title}
</ActionButton>
<Modal bind:this={modal}>

View File

@ -2,10 +2,18 @@
import { Modal, ActionButton } from "@budibase/bbui"
import CreateViewModal from "../modals/CreateViewModal.svelte"
export let disabled = false
let modal
</script>
<ActionButton icon="CollectionAdd" size="S" quiet on:click={modal.show}>
<ActionButton
{disabled}
icon="CollectionAdd"
size="S"
quiet
on:click={modal.show}
>
Create view
</ActionButton>
<Modal bind:this={modal}>

View File

@ -3,11 +3,18 @@
import ExportModal from "../modals/ExportModal.svelte"
export let view
export let disabled = false
let modal
</script>
<ActionButton icon="DataDownload" size="S" quiet on:click={modal.show}>
<ActionButton
{disabled}
icon="DataDownload"
size="S"
quiet
on:click={modal.show}
>
Export
</ActionButton>
<Modal bind:this={modal}>

View File

@ -8,6 +8,12 @@
}
</script>
<ActionButton icon="MagicWand" primary size="S" quiet on:click={hideOrUnhide}>
{#if hideAutocolumns}Show auto columns{:else}Hide auto columns{/if}
<ActionButton
icon={hideAutocolumns ? "VisibilityOff" : "Visibility"}
primary
size="S"
quiet
on:click={hideOrUnhide}
>
Auto columns
</ActionButton>

View File

@ -5,6 +5,7 @@
export let schema
export let filters
export let disabled = false
const dispatch = createEventDispatcher()
let modal
@ -17,6 +18,7 @@
icon="Filter"
size="S"
quiet
{disabled}
on:click={modal.show}
active={tempValue?.length > 0}
>

View File

@ -0,0 +1,78 @@
<script>
import { Select, Label, Combobox } from "@budibase/bbui"
import { onMount } from "svelte"
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
import { currentAsset, store } from "builderStore"
import {
getActionProviderComponents,
buildFormSchema,
} from "builderStore/dataBinding"
import { findComponent } from "builderStore/componentUtils"
export let parameters
export let bindings = []
const typeOptions = [
{
label: "Set value",
value: "set",
},
{
label: "Reset to default value",
value: "reset",
},
]
$: formComponent = findComponent($currentAsset.props, parameters.componentId)
$: formSchema = buildFormSchema(formComponent)
$: fieldOptions = Object.keys(formSchema || {})
$: actionProviders = getActionProviderComponents(
$currentAsset,
$store.selectedComponentId,
"ValidateForm"
)
onMount(() => {
if (!parameters.type) {
parameters.type = "set"
}
})
</script>
<div class="root">
<Label small>Form</Label>
<Select
bind:value={parameters.componentId}
options={actionProviders}
getOptionLabel={x => x._instanceName}
getOptionValue={x => x._id}
/>
<Label small>Type</Label>
<Select
placeholder={null}
bind:value={parameters.type}
options={typeOptions}
/>
<Label small>Field</Label>
<Combobox bind:value={parameters.field} options={fieldOptions} />
{#if parameters.type === "set"}
<Label small>Value</Label>
<DrawerBindableInput
{bindings}
value={parameters.value}
on:change={e => (parameters.value = e.detail)}
/>
{/if}
</div>
<style>
.root {
display: grid;
column-gap: var(--spacing-l);
row-gap: var(--spacing-s);
grid-template-columns: 60px 1fr;
align-items: center;
max-width: 400px;
margin: 0 auto;
}
</style>

View File

@ -14,3 +14,4 @@ export { default as DuplicateRow } from "./DuplicateRow.svelte"
export { default as S3Upload } from "./S3Upload.svelte"
export { default as ExportData } from "./ExportData.svelte"
export { default as ContinueIf } from "./ContinueIf.svelte"
export { default as UpdateFieldValue } from "./UpdateFieldValue.svelte"

View File

@ -42,25 +42,29 @@
"name": "Trigger Automation",
"component": "TriggerAutomation"
},
{
"name": "Update Field Value",
"component": "UpdateFieldValue"
},
{
"name": "Validate Form",
"component": "ValidateForm"
},
{
"name": "Log Out",
"component": "LogOut"
"name": "Change Form Step",
"component": "ChangeFormStep"
},
{
"name": "Clear Form",
"component": "ClearForm"
},
{
"name": "Close Screen Modal",
"component": "CloseScreenModal"
"name": "Log Out",
"component": "LogOut"
},
{
"name": "Change Form Step",
"component": "ChangeFormStep"
"name": "Close Screen Modal",
"component": "CloseScreenModal"
},
{
"name": "Refresh Data Provider",

View File

@ -75,8 +75,8 @@
<div class="title">
<div class="welcome">
<Layout noPadding gap="XS">
<Heading size="M">{createAppTitle}</Heading>
<Body size="S">
<Heading size="L">{createAppTitle}</Heading>
<Body size="M">
{welcomeBody}
</Body>
</Layout>
@ -84,7 +84,7 @@
<div class="buttons">
<Button
dataCy="create-app-btn"
size="L"
size="M"
icon="Add"
cta
on:click={initiateAppCreation}
@ -94,7 +94,7 @@
<Button
dataCy="import-app-btn"
icon="Import"
size="L"
size="M"
quiet
secondary
on:click={initiateAppImport}

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/cli",
"version": "1.0.105-alpha.29",
"version": "1.0.105-alpha.30",
"description": "Budibase CLI, for developers, self hosting and migrations.",
"main": "src/index.js",
"bin": {

View File

@ -1834,7 +1834,12 @@
"icon": "Form",
"hasChildren": true,
"illegalChildren": ["section", "form"],
"actions": ["ValidateForm", "ClearForm", "ChangeFormStep"],
"actions": [
"ValidateForm",
"ClearForm",
"ChangeFormStep",
"UpdateFieldValue"
],
"styles": ["size"],
"settings": [
{
@ -1975,6 +1980,17 @@
"label": "Default value",
"key": "defaultValue"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "boolean",
"label": "Disabled",
@ -2049,6 +2065,17 @@
"label": "Default value",
"key": "defaultValue"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "boolean",
"label": "Disabled",
@ -2089,6 +2116,17 @@
"label": "Default value",
"key": "defaultValue"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "boolean",
"label": "Disabled",
@ -2125,6 +2163,17 @@
"key": "placeholder",
"placeholder": "Choose an option"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "select",
"label": "Type",
@ -2274,6 +2323,17 @@
"label": "Default value",
"key": "defaultValue"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "boolean",
"label": "Autocomplete",
@ -2399,6 +2459,17 @@
"label": "Default value",
"key": "defaultValue"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "boolean",
"label": "Disabled",
@ -2439,6 +2510,17 @@
"label": "Default value",
"key": "defaultValue"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "select",
"label": "Formatting",
@ -2512,6 +2594,17 @@
"label": "Default value",
"key": "defaultValue"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "boolean",
"label": "Disabled",
@ -2657,6 +2750,17 @@
"label": "Extensions",
"key": "extensions"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "boolean",
"label": "Disabled",
@ -2697,6 +2801,17 @@
"label": "Default value",
"key": "defaultValue"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "boolean",
"label": "Autocomplete",
@ -2742,6 +2857,17 @@
"label": "Default value",
"key": "defaultValue"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "boolean",
"label": "Disabled",
@ -2750,6 +2876,62 @@
}
]
},
"s3upload": {
"name": "S3 File Upload",
"info": "This component can't be used with S3 datasources that use custom endpoints.",
"icon": "UploadToCloud",
"styles": ["size"],
"editable": true,
"settings": [
{
"type": "field/attachment",
"label": "Field",
"key": "field"
},
{
"type": "text",
"label": "Label",
"key": "label"
},
{
"type": "dataSource/s3",
"label": "S3 Datasource",
"key": "datasourceId"
},
{
"type": "text",
"label": "Bucket",
"key": "bucket"
},
{
"type": "text",
"label": "File Name",
"key": "key"
},
{
"type": "event",
"label": "On Change",
"key": "onChange",
"context": [
{
"label": "Field Value",
"key": "value"
}
]
},
{
"type": "boolean",
"label": "Disabled",
"key": "disabled",
"defaultValue": false
},
{
"type": "validation/attachment",
"label": "Validation",
"key": "validation"
}
]
},
"dataprovider": {
"name": "Data Provider",
"info": "Pagination is only available for data stored in tables.",
@ -3581,51 +3763,6 @@
}
]
},
"s3upload": {
"name": "S3 File Upload",
"info": "This component can't be used with S3 datasources that use custom endpoints.",
"icon": "UploadToCloud",
"styles": ["size"],
"editable": true,
"settings": [
{
"type": "field/attachment",
"label": "Field",
"key": "field"
},
{
"type": "text",
"label": "Label",
"key": "label"
},
{
"type": "dataSource/s3",
"label": "S3 Datasource",
"key": "datasourceId"
},
{
"type": "text",
"label": "Bucket",
"key": "bucket"
},
{
"type": "text",
"label": "File Name",
"key": "key"
},
{
"type": "boolean",
"label": "Disabled",
"key": "disabled",
"defaultValue": false
},
{
"type": "validation/attachment",
"label": "Validation",
"key": "validation"
}
]
},
"markdownviewer": {
"name": "Markdown Viewer",
"icon": "TaskList",

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/client",
"version": "1.0.105-alpha.29",
"version": "1.0.105-alpha.30",
"license": "MPL-2.0",
"module": "dist/budibase-client.js",
"main": "dist/budibase-client.js",
@ -19,9 +19,9 @@
"dev:builder": "rollup -cw"
},
"dependencies": {
"@budibase/bbui": "^1.0.105-alpha.29",
"@budibase/frontend-core": "^1.0.105-alpha.29",
"@budibase/string-templates": "^1.0.105-alpha.29",
"@budibase/bbui": "^1.0.105-alpha.30",
"@budibase/frontend-core": "^1.0.105-alpha.30",
"@budibase/string-templates": "^1.0.105-alpha.30",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",

View File

@ -8,6 +8,7 @@
export let disabled = false
export let validation
export let extensions
export let onChange
let fieldState
let fieldApi
@ -38,6 +39,13 @@
return []
}
}
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
</script>
<Field
@ -55,9 +63,7 @@
value={fieldState.value}
disabled={fieldState.disabled}
error={fieldState.error}
on:change={e => {
fieldApi.setValue(e.detail)
}}
on:change={handleChange}
{processFiles}
{handleFileTooLarge}
{extensions}

View File

@ -9,6 +9,7 @@
export let size
export let validation
export let defaultValue
export let onChange
let fieldState
let fieldApi
@ -25,6 +26,13 @@
}
return false
}
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
</script>
<Field
@ -44,8 +52,8 @@
error={fieldState.error}
id={fieldState.fieldId}
{size}
on:change={e => fieldApi.setValue(e.detail)}
{text}
on:change={handleChange}
/>
{/if}
</Field>

View File

@ -10,9 +10,17 @@
export let timeOnly = false
export let validation
export let defaultValue
export let onChange
let fieldState
let fieldApi
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
</script>
<Field
@ -28,7 +36,7 @@
{#if fieldState}
<CoreDatePicker
value={fieldState.value}
on:change={e => fieldApi.setValue(e.detail)}
on:change={handleChange}
disabled={fieldState.disabled}
error={fieldState.error}
id={fieldState.fieldId}

View File

@ -219,10 +219,10 @@
})
return valid
},
clear: () => {
// Clear the form by clearing each individual field
reset: () => {
// Reset the form by resetting each individual field
fields.forEach(field => {
get(field).fieldApi.clearValue()
get(field).fieldApi.reset()
})
},
changeStep: ({ type, number }) => {
@ -241,6 +241,22 @@
currentStep.set(step)
}
},
setFieldValue: (fieldName, value) => {
const field = getField(fieldName)
if (!field) {
return
}
const { fieldApi } = get(field)
fieldApi.setValue(value)
},
resetField: fieldName => {
const field = getField(fieldName)
if (!field) {
return
}
const { fieldApi } = get(field)
fieldApi.reset()
},
}
// Creates an API for a specific field
@ -268,11 +284,11 @@
return !error
}
// Clears the value of a certain field back to the initial value
const clearValue = () => {
// Clears the value of a certain field back to the default value
const reset = () => {
const fieldInfo = getField(field)
const { fieldState } = get(fieldInfo)
const newValue = initialValues[field] ?? fieldState.defaultValue
const newValue = fieldState.defaultValue
// Update field state
fieldInfo.update(state => {
@ -329,7 +345,7 @@
return {
setValue,
clearValue,
reset,
updateValidation,
setDisabled,
validate: () => {
@ -354,11 +370,20 @@
// register their fields to step 1
setContext("form-step", writable(1))
const handleUpdateFieldValue = ({ type, field, value }) => {
if (type === "set") {
formApi.setFieldValue(field, value)
} else {
formApi.resetField(field)
}
}
// Action context to pass to children
const actions = [
{ type: ActionTypes.ValidateForm, callback: formApi.validate },
{ type: ActionTypes.ClearForm, callback: formApi.clear },
{ type: ActionTypes.ClearForm, callback: formApi.reset },
{ type: ActionTypes.ChangeFormStep, callback: formApi.changeStep },
{ type: ActionTypes.UpdateFieldValue, callback: handleUpdateFieldValue },
]
</script>

View File

@ -8,6 +8,7 @@
export let placeholder
export let disabled = false
export let defaultValue = ""
export let onChange
const component = getContext("component")
const validation = [
@ -33,6 +34,14 @@
return value
}
}
const handleChange = e => {
const value = parseValue(e.detail)
fieldApi.setValue(value)
if (onChange) {
onChange({ value })
}
}
</script>
<Field
@ -49,7 +58,7 @@
<div style="--height: {height};">
<CoreTextArea
value={serialiseValue(fieldState.value)}
on:change={e => fieldApi.setValue(parseValue(e.detail))}
on:change={handleChange}
disabled={fieldState.disabled}
error={fieldState.error}
id={fieldState.fieldId}

View File

@ -11,6 +11,7 @@
export let validation
export let defaultValue = ""
export let format = "auto"
export let onChange
let fieldState
let fieldApi
@ -44,6 +45,13 @@
},
})
}
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
</script>
<Field
@ -61,7 +69,7 @@
{#if useRichText}
<CoreRichTextField
value={fieldState.value}
on:change={e => fieldApi.setValue(e.detail)}
on:change={handleChange}
disabled={fieldState.disabled}
error={fieldState.error}
id={fieldState.fieldId}
@ -78,7 +86,7 @@
{:else}
<CoreTextArea
value={fieldState.value}
on:change={e => fieldApi.setValue(e.detail)}
on:change={handleChange}
disabled={fieldState.disabled}
error={fieldState.error}
id={fieldState.fieldId}

View File

@ -14,6 +14,7 @@
export let valueColumn
export let customOptions
export let autocomplete = false
export let onChange
let fieldState
let fieldApi
@ -34,13 +35,18 @@
if (!values) {
return []
}
if (Array.isArray(values)) {
return values
}
return values.split(",").map(value => value.trim())
}
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
</script>
<Field
@ -62,7 +68,7 @@
getOptionValue={flatOptions ? x => x : x => x.value}
id={fieldState.fieldId}
disabled={fieldState.disabled}
on:change={e => fieldApi.setValue(e.detail)}
on:change={handleChange}
{placeholder}
{options}
{autocomplete}

View File

@ -16,6 +16,7 @@
export let customOptions
export let autocomplete = false
export let direction = "vertical"
export let onChange
let fieldState
let fieldApi
@ -30,6 +31,13 @@
valueColumn,
customOptions
)
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
</script>
<Field
@ -52,7 +60,7 @@
error={fieldState.error}
{options}
{placeholder}
on:change={e => fieldApi.setValue(e.detail)}
on:change={handleChange}
getOptionLabel={flatOptions ? x => x : x => x.label}
getOptionValue={flatOptions ? x => x : x => x.value}
{autocomplete}
@ -66,7 +74,7 @@
error={fieldState.error}
{options}
{direction}
on:change={e => fieldApi.setValue(e.detail)}
on:change={handleChange}
getOptionLabel={flatOptions ? x => x : x => x.label}
getOptionValue={flatOptions ? x => x : x => x.value}
/>

View File

@ -13,6 +13,7 @@
export let validation
export let autocomplete = false
export let defaultValue
export let onChange
let fieldState
let fieldApi
@ -62,11 +63,11 @@
}
const singleHandler = e => {
fieldApi.setValue(e.detail == null ? [] : [e.detail])
handleChange(e.detail == null ? [] : [e.detail])
}
const multiHandler = e => {
fieldApi.setValue(e.detail)
handleChange(e.detail)
}
const expand = values => {
@ -78,6 +79,13 @@
}
return values.split(",").map(value => value.trim())
}
const handleChange = value => {
fieldApi.setValue(value)
if (onChange) {
onChange({ value })
}
}
</script>
<Field

View File

@ -10,6 +10,7 @@
export let label
export let disabled = false
export let validation
export let onChange
let fieldState
let fieldApi
@ -88,6 +89,13 @@
}
}
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
onMount(() => {
uploadStore.actions.registerFileUpload($component.id, upload)
})
@ -113,9 +121,7 @@
value={fieldState.value}
disabled={loading || fieldState.disabled}
error={fieldState.error}
on:change={e => {
fieldApi.setValue(e.detail)
}}
on:change={handleChange}
{processFiles}
{handleFileTooLarge}
maximum={1}

View File

@ -10,9 +10,17 @@
export let validation
export let defaultValue = ""
export let align
export let onChange
let fieldState
let fieldApi
const handleChange = e => {
fieldApi.setValue(e.detail)
if (onChange) {
onChange({ value: e.detail })
}
}
</script>
<Field
@ -21,6 +29,7 @@
{disabled}
{validation}
{defaultValue}
{onChange}
type={type === "number" ? "number" : "string"}
bind:fieldState
bind:fieldApi
@ -29,7 +38,7 @@
<CoreTextField
updateOnChange={false}
value={fieldState.value}
on:change={e => fieldApi.setValue(e.detail)}
on:change={handleChange}
disabled={fieldState.disabled}
error={fieldState.error}
id={fieldState.fieldId}

View File

@ -21,6 +21,7 @@ export const UnsortableTypes = [
export const ActionTypes = {
ValidateForm: "ValidateForm",
UpdateFieldValue: "UpdateFieldValue",
RefreshDatasource: "RefreshDatasource",
AddDataProviderQueryExtension: "AddDataProviderQueryExtension",
RemoveDataProviderQueryExtension: "RemoveDataProviderQueryExtension",

View File

@ -162,6 +162,19 @@ const executeActionHandler = async (
}
}
const updateFieldValueHandler = async (action, context) => {
return await executeActionHandler(
context,
action.parameters.componentId,
ActionTypes.UpdateFieldValue,
{
type: action.parameters.type,
field: action.parameters.field,
value: action.parameters.value,
}
)
}
const validateFormHandler = async (action, context) => {
return await executeActionHandler(
context,
@ -295,6 +308,7 @@ const handlerMap = {
["Execute Query"]: queryExecutionHandler,
["Trigger Automation"]: triggerAutomationHandler,
["Validate Form"]: validateFormHandler,
["Update Field Value"]: updateFieldValueHandler,
["Refresh Data Provider"]: refreshDataProviderHandler,
["Log Out"]: logoutHandler,
["Clear Form"]: clearFormHandler,

View File

@ -1,12 +1,12 @@
{
"name": "@budibase/frontend-core",
"version": "1.0.105-alpha.29",
"version": "1.0.105-alpha.30",
"description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase",
"license": "MPL-2.0",
"svelte": "src/index.js",
"dependencies": {
"@budibase/bbui": "^1.0.105-alpha.29",
"@budibase/bbui": "^1.0.105-alpha.30",
"lodash": "^4.17.21",
"svelte": "^3.46.2"
}

View File

@ -2,10 +2,10 @@
"author": "Budibase",
"dependencies": {
"@apidevtools/swagger-parser": "^10.0.3",
"@budibase/backend-core": "^1.0.105-alpha.29",
"@budibase/client": "^1.0.105-alpha.29",
"@budibase/backend-core": "^1.0.105-alpha.30",
"@budibase/client": "^1.0.105-alpha.30",
"@budibase/pro": "^1.0.0",
"@budibase/string-templates": "^1.0.105-alpha.29",
"@budibase/string-templates": "^1.0.105-alpha.30",
"@bull-board/api": "^3.7.0",
"@bull-board/koa": "^3.7.0",
"@elastic/elasticsearch": "7.10.0",
@ -148,9 +148,6 @@
"license": "GPL-3.0",
"main": "src/index.ts",
"name": "@budibase/server",
"optionalDependencies": {
"oracledb": "^5.3.0"
},
"repository": {
"type": "git",
"url": "https://github.com/Budibase/budibase.git"
@ -179,5 +176,5 @@
"test": "jest --coverage --maxWorkers=2",
"test:watch": "jest --watch"
},
"version": "1.0.105-alpha.29"
"version": "1.0.105-alpha.30"
}

View File

@ -1,6 +1,6 @@
{
"name": "@budibase/string-templates",
"version": "1.0.105-alpha.29",
"version": "1.0.105-alpha.30",
"description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs",
"module": "dist/bundle.mjs",

View File

@ -1,7 +1,7 @@
{
"name": "@budibase/worker",
"email": "hi@budibase.com",
"version": "1.0.105-alpha.29",
"version": "1.0.105-alpha.30",
"description": "Budibase background service",
"main": "src/index.ts",
"repository": {
@ -31,9 +31,9 @@
"author": "Budibase",
"license": "GPL-3.0",
"dependencies": {
"@budibase/backend-core": "^1.0.105-alpha.29",
"@budibase/backend-core": "^1.0.105-alpha.30",
"@budibase/pro": "^1.0.0",
"@budibase/string-templates": "^1.0.105-alpha.29",
"@budibase/string-templates": "^1.0.105-alpha.30",
"@koa/router": "^8.0.0",
"@sentry/node": "6.17.7",
"@techpass/passport-openidconnect": "^0.3.0",