Merge branch 'develop' of github.com:Budibase/budibase into design-collab

This commit is contained in:
Andrew Kingston 2023-07-04 10:17:51 +01:00
commit f3ecbca6b4
19 changed files with 66 additions and 57 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "2.7.37-alpha.4", "version": "2.7.37-alpha.10",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*" "packages/*"

View File

@ -182,6 +182,15 @@
indexes, indexes,
}) })
dispatch("updatecolumns") dispatch("updatecolumns")
if (
saveColumn.type === LINK_TYPE &&
saveColumn.relationshipType === RelationshipTypes.MANY_TO_MANY
) {
// Fetching the new tables
tables.fetch()
// Fetching the new relationships
datasources.fetch()
}
if (originalName) { if (originalName) {
notifications.success("Column updated successfully") notifications.success("Column updated successfully")
} else { } else {

View File

@ -68,6 +68,7 @@
on:blur={() => dispatch("blur")} on:blur={() => dispatch("blur")}
{placeholder} {placeholder}
{error} {error}
options={allOptions}
/> />
{#if !disabled} {#if !disabled}
<div class="icon" on:click={bindingDrawer.show}> <div class="icon" on:click={bindingDrawer.show}>

View File

@ -20,6 +20,7 @@ import ValidationEditor from "./controls/ValidationEditor/ValidationEditor.svelt
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte" import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
import ColumnEditor from "./controls/ColumnEditor/ColumnEditor.svelte" import ColumnEditor from "./controls/ColumnEditor/ColumnEditor.svelte"
import BasicColumnEditor from "./controls/ColumnEditor/BasicColumnEditor.svelte" import BasicColumnEditor from "./controls/ColumnEditor/BasicColumnEditor.svelte"
import GridColumnEditor from "./controls/ColumnEditor/GridColumnEditor.svelte"
import BarButtonList from "./controls/BarButtonList.svelte" import BarButtonList from "./controls/BarButtonList.svelte"
import FieldConfiguration from "./controls/FieldConfiguration/FieldConfiguration.svelte" import FieldConfiguration from "./controls/FieldConfiguration/FieldConfiguration.svelte"
@ -47,6 +48,7 @@ const componentMap = {
fieldConfiguration: FieldConfiguration, fieldConfiguration: FieldConfiguration,
columns: ColumnEditor, columns: ColumnEditor,
"columns/basic": BasicColumnEditor, "columns/basic": BasicColumnEditor,
"columns/grid": GridColumnEditor,
"field/sortable": SortableFieldSelect, "field/sortable": SortableFieldSelect,
"field/string": FormFieldSelect, "field/string": FormFieldSelect,
"field/number": FormFieldSelect, "field/number": FormFieldSelect,

View File

@ -43,7 +43,9 @@
title="Destination" title="Destination"
placeholder="/screen" placeholder="/screen"
value={parameters.url} value={parameters.url}
on:change={value => (parameters.url = value.detail)} on:change={value => {
parameters.url = value.detail ? value.detail.trim() : value.detail
}}
{bindings} {bindings}
options={urlOptions} options={urlOptions}
appendBindingsAsOptions={false} appendBindingsAsOptions={false}
@ -55,7 +57,9 @@
title="Destination" title="Destination"
placeholder="/url" placeholder="/url"
value={parameters.url} value={parameters.url}
on:change={value => (parameters.url = value.detail)} on:change={value => {
parameters.url = value.detail ? value.detail.trim() : value.detail
}}
{bindings} {bindings}
/> />
<div /> <div />

View File

@ -18,6 +18,7 @@
export let options = [] export let options = []
export let schema = {} export let schema = {}
export let allowCellEditing = true export let allowCellEditing = true
export let allowReorder = true
const flipDurationMs = 150 const flipDurationMs = 150
let dragDisabled = true let dragDisabled = true
@ -110,6 +111,7 @@
{#each columns as column (column.id)} {#each columns as column (column.id)}
<div class="column" animate:flip={{ duration: flipDurationMs }}> <div class="column" animate:flip={{ duration: flipDurationMs }}>
<div <div
class:hide={!allowReorder}
class="handle" class="handle"
aria-label="drag-handle" aria-label="drag-handle"
style={dragDisabled ? "cursor: grab" : "cursor: grabbing"} style={dragDisabled ? "cursor: grab" : "cursor: grabbing"}
@ -193,6 +195,9 @@
display: grid; display: grid;
place-items: center; place-items: center;
} }
.handle.hide {
visibility: hidden;
}
.wide { .wide {
grid-column: 2 / -1; grid-column: 2 / -1;
} }

View File

@ -13,6 +13,7 @@
export let componentInstance export let componentInstance
export let value = [] export let value = []
export let allowCellEditing = true export let allowCellEditing = true
export let allowReorder = true
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -85,6 +86,7 @@
{options} {options}
{schema} {schema}
{allowCellEditing} {allowCellEditing}
{allowReorder}
/> />
</Drawer> </Drawer>

View File

@ -0,0 +1,10 @@
<script>
import ColumnEditor from "./ColumnEditor.svelte"
</script>
<ColumnEditor
{...$$props}
on:change
allowCellEditing={false}
allowReorder={false}
/>

View File

@ -5248,7 +5248,7 @@
"required": true "required": true
}, },
{ {
"type": "columns/basic", "type": "columns/grid",
"label": "Columns", "label": "Columns",
"key": "columns", "key": "columns",
"dependsOn": "table" "dependsOn": "table"
@ -5274,7 +5274,7 @@
{ {
"type": "select", "type": "select",
"label": "Row height", "label": "Row height",
"key": "initialRowHeight", "key": "fixedRowHeight",
"placeholder": "Default", "placeholder": "Default",
"options": [ "options": [
{ {

View File

@ -12,7 +12,7 @@
export let initialFilter = null export let initialFilter = null
export let initialSortColumn = null export let initialSortColumn = null
export let initialSortOrder = null export let initialSortOrder = null
export let initialRowHeight = null export let fixedRowHeight = null
export let columns = null export let columns = null
const component = getContext("component") const component = getContext("component")
@ -47,7 +47,7 @@
{initialFilter} {initialFilter}
{initialSortColumn} {initialSortColumn}
{initialSortOrder} {initialSortOrder}
{initialRowHeight} {fixedRowHeight}
{columnWhitelist} {columnWhitelist}
{schemaOverrides} {schemaOverrides}
showControls={false} showControls={false}

View File

@ -8,7 +8,8 @@
SmallRowHeight, SmallRowHeight,
} from "../lib/constants" } from "../lib/constants"
const { stickyColumn, columns, rowHeight, table } = getContext("grid") const { stickyColumn, columns, rowHeight, table, fixedRowHeight } =
getContext("grid")
// Some constants for column width options // Some constants for column width options
const smallColSize = 120 const smallColSize = 120
@ -86,6 +87,7 @@
<div class="options"> <div class="options">
{#each rowSizeOptions as option} {#each rowSizeOptions as option}
<ActionButton <ActionButton
disabled={$fixedRowHeight}
quiet quiet
selected={$rowHeight === option.size} selected={$rowHeight === option.size}
on:click={() => changeRowHeight(option.size)} on:click={() => changeRowHeight(option.size)}
@ -118,15 +120,15 @@
<style> <style>
.content { .content {
padding: 12px; padding: 12px;
display: flex;
flex-direction: column;
gap: 16px;
} }
.size { .size {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 8px; gap: 8px;
} }
.size:first-child {
margin-bottom: 16px;
}
.options { .options {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -43,7 +43,7 @@
export let initialFilter = null export let initialFilter = null
export let initialSortColumn = null export let initialSortColumn = null
export let initialSortOrder = null export let initialSortOrder = null
export let initialRowHeight = null export let fixedRowHeight = null
export let notifySuccess = null export let notifySuccess = null
export let notifyError = null export let notifyError = null
@ -90,7 +90,7 @@
initialFilter, initialFilter,
initialSortColumn, initialSortColumn,
initialSortOrder, initialSortOrder,
initialRowHeight, fixedRowHeight,
notifySuccess, notifySuccess,
notifyError, notifyError,
}) })

View File

@ -10,7 +10,7 @@ export const createStores = context => {
const initialSortColumn = getProp("initialSortColumn") const initialSortColumn = getProp("initialSortColumn")
const initialSortOrder = getProp("initialSortOrder") const initialSortOrder = getProp("initialSortOrder")
const initialFilter = getProp("initialFilter") const initialFilter = getProp("initialFilter")
const initialRowHeight = getProp("initialRowHeight") const fixedRowHeight = getProp("fixedRowHeight")
const schemaOverrides = getProp("schemaOverrides") const schemaOverrides = getProp("schemaOverrides")
const columnWhitelist = getProp("columnWhitelist") const columnWhitelist = getProp("columnWhitelist")
const notifySuccess = getProp("notifySuccess") const notifySuccess = getProp("notifySuccess")
@ -22,7 +22,7 @@ export const createStores = context => {
initialSortColumn, initialSortColumn,
initialSortOrder, initialSortOrder,
initialFilter, initialFilter,
initialRowHeight, fixedRowHeight,
schemaOverrides, schemaOverrides,
columnWhitelist, columnWhitelist,
notifySuccess, notifySuccess,

View File

@ -245,8 +245,7 @@ export const deriveStores = context => {
focusedCellId.set(`${rowId}-${erroredColumns[0]}`) focusedCellId.set(`${rowId}-${erroredColumns[0]}`)
} }
} else { } else {
// Some other error - just update the current cell get(notifications).error(error?.message || "An unknown error occurred")
validation.actions.setError(get(focusedCellId), error?.message || "Error")
} }
} }

View File

@ -14,7 +14,7 @@ export const createStores = context => {
const focusedCellAPI = writable(null) const focusedCellAPI = writable(null)
const selectedRows = writable({}) const selectedRows = writable({})
const hoveredRowId = writable(null) const hoveredRowId = writable(null)
const rowHeight = writable(props.initialRowHeight || DefaultRowHeight) const rowHeight = writable(props.fixedRowHeight || DefaultRowHeight)
const previousFocusedRowId = writable(null) const previousFocusedRowId = writable(null)
const gridFocused = writable(false) const gridFocused = writable(false)
const isDragging = writable(false) const isDragging = writable(false)
@ -134,7 +134,7 @@ export const initialise = context => {
hoveredRowId, hoveredRowId,
table, table,
rowHeight, rowHeight,
initialRowHeight, fixedRowHeight,
} = context } = context
// Ensure we clear invalid rows from state if they disappear // Ensure we clear invalid rows from state if they disappear
@ -187,13 +187,15 @@ export const initialise = context => {
} }
}) })
// Pull row height from table // Pull row height from table as long as we don't have a fixed height
table.subscribe($table => { table.subscribe($table => {
rowHeight.set($table?.rowHeight || DefaultRowHeight) if (!get(fixedRowHeight)) {
rowHeight.set($table?.rowHeight || DefaultRowHeight)
}
}) })
// Reset row height when initial row height prop changes // Reset row height when initial row height prop changes
initialRowHeight.subscribe(height => { fixedRowHeight.subscribe(height => {
if (height) { if (height) {
rowHeight.set(height) rowHeight.set(height)
} else { } else {

View File

@ -75,7 +75,7 @@
], ],
"numArgs": 2, "numArgs": 2,
"example": "{{ multiply 10 5 }} -> 50", "example": "{{ multiply 10 5 }} -> 50",
"description": "<p>Return the product of <code>a</code> times <code>b</code>.</p>\n" "description": "<p>Multiply number <code>a</code> by number <code>b</code>.</p>\n"
}, },
"plus": { "plus": {
"args": [ "args": [
@ -128,15 +128,6 @@
"numArgs": 1, "numArgs": 1,
"example": "{{ sum [1, 2, 3] }} -> 6", "example": "{{ sum [1, 2, 3] }} -> 6",
"description": "<p>Returns the sum of all numbers in the given array.</p>\n" "description": "<p>Returns the sum of all numbers in the given array.</p>\n"
},
"times": {
"args": [
"a",
"b"
],
"numArgs": 2,
"example": "{{ times 10 5 }} -> 50",
"description": "<p>Multiply number <code>a</code> by number <code>b</code>.</p>\n"
} }
}, },
"array": { "array": {
@ -497,19 +488,9 @@
"str" "str"
], ],
"numArgs": 1, "numArgs": 1,
"example": "{{ escape 'https://myurl?Hello%20There' }} -> https://myurl?Hello+There", "example": "{{ decodeURI 'https://myurl?Hello%20There' }} -> https://myurl?=Hello There",
"description": "<p>Decode a Uniform Resource Identifier (URI) component.</p>\n" "description": "<p>Decode a Uniform Resource Identifier (URI) component.</p>\n"
}, },
"url_encode": {
"args": [],
"numArgs": 0,
"description": "<p>Alias for <a href=\"#encodeuri\">encodeURI</a>.</p>\n"
},
"url_decode": {
"args": [],
"numArgs": 0,
"description": "<p>Alias for <a href=\"#decodeuri\">decodeURI</a>.</p>\n"
},
"urlResolve": { "urlResolve": {
"args": [ "args": [
"base", "base",
@ -625,7 +606,7 @@
"length" "length"
], ],
"numArgs": 2, "numArgs": 2,
"example": "{{ellipsis 'foo bar baz' 7}} -> foo bar…", "example": "{{ellipsis 'foo bar baz', 7}} -> foo bar…",
"description": "<p>Truncates a string to the specified <code>length</code>, and appends it with an elipsis, <code>…</code>.</p>\n" "description": "<p>Truncates a string to the specified <code>length</code>, and appends it with an elipsis, <code>…</code>.</p>\n"
}, },
"hyphenate": { "hyphenate": {
@ -1219,4 +1200,4 @@
"description": "<p>Produce a humanized duration left/until given an amount of time and the type of time measurement.</p>\n" "description": "<p>Produce a humanized duration left/until given an amount of time and the type of time measurement.</p>\n"
} }
} }
} }

View File

@ -25,7 +25,7 @@
"manifest": "node ./scripts/gen-collection-info.js" "manifest": "node ./scripts/gen-collection-info.js"
}, },
"dependencies": { "dependencies": {
"@budibase/handlebars-helpers": "^0.11.8", "@budibase/handlebars-helpers": "^0.11.9",
"dayjs": "^1.10.4", "dayjs": "^1.10.4",
"handlebars": "^4.7.6", "handlebars": "^4.7.6",
"handlebars-utils": "^1.0.6", "handlebars-utils": "^1.0.6",

View File

@ -9,8 +9,8 @@ const marked = require("marked")
* full list of supported helpers can be found here: * full list of supported helpers can be found here:
* https://github.com/budibase/handlebars-helpers * https://github.com/budibase/handlebars-helpers
*/ */
const { join } = require("path")
const DIRECTORY = fs.existsSync("node_modules") ? "." : ".." const DIRECTORY = join(__dirname, "..", "..", "..")
const COLLECTIONS = [ const COLLECTIONS = [
"math", "math",
"array", "array",
@ -20,7 +20,7 @@ const COLLECTIONS = [
"comparison", "comparison",
"object", "object",
] ]
const FILENAME = `${DIRECTORY}/manifest.json` const FILENAME = join(__dirname, "..", "manifest.json")
const outputJSON = {} const outputJSON = {}
const ADDED_HELPERS = { const ADDED_HELPERS = {
date: { date: {

View File

@ -48,14 +48,6 @@ describe("test the math helpers", () => {
}) })
expect(parseInt(output)).toBe(2) expect(parseInt(output)).toBe(2)
}) })
it("should be able to times", async () => {
const output = await processString("{{times a b}}", {
a: 5,
b: 5,
})
expect(parseInt(output)).toBe(25)
})
}) })
describe("test the array helpers", () => { describe("test the array helpers", () => {