diff --git a/plugins/plugin-annotations/src/cutlist.mjs b/plugins/plugin-annotations/src/cutlist.mjs index 1b78519aa5f..1cb6003e35c 100644 --- a/plugins/plugin-annotations/src/cutlist.mjs +++ b/plugins/plugin-annotations/src/cutlist.mjs @@ -24,23 +24,17 @@ export const cutlistHooks = { * @param {Store} store the Store * @param {Object} so a set of cutting instructions for a material * @param {number} so.cut = 2 the number of pieces to cut from the specified fabric - * @param {string} so.material = fabric the name of the material to cut from + * @param {string} so.from = fabric the name of the material to cut from * @param {boolean} so.identical = false should even numbers of pieces be cut in the same direction or mirrored - * @param {boolean} so.bias = false should the pieces in these cutting instructions be cut on the bias - * @param {boolean} so.ignoreOnFold should these cutting instructions ignore any cutOnFold information set by the part + * @param {boolean} so.onBias = false should the pieces in these cutting instructions be cut on the bias + * @param {boolean} so.onFold = false should these cutting instructions ignore any cutOnFold information set by the part */ function addCut(store, so = {}) { if (Array.isArray(so)) { for (const cut of so) addCut(store, cut) return store } - const { cut = 2, identical = false, bias = false, ignoreOnFold = false } = so - // Make 'material' an alias for 'from' - let { from = 'fabric' } = so - if (typeof so.material !== 'undefined') { - from = so.material - store.log.warn(`Using 'material' in cutlist is deprecated, please use 'from' instead'`) - } + const { cut = 2, from = 'fabric', identical = false, onBias = false, onFold = false } = so const partName = store.get('activePart') if (cut === false) { @@ -58,17 +52,17 @@ function addCut(store, so = {}) { } const path = ['cutlist', partName, 'materials', from] const existing = store.get(path, []) - store.set(path, existing.concat({ cut, identical, bias, ignoreOnFold })) + store.set(path, existing.concat({ cut, identical, onBias, onFold })) return store } /** Method to remove the cut info */ -function removeCut(store, material = false) { - return addCut(store, { cut: false, material }) +function removeCut(store, from = false) { + return addCut(store, { cut: false, from }) } -/** Method to add the grain info */ +/** Method to add the grain info (called by grainline and cutonfold macros) */ function setGrain(store, grain = false) { const partName = store.get('activePart') const path = ['cutlist', partName, 'grain'] @@ -80,7 +74,7 @@ function setGrain(store, grain = false) { return store.set(path, grain) } -/** Method to add the cutOnFold info */ +/** Method to add the cutOnFold info (called by cutonfold macro) */ function setCutOnFold(store, p1, p2) { const partName = store.get('activePart') const path = ['cutlist', partName, 'cutOnFold'] diff --git a/plugins/plugin-annotations/tests/cutlist.test.mjs b/plugins/plugin-annotations/tests/cutlist.test.mjs index 3b0b85e3ff3..5c67986d46a 100644 --- a/plugins/plugin-annotations/tests/cutlist.test.mjs +++ b/plugins/plugin-annotations/tests/cutlist.test.mjs @@ -43,8 +43,8 @@ describe('Cutlist Plugin Tests', () => { expect(pattern.setStores[0].cutlist.example_part.materials.fabric[0]).to.deep.equal({ cut: 2, identical: false, - bias: false, - ignoreOnFold: false, + onBias: false, + onFold: false, }) }) @@ -52,7 +52,7 @@ describe('Cutlist Plugin Tests', () => { const part = { name: 'example_part', draft: ({ store, part }) => { - store.cutlist.addCut({ cut: 3, material: 'lining', identical: true }) + store.cutlist.addCut({ cut: 3, from: 'lining', identical: true }) return part }, @@ -65,8 +65,8 @@ describe('Cutlist Plugin Tests', () => { expect(pattern.setStores[0].cutlist.example_part.materials.lining[0]).to.deep.equal({ cut: 3, identical: true, - bias: false, - ignoreOnFold: false, + onBias: false, + onFold: false, }) })