store methods don't become properties on shorthand
This commit is contained in:
parent
aaa25b76f3
commit
49748a7c00
25 changed files with 95 additions and 80 deletions
|
@ -19,7 +19,6 @@ export const pluginCutlist = plugin
|
|||
/**
|
||||
* Add a set of cutting instructions for the part
|
||||
* @param {Store} store the Store
|
||||
* @param {string} partName the name of the part
|
||||
* @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
|
||||
|
@ -27,8 +26,9 @@ export const pluginCutlist = plugin
|
|||
* @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
|
||||
*/
|
||||
function addCut(store, partName, so = {}) {
|
||||
function addCut(store, so = {}) {
|
||||
const { cut = 2, material = 'fabric', identical = false, bias = false, ignoreOnFold = false } = so
|
||||
const partName = store.get('activePart')
|
||||
if (cut === false) {
|
||||
if (material === false) store.unset(['cutlist', partName, 'materials'])
|
||||
else store.unset(['cutlist', partName, 'materials', material])
|
||||
|
@ -50,12 +50,13 @@ function addCut(store, partName, so = {}) {
|
|||
}
|
||||
|
||||
/** Method to remove the cut info */
|
||||
function removeCut(store, partName, material = false) {
|
||||
return addCut(store, partName, { cut: false, material })
|
||||
function removeCut(store, material = false) {
|
||||
return addCut(store, { cut: false, material })
|
||||
}
|
||||
|
||||
/** Method to add the grain info */
|
||||
function setGrain(store, partName, grain = false) {
|
||||
function setGrain(store, grain = false) {
|
||||
const partName = store.get('activePart')
|
||||
const path = ['cutlist', partName, 'grain']
|
||||
if (grain === false) return store.unset(path)
|
||||
if (typeof grain !== 'number') {
|
||||
|
@ -66,7 +67,8 @@ function setGrain(store, partName, grain = false) {
|
|||
}
|
||||
|
||||
/** Method to add the cutOnFold info */
|
||||
function setCutOnFold(store, partName, p1, p2) {
|
||||
function setCutOnFold(store, p1, p2) {
|
||||
const partName = store.get('activePart')
|
||||
const path = ['cutlist', partName, 'cutOnFold']
|
||||
if (p1 === false && typeof p2 === 'undefined') {
|
||||
return store.unset(path)
|
||||
|
|
|
@ -18,7 +18,7 @@ export const plugin = {
|
|||
},
|
||||
},
|
||||
macros: {
|
||||
cutonfold: function (so, { points, paths, Path, complete, setCutOnFold, setGrain, scale }) {
|
||||
cutonfold: function (so, { points, paths, Path, complete, store, scale }) {
|
||||
if (so === false) {
|
||||
delete points.cutonfoldFrom
|
||||
delete points.cutonfoldTo
|
||||
|
@ -26,8 +26,8 @@ export const plugin = {
|
|||
delete points.cutonfoldVia2
|
||||
delete paths.cutonfoldCutonfold
|
||||
// setCutOnFold relies on plugin-cutlist
|
||||
if (typeof setCutOnFold === 'function') {
|
||||
setCutOnFold(false) // Restore default
|
||||
if (typeof store.setCutOnFold === 'function') {
|
||||
store.setCutOnFold(false) // Restore default
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ export const plugin = {
|
|||
prefix: 'cutonfold',
|
||||
...so,
|
||||
}
|
||||
if (typeof setCutOnFold === 'function') {
|
||||
setCutOnFold(so.from, so.to)
|
||||
if (so.grainline) setGrain(so.from.angle(so.to))
|
||||
if (typeof store.setCutOnFold === 'function') {
|
||||
store.setCutOnFold(so.from, so.to)
|
||||
if (so.grainline) store.setGrain(so.from.angle(so.to))
|
||||
}
|
||||
if (complete) {
|
||||
points[so.prefix + 'From'] = so.from.shiftFractionTowards(so.to, so.margin / 100)
|
||||
|
|
|
@ -19,12 +19,14 @@ export const plugin = {
|
|||
},
|
||||
},
|
||||
macros: {
|
||||
grainline: function (so = {}, { points, paths, Path, complete, setGrain }) {
|
||||
grainline: function (so = {}, { points, paths, Path, complete, store }) {
|
||||
if (so === false) {
|
||||
delete points.grainlineFrom
|
||||
delete points.grainlineTo
|
||||
delete paths.grainline
|
||||
setGrain(90) // Restoring default
|
||||
if (typeof store.setGrain === 'function') {
|
||||
setGrain(false) // Restoring default
|
||||
}
|
||||
return true
|
||||
}
|
||||
so = {
|
||||
|
@ -32,8 +34,8 @@ export const plugin = {
|
|||
...so,
|
||||
}
|
||||
// setGrain relies on plugin-cutlist
|
||||
if (typeof setGrain === 'function') {
|
||||
setGrain(so.from.angle(so.to))
|
||||
if (typeof store.setGrain === 'function') {
|
||||
store.setGrain(so.from.angle(so.to))
|
||||
}
|
||||
if (complete) {
|
||||
points.grainlineFrom = so.from.shiftFractionTowards(so.to, 0.05)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue