fix: macro buttons with single char attribute (#903)

This commit is contained in:
Stefan Dej authored and GitHub committed 2022-06-15 07:55:47 +02:00
1 parent 21ad4c16e7
commit 8367f01bce
6 files changed
+42 -69

No files matched your search

+6 -3
View File
@@ -94,6 +94,10 @@ export default class MacroButton extends Mixins(BaseMixin) {
return this.$store.getters['printer/getMacro'](this.macro.name)
}
get isGcodeStyle() {
return this.macro.name.match(/[G|M]\d{1,3}/gm)
}
@Watch('klipperMacro')
klipperMacroChange() {
this.refreshParams()
@@ -103,7 +107,7 @@ export default class MacroButton extends Mixins(BaseMixin) {
this.paramArray.splice(0, this.paramArray.length)
this.params = {}
if (this.klipperMacro.params !== null) {
if (this.klipperMacro?.params !== null) {
Object.keys(this.klipperMacro.params).forEach((name: string) => {
if (!name.startsWith('_')) {
this.paramArray.push(name)
@@ -130,8 +134,7 @@ export default class MacroButton extends Mixins(BaseMixin) {
this.paramArray.forEach((paramname: string) => {
if (this.params[paramname].value !== null && this.params[paramname].value !== '') {
let tmp: string = paramname
if (paramname.length === 1) tmp += this.params[paramname].value
else tmp += '=' + this.params[paramname].value
tmp += this.isGcodeStyle ? this.params[paramname].value : `=${this.params[paramname].value}`
params.push(tmp)
}