instead of modifying the original menu keys, it adds new keys for the cis4 version of the menu

This commit is contained in:
SimonGschnell
2024-07-10 10:48:24 +02:00
parent bc9f247323
commit d364630d92
2 changed files with 23 additions and 10 deletions
@@ -277,11 +277,23 @@ class LvMenu extends FHCAPI_Controller
foreach ($menu as $key => $row){
$pos[$key] = $row['position'];
// replace the path to the icon
$menu[$key]['icon'] = base_url(str_replace("../../..","",$row['icon']));
// replace the quatations in the link_onclick
// adds new key with modified icon path to the menu
$menu[$key]['cis4_icon'] = base_url(str_replace("../../..","",$row['icon']));
// adds new key with modified link_onclick link to the menu
if(array_key_exists("link_onclick",$menu[$key])){
$menu[$key]['link_onclick'] = str_replace("\"","'",$menu[$key]['link_onclick']);
$menu[$key]['cis4_link_onclick'] = str_replace("\"","'",$menu[$key]['link_onclick']);
}
// adds new key with modified link to the menu
if(array_key_exists("link",$menu[$key])){
// only replace the link key if the link has an old path
if(strpos($menu[$key]['link'],"../../..") != false){
$menu[$key]['cis4_link'] = base_url(str_replace("../../..","",$row['link']));
}else{
$menu[$key]['cis4_link'] = $menu[$key]['link'];
}
}
}
@@ -20,8 +20,8 @@ export default {
},
methods:{
showModal: function(){
//this.$fhcApi.factory.addons.getLvMenu(this.event.lehrveranstaltung_id, this.event.studiensemester_kurzbz).then(res =>{
this.$fhcApi.factory.addons.getLvMenu(750, "WS2005").then(res =>{
this.$fhcApi.factory.addons.getLvMenu(this.event.lehrveranstaltung_id, this.event.studiensemester_kurzbz).then(res =>{
//this.$fhcApi.factory.addons.getLvMenu(750, "WS2005").then(res =>{
this.menu = res.data;
});
},
@@ -32,15 +32,16 @@ export default {
template:/*html*/`
<bs-modal @showBsModal="showModal" ref="modalContainer" dialogClass="modal-lg">
<template #title>
<span v-if="lv ">{{lv + (stg?' / ' + stg:'')}}</span>
<span v-else>Lehrveranstaltungs Übersicht</span>
<!--<span v-if="event.lv ">{{event.lv + (event.stg?' / ' + event.stg:'')}}</span>-->
<span >{{JSON.stringify(event,null,2)}}</span>
<!--Lehrveranstaltungs Übersicht-->
</template>
<template #default>
<div :style="{'display':'grid', 'row-gap':'10px', 'column-gap':'10px', 'grid-template-columns':'repeat(3,minmax(100px,1fr))', 'grid-template-rows':'repeat('+Math.ceil(menu.length / 3)+',minmax(100px,1fr))'} ">
<div v-for="(menuItem, index) in menu" :key="index">
<a :onclick="menuItem.link_onclick" class="d-flex flex-column align-items-center justify-content-center" :href="menuItem.link_onclick?'#':menuItem.link" :title="menuItem.name">
<a :onclick="menuItem.cis4_link_onclick?menuItem.cis4_link_onclick:null" class="d-flex flex-column align-items-center justify-content-center" :href="menuItem.cis4_link_onclick?'#':menuItem.cis4_link" :title="menuItem.name">
<span>{{menuItem.name}}</span>
<img :src="menuItem.icon" :alt="menuItem.name" ></img>
<img :src="menuItem.cis4_icon" :alt="menuItem.name" ></img>
</a>
</div>
</div>