1
0
Fork 0
mirror of synced 2024-08-14 09:31:49 +12:00

Merge branch 'develop' into account-portal-auth-api-testing-2

This commit is contained in:
Mitch-Budibase 2023-09-06 16:02:59 +01:00
commit 27ce59eaa2
15 changed files with 71 additions and 81 deletions

View file

@ -1,5 +1,5 @@
{
"version": "2.9.39-alpha.5",
"version": "2.9.39-alpha.9",
"npmClient": "yarn",
"packages": [
"packages/*"

View file

@ -1,4 +1,6 @@
*
!dist/**/*
dist/tsconfig.build.tsbuildinfo
!package.json
!package.json
!src/**
!tests/**

View file

@ -4,13 +4,6 @@
"description": "Budibase backend core libraries used in server and worker",
"main": "dist/index.js",
"types": "dist/src/index.d.ts",
"typesVersions": {
"*": {
"tests": [
"./dist/tests/index.d.ts"
]
}
},
"exports": {
".": "./dist/index.js",
"./tests": "./dist/tests/index.js",
@ -21,7 +14,7 @@
"scripts": {
"prebuild": "rimraf dist/",
"prepack": "cp package.json dist",
"build": "node ./scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null",
"build": "tsc -p tsconfig.build.json --paths null && node ./scripts/build.js",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
"test": "bash scripts/test.sh",

View file

@ -1,22 +1,4 @@
#!/usr/bin/node
const coreBuild = require("../../../scripts/build")
coreBuild("./src/plugin/index.ts", "./dist/plugins.js")
coreBuild("./src/index.ts", "./dist/index.js")
const glob = require("glob")
const inputFiles = [
...glob.sync("./src/**/*.[tj]s", { nodir: true }),
...glob.sync("./tests/**/*.[tj]s", { nodir: true }),
]
const path = require("path")
for (const file of inputFiles) {
coreBuild(file, `./${path.join("dist", file.replace(/\.ts$/, ".js"))}`, {
skipMeta: true,
bundle: false,
forcedFormat: "cjs",
silent: true,
})
}

View file

@ -102,7 +102,7 @@
bind:this={button}
>
{#if fieldIcon}
{#if !useOptionIconImage}x
{#if !useOptionIconImage}
<span class="option-extra icon">
<Icon size="S" name={fieldIcon} />
</span>

View file

@ -955,7 +955,9 @@ export const buildFormSchema = (component, asset) => {
const patched = convertOldFieldFormat(component.fields || [])
patched?.forEach(({ field, active }) => {
if (!active) return
schema[field] = { type: info?.schema[field].type }
if (info?.schema[field]) {
schema[field] = { type: info?.schema[field].type }
}
})
}

View file

@ -627,6 +627,7 @@ export const getFrontendStore = () => {
component[setting.key] = {
label: defaultDS.name,
tableId: defaultDS._id,
resourceId: defaultDS._id,
type: "table",
}
} else if (setting.type === "dataProvider") {
@ -1245,6 +1246,13 @@ export const getFrontendStore = () => {
const settings = getComponentSettings(component._component)
const updatedSetting = settings.find(setting => setting.key === name)
const resetFields = settings.filter(
setting => name === setting.resetOn
)
resetFields?.forEach(setting => {
component[setting.key] = null
})
if (
updatedSetting?.type === "dataSource" ||
updatedSetting?.type === "table"

View file

@ -8,7 +8,7 @@ export default function (datasources) {
}
return datasources.map(datasource => {
return {
name: `${datasource.name} - List`,
name: `${datasource.label} - List`,
create: () => createScreen(datasource),
id: ROW_LIST_TEMPLATE,
resourceId: datasource.resourceId,
@ -17,13 +17,13 @@ export default function (datasources) {
}
export const ROW_LIST_TEMPLATE = "ROW_LIST_TEMPLATE"
export const rowListUrl = datasource => sanitizeUrl(`/${datasource.name}`)
export const rowListUrl = datasource => sanitizeUrl(`/${datasource.label}`)
const generateTableBlock = datasource => {
const tableBlock = new Component("@budibase/standard-components/tableblock")
tableBlock
.customProps({
title: datasource.name,
title: datasource.label,
dataSource: datasource,
sortOrder: "Ascending",
size: "spectrum--medium",
@ -34,14 +34,14 @@ const generateTableBlock = datasource => {
titleButtonText: "Create row",
titleButtonClickBehaviour: "new",
})
.instanceName(`${datasource.name} - Table block`)
.instanceName(`${datasource.label} - Table block`)
return tableBlock
}
const createScreen = datasource => {
return new Screen()
.route(rowListUrl(datasource))
.instanceName(`${datasource.name} - List`)
.instanceName(`${datasource.label} - List`)
.addChild(generateTableBlock(datasource))
.json()
}

View file

@ -21,6 +21,9 @@
let fieldList
let schema
let cachedValue
let options
let sanitisedValue
let unconfigured
$: bindings = getBindableProperties($selectedScreen, componentInstance._id)
$: actionType = componentInstance.actionType
@ -34,16 +37,24 @@
}
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
$: resourceId = datasource.resourceId || datasource.tableId
$: if (!isEqual(value, cachedValue)) {
cachedValue = value
schema = getSchema($currentAsset, datasource)
cachedValue = cloneDeep(value)
}
$: options = Object.keys(schema || {})
$: sanitisedValue = getValidColumns(convertOldFieldFormat(value), options)
$: updateSanitsedFields(sanitisedValue)
$: unconfigured = buildUnconfiguredOptions(schema, sanitisedFields)
const updateState = value => {
schema = getSchema($currentAsset, datasource)
options = Object.keys(schema || {})
sanitisedValue = getValidColumns(convertOldFieldFormat(value), options)
updateSanitsedFields(sanitisedValue)
unconfigured = buildUnconfiguredOptions(schema, sanitisedFields)
fieldList = [...sanitisedFields, ...unconfigured]
.map(buildSudoInstance)
.filter(x => x != null)
}
$: updateState(cachedValue, resourceId)
// Builds unused ones only
const buildUnconfiguredOptions = (schema, selected) => {
@ -97,7 +108,6 @@
if (instance._component) {
return instance
}
const type = getComponentForField(instance.field, schema)
if (!type) {
return null
@ -118,12 +128,6 @@
return { ...instance, ...pseudoComponentInstance }
}
$: if (sanitisedFields) {
fieldList = [...sanitisedFields, ...unconfigured]
.map(buildSudoInstance)
.filter(x => x != null)
}
const processItemUpdate = e => {
const updatedField = e.detail
const parentFieldsUpdated = fieldList ? cloneDeep(fieldList) : []

View file

@ -8,15 +8,16 @@
const dispatch = createEventDispatcher()
$: tables = $tablesStore.list.map(table => ({
...table,
type: "table",
label: table.name,
tableId: table._id,
resourceId: table._id,
}))
$: views = $viewsV2.list.map(view => ({
...view,
type: "viewV2",
id: view.id,
label: view.name,
tableId: view.tableId,
resourceId: view.id,
}))
$: options = [...(tables || []), ...(views || [])]
@ -32,7 +33,7 @@
// Migrate old values before "resourceId" existed
if (value && !value.resourceId) {
const view = views.find(x => x.resourceId === value.id)
const table = tables.find(x => x.resourceId === value._id)
const table = tables.find(x => x.resourceId === value.tableId)
dispatch("change", view || table)
}
})

View file

@ -75,43 +75,37 @@
{@const views = Object.values(table.views || {}).filter(
view => view.version === 2
)}
{@const datasource = {
...table,
// Legacy properties
{@const tableDS = {
tableId: table._id,
label: table.name,
// New consistent properties
resourceId: table._id,
name: table.name,
type: "table",
}}
{@const selected = selectedScreens.find(
screen => screen.resourceId === datasource.resourceId
screen => screen.resourceId === tableDS.resourceId
)}
<DatasourceTemplateRow
on:click={() => toggleSelection(datasource)}
on:click={() => toggleSelection(tableDS)}
{selected}
{datasource}
datasource={tableDS}
/>
<!-- List all views inside this table -->
{#each views as view}
{@const datasource = {
...view,
// Legacy properties
{@const viewDS = {
label: view.name,
// New consistent properties
id: view.id,
resourceId: view.id,
name: view.name,
tableId: view.tableId,
type: "viewV2",
}}
{@const selected = selectedScreens.find(
x => x.resourceId === datasource.resourceId
x => x.resourceId === viewDS.resourceId
)}
<DatasourceTemplateRow
on:click={() => toggleSelection(datasource)}
on:click={() => toggleSelection(viewDS)}
{selected}
{datasource}
datasource={viewDS}
/>
{/each}
{/each}

View file

@ -8,7 +8,7 @@
<div class="data-source-entry" class:selected on:click>
<Icon name={icon} color="var(--spectrum-global-color-gray-600)" />
{datasource.name}
{datasource.label}
{#if selected}
<span class="data-source-check">
<Icon size="S" name="CheckmarkCircle" />

View file

@ -4745,7 +4745,8 @@
"dependsOn": {
"setting": "clickBehaviour",
"value": "details"
}
},
"resetOn": "dataSource"
},
{
"label": "Save button",
@ -5397,6 +5398,7 @@
"type": "fieldConfiguration",
"key": "fields",
"nested": true,
"resetOn": "dataSource",
"selectAllFields": true
},
{

View file

@ -275,7 +275,7 @@
dataSource,
showSaveButton: true,
showDeleteButton: false,
saveButtonLabel: sidePanelSaveLabel,
saveButtonLabel: sidePanelSaveLabel || "Save", //always show
actionType: "Create",
fields: sidePanelFields || normalFields,
title: "Create Row",

View file

@ -211,17 +211,19 @@
{/if}
</BlockComponent>
{/if}
<BlockComponent type="fieldgroup" props={{ labelPosition }} order={1}>
{#each fields as field, idx}
{#if getComponentForField(field) && field.active}
<BlockComponent
type={getComponentForField(field)}
props={getPropsForField(field)}
order={idx}
/>
{/if}
{/each}
</BlockComponent>
{#key fields}
<BlockComponent type="fieldgroup" props={{ labelPosition }} order={1}>
{#each fields as field, idx}
{#if getComponentForField(field) && field.active}
<BlockComponent
type={getComponentForField(field)}
props={getPropsForField(field)}
order={idx}
/>
{/if}
{/each}
</BlockComponent>
{/key}
</BlockComponent>
</BlockComponent>
{:else}