diff --git a/sites/shared/components/workbench/layout/cut/index.mjs b/sites/shared/components/workbench/layout/cut/index.mjs index a3ada1d56f2..fb94955e436 100644 --- a/sites/shared/components/workbench/layout/cut/index.mjs +++ b/sites/shared/components/workbench/layout/cut/index.mjs @@ -58,6 +58,8 @@ const useFabricList = (draft) => { const cutList = draft.setStores[0].get('cutlist') const fabricList = ['fabric'] for (const partName in cutList) { + if (draft.settings[0].only && !draft.settings[0].only.includes(partName)) continue + for (const matName in cutList[partName].materials) { if (!fabricList.includes(matName)) fabricList.push(matName) } diff --git a/sites/shared/components/workbench/layout/cut/plugin-cut-layout.mjs b/sites/shared/components/workbench/layout/cut/plugin-cut-layout.mjs index e70e1ae5371..522da549345 100644 --- a/sites/shared/components/workbench/layout/cut/plugin-cut-layout.mjs +++ b/sites/shared/components/workbench/layout/cut/plugin-cut-layout.mjs @@ -1,3 +1,4 @@ +import { addToOnly } from '../plugin-layout-part.mjs' const prefix = 'mirroredOnFold' // types of path operations @@ -14,12 +15,16 @@ export const cutLayoutPlugin = function (material, grainAngle) { hooks: { // after each part postPartDraft: (pattern) => { - // get the part that's just been drafted - const part = pattern.parts[pattern.activeSet][pattern.activePart] - // if it's a duplicated cut part, the fabric part, or it's hidden, leave it alone - if (pattern.activePart.startsWith('cut.') || pattern.activePart === 'fabric' || part.hidden) + // if it's a duplicated cut part, the fabric part, or it's not wanted by the pattern + if ( + pattern.activePart.startsWith('cut.') || + pattern.activePart === 'fabric' || + !pattern.__wants(pattern.activePart) + ) return + // get the part that's just been drafted + const part = pattern.parts[pattern.activeSet][pattern.activePart] // get this part's cutlist configuration let partCutlist = pattern.setStores[pattern.activeSet].get(['cutlist', pattern.activePart]) // if there isn't one, we're done here @@ -71,6 +76,9 @@ export const cutLayoutPlugin = function (material, grainAngle) { return part }, }) + + // add it to the only list if there is one + addToOnly(pattern, dupPartName) } }) } diff --git a/sites/shared/components/workbench/layout/cut/settings.mjs b/sites/shared/components/workbench/layout/cut/settings.mjs index 015d713331a..af5475100d1 100644 --- a/sites/shared/components/workbench/layout/cut/settings.mjs +++ b/sites/shared/components/workbench/layout/cut/settings.mjs @@ -46,7 +46,7 @@ const FabricSizer = ({ gist, updateGist, activeFabric, sheetWidth }) => { @@ -119,7 +119,7 @@ export const CutLayoutSettings = ({ {fabricLength} -
+
unsetGist(['layouts', 'cuttingLayout', activeFabric])} - className="btn btn-primary btn-outline" + className="btn btn-primary btn-outline ml-4" > {t('reset')} diff --git a/sites/shared/components/workbench/layout/plugin-layout-part.mjs b/sites/shared/components/workbench/layout/plugin-layout-part.mjs index e32838c8a14..385368b001e 100644 --- a/sites/shared/components/workbench/layout/plugin-layout-part.mjs +++ b/sites/shared/components/workbench/layout/plugin-layout-part.mjs @@ -94,7 +94,7 @@ const doScanForBlanks = (stacks, layout, x, y, w, h) => { return hasContent } -function addToOnly(pattern, partName) { +export function addToOnly(pattern, partName) { const only = pattern.settings[0].only if (only && !only.includes(partName)) { pattern.settings[0].only = [].concat(only, partName)