import { CoreFilterCmpt } from "../../../components/filter/Filter.js"; import Mailverteiler from "./ProfilComponents/Mailverteiler.js"; import RoleInformation from "./ProfilComponents/RoleInformation.js"; import ProfilEmails from "./ProfilComponents/ProfilEmails.js"; import ProfilInformation from "./ProfilComponents/ProfilInformation.js"; import QuickLinks from "./ProfilComponents/QuickLinks.js"; import { dateFilter } from "../../../tabulator/filters/Dates.js"; export default { components: { CoreFilterCmpt, Mailverteiler, RoleInformation, ProfilEmails, ProfilInformation, QuickLinks, }, inject: ["collapseFunction", "language"], data() { return { collapseIconFunktionen: true, funktionen_table_options: { persistenceID: "filterTableMaViewProfilFunktionen", persistence: { columns: false, }, minHeight: 300, layout: "fitColumns", responsiveLayout: "collapse", responsiveLayoutCollapseUseFormatters: false, responsiveLayoutCollapseFormatter: Vue.$collapseFormatter, locale: true, columns: [ //? option when wanting to hide the collapsed list { title: "", field: "collapse", headerSort: false, headerFilter: false, formatter: "responsiveCollapse", maxWidth: 40, headerClick: this.collapseFunction, visible: true, }, { title: "placeholder", titlePhrase: "ui/bezeichnung", field: "Bezeichnung", headerFilter: true, minWidth: 200, visible: true, }, { title: "placeholder", titlePhrase: "lehre/organisationseinheit", field: "Organisationseinheit", headerFilter: true, minWidth: 200, visible: true, }, { title: "placeholder", titlePhrase: "global/gueltigVon", field: "Gültig_von", headerFilterFunc: "dates", headerFilter: dateFilter, resizable: true, minWidth: 200, visible: true, formatter: "datetime", formatterParams: this.datetimeFormatterParams(), }, { title: "placeholder", titlePhrase: "global/gueltigBis", field: "Gültig_bis", headerFilterFunc: "dates", headerFilter: dateFilter, resizable: true, minWidth: 200, visible: true, formatter: "datetime", formatterParams: this.datetimeFormatterParams(), }, { title: "placeholder", titlePhrase: "profil/wochenstunden", field: "Wochenstunden", headerFilter: true, minWidth: 200, visible: true, }, ], }, }; }, //? this is the prop passed to the dynamic component with the custom data of the view props: ["data", "permissions"], methods: { funktionenTableBuilt: function () { this.$refs.funktionenTable.tabulator.setData(this.data.funktionen); }, datetimeFormatterParams: function () { const params = { inputFormat: "yyyy-MM-dd", outputFormat: "dd.MM.yyyy", invalidPlaceholder: "(invalid date)", timezone: FHC_JS_DATA_STORAGE_OBJECT.timezone, }; return params; }, }, watch: { "data.funktionen"(newVal) { if (this.$refs.funktionenTable) this.$refs.funktionenTable.tabulator.setData(newVal); }, "language.value"(newVal) { // reevaluates computed phrasen if (this.$refs.funktionenTable) this.$refs.funktionenTable.tabulator.setColumns( this.funktionen_table_options.columns, ); }, }, computed: { getTelefonValue() { if (this.data.standort_telefon?.kontakt) { return ( this.data.standort_telefon.kontakt + " " + this.data.telefonklappe ); } else if (this.data.standort_telefon) { return ( this.data.standort_telefon + " " + this.data.telefonklappe ); } else { return this.data.telefonklappe; } }, fotoStatus() { return this.data?.fotoStatus ?? null; }, personEmails() { return this.data?.emails ? this.data.emails : []; }, 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("profil", "Kurzzeichen")}`, value: this.data.kurzbz, }, telefon: { label: `${this.$p.t("profil", "Telefon")}`, value: this.getTelefonValue, }, office: { label: `${this.$p.t("profil", "Büro")}`, value: this.data.ort_kurzbz, }, }; }, quickLinks() { let quickLinks = []; if ( this.$props.permissions && this.$props.permissions["basis/other_lv_plan"] ) { quickLinks.push({ icon: "fa-calendar-days", phrase: "lehre/stundenplan", action: () => { this.$router.push({ name: "OtherLvPlan", params: { otherUid: this.$props.data.username }, }); }, }); } return quickLinks; }, }, template: /*html*/ `