mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 22:42:16 +00:00
moved LE loading and infoString setup into LehreinheitenModule, which can be bound to an instance of Primevue3 Dropdown via v-bind. WIP modularizing other common selections like LVA & Semester Kurzbz;
This commit is contained in:
@@ -666,8 +666,7 @@ class Lehre extends FHCAPI_Controller
|
||||
|
||||
if (!isset($person_id) || isEmptyString($person_id))
|
||||
$person_id = getAuthPersonId();
|
||||
|
||||
|
||||
|
||||
if($person_id !== getAuthPersonId()) {
|
||||
$this->load->library('PermissionLib');
|
||||
$isAdmin = $this->permissionlib->isBerechtigt('admin');
|
||||
@@ -692,33 +691,26 @@ class Lehre extends FHCAPI_Controller
|
||||
$sem_kurzbz = $this->input->get("sem_kurzbz",TRUE);
|
||||
|
||||
// TODO: error messages
|
||||
|
||||
if (!isset($projektarbeit_id) || isEmptyString($projektarbeit_id))
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
if(!isset($sem_kurzbz) || isEmptyString($sem_kurzbz))
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
if (!isset($uid) || isEmptyString($uid))
|
||||
$uid = getAuthUID();
|
||||
|
||||
$projektarbeit_obj = new projektarbeit();
|
||||
if($projektarbeit_id==-1)
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
if(!$projektarbeit_obj->load($projektarbeit_id))
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
$paIsCurrent = $projektarbeit_obj->projektarbeitIsCurrent($projektarbeit_id);
|
||||
|
||||
$this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel');
|
||||
$ret = $this->ProjektarbeitModel->getProjektarbeitAbgabetermine($projektarbeit_id);
|
||||
|
||||
// TODO: fetch zweitbetreuer
|
||||
|
||||
$this->terminateWithSuccess(array($ret, $paIsCurrent));
|
||||
|
||||
// querying other ma_uids data requires admin permission
|
||||
if($uid !== getAuthUID()) {
|
||||
$this->load->library('PermissionLib');
|
||||
$isAdmin = $this->permissionlib->isBerechtigt('admin');
|
||||
if(!$isAdmin) $this->terminateWithError($this->p->t('ui', 'keineBerechtigung'), 'general');
|
||||
}
|
||||
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$result = $this->LehrveranstaltungModel->getLvForLektorInSemester($sem_kurzbz, $uid);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getLeForLv() {
|
||||
$lv_id = $this->input->get("lv_id",TRUE);
|
||||
$sem_kurzbz = $this->input->get("sem_kurzbz",TRUE);
|
||||
@@ -728,11 +720,6 @@ class Lehre extends FHCAPI_Controller
|
||||
// $this->terminateWithSuccess($this->LehreinheitModel->getLesForLv($lv_id, $sem_kurzbz));
|
||||
$this->terminateWithSuccess($this->LehreinheitModel->getAllLehreinheitenForLvaAndMaUid($lv_id, getAuthUID(), $sem_kurzbz));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import ApiNoten from "../../../api/factory/noten.js";
|
||||
import ApiStudiensemester from "../../../api/factory/studiensemester.js";
|
||||
import BsModal from '../../Bootstrap/Modal.js';
|
||||
import VueDatePicker from '../../vueDatepicker.js.php';
|
||||
|
||||
import LehreinheitenModule from '../../DropdownModes/LehreinheitenModule';
|
||||
export const Benotungstool = {
|
||||
name: "Benotungstool",
|
||||
components: {
|
||||
@@ -39,7 +39,6 @@ export const Benotungstool = {
|
||||
loading: false,
|
||||
selectedUids: [], // shared selection state
|
||||
selectedLehreinheit: null,
|
||||
lehreinheiten: null,
|
||||
tabulatorCanBeBuilt: false,
|
||||
selectedPruefungNote: null,
|
||||
selectedPruefungDate: new Date(), // v-model for pruefung edit datepicker
|
||||
@@ -960,42 +959,8 @@ export const Benotungstool = {
|
||||
this.selectedLehrveranstaltung = this.lehrveranstaltungen.find(lva => lva.lehrveranstaltung_id == this.lv_id)
|
||||
})
|
||||
|
||||
this.$api.call(ApiLehre.getLeForLv(this.lv_id, this.sem_kurzbz)).then(res => {
|
||||
|
||||
const data = []
|
||||
// TODO: could be done on server in some shared function, copied from anw extension for now
|
||||
res.data?.retval?.forEach(entry => {
|
||||
|
||||
const existing = data.find(e => e.lehreinheit_id === entry.lehreinheit_id)
|
||||
if (existing) {
|
||||
// supplement info
|
||||
existing.infoString += ', '
|
||||
if (entry.gruppe_kurzbz !== null) {
|
||||
existing.infoString += entry.gruppe_kurzbz
|
||||
} else {
|
||||
existing.infoString += entry.kurzbzlang + '-' + entry.semester
|
||||
+ (entry.verband ? entry.verband : '')
|
||||
+ (entry.gruppe ? entry.gruppe : '')
|
||||
}
|
||||
} else {
|
||||
// entries are supposed to be fetched ordered by non null gruppe_kurzbz first
|
||||
// so a new entry will always start with those groups, others are appended afterwards
|
||||
entry.infoString = entry.kurzbz + ' - ' + entry.lehrform_kurzbz + ' - '
|
||||
if (entry.gruppe_kurzbz !== null) {
|
||||
entry.infoString += entry.gruppe_kurzbz
|
||||
} else {
|
||||
entry.infoString += entry.kurzbzlang + '-' + entry.semester
|
||||
+ (entry.verband ? entry.verband : '')
|
||||
+ (entry.gruppe ? entry.gruppe : '')
|
||||
}
|
||||
|
||||
data.push(entry)
|
||||
}
|
||||
})
|
||||
|
||||
this.lehreinheiten = [...data]
|
||||
|
||||
})
|
||||
LehreinheitenModule.setupContext(this.$.appContext.config.globalProperties)
|
||||
LehreinheitenModule.bindParams(Vue.ref(Vue.computed(() => this.LeDropdownParams)));
|
||||
|
||||
// fetch sem_kurzbz dropdown
|
||||
this.$api.call(ApiStudiensemester.getStudiensemester()).then(res => {
|
||||
@@ -1028,46 +993,6 @@ export const Benotungstool = {
|
||||
}
|
||||
})
|
||||
|
||||
// reload related LE to LV to repopulate LE filter dropdown
|
||||
|
||||
// TODO: reset old LE selection to null
|
||||
this.$api.call(ApiLehre.getLeForLv(e.value.lehrveranstaltung_id, this.sem_kurzbz)).then(res => {
|
||||
|
||||
const data = []
|
||||
// TODO: could be done on server in some shared function, copied from anw extension for now
|
||||
res.data?.retval?.forEach(entry => {
|
||||
|
||||
const existing = data.find(e => e.lehreinheit_id === entry.lehreinheit_id)
|
||||
if (existing) {
|
||||
// supplement info
|
||||
existing.infoString += ', '
|
||||
if (entry.gruppe_kurzbz !== null) {
|
||||
existing.infoString += entry.gruppe_kurzbz
|
||||
} else {
|
||||
existing.infoString += entry.kurzbzlang + '-' + entry.semester
|
||||
+ (entry.verband ? entry.verband : '')
|
||||
+ (entry.gruppe ? entry.gruppe : '')
|
||||
}
|
||||
} else {
|
||||
// entries are supposed to be fetched ordered by non null gruppe_kurzbz first
|
||||
// so a new entry will always start with those groups, others are appended afterwards
|
||||
entry.infoString = entry.kurzbz + ' - ' + entry.lehrform_kurzbz + ' - '
|
||||
if (entry.gruppe_kurzbz !== null) {
|
||||
entry.infoString += entry.gruppe_kurzbz
|
||||
} else {
|
||||
entry.infoString += entry.kurzbzlang + '-' + entry.semester
|
||||
+ (entry.verband ? entry.verband : '')
|
||||
+ (entry.gruppe ? entry.gruppe : '')
|
||||
}
|
||||
|
||||
data.push(entry)
|
||||
}
|
||||
})
|
||||
|
||||
this.lehreinheiten = [...data]
|
||||
|
||||
})
|
||||
|
||||
// reload data
|
||||
this.loadNoten(e.value.lehrveranstaltung_id, this.sem_kurzbz)
|
||||
},
|
||||
@@ -1092,44 +1017,6 @@ export const Benotungstool = {
|
||||
|
||||
this.selectedLehrveranstaltung = this.lehrveranstaltungen.find(lva => lva.lehrveranstaltung_id == this.lv_id)
|
||||
}).then(()=>{
|
||||
|
||||
// TODO: reset old LE selection to null
|
||||
this.$api.call(ApiLehre.getLeForLv(this.lv_id, e.value.studiensemester_kurzbz)).then(res => {
|
||||
|
||||
const data = []
|
||||
// TODO: could be done on server in some shared function, copied from anw extension for now
|
||||
res.data?.retval?.forEach(entry => {
|
||||
|
||||
const existing = data.find(e => e.lehreinheit_id === entry.lehreinheit_id)
|
||||
if (existing) {
|
||||
// supplement info
|
||||
existing.infoString += ', '
|
||||
if (entry.gruppe_kurzbz !== null) {
|
||||
existing.infoString += entry.gruppe_kurzbz
|
||||
} else {
|
||||
existing.infoString += entry.kurzbzlang + '-' + entry.semester
|
||||
+ (entry.verband ? entry.verband : '')
|
||||
+ (entry.gruppe ? entry.gruppe : '')
|
||||
}
|
||||
} else {
|
||||
// entries are supposed to be fetched ordered by non null gruppe_kurzbz first
|
||||
// so a new entry will always start with those groups, others are appended afterwards
|
||||
entry.infoString = entry.kurzbz + ' - ' + entry.lehrform_kurzbz + ' - '
|
||||
if (entry.gruppe_kurzbz !== null) {
|
||||
entry.infoString += entry.gruppe_kurzbz
|
||||
} else {
|
||||
entry.infoString += entry.kurzbzlang + '-' + entry.semester
|
||||
+ (entry.verband ? entry.verband : '')
|
||||
+ (entry.gruppe ? entry.gruppe : '')
|
||||
}
|
||||
|
||||
data.push(entry)
|
||||
}
|
||||
})
|
||||
|
||||
this.lehreinheiten = [...data]
|
||||
|
||||
})
|
||||
|
||||
// reload data
|
||||
this.loadNoten(this.lv_id, e.value.studiensemester_kurzbz)
|
||||
@@ -1441,6 +1328,15 @@ export const Benotungstool = {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
LehreinheitenModule() {
|
||||
return LehreinheitenModule;
|
||||
},
|
||||
LeDropdownParams() {
|
||||
return {
|
||||
lv_id: this.lv_id,
|
||||
sem_kurzbz: this.sem_kurzbz
|
||||
}
|
||||
},
|
||||
getStudentenOptions() {
|
||||
return this.studenten ? this.studenten : []
|
||||
},
|
||||
@@ -1597,11 +1493,11 @@ export const Benotungstool = {
|
||||
</Dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-2">
|
||||
<div class="col-lg-auto">
|
||||
<Dropdown @change="leChanged" :style="{'width': '100%'}" :optionLabel="getOptionLabelLe"
|
||||
v-model="selectedLehreinheit" :options="lehreinheiten" showClear appendTo="self">
|
||||
<Dropdown @change="leChanged" :style="{'width': '100%'}" v-bind="LehreinheitenModule"
|
||||
v-model="selectedLehreinheit" showClear appendTo="self">
|
||||
<template #option="slotProps">
|
||||
<div>
|
||||
{{ slotProps.option.infoString }}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import ApiLehre from "../../api/factory/lehre.js";
|
||||
|
||||
const options = Vue.ref([]);
|
||||
const params = Vue.ref({});
|
||||
let appContext = null;
|
||||
|
||||
export function setupContext(globalProps) {
|
||||
appContext = globalProps
|
||||
}
|
||||
|
||||
// bind and watch api params via reference
|
||||
export function bindParams(paramsRef) {
|
||||
Vue.watch(
|
||||
paramsRef,
|
||||
(newVal) => {
|
||||
params.value = { ...newVal };
|
||||
fetchLehreinheiten(newVal.lv_id, newVal.sem_kurzbz);
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
);
|
||||
}
|
||||
|
||||
async function fetchLehreinheiten(lv_id, sem_kurzbz) {
|
||||
appContext.$api.call(ApiLehre.getLeForLv(lv_id, sem_kurzbz)).then(res => {
|
||||
|
||||
const data = []
|
||||
// TODO: could be done on server in some shared function, copied from anw extension for now
|
||||
res.data?.retval?.forEach(entry => {
|
||||
|
||||
const existing = data.find(e => e.lehreinheit_id === entry.lehreinheit_id)
|
||||
if (existing) {
|
||||
// supplement info
|
||||
existing.infoString += ', '
|
||||
if (entry.gruppe_kurzbz !== null) {
|
||||
existing.infoString += entry.gruppe_kurzbz
|
||||
} else {
|
||||
existing.infoString += entry.kurzbzlang + '-' + entry.semester
|
||||
+ (entry.verband ? entry.verband : '')
|
||||
+ (entry.gruppe ? entry.gruppe : '')
|
||||
}
|
||||
} else {
|
||||
// entries are supposed to be fetched ordered by non null gruppe_kurzbz first
|
||||
// so a new entry will always start with those groups, others are appended afterwards
|
||||
entry.infoString = entry.kurzbz + ' - ' + entry.lehrform_kurzbz + ' - '
|
||||
if (entry.gruppe_kurzbz !== null) {
|
||||
entry.infoString += entry.gruppe_kurzbz
|
||||
} else {
|
||||
entry.infoString += entry.kurzbzlang + '-' + entry.semester
|
||||
+ (entry.verband ? entry.verband : '')
|
||||
+ (entry.gruppe ? entry.gruppe : '')
|
||||
}
|
||||
|
||||
data.push(entry)
|
||||
}
|
||||
})
|
||||
|
||||
options.value = [...data]
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
// export the module and relevant fields via reactive
|
||||
const LehreinheitenModule = Vue.reactive({
|
||||
options,
|
||||
optionLabel: 'infoString',
|
||||
placeholder: Vue.computed(()=>appContext?.$p.t('lehre/lehreinheit')),
|
||||
setupContext,
|
||||
bindParams
|
||||
});
|
||||
|
||||
export default LehreinheitenModule;
|
||||
Reference in New Issue
Block a user