From a3a71c8f15357467f85f9169dc20ef52aff2a535 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Fri, 10 Mar 2023 18:25:25 +0100 Subject: [PATCH] fix: only display PAUSE AT LAYER button, when the macros exists (#1291) --- src/components/panels/StatusPanel.vue | 31 +++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue index 40b393b2..3ce0ae7d 100644 --- a/src/components/panels/StatusPanel.vue +++ b/src/components/panels/StatusPanel.vue @@ -63,7 +63,7 @@ {{ mdiMessageProcessingOutline }} - {{ print_stats_message ? print_stats_message : display_message }} + {{ print_stats_message ?? display_message }} @@ -83,13 +83,13 @@ - + - + - + @@ -122,6 +122,7 @@ import { mdiLayersPlus, mdiDotsVertical, } from '@mdi/js' +import { PrinterStateMacro } from '@/store/printer/types' @Component({ components: { @@ -295,10 +296,10 @@ export default class StatusPanel extends Mixins(BaseMixin) { click: this.btnExcludeObject, }, { - text: this.$t('Panels.StatusPanel.PauseAtLayer.PauseAtLayer'), + text: this.$t('Panels.StatusPanel.PauseAtLayer.PauseAtLayer') + ' - ' + this.displayPauseAtLayerButton, loadingName: 'pauseAtLayer', icon: mdiLayersPlus, - status: () => this.layer_count !== null, + status: () => this.displayPauseAtLayerButton, disabled: () => ['paused', 'printing'].includes(this.printer_state), click: this.btnPauseAtLayer, }, @@ -306,7 +307,7 @@ export default class StatusPanel extends Mixins(BaseMixin) { } get multiFunctionMenuButtonsFiltered() { - return this.multiFunctionMenuButtons.filter((button) => button.status) + return this.multiFunctionMenuButtons.filter((button) => button.status()) } get multiFunctionButton() { @@ -315,6 +316,22 @@ export default class StatusPanel extends Mixins(BaseMixin) { return this.multiFunctionMenuButtonsFiltered.length > 1 } + get macros() { + return this.$store.getters['printer/getMacros'] ?? [] + } + + get existsSetPauseAtLayer() { + return this.macros.findIndex((macro: PrinterStateMacro) => macro.name === 'SET_PAUSE_AT_LAYER') !== -1 + } + + get existsSetPauseNextLayer() { + return this.macros.findIndex((macro: PrinterStateMacro) => macro.name === 'SET_PAUSE_NEXT_LAYER') !== -1 + } + + get displayPauseAtLayerButton() { + return this.layer_count !== null && (this.existsSetPauseAtLayer || this.existsSetPauseNextLayer) + } + mounted() { if (this.current_filename !== '') this.activeTab = 'status' }