2323 >
2424 <v-tooltip
2525 top
26- :disabled =" command.toolTipDisabled "
26+ :disabled =" ! command.description "
2727 >
2828 <template #activator =" { on , attrs } " >
2929 <app-btn
3030 class =" fill-width"
31- :disabled =" (command.disabledWhilePrinting && printerPrinting) || !klippyReady "
31+ :disabled =" !klippyReady || command.disabled "
3232 small
3333 v-bind =" attrs"
3434 v-on =" on"
4545 </app-btn >
4646 </template >
4747 <span >
48- {{ macroDescription( command.command) }}
48+ {{ command.description }}
4949 </span >
5050 </v-tooltip >
5151 </v-list-item >
5555 >
5656 <v-tooltip
5757 top
58- :disabled =" macro.toolTipDisabled "
58+ :disabled =" ! macro.macro.description "
5959 >
6060 <template #activator =" { on , attrs } " >
6161 <macro-btn
7070 </macro-btn >
7171 </template >
7272 <span >
73- {{ macroDescription( macro.macroName) }}
73+ {{ macro.macro.description }}
7474 </span >
7575 </v-tooltip >
7676 </v-list-item >
@@ -116,6 +116,22 @@ import MacroBtn from '@/components/widgets/macros/MacroBtn.vue'
116116import AfcSettingsDialog from ' @/components/widgets/afc/dialogs/AfcSettingsDialog.vue'
117117import type { GcodeCommands , KlipperPrinterAfcSettings , KlipperPrinterConfig , KlipperPrinterSettings , KlipperPrinterState } from ' @/store/printer/types'
118118import downloadUrl from ' @/util/download-url'
119+ import type { Macro } from ' @/store/macros/types'
120+
121+ type AfcCommand = {
122+ icon: string ,
123+ text: string ,
124+ command: string ,
125+ description? : string ,
126+ disabled? : boolean
127+ }
128+
129+ type AfcMacro = {
130+ text: string ,
131+ macroName: string ,
132+ macro: Macro ,
133+ disabled? : boolean
134+ }
119135
120136@Component ({
121137 components: {
@@ -141,95 +157,88 @@ export default class AfcCardButtons extends Mixins(StateMixin, AfcMixin) {
141157 get commands () {
142158 const availableCommands = this .availableCommands
143159
144- const buttons = [
145- {
160+ const commands: AfcCommand [] = []
161+
162+ if (' AFC_CALIBRATION' in availableCommands ) {
163+ commands .push ({
146164 icon: ' $afcCalibration' ,
147- text: this .$t (' app.afc.Calibrate' ),
165+ text: this .$t (' app.afc.Calibrate' ). toString () ,
148166 command: ' AFC_CALIBRATION' ,
149- disabled: false ,
150- toolTipDisabled: this .macroTooltipDisabled (' AFC_CALIBRATION' ),
151- disabledWhilePrinting: true ,
152- },
153- ]
167+ description: availableCommands [' AFC_CALIBRATION' ].help ,
168+ disabled: this .printerPrinting
169+ })
170+ }
154171
155172 if (this .afc ?.led_state === true ) {
156- buttons . push ( {
157- icon: ' $afcTurnOffLed ' ,
158- text: this . $t ( ' app.afc.LedOff ' ) ,
159- command: ' TURN_OFF_AFC_LED ' ,
160- disabled: false ,
161- toolTipDisabled: this . macroTooltipDisabled ( ' TURN_OFF_AFC_LED' ),
162- disabledWhilePrinting: false ,
163- })
173+ if ( ' TURN_OFF_AFC_LED ' in availableCommands ) {
174+ commands . push ({
175+ icon: ' $afcTurnOffLed ' ,
176+ text: this . $t ( ' app.afc.LedOff ' ). toString () ,
177+ command: ' TURN_OFF_AFC_LED ' ,
178+ description: availableCommands [ ' TURN_OFF_AFC_LED' ]. help
179+ })
180+ }
164181 } else {
165- buttons . push ( {
166- icon: ' $afcTurnOnLed ' ,
167- text: this . $t ( ' app.afc.LedOn ' ) ,
168- command: ' TURN_ON_AFC_LED ' ,
169- disabled: false ,
170- toolTipDisabled: this . macroTooltipDisabled ( ' TURN_ON_AFC_LED' ),
171- disabledWhilePrinting: false ,
172- })
182+ if ( ' TURN_ON_AFC_LED ' in availableCommands ) {
183+ commands . push ({
184+ icon: ' $afcTurnOnLed ' ,
185+ text: this . $t ( ' app.afc.LedOn ' ). toString () ,
186+ command: ' TURN_ON_AFC_LED ' ,
187+ description: availableCommands [ ' TURN_ON_AFC_LED' ]. help
188+ })
189+ }
173190 }
174191
175- if (this .afc ?.td1_present === true ) {
176- buttons .push ({
192+ if (
193+ this .afc ?.td1_present === true &&
194+ ' AFC_GET_TD_ONE_DATA' in availableCommands
195+ ) {
196+ commands .push ({
177197 icon: ' ' ,
178- text: ' Capture TD ' ,
198+ text: this . $t ( ' app.afc.CaptureTd ' ). toString () ,
179199 command: ' AFC_GET_TD_ONE_DATA' ,
180- disabled: false ,
181- toolTipDisabled: this .macroTooltipDisabled (' AFC_GET_TD_ONE_DATA' ),
182- disabledWhilePrinting: true ,
200+ description: availableCommands [' AFC_GET_TD_ONE_DATA' ].help ,
201+ disabled: this .printerPrinting
183202 })
184203 }
185204
186- return buttons
187- .filter (button => button .command .toUpperCase () in availableCommands )
188- }
189-
190- macroTooltipDisabled (macroName : string ): boolean {
191- return ! this .macroDescription (macroName )
192- }
193-
194- macroDescription (macroName : string ) {
195- const macro = this .$typedGetters [' macros/getMacroByName' ](macroName )
196-
197- return macro ?.description || ' '
205+ return commands
198206 }
199207
200208 get macros () {
201209 const settings: KlipperPrinterAfcSettings | undefined = this .printerSettings .afc
202210
203- const afcMacros = []
211+ const afcMacros: AfcMacro [] = []
204212
205213 if (settings ?.wipe ) {
206- const wipe_name: string = settings .wipe_cmd || ' AFC_BRUSH'
214+ const macroName: string = settings .wipe_cmd || ' AFC_BRUSH'
215+ const macro: Macro | undefined = this .$typedGetters [' macros/getMacroByName' ](macroName )
207216
208- afcMacros .push ({
209- text: this .$t (' app.afc.BrushNozzle' ),
210- macroName: wipe_name ,
211- disabled: this .printerPrinting ,
212- toolTipDisabled: this .macroTooltipDisabled (wipe_name ),
213- })
217+ if (macro != null ) {
218+ afcMacros .push ({
219+ text: this .$t (' app.afc.BrushNozzle' ).toString (),
220+ macroName ,
221+ macro ,
222+ disabled: this .printerPrinting
223+ })
224+ }
214225 }
215226
216227 if (settings ?.park ) {
217- const park_name: string = settings .park_cmd || ' AFC_PARK'
228+ const macroName: string = settings .park_cmd || ' AFC_PARK'
229+ const macro: Macro | undefined = this .$typedGetters [' macros/getMacroByName' ](macroName )
218230
219- afcMacros .push ({
220- text: this .$t (' app.afc.ParkNozzle' ),
221- macroName: park_name ,
222- disabled: this .printerPrinting ,
223- toolTipDisabled: this .macroTooltipDisabled (park_name ),
224- })
231+ if (macro != null ) {
232+ afcMacros .push ({
233+ text: this .$t (' app.afc.ParkNozzle' ).toString (),
234+ macroName ,
235+ macro ,
236+ disabled: this .printerPrinting
237+ })
238+ }
225239 }
226240
227241 return afcMacros
228- .map (button => ({
229- ... button ,
230- macro: this .$typedGetters [' macros/getMacroByName' ](button .macroName ),
231- }))
232- .filter ((button ) => button .macro != null )
233242 }
234243
235244 downloadDebugJson () {
0 commit comments