1
0
Fork 0

chore(lab): Changes for pattern data

This commit is contained in:
Joost De Cock 2022-09-01 08:48:10 +02:00
parent d6cc541da3
commit 13e32d9ed9
10 changed files with 18 additions and 18 deletions

View file

@ -57,8 +57,8 @@ const TextSpans = ({ point, className='', style={}, onClick=null }) => {
let text = []
// Handle translation
let translated = ''
for (let string of point.attributes.getAsArray('data-text')) {
translated += t(string.toString()).replace(/"/g, '"') + ' '
for (const string of point.attributes.getAsArray('data-text')) {
if (string) translated += t(string.toString()).replace(/"/g, '"') + ' '
}
// Handle muti-line text
if (translated.indexOf('\n') !== -1) {

View file

@ -3,7 +3,7 @@ import ClearIcon from 'shared/components/icons/clear.js'
import { useTranslation } from 'next-i18next'
const DesignOptionList = props => {
const { t } = useTranslation([`o_${props.design.config.name}`])
const { t } = useTranslation([`o_${props.design.config.data.name}`])
const { dflt, list, doNotTranslate=false } = props.design.config.options[props.option]
const val = (typeof props.gist?.options?.[props.option] === 'undefined')
? dflt
@ -48,7 +48,7 @@ const DesignOptionList = props => {
</span>
{doNotTranslate
? choice
: props.ot(`o_${props.design.config.name}:${props.option}.o.${choice}`)
: props.ot(`o_${props.design.config.data.name}:${props.option}.o.${choice}`)
}
</button>
))}

View file

@ -8,7 +8,7 @@ const CutLayout = props => {
<div>
<h2 className="capitalize">
{
t('layoutThing', { thing: props.design.config.name })
t('layoutThing', { thing: props.design.config.data.name })
+ ': '
+ t('forCutting')
}

View file

@ -48,7 +48,7 @@ const PrintLayout = props => {
<div>
<h2 className="capitalize">
{
t('layoutThing', { thing: props.design.config.name })
t('layoutThing', { thing: props.design.config.data.name })
+ ': '
+ t('forPrinting')
}

View file

@ -52,7 +52,7 @@ const WorkbenchMeasurements = ({ app, design, gist, updateGist, gistReady }) =>
<div className="m-auto max-w-2xl">
<h1>
<span className='capitalize mr-4 opacity-70'>
{design.config.name}:
{design.config.data.name}:
</span> {t('measurements')}
</h1>
<h2>{t('cfp:preloadMeasurements')}</h2>

View file

@ -6,7 +6,7 @@ import {values} from 'shared/components/workbench/menu/design-options/option-val
import {inputs} from 'shared/components/workbench/menu/design-options/option-input'
const Option = props => {
const { t } = useTranslation([`o_${props.design.config.name}`])
const { t } = useTranslation([`o_${props.design.config.data.name}`])
const opt = props.design.config.options[props.option];
const type = optionType(opt)
const Input = inputs[type]

View file

@ -29,7 +29,7 @@ const SumDiv = (props) => (
)
const Option = props => {
const { t } = useTranslation([`o_${props.design.config.name}`, 'workbench'])
const { t } = useTranslation([`o_${props.design.config.data.name}`, 'workbench'])
const active = (
props.gist.sample?.type === 'option' &&
props.gist.sample?.option === props.option
@ -56,7 +56,7 @@ const Option = props => {
{active ? <span>&bull;</span> : <span>&deg;</span>}
</span>
<span className={active ? 'text-secondary font-bold' : ''}>
{t(`o_${props.design.config.name}:${props.option}.t`)}
{t(`o_${props.design.config.data.name}:${props.option}.t`)}
</span>
</SumDiv>
</SumButton>

View file

@ -13,29 +13,29 @@ const View = props => {
},
{
name: 'draft',
title: t('draftDesign', { design: props.design.config.name }),
title: t('draftDesign', { design: props.design.config.data.name }),
onClick: () => props.updateGist(['_state', 'view'], 'draft', true)
},
{
name: 'test',
title: t('testDesign', { design: props.design.config.name }),
title: t('testDesign', { design: props.design.config.data.name }),
onClick: () => props.updateGist(['_state', 'view'], 'test', true)
},
{
name: 'printingLayout',
title: t('layoutThing', { thing: props.design.config.name })
title: t('layoutThing', { thing: props.design.config.data.name })
+ ': ' + t('forPrinting'),
onClick: () => props.updateGist(['_state', 'view'], 'printingLayout', true)
},
{
name: 'cuttingLayout',
title: t('layoutThing', { thing: props.design.config.name })
title: t('layoutThing', { thing: props.design.config.data.name })
+ ': ' + t('forCutting'),
onClick: () => props.updateGist(['_state', 'view'], 'cuttingLayout', true)
},
{
name: 'export',
title: t('exportThing', { thing: props.design.config.name }),
title: t('exportThing', { thing: props.design.config.data.name }),
onClick: () => props.updateGist(['_state', 'view'], 'export', true)
},
{

View file

@ -15,8 +15,8 @@ const preload = {
if (result.data.files['pattern.yaml'].content) {
let g = yaml.load(result.data.files['pattern.yaml'].content)
if (g.design !== undefined && g.design !== design.config.name) return [
false, `You tried loading a configuration for ${g.design} into a ${design.config.name} development environment`
if (g.design !== undefined && g.design !== design.config.data.name) return [
false, `You tried loading a configuration for ${g.design} into a ${design.config.data.name} development environment`
]
return g

View file

@ -8,7 +8,7 @@ import {useState} from 'react'
// Generates a default design gist to start from
export const defaultGist = (design, locale='en') => {
const gist = {
design: design.config.name,
design: design.config.data.name,
version: design.config.version,
...defaultSettings,
_state: {view: 'draft'}