forked from verdnatura/hedera-web
Menu order
This commit is contained in:
parent
ef3b41e4e2
commit
c72bfdc100
|
@ -108,7 +108,7 @@ export default {
|
|||
Connections: 'Conexiones',
|
||||
Visits: 'Visitas',
|
||||
News: 'Noticias',
|
||||
Photos: 'Imágenes',
|
||||
Photos: 'Fotos',
|
||||
Items: 'Artículos',
|
||||
Account: 'Cuenta',
|
||||
Addresses: 'Direcciones'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
import { ref, onMounted } from 'vue';
|
||||
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
@ -10,19 +10,14 @@ import { useAppStore } from 'stores/app';
|
|||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const appStore = useAppStore();
|
||||
const hiddenMenuItems = new Set(['Reports']);
|
||||
|
||||
const refreshContentKey = ref(0);
|
||||
const { mainUser, supplantedUser } = storeToRefs(userStore);
|
||||
const { menuEssentialLinks, title, subtitle, useRightDrawer, rightDrawerOpen } =
|
||||
const { title, subtitle, useRightDrawer, rightDrawerOpen, filteredMenuItems } =
|
||||
storeToRefs(appStore);
|
||||
const actions = ref(null);
|
||||
const leftDrawerOpen = ref(false);
|
||||
const filteredMenuItems = computed(() =>
|
||||
menuEssentialLinks.value.filter(
|
||||
item => !hiddenMenuItems.has(item.description)
|
||||
)
|
||||
);
|
||||
|
||||
const toggleLeftDrawer = () => {
|
||||
leftDrawerOpen.value = !leftDrawerOpen.value;
|
||||
};
|
||||
|
|
|
@ -16,6 +16,16 @@ export const useAppStore = defineStore('hedera', {
|
|||
rightDrawerOpen: false,
|
||||
isHeaderMounted: false,
|
||||
menuEssentialLinks: [],
|
||||
menuOrderLinks: [
|
||||
'Home',
|
||||
'Orders',
|
||||
'Basket',
|
||||
'Catalog',
|
||||
'Administration',
|
||||
'Agencies',
|
||||
'Configuration'
|
||||
],
|
||||
hiddenMenuLinks: new Set(['Reports']),
|
||||
basketOrderId: null,
|
||||
localeDates: {
|
||||
days: [],
|
||||
|
@ -24,7 +34,6 @@ export const useAppStore = defineStore('hedera', {
|
|||
monthsShort: []
|
||||
}
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async getMenuLinks() {
|
||||
const sections = await jApi.query('SELECT * FROM myMenu');
|
||||
|
@ -49,9 +58,19 @@ export const useAppStore = defineStore('hedera', {
|
|||
}
|
||||
}
|
||||
|
||||
// Crear un objeto que mapea los elementos de menuOrderLinks a sus índices
|
||||
const orderMap = {};
|
||||
this.menuOrderLinks.forEach((item, index) => {
|
||||
orderMap[item] = index;
|
||||
});
|
||||
|
||||
// Ordenar sectionTree basado en el orden de menuOrderLinks
|
||||
sectionTree.sort((a, b) => {
|
||||
return orderMap[a.name] - orderMap[b.name];
|
||||
});
|
||||
|
||||
this.menuEssentialLinks = sectionTree;
|
||||
},
|
||||
|
||||
async loadConfig() {
|
||||
const imageUrl = await jApi.getValue('SELECT url FROM imageConfig');
|
||||
this.$patch({ imageUrl });
|
||||
|
@ -147,6 +166,11 @@ export const useAppStore = defineStore('hedera', {
|
|||
}
|
||||
},
|
||||
getters: {
|
||||
filteredMenuItems: state => {
|
||||
return (state.menuEssentialLinks || []).filter(
|
||||
item => !state.hiddenMenuLinks.has(item.description)
|
||||
);
|
||||
},
|
||||
isMobile() {
|
||||
const $q = useQuasar();
|
||||
return $q?.screen?.width <= 768;
|
||||
|
|
Loading…
Reference in New Issue