import {CoreFilterCmpt} from "../../../components/filter/Filter.js"; import Mailverteiler from "./ProfilComponents/Mailverteiler.js"; import AusweisStatus from "./ProfilComponents/FhAusweisStatus.js"; import Adresse from "./ProfilComponents/Adresse.js"; import Kontakt from "./ProfilComponents/Kontakt.js"; import ProfilEmails from "./ProfilComponents/ProfilEmails.js"; import RoleInformation from "./ProfilComponents/RoleInformation.js"; import ProfilInformation from "./ProfilComponents/ProfilInformation.js"; import FetchProfilUpdates from "./ProfilComponents/FetchProfilUpdates.js"; import EditProfil from "./ProfilModal/EditProfil.js"; import QuickLinks from "./ProfilComponents/QuickLinks.js"; import CalendarSync from "./ProfilComponents/CalendarSync.js"; import ApiProfilUpdate from '../../../api/factory/profilUpdate.js'; import { dateFilter } from '../../../tabulator/filters/Dates.js'; export default { components: { CoreFilterCmpt, Mailverteiler, AusweisStatus, Adresse, Kontakt, ProfilEmails, RoleInformation, ProfilInformation, FetchProfilUpdates, EditProfil, QuickLinks, CalendarSync, }, inject: ["sortProfilUpdates", "collapseFunction", "isEditable"], data() { return { showModal: false, collapseIconBetriebsmittel: true, editDataFilter: null, // tabulator options zutrittsgruppen_table_options: { persistenceID: "filterTableStudentProfilZutrittsgruppen", persistence: { columns: false }, minHeight: 200, layout: "fitColumns", columns: [{ title: "placeholder", titlePhrase: "profil/zutrittsGruppen", field: "bezeichnung" } ], }, betriebsmittel_table_options: { persistenceID: "filterTableStudentProfilBetriebsmittel", persistence: { columns: false }, minHeight: 300, layout: "fitColumns", responsiveLayout: "collapse", responsiveLayoutCollapseUseFormatters: false, responsiveLayoutCollapseFormatter: Vue.$collapseFormatter, responsiveLayoutCollapseStartOpen: false, locale: true, columns: [ { title: "", field: "collapse", headerSort: false, headerFilter: false, formatter: "responsiveCollapse", maxWidth: 40, headerClick: this.collapseFunction, responsive: 0, }, { title: "placeholder", titlePhrase: "profil/entlehnteBetriebsmittel", field: "betriebsmittel", headerFilter: true, minWidth: 200, visible: true, responsive: 0, }, { title: "placeholder", titlePhrase: "profil/inventarnummer", field: "Nummer", headerFilter: true, resizable: true, minWidth: 200, visible: true, responsive: 2, }, { title: "placeholder", titlePhrase: "profil/ausgabedatum", field: "Ausgegeben_am", headerFilterFunc: 'dates', headerFilter: dateFilter, minWidth: 200, visible: true, formatter:"datetime", formatterParams: this.datetimeFormatterParams(), responsive: 1, }, ], }, }; }, props: { data: Object, editData: Object, calendarSyncUrls: Array, }, provide() { return { studiengang_kz: Vue.computed({ get: () => this.data.studiengang_kz }), } }, methods: { betriebsmittelTableBuilt: function () { this.$refs.betriebsmittelTable.tabulator.setData(this.data.mittel); }, zutrittsgruppenTableBuilt: function () { this.$refs.zutrittsgruppenTable.tabulator.setData( this.data.zuttritsgruppen ); }, fetchProfilUpdates: function () { this.$api .call(ApiProfilUpdate.selectProfilRequest()) .then((res) => { if (!res.error && res) { this.data.profilUpdates = res.data?.length ? res.data.sort(this.sortProfilUpdates) : null; } }); }, hideEditProfilModal: function () { //? checks the editModal component property result, if the user made a successful request or not if (this.$refs.editModal.result) { this.$api .call(ApiProfilUpdate.selectProfilRequest()) .then((request) => { if (!request.error && request.data) { this.data.profilUpdates = request.data; this.data.profilUpdates.sort(this.sortProfilUpdates); } else { console.error("Error when fetching profile updates: " + request); } }) .catch((err) => { console.error(err); }); } else { // when modal was closed without submitting request } this.showModal = false; this.editDataFilter = null; }, showEditProfilModal(view) { if (view) { this.editDataFilter = view; } this.showModal = true; // after a state change, wait for the DOM updates to complete Vue.nextTick(() => { this.$refs.editModal.show(); }); }, datetimeFormatterParams: function() { const params = { inputFormat:"yyyy-MM-dd", outputFormat:"dd.MM.yyyy", invalidPlaceholder:"(invalid date)", timezone:FHC_JS_DATA_STORAGE_OBJECT.timezone }; return params; } }, computed: { fotoStatus() { return this.data?.fotoStatus ?? null; }, filteredEditData() { return this.editDataFilter ? this.editData.data[this.editDataFilter] : this.editData; }, profilInformation() { if (!this.data) { return {}; } return { Vorname: this.data.vorname, Nachname: this.data.nachname, Username: this.data.username, Anrede: this.data.anrede, Titel: this.data.titel, Postnomen: this.data.postnomen, foto_sperre: this.data.foto_sperre, foto: this.data.foto, }; }, roleInformation() { if (!this.data) { return {}; } return { geburtsdatum: { label: `${this.$p.t('profil','Geburtsdatum')}`, value: this.data.gebdatum }, geburtsort: { label: `${this.$p.t('profil','Geburtsort')}`, value: this.data.gebort }, personenkennzeichen: { label: `${this.$p.t('person','personenkennzeichen')}`, value: this.data.personenkennzeichen }, matrikelnummer: { label: this.$p.t('person/matrikelnummer'), value: this.data.matrikelnummer }, studiengang: { label: `${this.$p.t('lehre','studiengang')}`, value: this.data.studiengang }, semester: { label: `${this.$p.t('lehre','semester')}`, value: this.data.semester }, verband: { label: `${this.$p.t('lehre','lehrverband')}`, value: this.data.verband }, gruppe: { label: `${this.$p.t('lehre','gruppe')}`, value: this.data.gruppe.trim() } }; }, quickLinks() { let quickLinks = []; // return quickLinks; }, }, created() { //? sorts the profil Updates: pending -> accepted -> rejected this.data.profilUpdates?.sort(this.sortProfilUpdates); }, template: /*html*/ `
{{$p.t('profil','privateKontakte')}}
{{$p.t('profil','privateAdressen')}}
`, };