feat(hunt): add public flag to hunts and implement hunt creation page
- Add 'public' boolean column to Hunt model with default true - Update hunt admin UI to toggle 'public' flag - Implement new hunt creation page with form supporting all hunt properties - Add sidebar navigation item for hunt creation for authorized users - Adjust home API to filter hunts by public flag only
This commit is contained in:
+29
-7
@@ -36,11 +36,11 @@
|
||||
},
|
||||
"enums": {
|
||||
"text_type": {
|
||||
"CHAR": "Ein Zeichen",
|
||||
"INTEGER": "Ganzzahl",
|
||||
"NUMBER": "Zahl",
|
||||
"TEXT": "Freitext",
|
||||
"WORD": "Ein Wort",
|
||||
"CHAR": "Ein Zeichen"
|
||||
"WORD": "Ein Wort"
|
||||
},
|
||||
"user_role": {
|
||||
"ADMIN": "Admin",
|
||||
@@ -80,6 +80,28 @@
|
||||
"refresh": "Aktualisieren",
|
||||
"update_btn": "Updaten"
|
||||
},
|
||||
"create_hunt": {
|
||||
"allow_join": "Beitreten erlauben",
|
||||
"create_btn": "Hunt erstellen",
|
||||
"de": "Deutsch",
|
||||
"description_de": "Beschreibung (Deutsch)",
|
||||
"description_en": "Beschreibung (Englisch)",
|
||||
"en": "Englisch",
|
||||
"end": "Ende",
|
||||
"has_end": "Hat ein Enddatum?",
|
||||
"has_start": "Hat ein Startdatum?",
|
||||
"name_de": "Name (Deutsch)",
|
||||
"name_en": "Name (Englisch)",
|
||||
"not_allowed": "Du benötigst die Creator- oder Admin-Rolle, um Hunts zu erstellen.",
|
||||
"public": "Öffentlich (auf der Startseite sichtbar)",
|
||||
"reveal_answers": "Antworten aufdecken",
|
||||
"reveal_quests": "Quests aufdecken",
|
||||
"sidebar": "Hunt erstellen",
|
||||
"start": "Start",
|
||||
"success": "Hunt erfolgreich erstellt!",
|
||||
"title": "Neuen Hunt erstellen",
|
||||
"virtual": "Virtueller Hunt"
|
||||
},
|
||||
"diashow": {
|
||||
"head": "Diashow"
|
||||
},
|
||||
@@ -129,11 +151,11 @@
|
||||
"title": "Impressum"
|
||||
},
|
||||
"pictures": {
|
||||
"head": "Bilderwand",
|
||||
"select_team": "Wähle ein Team",
|
||||
"filter_quest": "Filtere Bilder nach Quests",
|
||||
"filter_team": "Filtere Bilder nach Teams",
|
||||
"head": "Bilderwand",
|
||||
"select_quest": "Wähle eine Quest",
|
||||
"filter_quest": "Filtere Bilder nach Quests"
|
||||
"select_team": "Wähle ein Team"
|
||||
},
|
||||
"profile": {
|
||||
"admins_and_creators": "Admins & Ersteller",
|
||||
@@ -144,8 +166,8 @@
|
||||
"promote": "Befördern",
|
||||
"promote_user": "Benutzer befördern",
|
||||
"role": "Rolle",
|
||||
"role_changed": "Rolle aktualisiert!",
|
||||
"role_change_error": "Rolle konnte nicht geändert werden!",
|
||||
"role_changed": "Rolle aktualisiert!",
|
||||
"role_confirm": "Möchtest du die Rolle von {name} zu {role} ändern?",
|
||||
"search_user": "Benutzer per E-Mail suchen...",
|
||||
"uploaded_pictures": "Hochgeladene Bilder",
|
||||
@@ -273,4 +295,4 @@
|
||||
"uploadFile": "Datei hochladen",
|
||||
"voteRating": "vote rating {value} of {max}"
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
-7
@@ -36,11 +36,11 @@
|
||||
},
|
||||
"enums": {
|
||||
"text_type": {
|
||||
"CHAR": "One character",
|
||||
"INTEGER": "Whole number",
|
||||
"NUMBER": "Number",
|
||||
"TEXT": "Free text",
|
||||
"WORD": "One word",
|
||||
"CHAR": "One character"
|
||||
"WORD": "One word"
|
||||
},
|
||||
"user_role": {
|
||||
"ADMIN": "Admin",
|
||||
@@ -80,6 +80,28 @@
|
||||
"refresh": "Refresh",
|
||||
"update_btn": "Update"
|
||||
},
|
||||
"create_hunt": {
|
||||
"allow_join": "Allow joining",
|
||||
"create_btn": "Create Hunt",
|
||||
"de": "German",
|
||||
"description_de": "Description (German)",
|
||||
"description_en": "Description (English)",
|
||||
"en": "English",
|
||||
"end": "End",
|
||||
"has_end": "Has end date?",
|
||||
"has_start": "Has start date?",
|
||||
"name_de": "Name (German)",
|
||||
"name_en": "Name (English)",
|
||||
"not_allowed": "You need the Creator or Admin role to create hunts.",
|
||||
"public": "Public (visible on home page)",
|
||||
"reveal_answers": "Reveal answers",
|
||||
"reveal_quests": "Reveal quests",
|
||||
"sidebar": "Create Hunt",
|
||||
"start": "Start",
|
||||
"success": "Hunt created successfully!",
|
||||
"title": "Create a new Hunt",
|
||||
"virtual": "Virtual hunt"
|
||||
},
|
||||
"diashow": {
|
||||
"head": "Diashow"
|
||||
},
|
||||
@@ -129,11 +151,11 @@
|
||||
"title": "Imprint"
|
||||
},
|
||||
"pictures": {
|
||||
"head": "Picture wall",
|
||||
"select_team": "Select a team",
|
||||
"filter_quest": "Filter pictures by quests",
|
||||
"filter_team": "Filter pictures by teams",
|
||||
"head": "Picture wall",
|
||||
"select_quest": "Select a quest",
|
||||
"filter_quest": "Filter pictures by quests"
|
||||
"select_team": "Select a team"
|
||||
},
|
||||
"profile": {
|
||||
"admins_and_creators": "Admins & Creators",
|
||||
@@ -144,8 +166,8 @@
|
||||
"promote": "Promote",
|
||||
"promote_user": "Promote a user",
|
||||
"role": "Role",
|
||||
"role_changed": "Role updated!",
|
||||
"role_change_error": "Could not change role!",
|
||||
"role_changed": "Role updated!",
|
||||
"role_confirm": "Do you want to change the role of {name} to {role}?",
|
||||
"search_user": "Search user by email...",
|
||||
"uploaded_pictures": "Uploaded pictures",
|
||||
@@ -273,4 +295,4 @@
|
||||
"uploadFile": "Upload file",
|
||||
"voteRating": "vote rating {value} of {max}"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,18 @@ const isHuntAdmin = computed(
|
||||
<VaSidebarItemTitle>Home</VaSidebarItemTitle>
|
||||
</VaSidebarItemContent>
|
||||
</VaSidebarItem>
|
||||
<VaSidebarItem
|
||||
v-if="user?.role === 'CREATOR' || user?.role === 'ADMIN'"
|
||||
:to="localePath('/admin/hunt/create')"
|
||||
:active="localePath('/admin/hunt/create') === route.path"
|
||||
>
|
||||
<VaSidebarItemContent>
|
||||
<VaIcon name="add_circle" />
|
||||
<VaSidebarItemTitle>{{
|
||||
t('page.create_hunt.sidebar')
|
||||
}}</VaSidebarItemTitle>
|
||||
</VaSidebarItemContent>
|
||||
</VaSidebarItem>
|
||||
<VaSidebarItem
|
||||
:to="localePath('/impressum')"
|
||||
:active="localePath('/impressum') === route.path"
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
<script setup lang="ts">
|
||||
import { sluggy } from '#imports';
|
||||
|
||||
definePageMeta({
|
||||
middleware: ['auth']
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const { user } = useUserSession();
|
||||
const localePath = useLocalePath();
|
||||
const router = useRouter();
|
||||
const { init } = useToast();
|
||||
const validation = useValidation();
|
||||
|
||||
const canCreate = computed(
|
||||
() => user.value?.role === 'CREATOR' || user.value?.role === 'ADMIN'
|
||||
);
|
||||
|
||||
const form = reactive({
|
||||
name_de: '',
|
||||
name_en: '',
|
||||
description_de: '',
|
||||
description_en: '',
|
||||
virtual: false,
|
||||
start: null as Date | null,
|
||||
end: null as Date | null,
|
||||
allowJoin: false,
|
||||
revealQuests: false,
|
||||
revealAnswers: false,
|
||||
public: true
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
const formError = ref('');
|
||||
|
||||
async function submit() {
|
||||
loading.value = true;
|
||||
formError.value = '';
|
||||
|
||||
try {
|
||||
const hunt = await $fetch('/api/admin/hunt', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
...form,
|
||||
start: form.start?.toISOString() ?? null,
|
||||
end: form.end?.toISOString() ?? null
|
||||
}
|
||||
});
|
||||
|
||||
init({
|
||||
message: t('page.create_hunt.success'),
|
||||
color: 'success'
|
||||
});
|
||||
|
||||
await router.push(
|
||||
localePath(`/hunt/${sluggy({ id: hunt.id, name: hunt.name_de })}/admin`)
|
||||
);
|
||||
} catch (e) {
|
||||
formError.value = parseError(e);
|
||||
}
|
||||
|
||||
loading.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mx-auto max-w-2xl">
|
||||
<VaAlert v-if="!canCreate" color="warning" class="mb-4">
|
||||
{{ t('page.create_hunt.not_allowed') }}
|
||||
</VaAlert>
|
||||
<VaCard v-else stripe stripe-color="success">
|
||||
<VaCardTitle>{{ t('page.create_hunt.title') }}</VaCardTitle>
|
||||
<VaCardContent>
|
||||
<VaForm class="flex flex-col gap-4">
|
||||
<div class="grid grid-cols-1 gap-2 md:grid-cols-2">
|
||||
<h3 class="text-center">{{ t('page.create_hunt.de') }}</h3>
|
||||
<h3 class="text-center">{{ t('page.create_hunt.en') }}</h3>
|
||||
<VaInput
|
||||
v-model="form.name_de"
|
||||
:label="t('page.create_hunt.name_de')"
|
||||
:rules="[
|
||||
validation.required(t('page.create_hunt.name_de')),
|
||||
validation.max(t('page.create_hunt.name_de'), 256)
|
||||
]"
|
||||
counter
|
||||
max-length="256"
|
||||
/>
|
||||
<VaInput
|
||||
v-model="form.name_en"
|
||||
:label="t('page.create_hunt.name_en')"
|
||||
:rules="[
|
||||
validation.required(t('page.create_hunt.name_en')),
|
||||
validation.max(t('page.create_hunt.name_en'), 256)
|
||||
]"
|
||||
counter
|
||||
max-length="256"
|
||||
/>
|
||||
<VaTextarea
|
||||
v-model="form.description_de"
|
||||
:label="t('page.create_hunt.description_de')"
|
||||
max-length="1000"
|
||||
/>
|
||||
<VaTextarea
|
||||
v-model="form.description_en"
|
||||
:label="t('page.create_hunt.description_en')"
|
||||
max-length="1000"
|
||||
/>
|
||||
</div>
|
||||
<VaCheckbox
|
||||
v-model="form.virtual"
|
||||
:label="t('page.create_hunt.virtual')"
|
||||
/>
|
||||
<VaCheckbox
|
||||
v-model="form.public"
|
||||
:label="t('page.create_hunt.public')"
|
||||
/>
|
||||
<VaCheckbox
|
||||
v-model="form.allowJoin"
|
||||
:label="t('page.create_hunt.allow_join')"
|
||||
/>
|
||||
<VaCheckbox
|
||||
v-model="form.revealQuests"
|
||||
:label="t('page.create_hunt.reveal_quests')"
|
||||
/>
|
||||
<VaCheckbox
|
||||
v-model="form.revealAnswers"
|
||||
:label="t('page.create_hunt.reveal_answers')"
|
||||
/>
|
||||
<hr />
|
||||
<div class="flex flex-row gap-2">
|
||||
<VaCheckbox
|
||||
:label="t('page.create_hunt.has_start')"
|
||||
:model-value="!!form.start"
|
||||
@update:model-value="
|
||||
(newVal: boolean) => (form.start = newVal ? new Date() : null)
|
||||
"
|
||||
/>
|
||||
<VaDateInput
|
||||
v-if="form.start"
|
||||
v-model="form.start"
|
||||
:label="t('page.create_hunt.start')"
|
||||
manual-input
|
||||
/>
|
||||
<VaTimeInput
|
||||
v-if="form.start"
|
||||
v-model="form.start"
|
||||
:label="t('page.create_hunt.start')"
|
||||
view="seconds"
|
||||
manual-input
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-row gap-2">
|
||||
<VaCheckbox
|
||||
:label="t('page.create_hunt.has_end')"
|
||||
:model-value="!!form.end"
|
||||
@update:model-value="
|
||||
(newVal: boolean) => (form.end = newVal ? new Date() : null)
|
||||
"
|
||||
/>
|
||||
<VaDateInput
|
||||
v-if="form.end"
|
||||
v-model="form.end"
|
||||
:label="t('page.create_hunt.end')"
|
||||
manual-input
|
||||
/>
|
||||
<VaTimeInput
|
||||
v-if="form.end"
|
||||
v-model="form.end"
|
||||
:label="t('page.create_hunt.end')"
|
||||
view="seconds"
|
||||
manual-input
|
||||
/>
|
||||
</div>
|
||||
<VaAlert
|
||||
v-if="formError.length > 0"
|
||||
color="danger"
|
||||
class="w-full text-center"
|
||||
>{{ t(formError) }}</VaAlert
|
||||
>
|
||||
<VaButton
|
||||
:loading="loading"
|
||||
:disabled="
|
||||
loading || form.name_de.length < 1 || form.name_en.length < 1
|
||||
"
|
||||
color="success"
|
||||
icon="add"
|
||||
@click="submit"
|
||||
>{{ t('page.create_hunt.create_btn') }}</VaButton
|
||||
>
|
||||
</VaForm>
|
||||
</VaCardContent>
|
||||
</VaCard>
|
||||
</div>
|
||||
</template>
|
||||
@@ -253,6 +253,7 @@ async function deleteImage() {
|
||||
clearable-icon="replay"
|
||||
/>
|
||||
<VaCheckbox v-model="formData.cloned.value.virtual" label="Virtual" />
|
||||
<VaCheckbox v-model="formData.cloned.value.public" label="Public" />
|
||||
<VaCheckbox
|
||||
v-model="formData.cloned.value.allowJoin"
|
||||
label="Allow Join"
|
||||
|
||||
Reference in New Issue
Block a user