rename
This commit is contained in:
parent
4690f78775
commit
dc0bbbd450
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import ExplanationModal from './ExplanationModal/index.svelte'
|
import ExplanationModal from './ExplanationModal/index.svelte'
|
||||||
import { messages as messageConstants, getColumnInfoMessagesAndSupport, getExplanationWithPresets } from "./columnInfo";
|
import { messages as messageConstants, getExplanationMessagesAndSupport, 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 {
|
import {
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
let messages = []
|
let messages = []
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
const columnInfoMessagesAndSupport = getColumnInfoMessagesAndSupport(schema, explanationWithPresets)
|
const columnInfoMessagesAndSupport = getExplanationMessagesAndSupport(schema, explanationWithPresets)
|
||||||
support = columnInfoMessagesAndSupport.support
|
support = columnInfoMessagesAndSupport.support
|
||||||
messages = columnInfoMessagesAndSupport.messages
|
messages = columnInfoMessagesAndSupport.messages
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,52 +1,52 @@
|
||||||
import { capitalize } from 'lodash';
|
import { capitalize } from 'lodash';
|
||||||
|
|
||||||
export const messages = {
|
export const messages = {
|
||||||
jsonPrimitivesOnly: Symbol("column-info-json-primitives-only"),
|
jsonPrimitivesOnly: Symbol("explanation-json-primitives-only"),
|
||||||
stringAsNumber: Symbol("column-info-string-as-number"),
|
stringAsNumber: Symbol("explanation-string-as-number"),
|
||||||
dateAsNumber: Symbol("column-info-date-as-number"),
|
dateAsNumber: Symbol("explanation-date-as-number"),
|
||||||
notRequired: Symbol("column-info-not-required"),
|
notRequired: Symbol("explanation-not-required"),
|
||||||
contextError: Symbol("column-info-context-error"),
|
contextError: Symbol("explanation-context-error"),
|
||||||
}
|
}
|
||||||
|
|
||||||
export const support = {
|
export const support = {
|
||||||
unsupported: Symbol("column-info-unsupported"),
|
unsupported: Symbol("explanation-unsupported"),
|
||||||
partialSupport: Symbol("column-info-partialSupport"),
|
partialSupport: Symbol("explanation-partialSupport"),
|
||||||
supported: Symbol("column-info-supported")
|
supported: Symbol("explanation-supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const getSupport = (type, columnInfo) => {
|
const getSupport = (type, explanation) => {
|
||||||
if (!columnInfo?.typeSupport) {
|
if (!explanation?.typeSupport) {
|
||||||
return support.supported
|
return support.supported
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnInfo?.typeSupport?.supported?.find(mapping => mapping === type || mapping?.type === type)) {
|
if (explanation?.typeSupport?.supported?.find(mapping => mapping === type || mapping?.type === type)) {
|
||||||
return support.supported;
|
return support.supported;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnInfo?.typeSupport?.partialSupport?.find(mapping => mapping === type || mapping?.type === type)) {
|
if (explanation?.typeSupport?.partialSupport?.find(mapping => mapping === type || mapping?.type === type)) {
|
||||||
return support.partialSupport;
|
return support.partialSupport;
|
||||||
}
|
}
|
||||||
|
|
||||||
return support.unsupported
|
return support.unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSupportMessage = (type, columnInfo) => {
|
const getSupportMessage = (type, explanation) => {
|
||||||
if (!columnInfo?.typeSupport) {
|
if (!explanation?.typeSupport) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const supported = columnInfo?.typeSupport?.supported?.find(mapping => mapping?.type === type)
|
const supported = explanation?.typeSupport?.supported?.find(mapping => mapping?.type === type)
|
||||||
if (supported) {
|
if (supported) {
|
||||||
return messages[supported?.message]
|
return messages[supported?.message]
|
||||||
}
|
}
|
||||||
|
|
||||||
const partialSupport = columnInfo?.typeSupport?.partialSupport?.find(mapping => mapping?.type === type)
|
const partialSupport = explanation?.typeSupport?.partialSupport?.find(mapping => mapping?.type === type)
|
||||||
if (partialSupport) {
|
if (partialSupport) {
|
||||||
return messages[partialSupport?.message]
|
return messages[partialSupport?.message]
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsupported = columnInfo?.typeSupport?.unsupported?.find(mapping => mapping?.type === type)
|
const unsupported = explanation?.typeSupport?.unsupported?.find(mapping => mapping?.type === type)
|
||||||
if (unsupported) {
|
if (unsupported) {
|
||||||
return messages[unsupported?.message]
|
return messages[unsupported?.message]
|
||||||
}
|
}
|
||||||
|
@ -54,19 +54,19 @@ const getSupportMessage = (type, columnInfo) => {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getColumnInfoMessagesAndSupport = (fieldSchema, columnInfo, typeSupportPresets) => {
|
export const getExplanationMessagesAndSupport = (fieldSchema, explanation, typeSupportPresets) => {
|
||||||
try {
|
try {
|
||||||
const columnInfoMessagesAndSupport = {
|
const explanationMessagesAndSupport = {
|
||||||
support: getSupport(fieldSchema.type, columnInfo),
|
support: getSupport(fieldSchema.type, explanation),
|
||||||
messages: [getSupportMessage(fieldSchema.type, columnInfo)],
|
messages: [getSupportMessage(fieldSchema.type, explanation)],
|
||||||
}
|
}
|
||||||
|
|
||||||
const isRequired = fieldSchema?.constraints?.presence?.allowEmpty === false
|
const isRequired = fieldSchema?.constraints?.presence?.allowEmpty === false
|
||||||
if (!isRequired) {
|
if (!isRequired) {
|
||||||
columnInfoMessagesAndSupport.messages.push(messages.notRequired);
|
explanationMessagesAndSupport.messages.push(messages.notRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
return columnInfoMessagesAndSupport;
|
return explanationMessagesAndSupport;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return {
|
return {
|
||||||
support: support.partialSupport,
|
support: support.partialSupport,
|
||||||
|
|
Loading…
Reference in New Issue