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)
}
+1 -1
View File
@@ -43,7 +43,7 @@ export default class MacrogroupPanel extends Mixins(BaseMixin) {
}
get allMacros() {
return this.$store.getters['printer/getAllMacros'] ?? []
return this.$store.getters['printer/getMacros'] ?? []
}
get macros() {
+8 -1
View File
@@ -26,14 +26,21 @@ import BaseMixin from '../mixins/base'
import Panel from '@/components/ui/Panel.vue'
import MacroButton from '@/components/inputs/MacroButton.vue'
import { mdiCodeTags } from '@mdi/js'
import { PrinterStateMacro } from '@/store/printer/types'
@Component({
components: { MacroButton, Panel },
})
export default class MacrosPanel extends Mixins(BaseMixin) {
mdiCodeTags = mdiCodeTags
get hiddenMacros() {
return (this.$store.state.gui?.macros?.hiddenMacros ?? []).map((name: string) => name.toLowerCase())
}
get macros() {
return this.$store.getters['printer/getMacros']
const macros = this.$store.getters['printer/getMacros']
return macros.filter((macro: PrinterStateMacro) => !this.hiddenMacros.includes(macro.name.toLowerCase()))
}
}
</script>
@@ -381,7 +381,7 @@ export default class SettingsMacrosTabExpert extends Mixins(BaseMixin) {
}
get allMacros() {
return this.$store.getters['printer/getAllMacros'] ?? []
return this.$store.getters['printer/getMacros'] ?? []
}
get availableMacros() {
@@ -32,7 +32,7 @@ import SettingsRow from '@/components/settings/SettingsRow.vue'
})
export default class SettingsMacrosTabSimple extends Mixins(BaseMixin) {
get macros() {
return this.$store.getters['printer/getAllMacros'] ?? []
return this.$store.getters['printer/getMacros'] ?? []
}
get hiddenMacros() {