mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-10-12 15:04:04 +00:00
308 lines
8.3 KiB
JavaScript
308 lines
8.3 KiB
JavaScript
import FormForm from "../../Form/Form.js";
|
|
import FormInput from "../../Form/Input.js";
|
|
import FhcCalendar from "../../Calendar/LvPlan.js";
|
|
|
|
import ApiLvPlan from "../.././../api/factory/lvPlan.js";
|
|
import ApiOtherLvPlan from "../.././../api/factory/otherLvPlan.js";
|
|
import ApiAuthinfo from "../../../api/factory/authinfo.js";
|
|
import ApiStudienSemester from '../../../api/factory/studiensemester.js';
|
|
|
|
export const DEFAULT_MODE_LVPLAN_DESKTOP = "Week";
|
|
export const DEFAULT_MODE_LVPLAN_MOBILE = "List";
|
|
|
|
export default {
|
|
name: "OtherLvPlan",
|
|
components: {
|
|
FormForm,
|
|
FormInput,
|
|
FhcCalendar,
|
|
},
|
|
props: {
|
|
propsViewData: Object,
|
|
},
|
|
data() {
|
|
return {
|
|
localProps: {},
|
|
isOtherPersonMitarbeiter: false,
|
|
isOtherPersonStudent: false,
|
|
currentStgBezeichnung: null,
|
|
listVerband: [],
|
|
listGroup: [],
|
|
rangeIntervalFirst: null,
|
|
otherPersonData: {
|
|
fullNameWithTitle: "",
|
|
photo: "",
|
|
},
|
|
timezone: FHC_JS_DATA_STORAGE_OBJECT.timezone,
|
|
startSemester: null,
|
|
endSemester: null,
|
|
};
|
|
},
|
|
inject: ["isMobile"],
|
|
computed: {
|
|
currentDay() {
|
|
if (
|
|
!this.propsViewData?.focus_date ||
|
|
isNaN(new Date(this.propsViewData?.focus_date))
|
|
)
|
|
return luxon.DateTime.now().setZone(this.timezone).toISODate();
|
|
return this.propsViewData?.focus_date;
|
|
},
|
|
currentMode() {
|
|
let validModes = ["day", "month"];
|
|
validModes.push(this.isMobile ? "list" : "week");
|
|
|
|
const defaultMode = this.isMobile
|
|
? DEFAULT_MODE_LVPLAN_MOBILE
|
|
: DEFAULT_MODE_LVPLAN_DESKTOP;
|
|
|
|
if (
|
|
!this.propsViewData?.mode ||
|
|
!validModes.includes(this.propsViewData?.mode.toLowerCase())
|
|
)
|
|
return defaultMode;
|
|
return this.propsViewData?.mode;
|
|
},
|
|
downloadLinks() {
|
|
// do not show download links in otherLvPlan Mode
|
|
return false;
|
|
|
|
const startDate = this.startSemester?.start;
|
|
const endDate = this.endSemester ? this.endSemester.ende : this.startSemester?.ende;
|
|
|
|
if (!startDate || !endDate || !this.uid)
|
|
return false;
|
|
|
|
const type = this.isOtherPersonStudent
|
|
? "student"
|
|
: this.isOtherPersonMitarbeiter
|
|
? "lektor"
|
|
: null;
|
|
|
|
if (!type) return;
|
|
|
|
const opts = { zone: this.timezone };
|
|
const start = luxon.DateTime.fromISO(
|
|
startDate,
|
|
opts,
|
|
).toUnixInteger();
|
|
const ende = luxon.DateTime.fromISO(
|
|
endDate,
|
|
opts,
|
|
).toUnixInteger();
|
|
|
|
const download_link =
|
|
FHC_JS_DATA_STORAGE_OBJECT.app_root +
|
|
"cis/private/lvplan/stpl_kalender.php" +
|
|
"?type=" +
|
|
type +
|
|
"&pers_uid=" +
|
|
this.propsViewData.otherUid +
|
|
"&begin=" +
|
|
start +
|
|
"&ende=" +
|
|
ende;
|
|
|
|
return [
|
|
{
|
|
title: "excel",
|
|
icon: "fa-solid fa-file-excel",
|
|
link: download_link + "&format=excel",
|
|
},
|
|
{
|
|
title: "csv",
|
|
icon: "fa-solid fa-file-csv",
|
|
link: download_link + "&format=csv",
|
|
},
|
|
{
|
|
title: "ical1",
|
|
icon: "fa-regular fa-calendar",
|
|
link: download_link + "&format=ical&version=1&target=ical",
|
|
},
|
|
{
|
|
title: "ical2",
|
|
icon: "fa-regular fa-calendar",
|
|
link: download_link + "&format=ical&version=2&target=ical",
|
|
},
|
|
];
|
|
},
|
|
get_image_base64_src: function () {
|
|
if (!this.otherPersonData.photo?.length) {
|
|
return "";
|
|
}
|
|
return "data:image/jpeg;base64," + this.otherPersonData.photo;
|
|
},
|
|
},
|
|
watch: {
|
|
"propsViewData.otherUid": {
|
|
handler() {
|
|
this.$router.go();
|
|
},
|
|
},
|
|
async isMobile() {
|
|
await this.$nextTick();
|
|
this.handleChangeMode(
|
|
this.currentMode,
|
|
luxon.DateTime.fromISO(this.currentDay, {
|
|
zone: this.timezone,
|
|
}),
|
|
);
|
|
},
|
|
},
|
|
methods: {
|
|
handleChangeDate(day, newMode) {
|
|
return this.handleChangeMode(newMode, day);
|
|
},
|
|
handleChangeMode(newMode, day) {
|
|
const mode = newMode[0].toUpperCase() + newMode.slice(1);
|
|
const focus_date = day.toISODate();
|
|
|
|
this.$router.push({
|
|
name: "OtherLvPlan",
|
|
params: {
|
|
mode,
|
|
focus_date,
|
|
},
|
|
});
|
|
},
|
|
async updateRange(rangeInterval) {
|
|
const semesterResponse = await this.$api.call(
|
|
ApiStudienSemester.getContainingOrNearestByDateRange(
|
|
rangeInterval.s.toISO().slice(0, 10),
|
|
rangeInterval.e.toISO().slice(0, 10),
|
|
),
|
|
);
|
|
this.startSemester =
|
|
semesterResponse.data.length
|
|
? semesterResponse.data[0]
|
|
: null;
|
|
this.endSemester =
|
|
semesterResponse.data.length > 1
|
|
? semesterResponse.data[1]
|
|
: null;
|
|
},
|
|
getPromiseFunc(start, end) {
|
|
return [
|
|
this.$api.call(
|
|
ApiLvPlan.eventsPersonal(
|
|
start.toISODate(),
|
|
end.toISODate(),
|
|
this.propsViewData.otherUid,
|
|
),
|
|
),
|
|
this.$api.call(
|
|
ApiLvPlan.getLvPlanReservierungen(
|
|
start.toISODate(),
|
|
end.toISODate(),
|
|
this.propsViewData.otherUid,
|
|
),
|
|
),
|
|
];
|
|
},
|
|
async fetchViewData() {
|
|
const viewDataResponse = await this.$api.call(
|
|
ApiOtherLvPlan.getOtherLvPlanViewData(
|
|
this.propsViewData.otherUid,
|
|
),
|
|
);
|
|
|
|
const viewData = viewDataResponse.data;
|
|
|
|
this.isOtherPersonMitarbeiter =
|
|
!!viewData?.user_data?.is_mitarbeiter;
|
|
this.isOtherPersonStudent = !!viewData?.user_data?.is_student;
|
|
let fullNameWithTitleFragments = [
|
|
viewData?.user_data?.titel,
|
|
viewData?.user_data?.vorname,
|
|
viewData?.user_data?.nachname,
|
|
viewData?.user_data?.postnomen,
|
|
];
|
|
fullNameWithTitleFragments = fullNameWithTitleFragments.filter(
|
|
(fragment) => !!fragment,
|
|
);
|
|
this.otherPersonData.fullNameWithTitle =
|
|
fullNameWithTitleFragments.join(" ");
|
|
this.otherPersonData.photo = viewData?.user_data?.foto;
|
|
},
|
|
async redirectToMyLvPlanIfAuthUid() {
|
|
const authInfoResponse = await this.$api.call(
|
|
ApiAuthinfo.getAuthInfo(),
|
|
);
|
|
const authId = authInfoResponse.data.uid;
|
|
if (authId === this.propsViewData.otherUid) {
|
|
this.$router.push({ name: "MyLvPlan" });
|
|
}
|
|
},
|
|
copyFullNameWithTitleToClipboard() {
|
|
navigator.clipboard.writeText(
|
|
this.otherPersonData.fullNameWithTitle,
|
|
);
|
|
this.$fhcAlert.alertSuccess(
|
|
this.$p.t("profil/name_title_clipboard_copy_confirmation"),
|
|
);
|
|
},
|
|
},
|
|
async created() {
|
|
await this.redirectToMyLvPlanIfAuthUid();
|
|
await this.fetchViewData();
|
|
await this.$p.loadCategory(["profil"]);
|
|
},
|
|
template: /*html*/ `
|
|
<div class="d-flex flex-column h-100">
|
|
<h2>
|
|
<div class="d-flex flex-row justify-content-between align-items-center">
|
|
<span>
|
|
{{ $p.t('lehre/stundenplan') }}
|
|
<span v-if="startSemester?.studiensemester_kurzbz">
|
|
{{ startSemester.studiensemester_kurzbz }}
|
|
<span v-if="endSemester?.studiensemester_kurzbz">
|
|
{{ "- " + endSemester.studiensemester_kurzbz }}
|
|
</span>
|
|
</span>
|
|
</span>
|
|
<div @click="this.$router.push({name: 'ProfilView', params: {uid: propsViewData.otherUid}})" type="button" class="d-flex flex-row align-items-center gap-3">
|
|
<span v-if="otherPersonData.fullNameWithTitle?.length">
|
|
{{ otherPersonData.fullNameWithTitle }}
|
|
<span @click.stop="copyFullNameWithTitleToClipboard()" :title="$p.t('LvPlan/copy')" class="fs-4 h-100">
|
|
<i class="fa-regular fa-copy"></i>
|
|
</span>
|
|
</span>
|
|
<img v-if="otherPersonData.photo?.length" alt="profile picture" class=" img-thumbnail " style=" max-height:60px; " :src="get_image_base64_src"/>
|
|
</div>
|
|
</div>
|
|
</h2>
|
|
<hr>
|
|
<fhc-calendar
|
|
v-if="timezone"
|
|
ref="calendar"
|
|
:timezone="timezone"
|
|
:get-promise-func="getPromiseFunc"
|
|
:date="currentDay"
|
|
:mode="currentMode"
|
|
@update:date="handleChangeDate"
|
|
@update:mode="handleChangeMode"
|
|
@update:range="updateRange"
|
|
class="responsive-calendar"
|
|
>
|
|
<div
|
|
v-if="downloadLinks"
|
|
class="d-flex gap-1 justify-items-start"
|
|
>
|
|
<div v-for="{ title, icon, link } in downloadLinks">
|
|
<a
|
|
:href="link"
|
|
:aria-label="title"
|
|
class="py-1 btn btn-outline-secondary"
|
|
>
|
|
<div class="d-flex flex-column">
|
|
<i aria-hidden="true" :class="icon"></i>
|
|
<span style="font-size:.5rem">{{ title }}</span>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</fhc-calendar>
|
|
</div>
|
|
`,
|
|
};
|