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