From e40bf8b73d1b203087588335cffc648d9e17509b Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Tue, 16 Sep 2025 22:18:21 +0200 Subject: [PATCH] -drag menu continua --- src/components/CMenuItem/CMenuItem.scss | 5 - src/components/CMenuItem/CMenuItem.ts | 87 +- src/components/CMenuItem/CMenuItem.vue | 5 +- src/components/IconPicker/IconPicker.ts | 221 +++-- src/components/IconPicker/IconPicker.vue | 69 +- src/components/MenuPageItem/MenuPageItem.scss | 27 +- src/components/MenuPageItem/MenuPageItem.ts | 29 + src/components/MenuPageItem/MenuPageItem.vue | 98 +-- src/components/PageEditor/PageEditor.scss | 9 + src/components/PageEditor/PageEditor.ts | 479 ++--------- src/components/PageEditor/PageEditor.vue | 21 +- .../PagesConfigurator/PagesConfigurator.scss | 37 +- .../PagesConfigurator/PagesConfigurator.ts | 791 ++++++------------ .../PagesConfigurator/PagesConfigurator.vue | 81 +- src/store/Modules/tools.ts | 14 +- src/store/globalStore.ts | 6 + 16 files changed, 746 insertions(+), 1233 deletions(-) create mode 100644 src/components/MenuPageItem/MenuPageItem.ts diff --git a/src/components/CMenuItem/CMenuItem.scss b/src/components/CMenuItem/CMenuItem.scss index 3081895a..19151fbc 100755 --- a/src/components/CMenuItem/CMenuItem.scss +++ b/src/components/CMenuItem/CMenuItem.scss @@ -12,11 +12,6 @@ height: 0.5px; } -.router-link-active { - color: #027be3; - background-color: #dadada !important; - border-right: 2px solid #027be3; -} .list-label:first-child { line-height: 20px; diff --git a/src/components/CMenuItem/CMenuItem.ts b/src/components/CMenuItem/CMenuItem.ts index 6f1992f8..370aaf4c 100755 --- a/src/components/CMenuItem/CMenuItem.ts +++ b/src/components/CMenuItem/CMenuItem.ts @@ -1,16 +1,7 @@ -import { computed, defineComponent, PropType } from 'vue'; +import { tools } from 'app/src/store/Modules/tools'; +import { defineComponent, PropType, computed } from 'vue'; -const norm = (path: string): string => - path - .trim() - .replace(/^\/+|\/+$/g, '') - .toLowerCase(); - -const toNormPath = (p: any): string => { - if (!p) return ''; - if (typeof p === 'string') return norm(p); - return norm(p.path || ''); -}; +const norm = (path: string): string => tools.norm(path); export default defineComponent({ name: 'CMenuItem', @@ -21,52 +12,68 @@ export default defineComponent({ getmymenuclass: { type: Function, required: true }, getimgiconclass: { type: Function, required: true }, clBase: { type: String, default: '' }, - level: { type: Number, default: 1 }, + mainMenu: { type: Boolean, default: false }, + level: { type: Number, default: 0 }, }, - setup(props) { - const getmenuByPath = (input: any, depth = 0): any => { - if (depth > 5) return null; - - const path = toNormPath(input); - if (!path) return null; - - let page = props.tools.getmenuByPath ? props.tools.getmenuByPath(path) : null; - if (!page) return null; - - // Evita loop - const selfPath = toNormPath(props.item); - if (selfPath && path === selfPath) return null; - - return page; - }; - + emits: ['click'], + setup(props, { emit }) { + // Funzione per ottenere i figli ordinati const children = computed(() => { const item: any = props.item; const r2 = Array.isArray(item.routes2) ? item.routes2 : []; const sm = Array.isArray(item.sottoMenu) ? item.sottoMenu : []; - return [...r2, ...sm] - .map((ref) => - typeof ref === 'string' || !ref.path ? getmenuByPath(ref, props.level) : ref - ) - .filter(Boolean) - .sort((a: any, b: any) => (a.order ?? 0) - (b.order ?? 0)); + let ris = null; + + if (r2.length > 0) { + ris = [...r2] + .map((rec) => { + const norm = tools.norm(rec.path); + return props.tools.getmenuByPath(norm); + }) + .filter(Boolean) + .sort((a: any, b: any) => (a.order ?? 0) - (b.order ?? 0)); + } else { + ris = [...sm] + .map((path) => { + const norm = tools.norm(path); + return props.tools.getmenuByPath(norm); + }) + .filter(Boolean) + .sort((a: any, b: any) => (a.order ?? 0) - (b.order ?? 0)); + } + // console.log('RIS', ris); + return ris; }); + // Determina se ha figli const hasChildren = computed(() => children.value.length > 0); + // Ottiene l'icona appropriata const icon = computed(() => { const item: any = props.item; return item.materialIcon || item.icon || 'far fa-file-alt'; - }) + }); + + // Gestisce il click + function makeClick(event: MouseEvent) { + event.preventDefault(); + event.stopPropagation(); + + const route = props.getroute(props.item); + + if (route) { + window.location.href = typeof route === 'string' ? route : route.path; + } + + emit('click', props.item); + } return { children, hasChildren, icon, - makeClick: () => { - // niente per ora - }, + makeClick, }; }, }); diff --git a/src/components/CMenuItem/CMenuItem.vue b/src/components/CMenuItem/CMenuItem.vue index f440cb9a..2de47125 100755 --- a/src/components/CMenuItem/CMenuItem.vue +++ b/src/components/CMenuItem/CMenuItem.vue @@ -1,12 +1,11 @@