2025-04-29 13:10:30 +02:00
|
|
|
<template>
|
2025-04-29 18:32:08 +02:00
|
|
|
<BaseSetting title="Vereins-Auftritt Einstellungen" :submit-function="submit" v-slot="{ enableEdit }" @reset="reset">
|
2025-04-29 13:10:30 +02:00
|
|
|
<div class="w-full">
|
|
|
|
<p>Vereins-Icon</p>
|
2025-04-29 18:32:08 +02:00
|
|
|
<div class="flex flex-row gap-2">
|
|
|
|
<AppIcon v-if="icon != '' && !overwriteIcon" class="h-10! max-w-full mx-auto" />
|
|
|
|
<div
|
|
|
|
v-else-if="!overwriteIcon"
|
|
|
|
class="flex h-10 w-full border-2 border-gray-300 rounded-md items-center justify-center text-sm"
|
|
|
|
:class="{ 'cursor-pointer': enableEdit }"
|
|
|
|
@click="enableEdit ? ($refs.icon as HTMLInputElement).click() : null"
|
|
|
|
>
|
|
|
|
Kein eigenes Icon ausgewählt
|
|
|
|
</div>
|
2025-04-30 10:43:11 +02:00
|
|
|
<img ref="icon_img" class="hidden w-full h-10 object-contain" />
|
2025-04-29 18:32:08 +02:00
|
|
|
<XMarkIcon
|
|
|
|
v-if="enableEdit && (icon != '' || overwriteIcon)"
|
|
|
|
class="h-5 w-5 cursor-pointer"
|
|
|
|
@click="resetImage('icon')"
|
|
|
|
/>
|
2025-04-29 13:10:30 +02:00
|
|
|
</div>
|
2025-04-30 10:43:11 +02:00
|
|
|
<input class="hidden!" type="file" ref="icon" accept="image/png" @change="previewImage('icon')" />
|
2025-04-29 13:10:30 +02:00
|
|
|
</div>
|
|
|
|
<div class="w-full">
|
|
|
|
<p>Vereins-Logo</p>
|
2025-04-29 18:32:08 +02:00
|
|
|
<div class="flex flex-row gap-2">
|
|
|
|
<AppLogo v-if="logo != '' && !overwriteLogo" class="h-10! max-w-full mx-auto" />
|
|
|
|
<div
|
|
|
|
v-else-if="!overwriteLogo"
|
|
|
|
class="flex h-10 w-full border-2 border-gray-300 rounded-md items-center justify-center text-sm"
|
|
|
|
:class="{ 'cursor-pointer': enableEdit }"
|
|
|
|
@click="enableEdit ? ($refs.logo as HTMLInputElement).click() : null"
|
|
|
|
>
|
|
|
|
Kein eigenes Logo ausgewählt
|
|
|
|
</div>
|
2025-04-30 10:43:11 +02:00
|
|
|
<img ref="logo_img" class="hidden w-full h-10 object-contain" />
|
2025-04-29 18:32:08 +02:00
|
|
|
<XMarkIcon
|
|
|
|
v-if="enableEdit && (logo != '' || overwriteLogo)"
|
|
|
|
class="h-5 w-5 cursor-pointer"
|
|
|
|
@click="resetImage('logo')"
|
|
|
|
/>
|
2025-04-29 13:10:30 +02:00
|
|
|
</div>
|
2025-04-30 10:43:11 +02:00
|
|
|
<input class="hidden!" type="file" ref="logo" accept="image/png" @change="previewImage('logo')" />
|
2025-04-29 18:32:08 +02:00
|
|
|
</div>
|
|
|
|
</BaseSetting>
|
2025-04-29 13:10:30 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { defineComponent } from "vue";
|
|
|
|
import { mapActions, mapState } from "pinia";
|
|
|
|
import { useSettingStore } from "@/stores/admin/management/setting";
|
|
|
|
import AppIcon from "@/components/AppIcon.vue";
|
|
|
|
import AppLogo from "@/components/AppLogo.vue";
|
|
|
|
import { useAbilityStore } from "@/stores/ability";
|
|
|
|
import type { SettingString } from "@/types/settingTypes";
|
|
|
|
import BaseSetting from "./BaseSetting.vue";
|
2025-04-29 18:32:08 +02:00
|
|
|
import { XMarkIcon } from "@heroicons/vue/24/outline";
|
2025-04-29 13:10:30 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
export default defineComponent({
|
2025-04-29 18:32:08 +02:00
|
|
|
watch: {
|
|
|
|
clubSettings() {
|
|
|
|
this.reset();
|
|
|
|
},
|
|
|
|
},
|
2025-04-29 13:10:30 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2025-04-29 18:32:08 +02:00
|
|
|
logo: "",
|
|
|
|
icon: "",
|
2025-04-29 13:10:30 +02:00
|
|
|
overwriteIcon: false as boolean,
|
|
|
|
overwriteLogo: false as boolean,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState(useSettingStore, ["readByTopic"]),
|
|
|
|
...mapState(useAbilityStore, ["can"]),
|
|
|
|
clubSettings() {
|
|
|
|
return this.readByTopic("club");
|
|
|
|
},
|
|
|
|
},
|
2025-04-29 18:32:08 +02:00
|
|
|
mounted() {
|
|
|
|
this.reset();
|
|
|
|
},
|
2025-04-29 13:10:30 +02:00
|
|
|
methods: {
|
|
|
|
...mapActions(useSettingStore, ["updateSettings", "uploadImage"]),
|
2025-04-29 18:32:08 +02:00
|
|
|
reset() {
|
|
|
|
this.icon = this.clubSettings["club.icon"];
|
|
|
|
this.overwriteIcon = false;
|
|
|
|
(this.$refs.icon_img as HTMLImageElement).style.display = "none";
|
|
|
|
(this.$refs.icon as HTMLInputElement).value = "";
|
|
|
|
|
|
|
|
this.logo = this.clubSettings["club.logo"];
|
|
|
|
this.overwriteLogo = false;
|
|
|
|
(this.$refs.logo_img as HTMLImageElement).style.display = "none";
|
|
|
|
(this.$refs.logo as HTMLInputElement).value = "";
|
|
|
|
},
|
|
|
|
resetImage(inputname: "icon" | "logo") {
|
|
|
|
if (inputname == "icon") {
|
|
|
|
this.icon = "";
|
|
|
|
this.overwriteIcon = false;
|
|
|
|
(this.$refs.icon_img as HTMLImageElement).style.display = "none";
|
|
|
|
(this.$refs.icon as HTMLInputElement).value = "";
|
|
|
|
} else {
|
|
|
|
this.logo = "";
|
|
|
|
this.overwriteLogo = false;
|
|
|
|
(this.$refs.logo_img as HTMLImageElement).style.display = "none";
|
|
|
|
(this.$refs.logo as HTMLInputElement).value = "";
|
|
|
|
}
|
|
|
|
},
|
2025-04-29 13:10:30 +02:00
|
|
|
previewImage(inputname: "icon" | "logo") {
|
|
|
|
let input = this.$refs[inputname] as HTMLInputElement;
|
|
|
|
let previewElement = this.$refs[inputname + "_img"] as HTMLImageElement;
|
|
|
|
if (input.files && input.files[0]) {
|
|
|
|
const reader = new FileReader();
|
|
|
|
|
|
|
|
reader.onload = function (e) {
|
|
|
|
previewElement.src = e.target?.result as string;
|
|
|
|
previewElement.style.display = "block";
|
|
|
|
};
|
|
|
|
|
|
|
|
reader.readAsDataURL(input.files[0]);
|
2025-04-29 18:32:08 +02:00
|
|
|
|
|
|
|
if (inputname == "icon") {
|
|
|
|
this.overwriteIcon = true;
|
|
|
|
} else {
|
|
|
|
this.overwriteLogo = true;
|
|
|
|
}
|
2025-04-29 13:10:30 +02:00
|
|
|
} else {
|
|
|
|
previewElement.src = "";
|
|
|
|
previewElement.style.display = "none";
|
|
|
|
}
|
|
|
|
},
|
|
|
|
submit(e: any) {
|
|
|
|
return this.uploadImage([
|
|
|
|
{
|
2025-04-29 18:32:08 +02:00
|
|
|
key: "club.icon",
|
2025-04-30 10:43:11 +02:00
|
|
|
value:
|
|
|
|
(this.$refs.icon as HTMLInputElement).files?.[0] ??
|
|
|
|
(this.icon != "" && !this.overwriteIcon ? "keep" : undefined),
|
2025-04-29 13:10:30 +02:00
|
|
|
},
|
|
|
|
{
|
2025-04-29 18:32:08 +02:00
|
|
|
key: "club.logo",
|
2025-04-30 10:43:11 +02:00
|
|
|
value:
|
|
|
|
(this.$refs.logo as HTMLInputElement).files?.[0] ??
|
|
|
|
(this.logo != "" && !this.overwriteLogo ? "keep" : undefined),
|
2025-04-29 13:10:30 +02:00
|
|
|
},
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|