wip
This commit is contained in:
parent
96001dd409
commit
8eb60968d5
|
@ -3,7 +3,7 @@
|
||||||
import { getDatasourceForProvider, getSchemaForDatasource } from "dataBinding"
|
import { getDatasourceForProvider, getSchemaForDatasource } from "dataBinding"
|
||||||
import { selectedScreen } from "stores/builder"
|
import { selectedScreen } from "stores/builder"
|
||||||
import { createEventDispatcher } from "svelte"
|
import { createEventDispatcher } from "svelte"
|
||||||
import { validators, supported, partialSupport, unsupported } from "../fieldValidator";
|
import { validators, constants as validatorConstants } from "../fieldValidator";
|
||||||
|
|
||||||
export let componentInstance = {}
|
export let componentInstance = {}
|
||||||
export let value = ""
|
export let value = ""
|
||||||
|
@ -52,6 +52,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const getOptionIcon = option => {
|
const getOptionIcon = option => {
|
||||||
|
/*
|
||||||
const support = fieldSupport[option]?.support;
|
const support = fieldSupport[option]?.support;
|
||||||
|
|
||||||
if (support == null) return null;
|
if (support == null) return null;
|
||||||
|
@ -59,12 +60,14 @@
|
||||||
|
|
||||||
if (support === partialSupport) return "Warning"
|
if (support === partialSupport) return "Warning"
|
||||||
if (support === unsupported) return "Error"
|
if (support === unsupported) return "Error"
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
const getOptionIconTooltip = option => {
|
const getOptionIconTooltip = option => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const isOptionEnabled = option => {
|
const isOptionEnabled = option => {
|
||||||
|
return true
|
||||||
const support = fieldSupport[option]?.support;
|
const support = fieldSupport[option]?.support;
|
||||||
|
|
||||||
if (support == null) return true
|
if (support == null) return true
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import { getDatasourceForProvider, getSchemaForDatasource } from "dataBinding"
|
import { getDatasourceForProvider, getSchemaForDatasource } from "dataBinding"
|
||||||
import { selectedScreen } from "stores/builder"
|
import { selectedScreen } from "stores/builder"
|
||||||
import { createEventDispatcher } from "svelte"
|
import { createEventDispatcher } from "svelte"
|
||||||
import { validators, supported, partialSupport, unsupported } from "../fieldValidator";
|
import { validators, constants as validatorConstants } from "../fieldValidator";
|
||||||
|
|
||||||
export let componentInstance = {}
|
export let componentInstance = {}
|
||||||
export let value = ""
|
export let value = ""
|
||||||
|
@ -77,6 +77,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const foo = () => {
|
const foo = () => {
|
||||||
|
/*
|
||||||
const support = fieldSupport[option]?.support;
|
const support = fieldSupport[option]?.support;
|
||||||
|
|
||||||
if (support == null) return null;
|
if (support == null) return null;
|
||||||
|
@ -84,6 +85,7 @@
|
||||||
|
|
||||||
if (support === partialSupport) return "AlertCircleFilled"
|
if (support === partialSupport) return "AlertCircleFilled"
|
||||||
if (support === unsupported) return "AlertCircleFilled"
|
if (support === unsupported) return "AlertCircleFilled"
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
const getOptionIcon = optionKey => {
|
const getOptionIcon = optionKey => {
|
||||||
|
@ -115,6 +117,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const isOptionEnabled = optionKey => {
|
const isOptionEnabled = optionKey => {
|
||||||
|
return true;
|
||||||
// Remain enabled if already selected, so it can be deselected
|
// Remain enabled if already selected, so it can be deselected
|
||||||
if (value?.includes(optionKey)) return true
|
if (value?.includes(optionKey)) return true
|
||||||
const support = fieldSupport[optionKey]?.support;
|
const support = fieldSupport[optionKey]?.support;
|
||||||
|
|
|
@ -1,40 +1,64 @@
|
||||||
export const unsupported = Symbol("values-validator-unsupported")
|
export const constants = {
|
||||||
export const partialSupport = Symbol("values-validator-partial-support")
|
warning: Symbol("values-validator-warning"),
|
||||||
export const supported = Symbol("values-validator-supported")
|
error: Symbol("values-validator-error"),
|
||||||
|
unsupported: Symbol("values-validator-unsupported"),
|
||||||
|
partialSupport: Symbol("values-validator-partialSupport"),
|
||||||
|
supported: Symbol("values-validator-supported")
|
||||||
|
}
|
||||||
|
|
||||||
export const validators = {
|
export const validators = {
|
||||||
chart: (fieldSchema) => {
|
chart: (fieldSchema) => {
|
||||||
if (
|
try {
|
||||||
fieldSchema.type === "json" ||
|
const response = {
|
||||||
fieldSchema.type === "array" ||
|
support: null,
|
||||||
fieldSchema.type === "attachment" ||
|
message: null,
|
||||||
fieldSchema.type === "barcodeqr" ||
|
warnings: [],
|
||||||
fieldSchema.type === "link" ||
|
errors: []
|
||||||
fieldSchema.type === "bb_reference"
|
|
||||||
) {
|
|
||||||
return {
|
|
||||||
support: unsupported,
|
|
||||||
message: `"${fieldSchema.type}" columns cannot be used as a chart value long long long long long long long long long`
|
|
||||||
}
|
}
|
||||||
}
|
const generalUnsupportedFields = ["array", "attachment", "barcodeqr", "link", "bb_reference"]
|
||||||
|
if (generalUnsupportedFields.includes(fieldSchema.type)) {
|
||||||
if (fieldSchema.type === "string") {
|
response.errors.push(`${fieldSchema.type} columns can not be used as chart inputs.`)
|
||||||
return {
|
|
||||||
support: partialSupport,
|
|
||||||
message: "This field can be used as a chart value, but non-numeric values will not be parsed correctly"
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (fieldSchema.type === "number") {
|
if (fieldSchema.type === "json") {
|
||||||
return {
|
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.`)
|
||||||
support: supported,
|
|
||||||
message: "This field can be used for chart values"
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
if (fieldSchema.type === "string") {
|
||||||
support: partialSupport,
|
response.warnings.push(
|
||||||
message: "This field can be used as a chart value, but it may not be parsed correctly"
|
"This column can be used as input for a chart, but non-numeric values may cause unexpected behavior.")
|
||||||
|
}
|
||||||
|
if (fieldSchema.type === "date") {
|
||||||
|
response.warnings.push(
|
||||||
|
"This column can be used as input for a chart, but it is parsed differently for various charts.")
|
||||||
|
}
|
||||||
|
|
||||||
|
const isRequired = fieldSchema?.constraints?.presence?.allowEmpty === false
|
||||||
|
if (!isRequired) {
|
||||||
|
response.warnings.push(
|
||||||
|
"This column is optional, and some rows may not have a value.")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.errors.length > 0) {
|
||||||
|
response.support = constants.unsupported
|
||||||
|
response.message = "This column can not be used as a chart input."
|
||||||
|
} else if (response.warnings.length > 0) {
|
||||||
|
response.support = constants.partialSupport
|
||||||
|
response.message = "This column can be used as a chart input, but certain values may cause issues."
|
||||||
|
} else {
|
||||||
|
response.support = constants.supported
|
||||||
|
response.message = "This column can be used as a chart input."
|
||||||
|
}
|
||||||
|
|
||||||
|
return response
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
return {
|
||||||
|
support: constants.partialSupport,
|
||||||
|
message: "There was an issue validating this field, it may not be fully supported for use with charts.",
|
||||||
|
warnings: [],
|
||||||
|
errors: []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue