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

fix: fix hide/show navi points in different languages #1638

Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions src/components/mixins/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { GuiNavigationStateEntry } from '@/store/gui/navigation/types'
export interface NaviPoint {
type: 'link' | 'route'
title: string
orgTitle?: string
to?: string
href?: string
target?: string
Expand Down Expand Up @@ -53,6 +54,7 @@ export default class NavigationMixin extends Mixins(BaseMixin) {
points.push({
type: 'route',
title: this.$t(`Router.${element.title}`),
orgTitle: element.title,
icon: element.icon,
to: element.path,
position,
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/SettingsNavigationTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class SettingsNavigationTab extends Mixins(NavigationMixin, BaseM
newVal.forEach((naviPoint, index) => {
this.$store.dispatch('gui/navigation/updatePos', {
type: naviPoint.type,
title: naviPoint.title,
title: naviPoint.orgTitle ?? naviPoint.title,
visible: naviPoint.visible,
position: index + 1,
})
Expand Down
3 changes: 2 additions & 1 deletion src/store/gui/navigation/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ActionTree } from 'vuex'
import { RootState } from '@/store/types'
import Vue from 'vue'
import { GuiNavigationState, GuiNavigationStateEntry } from '@/store/gui/navigation/types'
import { NaviPoint } from '@/components/mixins/navigation'

export const actions: ActionTree<GuiNavigationState, RootState> = {
reset({ commit }) {
Expand All @@ -20,7 +21,7 @@ export const actions: ActionTree<GuiNavigationState, RootState> = {
commit('updatePos', payload)
},

changeVisibility({ commit, dispatch }, payload: GuiNavigationStateEntry) {
changeVisibility({ commit, dispatch }, payload: NaviPoint) {
commit('changeVisibility', payload)
dispatch('upload')
},
Expand Down
9 changes: 6 additions & 3 deletions src/store/gui/navigation/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getDefaultState } from './index'
import { MutationTree } from 'vuex'
import { GuiNavigationState, GuiNavigationStateEntry } from './types'
import Vue from 'vue'
import { NaviPoint } from '@/components/mixins/navigation'

export const mutations: MutationTree<GuiNavigationState> = {
reset(state) {
Expand Down Expand Up @@ -34,9 +35,11 @@ export const mutations: MutationTree<GuiNavigationState> = {
Vue.set(state, 'entries', entries)
},

changeVisibility(state, payload: GuiNavigationStateEntry) {
changeVisibility(state, payload: NaviPoint) {
const title = payload.orgTitle ?? payload.title

const index = state.entries.findIndex((entry) => {
return entry.type === payload.type && entry.title === payload.title
return entry.type === payload.type && entry.title === title
})

// update existing entry
Expand All @@ -48,7 +51,7 @@ export const mutations: MutationTree<GuiNavigationState> = {
// create new entry
const newEntry: GuiNavigationStateEntry = {
type: payload.type,
title: payload.title,
title,
visible: !payload.visible,
position: payload.position,
}
Expand Down
Loading