mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-03 20:09:29 +00:00
use router-link component to handle query params for compat controller links
This commit is contained in:
+1
-275
@@ -1,287 +1,13 @@
|
||||
import FhcDashboard from '../../components/Dashboard/Dashboard.js';
|
||||
import PluginsPhrasen from '../../plugins/Phrasen.js';
|
||||
import Theme from '../../plugins/Theme.js';
|
||||
import contrast from '../../directives/contrast.js';
|
||||
import {setScrollbarWidth} from "../../helpers/CssVarCalcHelpers.js";
|
||||
import LvPlan from "../../components/Cis/LvPlan/Lehrveranstaltung.js";
|
||||
import MyLvPlan from "../../components/Cis/LvPlan/MyLvPlan.js";
|
||||
import Mylv from "../../components/Cis/Mylv/MyLv.js";
|
||||
import Profil from "../../components/Cis/Profil/Profil.js";
|
||||
import Raumsuche from "../../components/Cis/Raumsuche/Raumsuche.js";
|
||||
import CmsNews from "../../components/Cis/Cms/News.js";
|
||||
import CmsContent from "../../components/Cis/Cms/Content.js";
|
||||
import Info from "../../components/Cis/Mylv/Semester/Studiengang/Lv/Info.js";
|
||||
import RoomInformation, {DEFAULT_MODE_RAUMINFO_DESKTOP, DEFAULT_MODE_RAUMINFO_MOBILE} from "../../components/Cis/Mylv/RoomInformation.js";
|
||||
import AbgabetoolStudent from "../../components/Cis/Abgabetool/AbgabetoolStudent.js";
|
||||
import AbgabetoolMitarbeiter from "../../components/Cis/Abgabetool/AbgabetoolMitarbeiter.js";
|
||||
import AbgabetoolAssistenz from "../../components/Cis/Abgabetool/AbgabetoolAssistenz.js";
|
||||
import DeadlineOverview from "../../components/Cis/Abgabetool/DeadlineOverview.js";
|
||||
import Studium from "../../components/Cis/Studium/Studium.js";
|
||||
import StgOrgLvPlan from "../../components/Cis/LvPlan/StgOrg.js";
|
||||
import OtherLvPlan from "../../components/Cis/LvPlan/OtherLvPlan.js";
|
||||
import PaabgabeUebersicht from "../../components/Cis/ProjektabgabeUebersicht/ProjektabgabeUebersicht.js";
|
||||
import Benotungstool from "../../components/Cis/Benotungstool/Benotungstool.js";
|
||||
import Zeitsperren from "../../components/Cis/Zeitsperren/Zeitsperren.js";
|
||||
import Compat from "../../components/Cis/Compat.js";
|
||||
|
||||
import ApiRouteInfo from '../../api/factory/routeinfo.js';
|
||||
import {capitalize} from "../../helpers/StringHelpers.js";
|
||||
import ApiAuthinfo from "../../api/factory/authinfo.js";
|
||||
|
||||
const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router;
|
||||
const isMobile = window.matchMedia("(max-width: 767px)").matches;
|
||||
|
||||
const router = VueRouter.createRouter({
|
||||
history: VueRouter.createWebHistory(`/${ciPath}`),
|
||||
routes: [
|
||||
{
|
||||
path: `/Cis/Compat/:mode(ci|legacy)/:path(.*)`,
|
||||
name: 'Compat',
|
||||
component: Compat,
|
||||
props: (route) => {
|
||||
return {
|
||||
mode: route.params.mode,
|
||||
path: route.params.path,
|
||||
query_string: VueRouter.stringifyQuery(route.query)
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: `/Cis/Studium`,
|
||||
name: 'Studium',
|
||||
component: Studium,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Profil/View/:uid`,
|
||||
name: 'ProfilView',
|
||||
component: Profil,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Profil`,
|
||||
name: 'Profil',
|
||||
component: Profil,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Abgabetool/Student/:student_uid_prop?`,
|
||||
name: 'AbgabetoolStudent',
|
||||
component: AbgabetoolStudent,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Abgabetool/Mitarbeiter`,
|
||||
name: 'AbgabetoolMitarbeiter',
|
||||
component: AbgabetoolMitarbeiter,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Abgabetool/Assistenz/:stg_kz_prop?`,
|
||||
name: 'AbgabetoolAssistenz',
|
||||
component: AbgabetoolAssistenz,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Abgabetool/Deadlines/:person_uid_prop?`,
|
||||
name: 'DeadlineOverview',
|
||||
component: DeadlineOverview,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Raumsuche`,
|
||||
name: 'Raumsuche',
|
||||
component: Raumsuche,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/ProjektabgabeUebersicht`,
|
||||
name: 'PaabgabeUebersicht',
|
||||
component: PaabgabeUebersicht,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Benotungstool/:lv_id?/:sem_kurzbz?`,
|
||||
name: 'Benotungstool',
|
||||
component: Benotungstool,
|
||||
props: true
|
||||
},
|
||||
// Redirect old links to new format
|
||||
{
|
||||
path: "/CisVue/Cms/getRoomInformation/:ort_kurzbz",
|
||||
name: "RoomInformationOld",
|
||||
component: RoomInformation,
|
||||
redirect: (to) => {
|
||||
return { // redirect to longer Rauminfo url and map params
|
||||
name: "RoomInformation",
|
||||
params: { // in this case always populate other params since they are not optional
|
||||
ort_kurzbz: to.params.ort_kurzbz,
|
||||
mode: isMobile ? DEFAULT_MODE_RAUMINFO_MOBILE : DEFAULT_MODE_RAUMINFO_DESKTOP,
|
||||
focus_date: new Date().toISOString().split("T")[0]
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
path: `/CisVue/Cms/getRoomInformation/:mode/:focus_date/:ort_kurzbz`,
|
||||
name: 'RoomInformation',
|
||||
component: RoomInformation,
|
||||
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()
|
||||
: (isMobile ? DEFAULT_MODE_RAUMINFO_MOBILE : DEFAULT_MODE_RAUMINFO_DESKTOP);
|
||||
|
||||
// default to today date if not provided
|
||||
const d = new Date(route.params.focus_date)
|
||||
const focus_date = !isNaN(d) ? 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`,
|
||||
name: 'Content',
|
||||
component: CmsContent,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/CisVue/Cms/News`,
|
||||
name: 'News',
|
||||
component: CmsNews,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/MyLv/:studiensemester?`,
|
||||
name: 'MyLv',
|
||||
component: Mylv,
|
||||
props: true,
|
||||
},
|
||||
{
|
||||
path: `/Cis/MyLv/Info/:studien_semester/:lehrveranstaltung_id`,
|
||||
name: 'LvInfo',
|
||||
component: Info,
|
||||
props: true
|
||||
},
|
||||
// Redirect old links to new format
|
||||
{
|
||||
// only trigger on first param being numeric to avoid paths like "LvPlan/Month" entering here
|
||||
path: "/Cis/LvPlan/:lv_id(\\d+)",
|
||||
name: "LvPlanOld",
|
||||
component: LvPlan,
|
||||
redirect(to) {
|
||||
const route = Vue.unref(router.currentRoute);
|
||||
const { mode, focus_date } = route.params; // keep mode and focus_date if available
|
||||
return { // redirect to longer LvPlan url and map params
|
||||
name: "LvPlan",
|
||||
params: {
|
||||
mode,
|
||||
focus_date,
|
||||
lv_id: to.params.lv_id
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
path: `/Cis/LvPlan/:mode?/:focus_date?/:lv_id?`,
|
||||
name: 'LvPlan',
|
||||
component: LvPlan,
|
||||
props(route) {
|
||||
return {
|
||||
propsViewData: route.params
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: `/Cis/MyLvPlan/:mode?/:focus_date?`,
|
||||
name: 'MyLvPlan',
|
||||
component: MyLvPlan,
|
||||
props(route) {
|
||||
return {
|
||||
propsViewData: route.params
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: `/Cis/StgOrgLvPlan/:mode?/:focus_date?/:stgkz?/:sem?/:verband?/:gruppe?`,
|
||||
name: 'StgOrgLvPlan',
|
||||
component: StgOrgLvPlan,
|
||||
props(route) {
|
||||
return {
|
||||
propsViewData: route.params
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: `/Cis/OtherLvPlan/:otherUid/:mode?/:focus_date?`,
|
||||
name: "OtherLvPlan",
|
||||
component: OtherLvPlan,
|
||||
props(route) {
|
||||
return {
|
||||
propsViewData: route.params
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: `/Cis4`,
|
||||
name: 'Cis4',
|
||||
component: FhcDashboard,
|
||||
props: {dashboard: 'CIS'},
|
||||
},
|
||||
{
|
||||
path: `/`,
|
||||
name: 'FhcDashboard',
|
||||
component: FhcDashboard,
|
||||
props: {dashboard: 'CIS'},
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'Fallback',
|
||||
component: FhcDashboard,
|
||||
props: {dashboard: 'CIS'},
|
||||
redirect: () => {
|
||||
return {
|
||||
name: "Cis4",
|
||||
params: {
|
||||
dashboard: 'CIS'
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
path: `/Cis/Zeitsperren`,
|
||||
name: 'Zeitsperren',
|
||||
component: Zeitsperren,
|
||||
props: true
|
||||
},
|
||||
]
|
||||
})
|
||||
import {router} from "../../routers/Cis/CisRouter.js";
|
||||
|
||||
const app = Vue.createApp({
|
||||
name: 'CisApp',
|
||||
|
||||
@@ -5,6 +5,8 @@ import Theme from "../../plugins/Theme.js";
|
||||
import ApiSearchbar from '../../api/factory/searchbar.js';
|
||||
import ApiLvPlan from "../../api/factory/lvPlan.js";
|
||||
|
||||
import {router} from "../../routers/Cis/CisRouter.js";
|
||||
|
||||
const app = Vue.createApp({
|
||||
name: 'CisMenuApp',
|
||||
components: {
|
||||
@@ -193,6 +195,7 @@ const app = Vue.createApp({
|
||||
|
||||
FhcApps.makeExtendable(app);
|
||||
|
||||
app.use(router);
|
||||
app.use(primevue.config.default, {
|
||||
zIndex: {
|
||||
overlay: 9000,
|
||||
|
||||
@@ -21,10 +21,11 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
propsWatchHelper: function() {
|
||||
let currentiFrameURL = this.$refs.compatiframe ? this.$refs.compatiframe.src : '';
|
||||
if(this.lastLoadediFrameURL === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('currentiFrameURL: ' + currentiFrameURL);
|
||||
console.log('lastLoadediFrameURL: ' + this.lastLoadediFrameURL);
|
||||
let currentiFrameURL = this.$refs.compatiframe ? this.$refs.compatiframe.src : '';
|
||||
|
||||
let url = this.buildSrcUrl();
|
||||
if(this.lastLoadediFrameURL !== url) {
|
||||
@@ -34,8 +35,6 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
buildSrcUrl: function() {
|
||||
console.log('srcUrl begin: ' + this.path);
|
||||
|
||||
let url = false;
|
||||
switch(this.mode) {
|
||||
case 'ci':
|
||||
@@ -51,13 +50,9 @@ export default {
|
||||
url += '?' + this.query_string;
|
||||
}
|
||||
|
||||
console.log('srcUrl end: ' + url);
|
||||
return url;
|
||||
},
|
||||
loadHandler: function() {
|
||||
console.log('loadHandler');
|
||||
console.log(JSON.stringify(this.$refs.compatiframe.contentWindow.location));
|
||||
|
||||
let iframe_href = this.$refs.compatiframe.contentWindow.location.href;
|
||||
let ci_urlstart = FHC_JS_DATA_STORAGE_OBJECT.app_root + 'index.ci.php/';
|
||||
let legacy_urlstart = FHC_JS_DATA_STORAGE_OBJECT.app_root;
|
||||
@@ -65,10 +60,6 @@ export default {
|
||||
|
||||
this.lastLoadediFrameURL = iframe_href;
|
||||
|
||||
console.log('iframe_href: ' + iframe_href);
|
||||
console.log('ci_urlstart: ' + ci_urlstart);
|
||||
console.log('legacy_url_start: ' + legacy_urlstart);
|
||||
|
||||
if(iframe_href.startsWith(ci_urlstart)) {
|
||||
routerpath = iframe_href.replace(
|
||||
ci_urlstart, '/Cis/Compat/ci/');
|
||||
@@ -79,8 +70,6 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(routerpath);
|
||||
|
||||
if(this.$route.fullPath !== routerpath) {
|
||||
this.$router.push(routerpath);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import CisMenuLink from "./Link.js";
|
||||
|
||||
export default {
|
||||
name: 'CisMenuEntry',
|
||||
components: {
|
||||
CisMenuLink
|
||||
},
|
||||
props: {
|
||||
entry: Object,
|
||||
level: {
|
||||
@@ -170,7 +175,7 @@ export default {
|
||||
<template v-else>
|
||||
<template v-if="hasChilds">
|
||||
<div class="btn-group w-100">
|
||||
<a :target="target"
|
||||
<cis-menu-link :target="target"
|
||||
:href="(entry.menu_open && hasFullLink) ? entry.url : null"
|
||||
@click="toggleCollapse"
|
||||
:class="{
|
||||
@@ -179,7 +184,7 @@ export default {
|
||||
'fw-bold':active
|
||||
}">
|
||||
{{ entry.titel }}
|
||||
</a>
|
||||
</cis-menu-link>
|
||||
<button @click.prevent="toggleCollapse" :aria-expanded="entry.menu_open"
|
||||
:class="{
|
||||
'btn btn-default rounded-0 dropdown-toggle dropdown-toggle-split flex-grow-0': true,
|
||||
@@ -193,7 +198,7 @@ export default {
|
||||
<cis-menu-entry :highestMatchingUrlCount="highestMatchingUrlCount" :activeContent="activeContent" v-for="child in entry.childs" :key="child" :entry="child" :level="level + 1"/>
|
||||
</ul>
|
||||
</template>
|
||||
<a v-else
|
||||
<cis-menu-link v-else
|
||||
:href="entry.url"
|
||||
:target="target"
|
||||
:class="{
|
||||
@@ -203,6 +208,6 @@ export default {
|
||||
}"
|
||||
@mouseup="setActiveEntry(entry.content_id)">
|
||||
{{ entry.titel }}
|
||||
</a>
|
||||
</cis-menu-link>
|
||||
</template>`
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
import {isCompatLink, calcCompatRouterLink} from '../../../helpers/CompatLinkHelpers.js';
|
||||
|
||||
export default {
|
||||
name: 'CisMenuLink',
|
||||
props: {
|
||||
href: {
|
||||
type: [String, null],
|
||||
default: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isCompatLink() {
|
||||
if(this.href === null) {
|
||||
return false;
|
||||
}
|
||||
return isCompatLink(this.href);
|
||||
},
|
||||
calcCompatRouterLink() {
|
||||
return calcCompatRouterLink(this.href);
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<router-link v-if="this.isCompatLink()"
|
||||
:to="this.calcCompatRouterLink()"
|
||||
>
|
||||
<slot></slot> (routerlink)
|
||||
</router-link>
|
||||
<a v-else
|
||||
:href="this.href"
|
||||
>
|
||||
<slot></slot> (ahref)
|
||||
</a>
|
||||
`
|
||||
};
|
||||
@@ -3,6 +3,8 @@ import LvPruefungen from "./Lv/Pruefungen.js";
|
||||
import ApiLehre from '../../../../../api/factory/lehre.js';
|
||||
import ApiAddons from '../../../../../api/factory/addons.js';
|
||||
|
||||
import {isCompatLink, calcCompatRouterLink} from '../../../../../helpers/CompatLinkHelpers.js';
|
||||
|
||||
// TODO(chris): L10n
|
||||
|
||||
export default {
|
||||
@@ -106,6 +108,12 @@ export default {
|
||||
pruefungenData: this.pruefungenData,
|
||||
bezeichnung: this.bezeichnung
|
||||
});
|
||||
},
|
||||
isCompatLink(link) {
|
||||
return isCompatLink(link);
|
||||
},
|
||||
calcCompatRouterLink(link) {
|
||||
return calcCompatRouterLink(link);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -159,7 +167,13 @@ export default {
|
||||
|
||||
<ul v-else class="dropdown-menu dropdown-menu p-0">
|
||||
<li v-for="([text, link], i) in menuItem.c4_linkList" :key="i">
|
||||
<a class="dropdown-item border-bottom" :href="link" target="#">{{ text }}</a>
|
||||
<template v-if="this.isCompatLink(link)">
|
||||
<router-link
|
||||
class="dropdown-item border-bottom"
|
||||
:to="this.calcCompatRouterLink(link)"
|
||||
>{{ text }}</router-link>
|
||||
</template>
|
||||
<a v-else="" class="dropdown-item border-bottom" :href="link" target="#">{{ text }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* check if an absolute url is a URL to Compat CI-Controller
|
||||
*
|
||||
* @param {string} link
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isCompatLink = function(link) {
|
||||
let ci_router_url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router;
|
||||
let isCompatLink = link.startsWith(ci_router_url + '/Cis/Compat/');
|
||||
return isCompatLink;
|
||||
};
|
||||
|
||||
/**
|
||||
* calc Param Object with path and query members for use with router-link component
|
||||
*
|
||||
* @param {string} link
|
||||
* @returns {object}
|
||||
*/
|
||||
const calcCompatRouterLink = function (link) {
|
||||
let ci_router_url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router;
|
||||
let uri = link.replace(ci_router_url, '').split('?');
|
||||
let path = uri[0];
|
||||
let query = (uri.length === 2) ? VueRouter.parseQuery(uri[1]) : {};
|
||||
return {
|
||||
"path": path,
|
||||
"query": query
|
||||
};
|
||||
};
|
||||
|
||||
const isRouterLink = function(router, url) {
|
||||
if(url === null) {
|
||||
return false;
|
||||
}
|
||||
const robj = router.resolve(url, router.currentRoute);
|
||||
console.log('isRouterLink');
|
||||
};
|
||||
|
||||
export {
|
||||
isCompatLink,
|
||||
calcCompatRouterLink,
|
||||
isRouterLink
|
||||
};
|
||||
|
||||
export default {
|
||||
isCompatLink,
|
||||
calcCompatRouterLink,
|
||||
isRouterLink
|
||||
};
|
||||
@@ -0,0 +1,280 @@
|
||||
import FhcDashboard from '../../components/Dashboard/Dashboard.js';
|
||||
import LvPlan from "../../components/Cis/LvPlan/Lehrveranstaltung.js";
|
||||
import MyLvPlan from "../../components/Cis/LvPlan/MyLvPlan.js";
|
||||
import Mylv from "../../components/Cis/Mylv/MyLv.js";
|
||||
import Profil from "../../components/Cis/Profil/Profil.js";
|
||||
import Raumsuche from "../../components/Cis/Raumsuche/Raumsuche.js";
|
||||
import CmsNews from "../../components/Cis/Cms/News.js";
|
||||
import CmsContent from "../../components/Cis/Cms/Content.js";
|
||||
import Info from "../../components/Cis/Mylv/Semester/Studiengang/Lv/Info.js";
|
||||
import RoomInformation, {DEFAULT_MODE_RAUMINFO_DESKTOP, DEFAULT_MODE_RAUMINFO_MOBILE} from "../../components/Cis/Mylv/RoomInformation.js";
|
||||
import AbgabetoolStudent from "../../components/Cis/Abgabetool/AbgabetoolStudent.js";
|
||||
import AbgabetoolMitarbeiter from "../../components/Cis/Abgabetool/AbgabetoolMitarbeiter.js";
|
||||
import AbgabetoolAssistenz from "../../components/Cis/Abgabetool/AbgabetoolAssistenz.js";
|
||||
import DeadlineOverview from "../../components/Cis/Abgabetool/DeadlineOverview.js";
|
||||
import Studium from "../../components/Cis/Studium/Studium.js";
|
||||
import StgOrgLvPlan from "../../components/Cis/LvPlan/StgOrg.js";
|
||||
import OtherLvPlan from "../../components/Cis/LvPlan/OtherLvPlan.js";
|
||||
import PaabgabeUebersicht from "../../components/Cis/ProjektabgabeUebersicht/ProjektabgabeUebersicht.js";
|
||||
import Benotungstool from "../../components/Cis/Benotungstool/Benotungstool.js";
|
||||
import Zeitsperren from "../../components/Cis/Zeitsperren/Zeitsperren.js";
|
||||
import Compat from "../../components/Cis/Compat.js";
|
||||
|
||||
const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router;
|
||||
const isMobile = window.matchMedia("(max-width: 767px)").matches;
|
||||
|
||||
const router = VueRouter.createRouter({
|
||||
history: VueRouter.createWebHistory(`/${ciPath}`),
|
||||
routes: [
|
||||
{
|
||||
path: `/Cis/Compat/:mode(ci|legacy)/:path(.*)`,
|
||||
name: 'Compat',
|
||||
component: Compat,
|
||||
props: (route) => {
|
||||
return {
|
||||
mode: route.params.mode,
|
||||
path: route.params.path,
|
||||
query_string: VueRouter.stringifyQuery(route.query)
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: `/Cis/Studium`,
|
||||
name: 'Studium',
|
||||
component: Studium,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Profil/View/:uid`,
|
||||
name: 'ProfilView',
|
||||
component: Profil,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Profil`,
|
||||
name: 'Profil',
|
||||
component: Profil,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Abgabetool/Student/:student_uid_prop?`,
|
||||
name: 'AbgabetoolStudent',
|
||||
component: AbgabetoolStudent,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Abgabetool/Mitarbeiter`,
|
||||
name: 'AbgabetoolMitarbeiter',
|
||||
component: AbgabetoolMitarbeiter,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Abgabetool/Assistenz/:stg_kz_prop?`,
|
||||
name: 'AbgabetoolAssistenz',
|
||||
component: AbgabetoolAssistenz,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Abgabetool/Deadlines/:person_uid_prop?`,
|
||||
name: 'DeadlineOverview',
|
||||
component: DeadlineOverview,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Raumsuche`,
|
||||
name: 'Raumsuche',
|
||||
component: Raumsuche,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/ProjektabgabeUebersicht`,
|
||||
name: 'PaabgabeUebersicht',
|
||||
component: PaabgabeUebersicht,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/Benotungstool/:lv_id?/:sem_kurzbz?`,
|
||||
name: 'Benotungstool',
|
||||
component: Benotungstool,
|
||||
props: true
|
||||
},
|
||||
// Redirect old links to new format
|
||||
{
|
||||
path: "/CisVue/Cms/getRoomInformation/:ort_kurzbz",
|
||||
name: "RoomInformationOld",
|
||||
component: RoomInformation,
|
||||
redirect: (to) => {
|
||||
return { // redirect to longer Rauminfo url and map params
|
||||
name: "RoomInformation",
|
||||
params: { // in this case always populate other params since they are not optional
|
||||
ort_kurzbz: to.params.ort_kurzbz,
|
||||
mode: isMobile ? DEFAULT_MODE_RAUMINFO_MOBILE : DEFAULT_MODE_RAUMINFO_DESKTOP,
|
||||
focus_date: new Date().toISOString().split("T")[0]
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
path: `/CisVue/Cms/getRoomInformation/:mode/:focus_date/:ort_kurzbz`,
|
||||
name: 'RoomInformation',
|
||||
component: RoomInformation,
|
||||
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()
|
||||
: (isMobile ? DEFAULT_MODE_RAUMINFO_MOBILE : DEFAULT_MODE_RAUMINFO_DESKTOP);
|
||||
|
||||
// default to today date if not provided
|
||||
const d = new Date(route.params.focus_date)
|
||||
const focus_date = !isNaN(d) ? 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`,
|
||||
name: 'Content',
|
||||
component: CmsContent,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/CisVue/Cms/News`,
|
||||
name: 'News',
|
||||
component: CmsNews,
|
||||
props: true
|
||||
},
|
||||
{
|
||||
path: `/Cis/MyLv/:studiensemester?`,
|
||||
name: 'MyLv',
|
||||
component: Mylv,
|
||||
props: true,
|
||||
},
|
||||
{
|
||||
path: `/Cis/MyLv/Info/:studien_semester/:lehrveranstaltung_id`,
|
||||
name: 'LvInfo',
|
||||
component: Info,
|
||||
props: true
|
||||
},
|
||||
// Redirect old links to new format
|
||||
{
|
||||
// only trigger on first param being numeric to avoid paths like "LvPlan/Month" entering here
|
||||
path: "/Cis/LvPlan/:lv_id(\\d+)",
|
||||
name: "LvPlanOld",
|
||||
component: LvPlan,
|
||||
redirect(to) {
|
||||
const route = Vue.unref(router.currentRoute);
|
||||
const { mode, focus_date } = route.params; // keep mode and focus_date if available
|
||||
return { // redirect to longer LvPlan url and map params
|
||||
name: "LvPlan",
|
||||
params: {
|
||||
mode,
|
||||
focus_date,
|
||||
lv_id: to.params.lv_id
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
path: `/Cis/LvPlan/:mode?/:focus_date?/:lv_id?`,
|
||||
name: 'LvPlan',
|
||||
component: LvPlan,
|
||||
props(route) {
|
||||
return {
|
||||
propsViewData: route.params
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: `/Cis/MyLvPlan/:mode?/:focus_date?`,
|
||||
name: 'MyLvPlan',
|
||||
component: MyLvPlan,
|
||||
props(route) {
|
||||
return {
|
||||
propsViewData: route.params
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: `/Cis/StgOrgLvPlan/:mode?/:focus_date?/:stgkz?/:sem?/:verband?/:gruppe?`,
|
||||
name: 'StgOrgLvPlan',
|
||||
component: StgOrgLvPlan,
|
||||
props(route) {
|
||||
return {
|
||||
propsViewData: route.params
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: `/Cis/OtherLvPlan/:otherUid/:mode?/:focus_date?`,
|
||||
name: "OtherLvPlan",
|
||||
component: OtherLvPlan,
|
||||
props(route) {
|
||||
return {
|
||||
propsViewData: route.params
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
path: `/Cis4`,
|
||||
name: 'Cis4',
|
||||
component: FhcDashboard,
|
||||
props: {dashboard: 'CIS'},
|
||||
},
|
||||
{
|
||||
path: `/`,
|
||||
name: 'FhcDashboard',
|
||||
component: FhcDashboard,
|
||||
props: {dashboard: 'CIS'},
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'Fallback',
|
||||
component: FhcDashboard,
|
||||
props: {dashboard: 'CIS'},
|
||||
redirect: () => {
|
||||
return {
|
||||
name: "Cis4",
|
||||
params: {
|
||||
dashboard: 'CIS'
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
path: `/Cis/Zeitsperren`,
|
||||
name: 'Zeitsperren',
|
||||
component: Zeitsperren,
|
||||
props: true
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
export {
|
||||
router
|
||||
}
|
||||
Reference in New Issue
Block a user