feature(StudiengangInformations componente): creates a Vue component for the StudiengangsInformationen that were displayed next to the news

This commit is contained in:
SimonGschnell
2024-12-04 11:20:52 +01:00
parent af3334f227
commit a3dc5aec93
7 changed files with 396 additions and 10 deletions
@@ -0,0 +1,58 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Studgang extends FHCAPI_Controller
{
/**
* Object initialization
*/
public function __construct()
{
parent::__construct([
'getStudiengangInfo'=> self::PERM_LOGGED,
]);
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
// Loads phrases system
$this->loadPhrases([
'global'
]);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
public function getStudiengangInfo(){
// fetches the Studiengang Information which is used next the the news
$studiengangInfo = $this->StudiengangModel->getStudiengangInfoForNews();
$studiengangInfo= $this->getDataOrTerminateWithError($studiengangInfo);
$this->terminateWithSuccess($studiengangInfo);
}
//------------------------------------------------------------------------------------------------------------------
// Private methods
}
@@ -647,4 +647,121 @@ class Studiengang_model extends DB_Model
return $this->load();
}
/**
* @return stdClass
*/
public function getStudiengangInfoForNews()
{
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
$this->load->model('person/Person_model', 'PersonModel');
$addEmailProperty= function(&$benutzerfunktionen){
if(count($benutzerfunktionen) && defined('DOMAIN'))
{
$benutzerfunktionen = array_map(function($benutzer)
{
$benutzer->email = $benutzer->alias."@".DOMAIN;
return $benutzer;
},$benutzerfunktionen) ;
}
};
$addFotoProperty= function(&$collection){
$collection = array_map(function($item){
$person_id = $this->PersonModel->getByUid($item->uid);
if(isError($person_id))
return error($person_id);
$person_id = current(getData($person_id))->person_id;
$this->PersonModel->addSelect('foto');
$foto = $this->PersonModel->loadWhere(array('person_id'=>$person_id));
if(isError($foto))
return error($foto);
$foto = current(getData($foto))->foto;
$item->foto = $foto;
return $item;
},$collection);
};
$this->load->model('crm/Student_model', 'StudentModel');
//TODO: this does not work for Mitarbeiter
$student = $this->StudentModel->loadWhere(['student_uid' => getAuthUID()]);
if (isError($student))
return error($student);
if (getData($student)) {
$student = current(getData($student));
$studiengang_kz = $student->studiengang_kz;
$semester = $student->semester;
}
$stg_obj = $this->load($studiengang_kz);
if(isError($stg_obj))
return error($stg_obj);
if(getData($stg_obj))
{
$stg_obj = current(getData($stg_obj));
}
$stg_ltg = $this->getLeitungDetailed($stg_obj->studiengang_kz);
if (isError($stg_ltg))
return $stg_ltg;
$stg_ltg = getData($stg_ltg) ?: [];
$addFotoProperty($stg_ltg);
$gf_ltg = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('gLtg', $stg_obj->oe_kurzbz);
if (isError($gf_ltg))
return $gf_ltg;
$gf_ltg = getData($gf_ltg) ?: [];
$addEmailProperty($gf_ltg);
$stv_ltg = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('stvLtg', $stg_obj->oe_kurzbz);
if (isError($stv_ltg))
return $stv_ltg;
$stv_ltg = getData($stv_ltg) ?: [];
$addEmailProperty($stv_ltg);
$ass = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('ass', $stg_obj->oe_kurzbz);
if (isError($ass))
return $ass;
$ass = getData($ass) ?: [];
$addEmailProperty($ass);
$addFotoProperty($ass);
$hochschulvertr = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('hsv');
if (isError($hochschulvertr))
return $hochschulvertr;
$hochschulvertr = getData($hochschulvertr) ?: [];
$addEmailProperty($hochschulvertr);
$stdv = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('stdv', $stg_obj->oe_kurzbz);
if (isError($stdv))
return $stdv;
$stdv = getData($stdv) ?: [];
$addEmailProperty($stdv);
$jahrgangsvertr = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('jgv', $stg_obj->oe_kurzbz, $semester);
if (isError($jahrgangsvertr))
return $jahrgangsvertr;
$jahrgangsvertr = getData($jahrgangsvertr) ?: [];
$addEmailProperty($jahrgangsvertr);
$result_object = new stdClass();
$result_object->studiengang = $stg_obj;
$result_object->semester = $semester;
$result_object->stg_ltg = $stg_ltg;
$result_object->gf_ltg = $gf_ltg;
$result_object->stv_ltg = $stv_ltg;
$result_object->ass = $ass;
$result_object->hochschulvertr = $hochschulvertr;
$result_object->stdv = $stdv;
$result_object->jahrgangsvertr = $jahrgangsvertr;
return success($result_object);
}
}
+7 -9
View File
@@ -11,15 +11,6 @@ export default {
);
},
news(limit) {
return this.$fhcApi.get(
"/api/frontend/v1/Cms/news",
{
limit: limit
}
);
},
getNews(page = 1, page_size = 10) {
return this.$fhcApi.get(
"/api/frontend/v1/Cms/getNews",
@@ -36,5 +27,12 @@ export default {
{}
);
},
getNewsExtra: function(){
return this.$fhcApi.get(
"/api/frontend/v1/Cms/getStudiengangInfoForNews",
{}
);
}
}
+3 -1
View File
@@ -33,6 +33,7 @@ import ort from "./ort.js";
import cms from "./cms.js";
import lehre from "./lehre.js";
import addons from "./addons.js";
import studiengang from "./studiengang.js";
export default {
search,
@@ -52,5 +53,6 @@ export default {
ort,
cms,
lehre,
addons
addons,
studiengang,
};
+9
View File
@@ -0,0 +1,9 @@
export default {
studiengangInformation: function () {
return this.$fhcApi.get(
"/api/frontend/v1/Studgang/getStudiengangInfo",
{}
);
}
}
@@ -0,0 +1,117 @@
import StudiengangPerson from "./StudiengangPerson";
export default {
data(){
return{
studiengang:null,
semester: null,
stg_ltg: null,
gf_ltg: null,
stv_ltg: null,
ass: null,
hochschulvertr: null,
stdv: null,
jahrgangsvertr: null,
}
},
components:{
StudiengangPerson
},
template:/*html*/`
<template v-for="{title, collection} in collection_array">
<h3 v-if="Array.isArray(collection) && collection.length !==0">{{title}}</h3>
<template v-for="person in studiengangs_person_data(collection)">
<div class="mb-3">
<studiengang-person :person_data="person"></studiengang-person>
</div>
</template>
</template>
`,
computed:{
collection_array: function(){
return [{ title: "Studiengangsleitung", collection: this.stg_ltg }, { title: "geschäftsführende Leitung", collection: this.gf_ltg },{ title: "stellvertretende Leitung", collection: this.stv_ltg },{ title: "Sekretariat", collection: this.ass} ];
},
studiengangs_assistenz_array: function () {
// early return if the reactive data is not yet loaded or not present
if (!this.ass)
return null;
return this.ass.map((assistenz) => {
return {
fullname: this.studiengangs_person_fullname(assistenz.titelpre, assistenz.vorname, assistenz.nachname),
telefone: this.studiengangs_person_phone(assistenz.kontakt, assistenz.telefonklappe),
ort: assistenz.planbezeichnung ?? null,
email: this.studiengangs_person_email(assistenz.email),
}
})
},
},
methods:{
studiengangs_person_data: function (collection) {
// early return if the reactive data is not yet loaded or not present
if (!collection || !Array.isArray(collection) || collection.length === 0)
return null;
return collection.map((item) => {
return {
fullname: this.studiengangs_person_fullname(item.titelpre, item.vorname, item.nachname),
telefone: this.studiengangs_person_phone(item.kontakt, item.telefonklappe),
ort: item.planbezeichnung ?? null,
email: this.studiengangs_person_email(item.email),
foto: item.foto ? 'data:image/png;base64,'.concat(item.foto) : null,
}
})
},
studiengangs_person_fullname: function(titelpre, vorname, nachname){
if (titelpre && vorname && nachname)
{
return `${titelpre} ${vorname} ${nachname}`;
}
else if (vorname && nachname)
{
return `${vorname} ${nachname}`;
}
else if (nachname)
{
return vorname;
}
else
{
return null;
}
},
studiengangs_person_phone: function (telefone,telefoneklappe) {
if(telefone && telefoneklappe)
{
return "tel:".concat(telefone).concat(" "+telefoneklappe);
}
else if(telefone)
{
return "tel:".concat(telefone);
}
else
{
return null;
}
},
studiengangs_person_email: function (email) {
if (email)
{
return "mailto:".concat(email);
}
else {
return null;
}
},
},
mounted(){
this.$fhcApi.factory.studiengang.studiengangInformation()
.then(res => res.data)
.then(studiengangInformationen => {
Object.assign(this, studiengangInformationen);
});
},
};
@@ -0,0 +1,85 @@
export default {
data(){
},
props:{
person_data:
{
type: Object,
required: true
}
},
computed:{
formattedEmail: function(){
if(!this.person_data ) return null;
let emailString= this.person_data.email.replace("mailto:", "");
// when splitting a string, the letter that is used to split the string will be removed from the result
let emailArray = emailString.split('@');
// returns both parts of the splitted string in combination with the removed letter and a word break
return emailArray[0] + '@<wbr>' + emailArray[1];
},
},
template:/*html*/`
<div class="card" style="width: 15rem;">
<div class="bg-dark d-flex justify-content-center">
<img :src="person_data.foto" alt="person_dataFoto" style="width: 110px; height: auto; object-fir:scale-down;" class="card-img-top" >
</div>
<div class="card-body">
<h5 class="text-center card-title mb-0">{{person_data.fullname}}</h5>
</div>
<hr class="my-0">
<div class="card-body">
<div class="flex flex-column gap-3">
<div class="mb-3">
<span>
<i class="fa fa-phone me-2"></i>
<a :href="person_data.telefone">{{person_data.telefone?.replace("tel:","")}}</a>
</span>
</div>
<div class="mb-3">
<span>
<i class="fa fa-home me-2"></i>
{{person_data.ort}}
</span>
</div>
<div>
<span>
<i class="fa-regular fa-envelope me-2"></i>
<a :href="person_data.email" v-html="formattedEmail"></a>
</span>
</div>
</div>
</div>
</div>
<!--<div class="flex flex-column gap-3">
<div class="mb-3">
<span>
<i class="fa fa-user me-2"></i>
{{person_data.fullname}}
</span>
</div>
<div class="mb-3">
<span>
<i class="fa fa-phone me-2"></i>
<a :href="person_data.telefone">{{person_data.telefone?.replace("tel:","")}}</a>
</span>
</div>
<div class="mb-3">
<span>
<i class="fa fa-home me-2"></i>
{{person_data.ort}}
</span>
</div>
<div class="mb-3">
<span>
<i class="fa-regular fa-envelope me-2"></i>
<a :href="person_data.email"> {{person_data.email.replace("mailto:","")}}</a>
</span>
</div>
<div class="mb-3">
<img :src="person_data.foto" alt="person_dataFoto" style="width: 100px; height: auto; object-fir:scale-down;">
</div>
</div>-->`,
}