Add inline admin create forms to home page components
Deploy with Docker Compose / deploy (push) Successful in 28s

Lazy-load create forms (Post, Activity, Favorite, Rowing) directly
into their corresponding home components with an admin-only toggle
button, replacing the need to navigate to the admin page.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
2026-04-13 12:13:13 +01:00
co-authored by Claude Sonnet 4.6
parent 66f32cdbd2
commit a911e6ca69
8 changed files with 78 additions and 10 deletions
+16 -2
View File
@@ -3,15 +3,29 @@ import AutoScroll from "@/components/util/AutoScroll.vue";
import LinkTable from "@/components/util/LinkTable.vue";
import Header from "@/components/text/Header.vue";
import { ref, defineAsyncComponent } from "vue";
import { useActivityStore } from "@/stores/activity";
import { useAuthStore } from "@/stores/auth";
const CreateActivity = defineAsyncComponent(() => import("@/views/admin/CreateActivity.vue"));
const activityStore = useActivityStore();
const authStore = useAuthStore();
const showCreate = ref(false);
</script>
<template>
<div class="flex flex-col items-center">
<Header>Consumption</Header>
<AutoScroll class="flex-1 w-full">
<Header>
<span class="flex items-center justify-between w-full">
{{ showCreate ? "Create Activity" : "Consumption" }}
<button v-if="authStore.user.admin" class="text-sm px-1" @click="showCreate = !showCreate">
{{ showCreate ? "x" : "+" }}
</button>
</span>
</Header>
<CreateActivity v-if="showCreate" class="flex-1 w-full p-1" @done="showCreate = false" @cancel="showCreate = false" />
<AutoScroll v-if="!showCreate" class="flex-1 w-full">
<LinkTable variant="table" class="w-full" :items="activityStore.activity" />
</AutoScroll>
</div>
+16 -2
View File
@@ -3,15 +3,29 @@ import Header from "@/components/text/Header.vue";
import LinkTable from "@/components/util/LinkTable.vue";
import AutoScroll from "@/components/util/AutoScroll.vue";
import { ref, defineAsyncComponent } from "vue";
import { useFavoritesStore } from "@/stores/favorites";
import { useAuthStore } from "@/stores/auth";
const CreateFavorite = defineAsyncComponent(() => import("@/views/admin/CreateFavorite.vue"));
const favoritesStore = useFavoritesStore();
const authStore = useAuthStore();
const showCreate = ref(false);
</script>
<template>
<div class="flex flex-col items-center">
<Header>favs</Header>
<AutoScroll class="w-full flex-1">
<Header>
<span class="flex items-center justify-between w-full">
{{ showCreate ? "Create Favorite" : "favs" }}
<button v-if="authStore.user.admin" class="text-sm px-1" @click="showCreate = !showCreate">
{{ showCreate ? "x" : "+" }}
</button>
</span>
</Header>
<CreateFavorite v-if="showCreate" class="w-full flex-1 p-1" @done="showCreate = false" @cancel="showCreate = false" />
<AutoScroll v-if="!showCreate" class="w-full flex-1">
<LinkTable
variant="table"
class="w-full"
+14 -2
View File
@@ -3,14 +3,17 @@ import Button from "@/components/input/Button.vue";
import Markdown from "@/components/util/Markdown.vue";
import Header from "@/components/text/Header.vue";
import { ref, computed, onBeforeMount } from "vue";
import { ref, computed, defineAsyncComponent } from "vue";
import { useAuthStore } from "@/stores/auth";
import { usePostsStore } from "@/stores/posts";
const CreatePost = defineAsyncComponent(() => import("@/views/admin/CreatePost.vue"));
const authStore = useAuthStore();
const postsStore = usePostsStore();
const idx = ref(0);
const showCreate = ref(false);
const leftCap = computed(() => idx.value === 0);
const rightCap = computed(() => idx.value === postsStore.postsCount - 1);
@@ -39,8 +42,17 @@ function deletePost() {
<template>
<div class="flex flex-col flex-1 min-h-0">
<Header>{{ post.title }}</Header>
<Header>
<span class="flex items-center justify-between w-full">
{{ showCreate ? "Create Post" : post.title }}
<button v-if="authStore.user.admin" class="text-sm px-1" @click="showCreate = !showCreate">
{{ showCreate ? "x" : "+" }}
</button>
</span>
</Header>
<CreatePost v-if="showCreate" class="flex-1 min-h-0 p-1" @done="showCreate = false" @cancel="showCreate = false" />
<div
v-if="!showCreate"
class="flex flex-col flex-1 min-h-0 p-1 overflow-auto text-left items-start justify-start"
>
<small
+16 -3
View File
@@ -1,11 +1,16 @@
<script setup>
import { ref, computed } from "vue";
import { ref, computed, defineAsyncComponent } from "vue";
import Header from "@/components/text/Header.vue";
import { useHomeDataStore } from "@/stores/homeData";
import { useAuthStore } from "@/stores/auth";
import { storeToRefs } from "pinia";
const CreateRowing = defineAsyncComponent(() => import("@/views/admin/CreateRowing.vue"));
const store = useHomeDataStore();
const authStore = useAuthStore();
const { loaded, error, rowingSessions } = storeToRefs(store);
const showCreate = ref(false);
const rows = computed(() => rowingSessions.value.slice().reverse());
const loading = computed(() => !loaded.value);
@@ -109,9 +114,17 @@ function formatValue(key, val) {
<template>
<div class="flex flex-col h-full overflow-hidden">
<Header>Rowing</Header>
<Header>
<span class="flex items-center justify-between w-full">
{{ showCreate ? "Upload Rowing" : "Rowing" }}
<button v-if="authStore.user.admin" class="text-sm px-1" @click="showCreate = !showCreate">
{{ showCreate ? "x" : "+" }}
</button>
</span>
</Header>
<div v-if="loading" class="flex-1 flex items-center justify-center">
<CreateRowing v-if="showCreate" class="flex-1 p-1" @done="showCreate = false" @cancel="showCreate = false" />
<div v-else-if="loading" class="flex-1 flex items-center justify-center">
<p>Loading...</p>
</div>
<div v-else-if="error" class="flex-1 flex items-center justify-center">