Skip to content

Commit

Permalink
fix: group and wrap tool change commands (#1543)
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas authored Dec 2, 2024
1 parent 6b3d941 commit ef8da05
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/components/widgets/toolhead/ToolChangeCommands.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<template>
<v-row v-if="toolChangeCommands.length > 0">
<v-col>
<v-col
v-for="(toolChangeCommandsGroup, index2) in toolChangeCommandsGrouped"
:key="index2"
cols="12"
>
<app-btn-group
class="app-toolchanger-control d-flex"
:class="{
[$vuetify.theme.dark ? 'theme--dark': 'theme--light']: true,
}"
>
<v-tooltip
v-for="(macro, index) of toolChangeCommands"
v-for="(macro, index) of toolChangeCommandsGroup"
:key="index"
top
>
Expand Down Expand Up @@ -55,6 +59,7 @@ import StateMixin from '@/mixins/state'
import type { GcodeCommands } from '@/store/printer/types'
import type { TranslateResult } from 'vue-i18n'
import type { Spool } from '@/store/spoolman/types'
import { chunk } from 'lodash-es'
type ToolChangeCommand = {
name: string,
Expand Down Expand Up @@ -99,6 +104,14 @@ export default class ToolChangeCommands extends Mixins(StateMixin) {
})
}
get toolChangeCommandsGrouped (): ToolChangeCommand[][] {
const toolChangeCommands = this.toolChangeCommands
const cols = Math.ceil(toolChangeCommands.length / Math.ceil(toolChangeCommands.length / 6))
return chunk(toolChangeCommands, cols)
}
getSpoolById (id: number): Spool | undefined {
return this.$store.getters['spoolman/getSpoolById'](id)
}
Expand Down

0 comments on commit ef8da05

Please sign in to comment.