diff --git a/application/config/routes.php b/application/config/routes.php index 8acf9b5ea..eb4c267ce 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -61,7 +61,7 @@ $route['api/v1/organisation/[O|o]rganisationseinheit/(:any)'] = 'api/v1/organisa $route['api/v1/ressource/[B|b]etriebsmittelperson/(:any)'] = 'api/v1/ressource/betriebsmittelperson2/$1'; $route['api/v1/system/[S|s]prache/(:any)'] = 'api/v1/system/sprache2/$1'; -$route['Cis/Stundenplan/(:any)?'] = 'Cis/Stundenplan/index/$1'; +$route['Cis/Stundenplan/.*'] = 'Cis/Stundenplan/index/$1'; // load routes from extensions $subdir = 'application/config/extensions'; diff --git a/application/controllers/Cis/Stundenplan.php b/application/controllers/Cis/Stundenplan.php index f6fb0bd67..71e01be8b 100644 --- a/application/controllers/Cis/Stundenplan.php +++ b/application/controllers/Cis/Stundenplan.php @@ -23,10 +23,10 @@ class Stundenplan extends Auth_Controller /** * @return void */ - public function index($lv_id = null) + public function index() { + $viewData = array( - 'lv_id' => $lv_id, 'uid'=>getAuthUID(), ); diff --git a/application/controllers/api/frontend/v1/Stundenplan.php b/application/controllers/api/frontend/v1/Stundenplan.php index 0a56dac71..2ec02fea9 100644 --- a/application/controllers/api/frontend/v1/Stundenplan.php +++ b/application/controllers/api/frontend/v1/Stundenplan.php @@ -153,6 +153,11 @@ class Stundenplan extends FHCAPI_Controller $stundenplan_data = $this->StundenplanModel->getStundenplanLVA($start_date, $end_date, $lv_id); $stundenplan_data = $this->getDataOrTerminateWithError($stundenplan_data) ?? []; $this->expand_object_information($stundenplan_data); + + // query lv itself in case its Stundenplan is being queried and it has no entries + $this->load->model('education/Lehrveranstaltung_model','LehrveranstaltungModel'); + $lv = getData($this->LehrveranstaltungModel->load($lv_id))[0]; + $this->addMeta('lv', $lv); $this->terminateWithSuccess($stundenplan_data); } diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index 8044fa9de..44f9834d8 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -556,16 +556,6 @@ class Lehrveranstaltung_model extends DB_Model */ public function getLvsByStudentWithGrades($student_uid, $studiensemester_kurzbz, $sprache = null, $lvid=null) { - if ($sprache) { - $sprache_qry = $this->db->compile_binds('SELECT index FROM public.tbl_sprache WHERE sprache = ?', [$sprache]); - $bezeichnung = 'bezeichnung_mehrsprachig[(' . $sprache_qry . ')]'; - $sgbezeichnung = $sprache == 'English' ? 'COALESCE(sg.english, sg.bezeichnung)' : 'sg.bezeichnung'; - $lvbezeichnung = $sprache == 'English' ? 'COALESCE(v.bezeichnung_english, v.bezeichnung)' : 'v.bezeichnung'; - } else { - $bezeichnung = 'bezeichnung'; - $sgbezeichnung = 'sg.bezeichnung'; - $lvbezeichnung = 'v.bezeichnung'; - } $this->addDistinct(); // TODO(chris): selects @@ -605,16 +595,20 @@ class Lehrveranstaltung_model extends DB_Model $this->addSelect('znn.positiv'); #$this->addSelect('splv.module'); - $this->addSelect($lvbezeichnung . ' AS bezeichnung'); - $this->addSelect($sgbezeichnung . ' AS sg_bezeichnung'); + $this->addSelect('v.bezeichnung AS bezeichnung'); + $this->addSelect('v.bezeichnung_english AS bezeichnung_eng'); + $this->addSelect('sg.bezeichnung AS sg_bezeichnung'); + $this->addSelect('sg.english AS sg_bezeichnung_eng'); $this->addSelect('UPPER(sg.typ::VARCHAR(1) || sg.kurzbz) AS studiengang_kuerzel'); //also adds returns the index of the grade //TODO: ist zeugnissnote immer gleich wie die lvgesamtnote $this->addSelect('COALESCE(zn.note::numeric,gn.note::numeric) as note_index'); $this->addSelect('COALESCE(znn.positiv,gnn.positiv) as positiv'); - $this->addSelect('COALESCE(gnn.' . $bezeichnung . ', gnn.bezeichnung, gn.note::text) AS lvnote'); - $this->addSelect('COALESCE(znn.' . $bezeichnung . ', znn.bezeichnung, zn.note::text) AS znote'); + $this->addSelect('gnn.bezeichnung_mehrsprachig AS lvnotebez'); + $this->addSelect('gnn.note AS lvnote'); + $this->addSelect('znn.bezeichnung_mehrsprachig AS znotebez'); + $this->addSelect('znn.note AS znote'); // TODO(chris): Potentielle Anpassung "Eine UID" $this->addJoin('campus.vw_student_lehrveranstaltung v', 'lehrveranstaltung_id'); diff --git a/include/tw/cis_menu_lv.inc.php b/include/tw/cis_menu_lv.inc.php index a18af4bde..fa35362bd 100644 --- a/include/tw/cis_menu_lv.inc.php +++ b/include/tw/cis_menu_lv.inc.php @@ -402,6 +402,7 @@ function checkZeilenUmbruch() 'id'=>'core_menu_mailanstudierende', 'position'=>'100', 'name'=>$p->t('lehre/mail'), + 'phrase'=>'lehre/mail', 'icon'=>'../../../skin/images/button_feedback.png', 'link'=>$mailto, 'link_onclick'=>$link_onclick @@ -477,6 +478,7 @@ function checkZeilenUmbruch() 'id'=>'core_menu_anerkennungNachgewiesenerKenntnisse', 'position'=>'128', 'name'=>$p->t('lehre/anrechnung'), + 'phrase'=>'lehre/anrechnung', 'icon'=>'../../../skin/images/button_listen.png', 'link' => APP_ROOT. 'index.ci.php/lehre/anrechnung/RequestAnrechnung?studiensemester='.urlencode($angezeigtes_stsem).'&lv_id='.urlencode($lvid) ); @@ -491,6 +493,7 @@ if((!defined('CIS_LEHRVERANSTALTUNG_ANRECHNUNG_ANZEIGEN') || CIS_LEHRVERANSTALTU 'id'=>'core_menu_anerkennungNachgewiesenerKenntnisse_empfehlen', 'position'=>'128', 'name'=>$p->t('lehre/anrechnungen'), + 'phrase'=>'lehre/anrechnung', 'icon'=>'../../../skin/images/button_listen.png', 'link' => APP_ROOT. 'index.ci.php/lehre/anrechnung/ReviewAnrechnungUebersicht?studiensemester='.urlencode($angezeigtes_stsem) ); diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index 19f6b3a2b..d49195399 100644 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -3,13 +3,13 @@ import FhcApi from '../../plugin/FhcApi.js'; import Phrasen from '../../plugin/Phrasen.js'; import contrast from '../../directives/contrast.js'; import {setScrollbarWidth} from "../../helpers/CssVarCalcHelpers.js"; -import Stundenplan from "../../components/Cis/Stundenplan/Stundenplan.js"; +import Stundenplan, {DEFAULT_MODE_STUNDENPLAN} from "../../components/Cis/Stundenplan/Stundenplan.js"; import MylvStudent from "../../components/Cis/Mylv/Student.js"; import Profil from "../../components/Cis/Profil/Profil.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 from "../../components/Cis/Mylv/RoomInformation.js"; +import RoomInformation, { DEFAULT_MODE_RAUMINFO } from "../../components/Cis/Mylv/RoomInformation.js"; const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router; @@ -28,11 +28,65 @@ 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: { // in this case always populate other params since they are not optional + ort_kurzbz: to.params.ort_kurzbz, + mode: DEFAULT_MODE_RAUMINFO, + focus_date: new Date().toISOString().split("T")[0] + }, + }; + }, + }, + { + 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 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`, @@ -58,10 +112,68 @@ const router = VueRouter.createRouter({ component: Info, props: true }, + // Redirect old links to new format { - path: `/Cis/Stundenplan/:lv_id?`, + // only trigger on first param being numeric to avoid paths like "Stundenplan/Month" entering here + path: "/Cis/Stundenplan/:lv_id(\\d+)", + name: "StundenplanOld", + component: Stundenplan, + redirect: (to) => { + return { // redirect to longer Stundenplan url and map params + name: "Stundenplan", + params: { + lv_id: to.params.lv_id + }, + }; + }, + }, + { + path: `/Cis/Stundenplan/:mode?/:focus_date?/:lv_id?`, name: 'Stundenplan', - component: Stundenplan + component: Stundenplan, + 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_STUNDENPLAN; + + // default to today date if not provided or string forms invalid date + 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, + lv_id: route.params.lv_id + } + }; + }, + beforeEnter: (to, from, next) => { + // missing mode or focus_date -> set defaults + if (!to.params.mode || !to.params.focus_date) { + next({ + name: "Stundenplan", + params: { + mode: to.params.mode || DEFAULT_MODE_STUNDENPLAN, + focus_date: to.params.focus_date || new Date().toISOString().split("T")[0], + lv_id: to.params.lv_id + } + }); + } else { + next(); + } + } + }, + { + path: `/Cis4`, + name: 'Cis4', + component: FhcDashboard, + props: {dashboard: 'CIS'}, }, { path: `/`, @@ -70,14 +182,32 @@ 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' + }, + }; + }, + }, ] }) +router.beforeEach((to, from) => { + // this avoids redundant routing navigation in place due to router.replace on a route with param function and + // beforeEnter navigation guard + + // TODO: manage the infinite forward navigation issue somehow + if (to.fullPath === from.fullPath) { + return false + } +}) + const app = Vue.createApp({ name: 'FhcApp', data: () => ({ @@ -111,7 +241,7 @@ const app = Vue.createApp({ // let click event propagate normally if we dont route internally const res = this.$router.resolve(route) - if(!res?.matched?.length) return + if(!res?.matched?.length || res.name === 'Fallback') return event.preventDefault(); // Prevent browser navigation diff --git a/public/js/components/Calendar/Calendar.js b/public/js/components/Calendar/Calendar.js index c3515df45..cdceb38db 100644 --- a/public/js/components/Calendar/Calendar.js +++ b/public/js/components/Calendar/Calendar.js @@ -62,6 +62,9 @@ export default { noMonthView: Boolean }, watch:{ + mode(newVal) { + this.$emit('change:mode', newVal) + }, selectedEvent:{ handler(newSelectedEvent) { this.$emit('selectedEvent', newSelectedEvent); @@ -92,7 +95,8 @@ export default { 'select:event', 'change:range', 'update:minimized', - 'selectedEvent' + 'selectedEvent', + 'change:offset' ], data() { return { @@ -161,12 +165,12 @@ export default { if (this.events && Array.isArray(this.events) && this.events.length > 0) { let filteredEvents = this.events.filter(event => { let eventDate = new CalendarDate(new Date(event.datum)); - if (this.mode == 'week') + if (this.mode == 'week' || this.mode == 'Week') { // week view filters the elements only for the same week return this.focusDate.w == eventDate.w; } - else if (this.mode == 'day') + else if (this.mode == 'day' || this.mode == 'Day') { // day view filters the elements for the same day and the same week return this.focusDate.d == eventDate.d && this.focusDate.w == eventDate.w; @@ -187,17 +191,21 @@ export default { }, }, methods: { + setMode(mode) { + this.mode = mode + }, handleInput(day) { this.$emit(day[0], day[1]); }, }, created() { - const allowedInitialModes = ['years']; + const initMode = this.initialMode.toLowerCase() + const allowedInitialModes = ['day']; if (!this.noWeekView) allowedInitialModes.push('week'); if (!this.noMonthView) allowedInitialModes.push('month'); - this.mode = allowedInitialModes[allowedInitialModes.indexOf(this.initialMode)] || allowedInitialModes.pop(); + this.mode = allowedInitialModes[allowedInitialModes.indexOf(initMode)] || allowedInitialModes.pop(); this.date.set(new Date(this.initialDate)); this.focusDate.set(this.date); }, @@ -227,14 +235,14 @@ export default { } }).observe(this.$refs.container); } - }, unmounted(){ CalendarDates.cleanup(); }, template: /*html*/`
this is a placeholder which means that no template was passed to the Calendar Page slot