From 7e90771f89aac9bbc46ed85cf1bc332ae6b0dc33 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 3 Jun 2025 09:30:10 +0200 Subject: [PATCH] refactor(Moodle Events DependencyInjection): changes the lazy loading for the moodle events in Stundenplan --- public/js/apps/Dashboard/Fhc.js | 18 ++++++- public/js/components/Cis/Mylv/LvModal.js | 22 +++----- .../Cis/Mylv/{LvInfo.js => modalContent.js} | 22 ++++---- public/js/components/Cis/Mylv/modalTitle.js | 12 +++++ .../{lehreinheitEvent.js => calendarEvent.js} | 0 .../components/Cis/Stundenplan/Stundenplan.js | 54 ++++++++++++------- 6 files changed, 80 insertions(+), 48 deletions(-) rename public/js/components/Cis/Mylv/{LvInfo.js => modalContent.js} (95%) create mode 100644 public/js/components/Cis/Mylv/modalTitle.js rename public/js/components/Cis/Stundenplan/EventTypes/{lehreinheitEvent.js => calendarEvent.js} (100%) diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index cdd69362c..830bd2ec3 100644 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -237,7 +237,7 @@ const app = Vue.createApp({ name: 'FhcApp', data: () => ({ appSideMenuEntries: {}, - renderers: {}, + renderers: null, }), components: {}, computed: { @@ -291,7 +291,21 @@ const app = Vue.createApp({ .call(ApiRenderers.loadRenderers()) .then(res => res.data) .then(data => { - this.renderers = data; + for (let rendertype of Object.keys(data)) { + + let modalTitel = Vue.defineAsyncComponent(() => import(data[rendertype].modalTitel)); + let modalContent = Vue.defineAsyncComponent(() => import(data[rendertype].modalContent)); + let calendarEvent = Vue.defineAsyncComponent(() => import(data[rendertype].calendarEvent)); + if(this.renderers === null) { + this.renderers = {}; + } + if (!this.renderers[rendertype]) { + this.renderers[rendertype] = {} + } + this.renderers[rendertype].modalTitel = modalTitel; + this.renderers[rendertype].modalContent = modalContent; + this.renderers[rendertype].calendarEvent = calendarEvent; + } }); }, mounted() { diff --git a/public/js/components/Cis/Mylv/LvModal.js b/public/js/components/Cis/Mylv/LvModal.js index 6509e4dfc..969035711 100644 --- a/public/js/components/Cis/Mylv/LvModal.js +++ b/public/js/components/Cis/Mylv/LvModal.js @@ -1,7 +1,6 @@ import BsModal from "../../Bootstrap/Modal.js"; import Alert from "../../Bootstrap/Alert.js"; import LvMenu from "./LvMenu.js" -import LvInfo from "./LvInfo.js" import ApiStundenplan from '../../../api/factory/stundenplan.js'; import ApiAddons from '../../../api/factory/addons.js'; @@ -11,7 +10,6 @@ export default { BsModal, Alert, LvMenu, - LvInfo, }, mixins: [BsModal], props: { @@ -44,6 +42,9 @@ export default { }; }, methods:{ + onHideModal: function(){ + this.menu = null; + }, onModalShow: function() { // do not load the menu if the menu is not getting rendered @@ -74,22 +75,13 @@ export default { return BsModal.popup.bind(this)(null, options); }, template: /*html*/ ` - +