+
•
handleMouseenter("support")}
on:mouseleave={() => handleMouseleave("support")}
- icon={supportLevelIcon}
- color={supportLevelIconColor}
- text={supportLevelText}
+ icon={support.icon}
+ color={support.iconColor}
+ text={support.text}
/>
with
@@ -110,7 +105,7 @@
/>
.
- {#if warnings.includes("string number warning")}
+ {#if support?.warnings?.includes(warnings.stringAsNumber)}
•
Any
@@ -118,7 +113,7 @@
handleMouseenter("stringsAndNumbers")}
on:mouseleave={() => handleMouseleave("stringsAndNumbers")}
- text="non-number-values"
+ text="non-number values"
/>
@@ -127,7 +122,7 @@
.
{/if}
- {#if warnings.includes("optional warning")}
+ {#if support?.warnings?.includes(warnings.notRequired)}
•
No
@@ -152,11 +147,14 @@
{/if}
-
+
+{#if explanationModal}
+
+{/if}
diff --git a/packages/builder/src/components/design/settings/fieldValidator.js b/packages/builder/src/components/design/settings/fieldValidator.js
index 5ecda9b1f8..4580c41911 100644
--- a/packages/builder/src/components/design/settings/fieldValidator.js
+++ b/packages/builder/src/components/design/settings/fieldValidator.js
@@ -1,8 +1,18 @@
import { capitalize } from 'lodash';
+export const errors = {
+ // fail without explanation
+ general: Symbol("values-validator-general"),
+ jsonPrimitivesOnly: Symbol("values-validator-json-primitives-only"),
+}
+
+export const warnings = {
+ stringAsNumber: Symbol("values-validator-string-as-number"),
+ chartDatetime: Symbol("values-validator-chart-datetime"),
+ notRequired: Symbol("values-validator-not-required"),
+}
+
export const constants = {
- warning: Symbol("values-validator-warning"),
- error: Symbol("values-validator-error"),
unsupported: Symbol("values-validator-unsupported"),
partialSupport: Symbol("values-validator-partialSupport"),
supported: Symbol("values-validator-supported")
@@ -13,54 +23,60 @@ export const validators = {
try {
const response = {
level: null,
- message: null,
warnings: [],
- errors: []
+ errors: [],
+ text: "",
+ icon: "",
+ iconColor: ""
}
const generalUnsupportedFields = ["array", "attachment", "barcodeqr", "link", "bb_reference"]
if (generalUnsupportedFields.includes(fieldSchema.type)) {
- response.errors.push('This column can not be used a chart input.')
+ response.errors.push(errors.general)
}
if (fieldSchema.type === "json") {
- 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.`)
+ response.errors.push(errors.jsonPrimitivesOnly)
}
if (fieldSchema.type === "string") {
-
- response.warnings.push(
- "string number warning")
+ response.warnings.push(warnings.stringAsNumber)
}
if (fieldSchema.type === "datetime") {
- response.warnings.push(
- "This column can be used as an input for a chart, but it may be parsed differently depending on which is used.")
+ response.warnings.push(warnings.chartDatetime);
+ //"This column can be used as an input for a chart, but it may be parsed differently depending on which is used.
}
const isRequired = fieldSchema?.constraints?.presence?.allowEmpty === false
if (!isRequired) {
- response.warnings.push(
- "optional warning")
+ response.warnings.push(warnings.notRequired);
}
if (response.errors.length > 0) {
response.level = constants.unsupported
- response.message = "This column can not be used as a chart input."
+ response.text = "Not compatible"
+ response.icon = "Alert"
+ response.iconColor = "var(--red)"
} else if (response.warnings.length > 0) {
response.level = constants.partialSupport
- response.message = "This column can be used as a chart input, but certain values may cause issues."
+ response.text = "Partially compatible"
+ response.icon = "AlertCheck"
+ response.iconColor = "var(--yellow)"
} else {
response.level = constants.supported
- response.message = "This column can be used as a chart input."
+ response.text = "Compatible"
+ response.icon = "CheckmarkCircle"
+ response.iconColor = "var(--green)"
}
return response
} catch (e) {
- console.log(e)
return {
level: constants.partialSupport,
- message: "There was an issue validating this field, it may not be fully supported for use with charts.",
warnings: [],
- errors: []
+ errors: [],
+ text: "Partially compatible",
+ icon: "AlertCheck",
+ iconColor: "var(--yellow)"
}
}
}