[org] fix: Restore public view of measurement sets (#247)
Also by default view imperial measurement sets as imperial and metric ones as metric (this is questionable, and should probably be discussed, alternatively we could default displayAsMetric to the account setting?) Fixes #230 Reviewed-on: https://codeberg.org/freesewing/freesewing/pulls/247 Reviewed-by: Joost De Cock <joostdecock@noreply.codeberg.org> Co-authored-by: Jonathan Haas <haasjona@gmail.com> Co-committed-by: Jonathan Haas <haasjona@gmail.com>
This commit is contained in:
parent
915e52b7d4
commit
bc1d873b19
2 changed files with 31 additions and 17 deletions
|
@ -6,7 +6,7 @@ import {
|
||||||
urls,
|
urls,
|
||||||
} from '@freesewing/config'
|
} from '@freesewing/config'
|
||||||
import { measurements as measurementTranslations } from '@freesewing/i18n'
|
import { measurements as measurementTranslations } from '@freesewing/i18n'
|
||||||
import { i18n, measurements as designMeasurements } from '@freesewing/collection'
|
import { measurements as designMeasurements } from '@freesewing/collection'
|
||||||
import {
|
import {
|
||||||
cloudflareImageUrl,
|
cloudflareImageUrl,
|
||||||
formatMm,
|
formatMm,
|
||||||
|
@ -31,8 +31,6 @@ import {
|
||||||
CompareIcon,
|
CompareIcon,
|
||||||
CuratedMeasurementsSetIcon,
|
CuratedMeasurementsSetIcon,
|
||||||
EditIcon,
|
EditIcon,
|
||||||
FlagIcon,
|
|
||||||
MeasurementsSetIcon,
|
|
||||||
NoIcon,
|
NoIcon,
|
||||||
OkIcon,
|
OkIcon,
|
||||||
ResetIcon,
|
ResetIcon,
|
||||||
|
@ -58,10 +56,6 @@ import { Yaml } from '@freesewing/react/components/Yaml'
|
||||||
import { Popout } from '@freesewing/react/components/Popout'
|
import { Popout } from '@freesewing/react/components/Popout'
|
||||||
import { bundlePatternTranslations, draft, flattenFlags } from '../Editor/lib/index.mjs'
|
import { bundlePatternTranslations, draft, flattenFlags } from '../Editor/lib/index.mjs'
|
||||||
import { Bonny } from '@freesewing/bonny'
|
import { Bonny } from '@freesewing/bonny'
|
||||||
import { ZoomablePattern } from '../Editor/components/ZoomablePattern.mjs'
|
|
||||||
import { HeaderMenuDraftViewFlags } from '../Editor/components/HeaderMenu.mjs'
|
|
||||||
import { Flag, FlagsAccordionEntries } from '../Editor/components/Flag.mjs'
|
|
||||||
import { i18n as pluginI18n } from '@freesewing/core-plugins'
|
|
||||||
import { MiniNote, MiniTip } from '../Mini/index.mjs'
|
import { MiniNote, MiniTip } from '../Mini/index.mjs'
|
||||||
|
|
||||||
const t = (input) => {
|
const t = (input) => {
|
||||||
|
@ -74,7 +68,7 @@ const t = (input) => {
|
||||||
*
|
*
|
||||||
* @param {object} props - All React props
|
* @param {object} props - All React props
|
||||||
* @param {number} id - The ID of the measurements set to load
|
* @param {number} id - The ID of the measurements set to load
|
||||||
* @param {bool} publicOnly - FIXME
|
* @param {bool} publicOnly - If the set should be used with the backend.getPublicSet method
|
||||||
* @param {function} Link - An optional framework-specific Link component to use for client-side routing
|
* @param {function} Link - An optional framework-specific Link component to use for client-side routing
|
||||||
* @param {object} measurementHelpProvider - A function that returns a url or action to show help for a specific measurement
|
* @param {object} measurementHelpProvider - A function that returns a url or action to show help for a specific measurement
|
||||||
*/
|
*/
|
||||||
|
@ -116,6 +110,7 @@ export const Set = ({ id, publicOnly = false, Link = false, measurementHelpProvi
|
||||||
setImperial(body.set.imperial ? true : false)
|
setImperial(body.set.imperial ? true : false)
|
||||||
setNotes(body.set.notes)
|
setNotes(body.set.notes)
|
||||||
setMeasies(body.set.measies)
|
setMeasies(body.set.measies)
|
||||||
|
setDisplayAsMetric(body.set.imperial ? false : true)
|
||||||
setLoadingStatus([true, 'Measurements set loaded', true, true])
|
setLoadingStatus([true, 'Measurements set loaded', true, true])
|
||||||
} else setLoadingStatus([true, 'An error occured while contacting the backend', true, false])
|
} else setLoadingStatus([true, 'An error occured while contacting the backend', true, false])
|
||||||
}
|
}
|
||||||
|
@ -123,17 +118,20 @@ export const Set = ({ id, publicOnly = false, Link = false, measurementHelpProvi
|
||||||
setLoadingStatus([true, 'Contacting the backend'])
|
setLoadingStatus([true, 'Contacting the backend'])
|
||||||
const [status, body] = await backend.getPublicSet(id)
|
const [status, body] = await backend.getPublicSet(id)
|
||||||
if (status === 200 && body.result === 'success') {
|
if (status === 200 && body.result === 'success') {
|
||||||
|
const isImperial = body.units === 'imperial'
|
||||||
setMset({
|
setMset({
|
||||||
...body.data,
|
...body,
|
||||||
public: true,
|
public: true,
|
||||||
measies: body.data.measurements,
|
measies: body.measurements,
|
||||||
|
imperial: isImperial,
|
||||||
})
|
})
|
||||||
setName(body.data.name)
|
setName(body.name)
|
||||||
setImage(body.data.image)
|
setImage(body.image)
|
||||||
setIsPublic(body.data.public ? true : false)
|
setIsPublic(body.public ? true : false)
|
||||||
setImperial(body.data.imperial ? true : false)
|
setImperial(isImperial)
|
||||||
setNotes(body.data.notes)
|
setNotes(body.notes)
|
||||||
setMeasies(body.data.measurements)
|
setMeasies(body.measurements)
|
||||||
|
setDisplayAsMetric(!isImperial)
|
||||||
setLoadingStatus([true, 'Measurements set loaded', true, true])
|
setLoadingStatus([true, 'Measurements set loaded', true, true])
|
||||||
} else
|
} else
|
||||||
setLoadingStatus([
|
setLoadingStatus([
|
||||||
|
@ -276,7 +274,7 @@ export const Set = ({ id, publicOnly = false, Link = false, measurementHelpProvi
|
||||||
</button>
|
</button>
|
||||||
) : null}
|
) : null}
|
||||||
{account.control > 2 ? (
|
{account.control > 2 ? (
|
||||||
<BookmarkButton slug={`sets/${mset.id}`} title={mset.name} type="set" thing="set" />
|
<BookmarkButton slug={`set?id=${mset.id}`} title={mset.name} type="set" thing="set" />
|
||||||
) : null}
|
) : null}
|
||||||
<button
|
<button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
|
|
16
sites/org/docs/set/index.mdx
Normal file
16
sites/org/docs/set/index.mdx
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
title: Measurement Set
|
||||||
|
sidebar_class_name: tw-hidden
|
||||||
|
---
|
||||||
|
|
||||||
|
import { getSearchParam } from '@freesewing/utils'
|
||||||
|
import { DocusaurusDoc } from '@freesewing/react/components/Docusaurus'
|
||||||
|
import { RoleBlock } from '@freesewing/react/components/Role'
|
||||||
|
import { Set } from '@freesewing/react/components/Account'
|
||||||
|
import Link from '@docusaurus/Link'
|
||||||
|
|
||||||
|
<DocusaurusDoc>
|
||||||
|
<RoleBlock user>
|
||||||
|
<Set Link={Link} id={getSearchParam('id')} publicOnly={true} />
|
||||||
|
</RoleBlock>
|
||||||
|
</DocusaurusDoc>
|
Loading…
Add table
Add a link
Reference in a new issue