adapt new calendar url format for rauminfo page; readded vue router dashboard fallback since there are possible url combinations that can not be resolved properly;

This commit is contained in:
Johann Hoffmann
2025-02-18 16:31:05 +01:00
parent 8e76d93a5a
commit cb42ba110e
4 changed files with 188 additions and 30 deletions
+74 -10
View File
@@ -9,7 +9,7 @@ import Profil from "../../components/Cis/Profil/Profil";
import CmsNews from "../../components/Cis/Cms/News";
import CmsContent from "../../components/Cis/Cms/Content";
import Info from "../../components/Cis/Mylv/Semester/Studiengang/Lv/Info";
import RoomInformation from "../../components/Cis/Mylv/RoomInformation";
import RoomInformation, {DEFAULT_MODE_RAUMINFO} from "../../components/Cis/Mylv/RoomInformation";
const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router;
@@ -28,11 +28,62 @@ const router = VueRouter.createRouter({
component: Profil,
props: true
},
// Redirect old links to new format
{
path: `/CisVue/Cms/getRoomInformation/:ort_kurzbz`,
path: "/CisVue/Cms/getRoomInformation/:ort_kurzbz",
name: "RoomInformationOld",
component: RoomInformation,
redirect: (to) => {
return { // redirect to longer Rauminfo url and map params
name: "RoomInformation",
params: {
ort_kurzbz: to.params.ort_kurzbz
},
};
},
},
{
path: `/CisVue/Cms/getRoomInformation/:mode/:focus_date/:ort_kurzbz`,
name: 'RoomInformation',
component: RoomInformation,
props: true
props: (route) => { // validate and set mode/focus date if for some reason missing
const validModes = ["Month", "Week", "Day"];
// check mode string
const mode = route.params.mode &&
validModes.includes(route.params.mode.charAt(0).toUpperCase() + route.params.mode.slice(1).toLowerCase())
? route.params.mode.charAt(0).toUpperCase() + route.params.mode.slice(1).toLowerCase()
: DEFAULT_MODE_RAUMINFO;
// default to today date if not provided
const focus_date = route.params.focus_date || new Date().toISOString().split("T")[0];
// for consistency reasons format the props into one object but actually use a new name to we dont collide with
// existing viewData declaration written from codeigniter 3 into routerview tag
return {
propsViewData: {
mode,
focus_date,
ort_kurzbz: route.params.ort_kurzbz
}
};
},
beforeEnter: (to, from, next) => {
// missing mode or focus_date -> set defaults
if (!to.params.mode || !to.params.focus_date) {
next({
name: "RoomInformation",
params: {
mode: to.params.mode || DEFAULT_MODE_RAUMINFO,
focus_date: to.params.focus_date || new Date().toISOString().split("T")[0],
ort_kurzbz: route.params.ort_kurzbz
}
});
} else {
next();
}
}
},
{
path: `/CisVue/Cms/Content/:content_id`,
@@ -81,20 +132,19 @@ const router = VueRouter.createRouter({
const validModes = ["Month", "Week", "Day"];
// check mode string
let mode = route.params.mode &&
const mode = route.params.mode &&
validModes.includes(route.params.mode.charAt(0).toUpperCase() + route.params.mode.slice(1).toLowerCase())
? route.params.mode.charAt(0).toUpperCase() + route.params.mode.slice(1).toLowerCase()
: DEFAULT_MODE_STUNDENPLAN;
// default to today date if not provided
let focusDate = route.params.focus_date || new Date().toISOString().split("T")[0];
const focus_date = route.params.focus_date || new Date().toISOString().split("T")[0];
// for consistency reasons format the props into one object but actually use a new name to we dont collide with
// existing viewData declaration written from codeigniter 3 into routerview tag
return {
propsViewData: {
mode,
focusDate,
focus_date,
lv_id: route.params.lv_id
}
};
@@ -115,6 +165,12 @@ const router = VueRouter.createRouter({
}
}
},
{
path: `/Cis4`,
name: 'Cis4',
component: FhcDashboard,
props: {dashboard: 'CIS'},
},
{
path: `/`,
name: 'FhcDashboard',
@@ -122,11 +178,19 @@ const router = VueRouter.createRouter({
props: {dashboard: 'CIS'},
},
{
path: `/Cis4`,
name: 'Cis4',
path: '/:pathMatch(.*)*',
name: 'Fallback',
component: FhcDashboard,
props: {dashboard: 'CIS'},
}
redirect: () => {
return {
name: "Cis4",
params: {
dashboard: 'CIS'
},
};
},
},
]
})
@@ -3,15 +3,14 @@ import CalendarDate from "../../../composables/CalendarDate.js";
import LvModal from "../../../components/Cis/Mylv/LvModal.js";
import LvInfo from "../../../components/Cis/Mylv/LvInfo.js"
export const DEFAULT_MODE = 'Week'
export const DEFAULT_MODE_RAUMINFO = 'Week'
const RoomInformation = {
name: "RoomInformation",
props:{
ort_kurzbz: {
type: String,
required: true,
}
propsViewData: {
type: Object
}
},
components: {
FhcCalendar,
@@ -21,9 +20,10 @@ const RoomInformation = {
data() {
return {
events: null,
calendarMode: DEFAULT_MODE_RAUMINFO,
calendarDate: new CalendarDate(new Date()),
currentlySelectedEvent: null,
currentDay: new Date(),
currentDay: this.propsViewData?.focus_date ? new Date(this.propsViewData.focus_date) : new Date(),
minimized: false,
}
@@ -45,6 +45,17 @@ const RoomInformation = {
return this.calendarDateToString(this.calendarDate.cdLastDayOfCalendarMonth);
},
},
watch: {
'propsViewData.ort_kurzbz'(newVal) {
// relevant if ort_kurzbz can be changed from within this component
},
'propsViewData.mode'(newVal) {
if(this.$refs.calendar) this.$refs.calendar.setMode(newVal)
},
'propsViewData.focus_date'(newVal) {
this.currentDate = new Date(newVal)
}
},
methods:{
setSelectedEvent: function(event){
this.currentlySelectedEvent = event;
@@ -52,9 +63,38 @@ const RoomInformation = {
getLvID: function () {
this.lv_id = window.location.pathname
},
selectDay: function (day) {
selectDay: function(day){
debugger
const date = day.getFullYear() + "-" +
String(day.getMonth() + 1).padStart(2, "0") + "-" +
String(day.getDate()).padStart(2, "0");
this.$router.push({
name: "RoomInformation",
params: {
mode: this.calendarMode,
focus_date: date,
ort_kurzbz: this.propsViewData.ort_kurzbz
}
})
this.currentDay = day;
},
handleChangeMode(mode) {
debugger
const modeCapitalized = mode.charAt(0).toUpperCase() + mode.slice(1)
this.$router.push({
name: "RoomInformation",
params: {
mode: modeCapitalized,
focus_date: this.currentDay.toISOString().split("T")[0],
ort_kurzbz: this.propsViewData.ort_kurzbz
}
})
this.calendarMode = mode
},
showModal: function (event) {
this.currentlySelectedEvent = event;
Vue.nextTick(() => {
@@ -88,8 +128,8 @@ const RoomInformation = {
// bundles the room_events and the reservierungen together into the this.events array
Promise.allSettled([
this.$fhcApi.factory.stundenplan.getRoomInfo(this.ort_kurzbz, this.monthFirstDay, this.monthLastDay),
this.$fhcApi.factory.stundenplan.getOrtReservierungen(this.ort_kurzbz, this.monthFirstDay, this.monthLastDay)
this.$fhcApi.factory.stundenplan.getRoomInfo(this.propsViewData.ort_kurzbz, this.monthFirstDay, this.monthLastDay),
this.$fhcApi.factory.stundenplan.getOrtReservierungen(this.propsViewData.ort_kurzbz, this.monthFirstDay, this.monthLastDay)
]).then((result) => {
let promise_events = [];
result.forEach((promise_result) => {
@@ -122,10 +162,21 @@ const RoomInformation = {
this.loadEvents();
},
template: /*html*/`
<h2>Room Information {{ ort_kurzbz }}</h2>
<h2>{{ $p.t('rauminfo/rauminfo') }} {{ propsViewData.ort_kurzbz }}</h2>
<hr>
<lv-modal v-if="currentlySelectedEvent" :showMenu="false" :event="currentlySelectedEvent" ref="lvmodal" />
<fhc-calendar @selectedEvent="setSelectedEvent" :initial-date="currentDay" @change:range="updateRange" :events="events" initial-mode="DEFAULT_MODE" show-weeks @select:day="selectDay" v-model:minimized="minimized">
<fhc-calendar
ref="calendar"
@selectedEvent="setSelectedEvent"
:initial-date="currentDay"
@change:range="updateRange"
:events="events"
:initial-mode="propsViewData.mode"
show-weeks
@select:day="selectDay"
@change:mode="handleChangeMode"
v-model:minimized="minimized"
>
<template #monthPage="{event,day}">
<span >
{{event.topic}}
@@ -141,15 +192,15 @@ const RoomInformation = {
<template #dayPage="{event,day,mobile}">
<div @click="mobile? showModal(event?.orig):null" type="button" class="fhc-entry border border-secondary border row h-100 justify-content-center align-items-center text-center">
<div class="col ">
<p>Lehrveranstaltung:</p>
<p>{{ $p.t('lehre/lehrveranstaltung') }}:</p>
<p class="m-0">{{event?.orig.topic}}</p>
</div>
<div class="col ">
<p>Lektor:</p>
<p>{{ $p.t('lehre/lektor') }}:</p>
<p class="m-0" v-for="lektor in event?.orig.lektor">{{lektor.kurzbz}}</p>
</div>
<div class="col ">
<p>Ort: </p>
<p>{{ $p.t('profil/Ort') }}: </p>
<p class="m-0">{{event?.orig.ort_kurzbz}}</p>
</div>
</div>
@@ -161,7 +212,7 @@ const RoomInformation = {
</div>
</template>
<template #pageMobilContentEmpty >
<h3>Keine Raum Reservierung</h3>
<h3>{{$p.t('rauminfo','keineRaumReservierung')}}</h3>
</template>
</fhc-calendar>
`,
@@ -15,7 +15,7 @@ const Stundenplan = {
calendarDate: new CalendarDate(new Date()),
eventCalendarDate: new CalendarDate(new Date()),
currentlySelectedEvent: null,
currentDay: this.viewData?.focus_date ? new Date(this.viewData.focus_date) : new Date(),
currentDay: this.propsViewData?.focus_date ? new Date(this.propsViewData.focus_date) : new Date(),
minimized: false,
studiensemester_kurzbz: null,
studiensemester_start: null,
@@ -23,9 +23,9 @@ const Stundenplan = {
uid: null
}
},
props: [
"propsViewData"
],
props: {
propsViewData: Object
},
watch: {
weekFirstDay: {
handler: async function (newValue) {
@@ -39,10 +39,14 @@ const Stundenplan = {
},
// forward/backward on history entries happening in stundenplan
'propsViewData.lv_id'(newVal) {
// relevant if lv_id can be changed from within this component
},
'propsViewData.mode'(newVal) {
if(this.$refs.calendar) this.$refs.calendar.setMode(newVal)
},
'propsViewData.focus_date'(newVal) {
this.currentDate = new Date(newVal)
}
},
components: {
FhcCalendar, LvModal, LvMenu, LvInfo
@@ -115,7 +119,6 @@ const Stundenplan = {
})
this.calendarMode = mode
},
showModal: function(event){
this.currentlySelectedEvent = event;
+40
View File
@@ -20164,6 +20164,46 @@ array(
)
)
),
array(
'app' => 'core',
'category' => 'rauminfo',
'phrase' => 'rauminfo',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => "Raum Informationen",
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => "Room Information",
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'rauminfo',
'phrase' => 'keineRaumReservierung',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => "Keine Raum Reservierungen gefunden",
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => "No Room Reservations found",
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'lehre',