/** * Copyright (C) 2024 fhcomplete.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import {CoreFetchCmpt} from '../../components/Fetch.js'; import ApiNavigation from '../../api/factory/navigation.js'; /** * */ export const CoreNavigationCmpt = { components: { CoreFetchCmpt }, props: { addHeaderMenuEntries: Object, // property used to add new header menu entries from another app/component addSideMenuEntries: Object, // property used to add new side menu entries from another app/component hideTopMenu: Boolean, leftNavCssClasses: { type: String, default: 'navbar navbar-left-side' } }, data() { return { headerMenu: {}, // header menu entries sideMenu: {} // side menu entries }; }, computed: { /** * */ headerMenuEntries() { // let hm = this.headerMenu ? {...this.headerMenu} : {}; if (this.headerMenu != null && this.addHeaderMenuEntries != null && Object.keys(this.addHeaderMenuEntries).length > 0) { hm[this.addHeaderMenuEntries.description] = this.addHeaderMenuEntries; } return hm; }, /** * */ sideMenuEntries() { // let sm = this.sideMenu ? {...this.sideMenu} : {}; if (this.sideMenu != null && this.addSideMenuEntries != null && Object.keys(this.addSideMenuEntries).length > 0) { sm[this.addSideMenuEntries.description] = this.addSideMenuEntries; } return sm; } }, methods: { /** * */ getNavigationPage() { return FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method; }, /** * */ fetchCmptApiFunctionHeader() { return this.$api.call(ApiNavigation.getHeader(this.getNavigationPage())) }, /** * */ fetchCmptApiFunctionSideMenu() { return this.$api.call(ApiNavigation.getMenu(this.getNavigationPage())) }, /** * */ fetchCmptDataFetchedHeader(data) { this.headerMenu = data || {}; }, /** * */ fetchCmptDataFetchedMenu(data) { this.sideMenu = data || {}; }, /** * */ getDataBsToggle(header) { return !header.children ? null : 'dropdown'; } }, template: ` ` };