1
0
Fork 0

Merge pull request #6076 from BenJamesBen/include-setname-in-titles-and-pdf

fix(shared, plugins): Provide measurement set name to patterns
This commit is contained in:
Joost De Cock 2024-02-17 16:31:33 +01:00 committed by GitHub
commit c20ed9743d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 45 additions and 15 deletions

View file

@ -3,7 +3,7 @@
import { Fragment } from 'react'
import { nsMerge } from 'shared/utils.mjs'
import { ns as authNs } from 'shared/components/wrappers/auth/index.mjs'
import { designMeasurements, horFlexClasses } from 'shared/utils.mjs'
import { designMeasurements, horFlexClasses, capitalize } from 'shared/utils.mjs'
// Hooks
import { useTranslation } from 'next-i18next'
// Components
@ -24,12 +24,21 @@ const iconClasses = { className: 'w-8 h-8 md:w-10 md:h-10 lg:w-12 lg:h-12 shrink
export const MeasiesView = ({ design, Design, settings, update, missingMeasurements, setView }) => {
const { t } = useTranslation(['workbench'])
const { i18n } = useTranslation(ns)
const lang = i18n.language
const loadMeasurements = (set) => {
update.settings([
[['measurements'], designMeasurements(Design, set.measies)],
[['units'], set.imperial ? 'imperial' : 'metric'],
])
// Save the measurement set name to pattern settings
if (set[`name${capitalize(lang)}`])
// Curated measurement set
update.settings([[['metadata'], { setName: set[`name${capitalize(lang)}`] }]])
else if (set?.name)
// User measurement set
update.settings([[['metadata'], { setName: set.name }]])
setView('draft')
}