This commit is contained in:
Gerard Burns 2024-04-04 09:53:15 +01:00
parent 6c823f5c60
commit 2e68d8b7d6
3 changed files with 43 additions and 16 deletions

View File

@ -16,6 +16,22 @@
export let errors = [] export let errors = []
export let warnings = [] export let warnings = []
const getDocLink = (columnType) => {
if (columnType === "number") {
return "https://docs.budibase.com/docs/number"
}
if (columnType === "string") {
return "https://docs.budibase.com/docs/text"
}
if (columnType === "attachment") {
return "https://docs.budibase.com/docs/attachments"
}
return ""
}
$: docLink = getDocLink(columnType);
</script> </script>
<div <div
@ -28,12 +44,12 @@
<div class="contextTooltipContent"> <div class="contextTooltipContent">
<div class="contextTooltipHeader"> <div class="contextTooltipHeader">
<span class="columnName"> <span class="columnName">
{columnName} {columnName}
</span><span> is a </span> </span><span> is a </span>
<div class="link"> <a target=”_blank” href={docLink} class="link">
<Icon name={columnIcon} /> <Icon name={columnIcon} />
<span>{columnType}</span> <span>{columnType}</span>
</div> </a>
<span>column.</span> <span>column.</span>
</div> </div>
@ -45,6 +61,8 @@
{#each warnings as datum} {#each warnings as datum}
<p>{datum}</p> <p>{datum}</p>
{/each} {/each}
{:else}
<p>{supportLevelIconTooltip}</p>
{/if} {/if}
</div> </div>
</div> </div>
@ -75,13 +93,14 @@
} }
.contextTooltipHeader { .contextTooltipHeader {
row-gap: 4px; row-gap: 6px;
column-gap: 5px;
background-color: var(--background-alt); background-color: var(--background-alt);
color: var(--ink); color: var(--ink);
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
align-items: center; align-items: center;
padding: 4px 4px; padding: 6px 8px;
border-width: var(--spectrum-actionbutton-border-size); border-width: var(--spectrum-actionbutton-border-size);
border-radius: var(--spectrum-alias-border-radius-regular); border-radius: var(--spectrum-alias-border-radius-regular);
border: 1px solid border: 1px solid
@ -107,7 +126,6 @@
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
margin-right: 5px;
} }
.link { .link {
@ -116,7 +134,12 @@
border-radius: 5px; border-radius: 5px;
background-color: var(--spectrum-global-color-blue-500); background-color: var(--spectrum-global-color-blue-500);
color: white; color: white;
margin: 0 8px; transition: background-color 300ms
}
.link:hover {
background-color: var(--spectrum-global-color-blue-700);
cursor: pointer;
} }
.link :global(svg) { .link :global(svg) {

View File

@ -5,6 +5,7 @@
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import { validators, constants as validatorConstants } from "../fieldValidator"; import { validators, constants as validatorConstants } from "../fieldValidator";
import ChartFieldContext from './FieldContext/Chart.svelte' import ChartFieldContext from './FieldContext/Chart.svelte'
import { FIELDS } from 'constants/backend'
export let componentInstance = {} export let componentInstance = {}
export let value = "" export let value = ""
@ -63,9 +64,6 @@
$: fieldSupport = getFieldSupport(schema, fieldValidator); $: fieldSupport = getFieldSupport(schema, fieldValidator);
$: boundValue = getValidOptions(value, options) $: boundValue = getValidOptions(value, options)
$: {
console.log(schema)
}
const getValidOptions = (selectedOptions, allOptions) => { const getValidOptions = (selectedOptions, allOptions) => {
// Fix the hardcoded default string value // Fix the hardcoded default string value
@ -100,7 +98,14 @@
const getOptionIconTooltip = optionKey => { const getOptionIconTooltip = optionKey => {
const option = schema[optionKey] const option = schema[optionKey]
return option?.type; const type = option?.type;
const field = Object.values(FIELDS).find(f => f.type === type)
if (field) {
return field.name
}
return ""
} }
const isOptionEnabled = optionKey => { const isOptionEnabled = optionKey => {
@ -157,7 +162,6 @@
$: previousOptionSupport = getSupportLevel(previousOption) $: previousOptionSupport = getSupportLevel(previousOption)
const onOptionMouseenter = (e, option, idx) => { const onOptionMouseenter = (e, option, idx) => {
console.log(option)
contextTooltipId += 1; contextTooltipId += 1;
const invokedContextTooltipId = contextTooltipId const invokedContextTooltipId = contextTooltipId

View File

@ -20,20 +20,20 @@ export const validators = {
} }
const generalUnsupportedFields = ["array", "attachment", "barcodeqr", "link", "bb_reference"] const generalUnsupportedFields = ["array", "attachment", "barcodeqr", "link", "bb_reference"]
if (generalUnsupportedFields.includes(fieldSchema.type)) { if (generalUnsupportedFields.includes(fieldSchema.type)) {
response.errors.push(`${capitalize(fieldSchema.type)} columns are unsupported.`) response.errors.push('This column can not be used a chart input.')
} }
if (fieldSchema.type === "json") { if (fieldSchema.type === "json") {
response.errors.push(`JSON columns can not be used as chart inputs, but individual properties of this JSON field can be be used if supported.`) response.errors.push(`This column can not be used as a chart input, but individual properties of a JSON object can be be used if supported.`)
} }
if (fieldSchema.type === "string") { if (fieldSchema.type === "string") {
response.warnings.push( response.warnings.push(
"String columns can be used as input for a chart, but non-numeric values may cause unexpected behavior.") "This column can be used as input for a chart, but non-numeric values may cause unexpected behavior.")
} }
if (fieldSchema.type === "datetime") { if (fieldSchema.type === "datetime") {
response.warnings.push( response.warnings.push(
"This column can be used as input for a chart, but it is parsed differently for various charts.") "This column can be used as input for a chart, but it may be parsed differently depending on the which is used.")
} }
const isRequired = fieldSchema?.constraints?.presence?.allowEmpty === false const isRequired = fieldSchema?.constraints?.presence?.allowEmpty === false