diff --git a/application/controllers/components/Cis/Mylv.php b/application/controllers/components/Cis/Mylv.php index 3ce6106b0..b6d10931c 100644 --- a/application/controllers/components/Cis/Mylv.php +++ b/application/controllers/components/Cis/Mylv.php @@ -13,12 +13,13 @@ class Mylv extends Auth_Controller */ public function __construct() { + parent::__construct([ - 'Student' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions? - 'Studiensemester' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions? - 'Lvs' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions? - 'Info' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions? - 'Pruefungen' => ['student/anrechnung_beantragen:r','user:r'] // TODO(chris): permissions? + 'Student' => ['student/anrechnung_beantragen:r','user:r', 'basis/cis:r'], // TODO(chris): permissions? + 'Studiensemester' => ['student/anrechnung_beantragen:r','user:r', 'basis/cis:r'], // TODO(chris): permissions? + 'Lvs' => ['student/anrechnung_beantragen:r','user:r', 'basis/cis:r'], // TODO(chris): permissions? + 'Info' => ['student/anrechnung_beantragen:r','user:r', 'basis/cis:r'], // TODO(chris): permissions? + 'Pruefungen' => ['student/anrechnung_beantragen:r','user:r', 'basis/cis:r'] // TODO(chris): permissions? ]); } @@ -48,7 +49,6 @@ class Mylv extends Auth_Controller $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); $isMitarbeiter = getData($this->MitarbeiterModel->isMitarbeiter(getAuthUID())) ?? false; - $isStudent = getData($this->StudentModel->isStudent(getAuthUID())) ?? false; if($isMitarbeiter) { $result = $this->StudiensemesterModel->getWhereMitarbeiterHasLvs(getAuthUID()); @@ -56,7 +56,7 @@ class Mylv extends Auth_Controller return $this->outputJsonError(getError($result)); $this->outputJsonSuccess(getData($result)); - } else if($isStudent) { // $isStudent + } else if(getData($this->StudentModel->isStudent(getAuthUID())) ?? false) { // $isStudent $result = $this->StudiensemesterModel->getWhereStudentHasLvs(getAuthUID()); if (isError($result)) @@ -83,14 +83,14 @@ class Mylv extends Auth_Controller if (isError($result)) return $this->outputJsonError(getError($result)); - $this->outputJsonSuccess([getData($result), 'employee']); + $this->outputJsonSuccess(getData($result)); } else if(getData($this->StudentModel->isStudent(getAuthUID())) ?? false) { // $isStudent $result = $this->LehrveranstaltungModel->getLvsByStudentWithGrades(getAuthUID(), $studiensemester_kurzbz, getUserLanguage()); if (isError($result)) return $this->outputJsonError(getError($result)); - $this->outputJsonSuccess([getData($result), 'student']); + $this->outputJsonSuccess(getData($result)); } else { $this->outputJsonError('neither student or mitarbeiter'); } diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index 140c76402..401c11b30 100644 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -5,7 +5,7 @@ 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/Personal.js"; -import MylvStudent from "../../components/Cis/Mylv/Student.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"; @@ -21,6 +21,7 @@ import Studium from "../../components/Cis/Studium/Studium.js"; import ApiRenderers from '../../api/factory/renderers.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; @@ -149,7 +150,7 @@ const router = VueRouter.createRouter({ { path: `/Cis/MyLv/:studiensemester?`, name: 'MyLv', - component: MylvStudent, + component: Mylv, props: true, }, { @@ -231,6 +232,9 @@ const app = Vue.createApp({ data: () => ({ appSideMenuEntries: {}, renderers: null, + uid: '', + isStudent: null, + isMitarbeiter: null }), components: {}, computed: { @@ -244,7 +248,10 @@ const app = Vue.createApp({ return { // provide injectable & watchable language property language: Vue.computed(() => this.$p.user_language), renderers: Vue.computed(() => this.renderers), - isMobile: this.isMobile + isMobile: this.isMobile, + uid: Vue.computed(() => this.uid), + isStudent: Vue.computed(() => this.isStudent), + isMitarbeiter: Vue.computed(() => this.isMitarbeiter) } }, methods: { @@ -321,6 +328,14 @@ const app = Vue.createApp({ this.renderers[rendertype].calendarEvent = calendarEvent; } }); + + await this.$api + .call(ApiAuthinfo.getAuthInfo()) + .then(res => { + this.uid = res.data.uid; + this.isMitarbeiter = res.data.isMitarbeiter; + this.isStudent = res.data.isStudent; + }); }, mounted() { document.addEventListener('click', this.handleClick); diff --git a/public/js/components/Cis/Mylv/Student.js b/public/js/components/Cis/Mylv/MyLv.js similarity index 93% rename from public/js/components/Cis/Mylv/Student.js rename to public/js/components/Cis/Mylv/MyLv.js index d1837ed16..4bbc161bd 100644 --- a/public/js/components/Cis/Mylv/Student.js +++ b/public/js/components/Cis/Mylv/MyLv.js @@ -5,7 +5,7 @@ import Phrasen from "../../../mixins/Phrasen.js"; // TODO(chris): phrase: next & prev +aria-label export default { - name: 'Student', + name: 'MyLv', components: { MylvSemester }, @@ -17,7 +17,6 @@ export default { firstLoad: true, studiensemester: null, lvs: {}, - type: null, currentSemester: null }; }, @@ -26,7 +25,13 @@ export default { type: Vue.computed(() => this.type) } }, + inject: ['isStudent', 'isMitarbeiter'], computed: { + type() { + if(this.isStudent) return 'student' + if(this.isMitarbeiter) return 'employee' + return null + }, ready() { return this.studiensemester !== null && (!this.firstLoad || this.current.lvs !== null); }, @@ -39,8 +44,7 @@ export default { lvs: null }; axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/Cis/Mylv/Lvs/' + this.currentSemester).then(res => { - this.lvs[this.currentSemester].lvs = res.data.retval[0] || []; - this.type = res.data.retval[1] // student or employee + this.lvs[this.currentSemester].lvs = res.data.retval || []; this.firstLoad = false; }); } @@ -107,7 +111,7 @@ export default {