feat(core): Pass shorthand() to draft methods
This commit is contained in:
parent
3b510fc2fb
commit
ac4d134075
6 changed files with 32 additions and 52 deletions
|
@ -185,6 +185,7 @@ Part.prototype.shorthand = function () {
|
|||
const paperless = this.context.settings?.paperless === true ? true : false
|
||||
const sa = this.context.settings?.complete ? this.context.settings?.sa || 0 : 0
|
||||
const shorthand = {
|
||||
part: this,
|
||||
sa,
|
||||
scale: this.context.settings?.scale,
|
||||
store: this.context.store,
|
||||
|
|
|
@ -237,10 +237,10 @@ Pattern.prototype.draft = function () {
|
|||
// Draft part
|
||||
if (typeof this.__parts?.[partName]?.draft === 'function') {
|
||||
try {
|
||||
this.parts[partName] = this.__parts[partName].draft(this.parts[partName])
|
||||
if (typeof this.parts[partName] === 'undefined') {
|
||||
const result = this.__parts[partName].draft(this.parts[partName].shorthand())
|
||||
if (typeof result === 'undefined') {
|
||||
this.store.log.error(`Result of drafting part ${partName} was undefined. Did you forget to return the part?`)
|
||||
}
|
||||
} else this.parts[partName] = result
|
||||
} catch (err) {
|
||||
this.store.log.error([`Unable to draft part \`${partName}\``, err])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue