add explanation modal type presets
This commit is contained in:
parent
e4386ed781
commit
4690f78775
|
@ -1,10 +1,13 @@
|
||||||
<script>
|
<script>
|
||||||
import ExplanationModal from './ExplanationModal/index.svelte'
|
import ExplanationModal from './ExplanationModal/index.svelte'
|
||||||
import { messages as messageConstants, getColumnInfoMessagesAndSupport } from "./columnInfo";
|
import { messages as messageConstants, getColumnInfoMessagesAndSupport, getExplanationWithPresets } from "./columnInfo";
|
||||||
import { Column, Support, NotRequired, StringNumber, JSONPrimitivesOnly, DateAsNumber } from "./lines"
|
import { Column, Support, NotRequired, StringNumber, JSONPrimitivesOnly, DateAsNumber } from "./lines"
|
||||||
import subjects from './subjects';
|
import subjects from './subjects';
|
||||||
|
import {
|
||||||
|
componentStore,
|
||||||
|
} from "stores/builder"
|
||||||
|
|
||||||
export let columnInfo
|
export let explanation
|
||||||
export let columnIcon
|
export let columnIcon
|
||||||
export let columnType
|
export let columnType
|
||||||
export let columnName
|
export let columnName
|
||||||
|
@ -14,11 +17,12 @@
|
||||||
|
|
||||||
export let schema
|
export let schema
|
||||||
|
|
||||||
|
$: explanationWithPresets = getExplanationWithPresets(explanation, $componentStore.typeSupportPresets)
|
||||||
let support
|
let support
|
||||||
let messages = []
|
let messages = []
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
const columnInfoMessagesAndSupport = getColumnInfoMessagesAndSupport(schema, columnInfo)
|
const columnInfoMessagesAndSupport = getColumnInfoMessagesAndSupport(schema, explanationWithPresets)
|
||||||
support = columnInfoMessagesAndSupport.support
|
support = columnInfoMessagesAndSupport.support
|
||||||
messages = columnInfoMessagesAndSupport.messages
|
messages = columnInfoMessagesAndSupport.messages
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ const getSupportMessage = (type, columnInfo) => {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getColumnInfoMessagesAndSupport = (fieldSchema, columnInfo) => {
|
export const getColumnInfoMessagesAndSupport = (fieldSchema, columnInfo, typeSupportPresets) => {
|
||||||
try {
|
try {
|
||||||
const columnInfoMessagesAndSupport = {
|
const columnInfoMessagesAndSupport = {
|
||||||
support: getSupport(fieldSchema.type, columnInfo),
|
support: getSupport(fieldSchema.type, columnInfo),
|
||||||
|
@ -74,3 +74,14 @@ export const getColumnInfoMessagesAndSupport = (fieldSchema, columnInfo) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getExplanationWithPresets = (explanation, presets) => {
|
||||||
|
if (explanation?.typeSupport?.preset) {
|
||||||
|
return {
|
||||||
|
...explanation,
|
||||||
|
typeSupport: presets[explanation?.typeSupport?.preset]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return explanation
|
||||||
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
export let componentInstance = {}
|
export let componentInstance = {}
|
||||||
export let value = ""
|
export let value = ""
|
||||||
export let placeholder
|
export let placeholder
|
||||||
export let columnInfo
|
export let explanation
|
||||||
|
|
||||||
let contextTooltipAnchor = null
|
let contextTooltipAnchor = null
|
||||||
let currentOption = null
|
let currentOption = null
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
{onOptionMouseleave}
|
{onOptionMouseleave}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if columnInfo}
|
{#if explanation}
|
||||||
<ContextTooltip
|
<ContextTooltip
|
||||||
visible={contextTooltipVisible}
|
visible={contextTooltipVisible}
|
||||||
anchor={contextTooltipAnchor}
|
anchor={contextTooltipAnchor}
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
columnIcon={getOptionIcon(currentOption)}
|
columnIcon={getOptionIcon(currentOption)}
|
||||||
columnName={currentOption}
|
columnName={currentOption}
|
||||||
columnType={getOptionIconTooltip(currentOption)}
|
columnType={getOptionIconTooltip(currentOption)}
|
||||||
{columnInfo}
|
{explanation}
|
||||||
/>
|
/>
|
||||||
<FieldContext
|
<FieldContext
|
||||||
slot="previous"
|
slot="previous"
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
columnIcon={getOptionIcon(previousOption)}
|
columnIcon={getOptionIcon(previousOption)}
|
||||||
columnName={previousOption}
|
columnName={previousOption}
|
||||||
columnType={getOptionIconTooltip(previousOption)}
|
columnType={getOptionIconTooltip(previousOption)}
|
||||||
{columnInfo}
|
{explanation}
|
||||||
/>
|
/>
|
||||||
</ContextTooltip>
|
</ContextTooltip>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -14,7 +14,11 @@
|
||||||
export let componentInstance = {}
|
export let componentInstance = {}
|
||||||
export let value = ""
|
export let value = ""
|
||||||
export let placeholder
|
export let placeholder
|
||||||
export let columnInfo
|
export let explanation
|
||||||
|
|
||||||
|
$: {
|
||||||
|
console.log($componentStore);
|
||||||
|
}
|
||||||
|
|
||||||
let contextTooltipAnchor = null
|
let contextTooltipAnchor = null
|
||||||
let currentOption = null
|
let currentOption = null
|
||||||
|
@ -109,7 +113,7 @@
|
||||||
{onOptionMouseleave}
|
{onOptionMouseleave}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if columnInfo}
|
{#if explanation}
|
||||||
<ContextTooltip
|
<ContextTooltip
|
||||||
visible={contextTooltipVisible}
|
visible={contextTooltipVisible}
|
||||||
anchor={contextTooltipAnchor}
|
anchor={contextTooltipAnchor}
|
||||||
|
@ -122,7 +126,7 @@
|
||||||
columnIcon={getOptionIcon(currentOption)}
|
columnIcon={getOptionIcon(currentOption)}
|
||||||
columnName={currentOption}
|
columnName={currentOption}
|
||||||
columnType={getOptionIconTooltip(currentOption)}
|
columnType={getOptionIconTooltip(currentOption)}
|
||||||
{columnInfo}
|
{explanation}
|
||||||
/>
|
/>
|
||||||
<FieldContext
|
<FieldContext
|
||||||
slot="previous"
|
slot="previous"
|
||||||
|
@ -130,7 +134,7 @@
|
||||||
columnIcon={getOptionIcon(previousOption)}
|
columnIcon={getOptionIcon(previousOption)}
|
||||||
columnName={previousOption}
|
columnName={previousOption}
|
||||||
columnType={getOptionIconTooltip(previousOption)}
|
columnType={getOptionIconTooltip(previousOption)}
|
||||||
{columnInfo}
|
{explanation}
|
||||||
/>
|
/>
|
||||||
</ContextTooltip>
|
</ContextTooltip>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -193,8 +193,7 @@
|
||||||
max: setting.max ?? null,
|
max: setting.max ?? null,
|
||||||
|
|
||||||
// Field select settings
|
// Field select settings
|
||||||
columnInfo: setting.columnInfo,
|
explanation: setting.explanation,
|
||||||
valueTypes: setting.valueTypes
|
|
||||||
}}
|
}}
|
||||||
{bindings}
|
{bindings}
|
||||||
{componentBindings}
|
{componentBindings}
|
||||||
|
|
|
@ -95,6 +95,7 @@ export class ComponentStore extends BudiStore {
|
||||||
// Fetch definitions and filter out custom component definitions so we
|
// Fetch definitions and filter out custom component definitions so we
|
||||||
// can flag them
|
// can flag them
|
||||||
const components = await API.fetchComponentLibDefinitions(appId)
|
const components = await API.fetchComponentLibDefinitions(appId)
|
||||||
|
console.log(components);
|
||||||
const customComponents = Object.keys(components).filter(key =>
|
const customComponents = Object.keys(components).filter(key =>
|
||||||
key.startsWith("plugin/")
|
key.startsWith("plugin/")
|
||||||
)
|
)
|
||||||
|
@ -104,6 +105,7 @@ export class ComponentStore extends BudiStore {
|
||||||
...state,
|
...state,
|
||||||
components,
|
components,
|
||||||
customComponents,
|
customComponents,
|
||||||
|
typeSupportPresets: components?.typeSupportPresets ?? {}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// Sync client features to app store
|
// Sync client features to app store
|
||||||
|
|
|
@ -13,6 +13,22 @@
|
||||||
"sidePanel": true,
|
"sidePanel": true,
|
||||||
"skeletonLoader": true
|
"skeletonLoader": true
|
||||||
},
|
},
|
||||||
|
"typeSupportPresets": {
|
||||||
|
"chartValue": {
|
||||||
|
"supported": ["number", "boolean"],
|
||||||
|
"partialSupport": [
|
||||||
|
{ "type": "longform", "message": "stringAsNumber" },
|
||||||
|
{ "type": "string", "message": "stringAsNumber" },
|
||||||
|
{ "type": "bigint", "message": "stringAsNumber" },
|
||||||
|
{ "type": "options", "message": "stringAsNumber" },
|
||||||
|
{ "type": "formula", "message": "stringAsNumber" },
|
||||||
|
{ "type": "datetime", "message": "dateAsNumber"}
|
||||||
|
],
|
||||||
|
"unsupported": [
|
||||||
|
{ "type": "json", "message": "jsonPrimitivesOnly" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"layout": {
|
"layout": {
|
||||||
"name": "Layout",
|
"name": "Layout",
|
||||||
"description": "This component is specific only to layouts",
|
"description": "This component is specific only to layouts",
|
||||||
|
@ -1634,20 +1650,9 @@
|
||||||
"label": "Data columns",
|
"label": "Data columns",
|
||||||
"key": "valueColumns",
|
"key": "valueColumns",
|
||||||
"dependsOn": "dataProvider",
|
"dependsOn": "dataProvider",
|
||||||
"columnInfo": {
|
"explanation": {
|
||||||
"typeSupport": {
|
"typeSupport": {
|
||||||
"supported": ["number", "boolean"],
|
"preset": "chartValue"
|
||||||
"partialSupport": [
|
|
||||||
{ "type": "longform", "message": "stringAsNumber" },
|
|
||||||
{ "type": "string", "message": "stringAsNumber" },
|
|
||||||
{ "type": "bigint", "message": "stringAsNumber" },
|
|
||||||
{ "type": "options", "message": "stringAsNumber" },
|
|
||||||
{ "type": "formula", "message": "stringAsNumber" },
|
|
||||||
{ "type": "datetime", "message": "dateAsNumber"}
|
|
||||||
],
|
|
||||||
"unsupported": [
|
|
||||||
{ "type": "json", "message": "jsonPrimitivesOnly" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": true
|
"required": true
|
||||||
|
@ -1809,20 +1814,9 @@
|
||||||
"label": "Data columns",
|
"label": "Data columns",
|
||||||
"key": "valueColumns",
|
"key": "valueColumns",
|
||||||
"dependsOn": "dataProvider",
|
"dependsOn": "dataProvider",
|
||||||
"columnInfo": {
|
"explanation": {
|
||||||
"typeSupport": {
|
"typeSupport": {
|
||||||
"supported": ["number", "boolean"],
|
"preset": "chartValue"
|
||||||
"partialSupport": [
|
|
||||||
{ "type": "longform", "message": "stringAsNumber" },
|
|
||||||
{ "type": "string", "message": "stringAsNumber" },
|
|
||||||
{ "type": "bigint", "message": "stringAsNumber" },
|
|
||||||
{ "type": "options", "message": "stringAsNumber" },
|
|
||||||
{ "type": "formula", "message": "stringAsNumber" },
|
|
||||||
{ "type": "datetime", "message": "dateAsNumber"}
|
|
||||||
],
|
|
||||||
"unsupported": [
|
|
||||||
{ "type": "json", "message": "jsonPrimitivesOnly" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": true
|
"required": true
|
||||||
|
@ -1979,20 +1973,9 @@
|
||||||
"label": "Data columns",
|
"label": "Data columns",
|
||||||
"key": "valueColumns",
|
"key": "valueColumns",
|
||||||
"dependsOn": "dataProvider",
|
"dependsOn": "dataProvider",
|
||||||
"columnInfo": {
|
"explanation": {
|
||||||
"typeSupport": {
|
"typeSupport": {
|
||||||
"supported": ["number", "boolean"],
|
"preset": "chartValue"
|
||||||
"partialSupport": [
|
|
||||||
{ "type": "longform", "message": "stringAsNumber" },
|
|
||||||
{ "type": "string", "message": "stringAsNumber" },
|
|
||||||
{ "type": "bigint", "message": "stringAsNumber" },
|
|
||||||
{ "type": "options", "message": "stringAsNumber" },
|
|
||||||
{ "type": "formula", "message": "stringAsNumber" },
|
|
||||||
{ "type": "datetime", "message": "dateAsNumber"}
|
|
||||||
],
|
|
||||||
"unsupported": [
|
|
||||||
{ "type": "json", "message": "jsonPrimitivesOnly" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": true
|
"required": true
|
||||||
|
|
|
@ -20,7 +20,7 @@ export async function fetchAppComponentDefinitions(ctx: UserCtx) {
|
||||||
const definitions: { [key: string]: any } = {}
|
const definitions: { [key: string]: any } = {}
|
||||||
for (let { manifest, library } of componentManifests) {
|
for (let { manifest, library } of componentManifests) {
|
||||||
for (let key of Object.keys(manifest)) {
|
for (let key of Object.keys(manifest)) {
|
||||||
if (key === "features") {
|
if (key === "features" || key === "typeSupportPresets") {
|
||||||
definitions[key] = manifest[key]
|
definitions[key] = manifest[key]
|
||||||
} else {
|
} else {
|
||||||
const fullComponentName = `${library}/${key}`.toLowerCase()
|
const fullComponentName = `${library}/${key}`.toLowerCase()
|
||||||
|
|
Loading…
Reference in New Issue