fix variables list

pull/555/merge
Pete Matsyburka 5 days ago
parent 4cfee2fe45
commit 4db29126e9

@ -22,28 +22,30 @@
class="border-base-300" class="border-base-300"
> >
<label class="peer flex items-center py-1.5 cursor-pointer select-none"> <label class="peer flex items-center py-1.5 cursor-pointer select-none">
<input <span class="w-5 flex justify-center items-center">
type="checkbox" <input
class="hidden peer" type="checkbox"
checked class="hidden peer"
> checked
<IconChevronDown >
class="hidden peer-checked:block" <IconChevronDown
:width="14" class="hidden peer-checked:block ml-0.5"
:stroke-width="1.6" :width="14"
/> :stroke-width="1.6"
<IconChevronRight />
class="block peer-checked:hidden" <IconChevronRight
:width="14" class="block peer-checked:hidden ml-0.5"
:stroke-width="1.6" :width="14"
/> :stroke-width="1.6"
/>
</span>
<span class="ml-1">{{ key }}</span> <span class="ml-1">{{ key }}</span>
<span <span
v-if="node.type === 'array'" v-if="node.type === 'array'"
class="text-xs bg-base-200 rounded px-1 ml-1" class="text-xs bg-base-200 rounded px-1 ml-1"
>{{ t('list') }}</span> >{{ t('list') }}</span>
</label> </label>
<div class="hidden peer-has-[:checked]:block pl-3.5"> <div class="hidden peer-has-[:checked]:block pl-5">
<template <template
v-for="[varNode, varPath] in nestedVariables(node, key)" v-for="[varNode, varPath] in nestedVariables(node, key)"
:key="varPath" :key="varPath"
@ -101,7 +103,7 @@ export default {
}, },
methods: { methods: {
isGroup (node) { isGroup (node) {
return (node.type === 'object' && node.properties) || (node.type === 'array' && node.items?.properties) return (node.type === 'object' && node.properties) || (node.type === 'array' && node.items?.type === 'object' && node.items?.properties)
}, },
nestedVariables (node, groupKey) { nestedVariables (node, groupKey) {
const properties = node.type === 'array' ? node.items?.properties : node.properties const properties = node.type === 'array' ? node.items?.properties : node.properties

@ -353,7 +353,26 @@ function extractConditionVariables (node, acc = []) {
return acc return acc
} }
const IRREGULAR_PLURALS = {
people: 'person',
men: 'man',
women: 'woman',
children: 'child',
teeth: 'tooth',
feet: 'foot',
mice: 'mouse',
geese: 'goose',
oxen: 'ox',
criteria: 'criterion',
phenomena: 'phenomenon',
alumni: 'alumnus',
data: 'datum',
media: 'medium'
}
function singularize (word) { function singularize (word) {
if (IRREGULAR_PLURALS[word]) return IRREGULAR_PLURALS[word]
if (word.endsWith('ies')) return word.slice(0, -3) + 'y' if (word.endsWith('ies')) return word.slice(0, -3) + 'y'
if (word.endsWith('ches') || word.endsWith('shes')) return word.slice(0, -2) if (word.endsWith('ches') || word.endsWith('shes')) return word.slice(0, -2)
if (word.endsWith('ses') || word.endsWith('xes') || word.endsWith('zes')) return word.slice(0, -2) if (word.endsWith('ses') || word.endsWith('xes') || word.endsWith('zes')) return word.slice(0, -2)
@ -513,6 +532,12 @@ function processOperators (operators, propertiesHash = {}, parentProperties = {}
assignNestedSchema(propertiesHash, parentProperties, op.variableName, { type: 'array', items: itemProperties }) assignNestedSchema(propertiesHash, parentProperties, op.variableName, { type: 'array', items: itemProperties })
processOperators(op.children, propertiesHash, { ...parentProperties, [singularKey]: itemProperties }) processOperators(op.children, propertiesHash, { ...parentProperties, [singularKey]: itemProperties })
if (itemProperties.type === 'object' && itemProperties.properties && Object.keys(itemProperties.properties).length === 0) {
delete itemProperties.properties
itemProperties.type = 'string'
}
break break
} }
} }

Loading…
Cancel
Save