Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactor Console & MiniConsole #2031

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: fix toggle custom filters in console
Signed-off-by: Stefan Dej <meteyou@gmail.com>
meteyou committed Oct 21, 2024
commit 5a60875861def58ef7ea075a816a77de1f993695
5 changes: 3 additions & 2 deletions src/components/mixins/console.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Vue from 'vue'
meteyou marked this conversation as resolved.
Show resolved Hide resolved
import Component from 'vue-class-component'
import { CommandHelp } from '@/store/printer/types'
import { GuiConsoleStateFilter } from '@/store/gui/console/types'

@Component
export default class ConsoleMixin extends Vue {
@@ -52,8 +53,8 @@ export default class ConsoleMixin extends Vue {
return this.$store.state.gui.gcodehistory.entries ?? []
}

toggleFilter(filter: string): void {
this.$store.dispatch('gui/updateConsoleFilter', filter)
toggleFilter(id: string | number, filter: GuiConsoleStateFilter): void {
this.$store.dispatch('gui/console/filterUpdate', { id, values: filter })
}

clearConsole() {
2 changes: 1 addition & 1 deletion src/components/panels/MiniconsolePanel.vue
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@
class="mt-0"
hide-details
:label="filter.name"
@change="toggleFilter(filter)" />
@change="toggleFilter(index, filter)" />
</v-list-item>
<v-list-item class="minHeight36">
<v-checkbox
2 changes: 1 addition & 1 deletion src/pages/Console.vue
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@
class="mt-0"
hide-details
:label="filter.name"
@change="toggleFilter(filter)" />
@change="toggleFilter(index, filter)" />
</v-list-item>
<v-list-item class="minHeight36">
<v-checkbox
16 changes: 8 additions & 8 deletions src/store/gui/console/mutations.ts
Original file line number Diff line number Diff line change
@@ -17,17 +17,17 @@ export const mutations: MutationTree<GuiConsoleState> = {
},

filterUpdate(state, payload) {
if (payload.id in state.consolefilters) {
const preset = { ...state.consolefilters[payload.id] }
Object.assign(preset, payload.values)
if (!(payload.id in state.consolefilters)) return

Vue.set(state.consolefilters, payload.id, preset)
}
const preset = { ...state.consolefilters[payload.id] }
Object.assign(preset, payload.values)

Vue.set(state.consolefilters, payload.id, preset)
},

filterDelete(state, payload) {
if (payload in state.consolefilters) {
Vue.delete(state.consolefilters, payload)
}
if (!(payload in state.consolefilters)) return

Vue.delete(state.consolefilters, payload)
},
}