Open home widget create forms in popup modals
Deploy with Docker Compose / deploy (push) Successful in 23s
Weekly Maintenance / maintenance (push) Successful in 1m19s

The Places tab already popped its create form up over the page; every other
/stp widget swapped its contents for the form instead, which meant losing
sight of the list you were adding to and a cramped form inside a grid cell.

Extract the Places modal into a shared components/util/Modal.vue (teleported
backdrop, click-outside and Escape to close) and use it for the Feed, Bookmarks,
Favorites, Consumption and Rowing create forms as well. Widget headers keep
their normal titles now that each form carries its own heading in the modal.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KcFtkisHcKJuTZAnv3fVzA
This commit is contained in:
2026-09-12 18:50:17 +01:00
co-authored by Claude Opus 5
parent 894c158afd
commit fe6fc02b6b
9 changed files with 106 additions and 73 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
<script setup>
import { useAuthStore } from "@/stores/auth";
// "+" / "x" button, shown to admins only. Toggles a home widget between its
// normal view and its create form. Designed for <Header>'s #action slot.
// "+" / "x" button, shown to admins only. Opens a home widget's create form in
// a popup <Modal>. Designed for <Header>'s #action slot.
const show = defineModel({ type: Boolean, default: false });
const auth = useAuthStore();
</script>
+61
View File
@@ -0,0 +1,61 @@
<script setup>
import { watch, onUnmounted } from "vue";
// Popup modal: a dimmed backdrop over the page with the content floated on top.
// Closes on backdrop click or Escape. Used by the home widgets so their create
// forms pop up instead of replacing the widget's contents.
const open = defineModel({ type: Boolean, default: false });
const props = defineProps({
maxWidth: { type: String, default: "420px" },
});
function onKeydown(e) {
if (e.key === "Escape") open.value = false;
}
watch(
open,
(isOpen) => {
if (isOpen) {
window.addEventListener("keydown", onKeydown);
} else {
window.removeEventListener("keydown", onKeydown);
}
},
{ immediate: true },
);
onUnmounted(() => window.removeEventListener("keydown", onKeydown));
</script>
<template>
<Teleport to="body">
<div v-if="open" class="modal-backdrop" @click.self="open = false">
<div class="modal bdr-1" :style="{ maxWidth: props.maxWidth }">
<slot />
</div>
</div>
</Teleport>
</template>
<style scoped>
.modal-backdrop {
position: fixed;
inset: 0;
background-color: rgba(0, 0, 0, 0.65);
display: flex;
align-items: center;
justify-content: center;
z-index: 50;
padding: 12px;
}
.modal {
background-color: var(--color-surface);
padding: 16px;
width: 100%;
max-height: 90vh;
overflow-y: auto;
}
</style>
+9 -8
View File
@@ -1,6 +1,7 @@
<script setup>
import { computed, ref, defineAsyncComponent } from "vue";
import LinkTable from "@/components/util/LinkTable.vue";
import Modal from "@/components/util/Modal.vue";
import Header from "@/components/text/Header.vue";
import CreateToggle from "@/components/input/CreateToggle.vue";
import { useHomeDataStore } from "@/stores/homeData";
@@ -26,16 +27,10 @@ const groupedBookmarks = computed(() => {
<template>
<div class="bookmarks-wrapper">
<Header class="text-left">
{{ showCreate ? "Create Bookmark" : "Bookmarks" }}
Bookmarks
<template #action><CreateToggle v-model="showCreate" /></template>
</Header>
<CreateBookmark
v-if="showCreate"
class="flex-1 min-h-0 p-1"
@done="showCreate = false"
@cancel="showCreate = false"
/>
<div v-if="!showCreate" class="bookmarks-scroll">
<div class="bookmarks-scroll">
<LinkTable
v-for="group in groupedBookmarks"
:key="group[0]"
@@ -43,6 +38,12 @@ const groupedBookmarks = computed(() => {
:items="group[1]"
/>
</div>
<Modal v-model="showCreate">
<CreateBookmark
@done="showCreate = false"
@cancel="showCreate = false"
/>
</Modal>
</div>
</template>
+4 -30
View File
@@ -1,6 +1,7 @@
<script setup>
import { ref, computed } from "vue";
import Slideshow from "@/components/util/Slideshow.vue";
import Modal from "@/components/util/Modal.vue";
import PlacesTable from "./PlacesTable.vue";
import CreatePlace from "@/views/admin/CreatePlace.vue";
import { useAuthStore } from "@/stores/auth";
@@ -47,16 +48,9 @@ const isAdmin = computed(() => !!auth.user?.admin);
<PlacesTable v-else />
</div>
<Teleport to="body">
<div v-if="showAdd" class="modal-backdrop" @click.self="showAdd = false">
<div class="modal bdr-1">
<CreatePlace
@done="showAdd = false"
@cancel="showAdd = false"
/>
</div>
</div>
</Teleport>
<Modal v-model="showAdd">
<CreatePlace @done="showAdd = false" @cancel="showAdd = false" />
</Modal>
</div>
</template>
@@ -114,24 +108,4 @@ const isAdmin = computed(() => !!auth.user?.admin);
position: relative;
overflow: hidden;
}
.modal-backdrop {
position: fixed;
inset: 0;
background-color: rgba(0, 0, 0, 0.65);
display: flex;
align-items: center;
justify-content: center;
z-index: 50;
padding: 12px;
}
.modal {
background-color: var(--color-surface);
padding: 16px;
width: 100%;
max-width: 420px;
max-height: 90vh;
overflow-y: auto;
}
</style>
+9 -8
View File
@@ -1,5 +1,6 @@
<script setup>
import AutoScroll from "@/components/util/AutoScroll.vue";
import Modal from "@/components/util/Modal.vue";
import LinkTable from "@/components/util/LinkTable.vue";
import Header from "@/components/text/Header.vue";
import CreateToggle from "@/components/input/CreateToggle.vue";
@@ -18,21 +19,21 @@ const showCreate = ref(false);
<template>
<div class="flex flex-col items-center">
<Header>
{{ showCreate ? "Create Activity" : "Consumption" }}
Consumption
<template #action><CreateToggle v-model="showCreate" /></template>
</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">
<AutoScroll class="flex-1 w-full">
<LinkTable
variant="table"
class="w-full"
:items="activityStore.activity"
/>
</AutoScroll>
<Modal v-model="showCreate">
<CreateActivity
@done="showCreate = false"
@cancel="showCreate = false"
/>
</Modal>
</div>
</template>
+9 -8
View File
@@ -3,6 +3,7 @@ import Header from "@/components/text/Header.vue";
import CreateToggle from "@/components/input/CreateToggle.vue";
import LinkTable from "@/components/util/LinkTable.vue";
import AutoScroll from "@/components/util/AutoScroll.vue";
import Modal from "@/components/util/Modal.vue";
import { ref, defineAsyncComponent } from "vue";
import { useFavoritesStore } from "@/stores/favorites";
@@ -18,21 +19,21 @@ const showCreate = ref(false);
<template>
<div class="flex flex-col items-center">
<Header>
{{ showCreate ? "Create Favorite" : "favs" }}
favs
<template #action><CreateToggle v-model="showCreate" /></template>
</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">
<AutoScroll class="w-full flex-1">
<LinkTable
variant="table"
class="w-full"
:items="favoritesStore.favorites"
/>
</AutoScroll>
<Modal v-model="showCreate">
<CreateFavorite
@done="showCreate = false"
@cancel="showCreate = false"
/>
</Modal>
</div>
</template>
+5 -8
View File
@@ -1,6 +1,7 @@
<script setup>
import Button from "@/components/input/Button.vue";
import Markdown from "@/components/util/Markdown.vue";
import Modal from "@/components/util/Modal.vue";
import Header from "@/components/text/Header.vue";
import CreateToggle from "@/components/input/CreateToggle.vue";
@@ -46,17 +47,10 @@ function deletePost() {
<template>
<div class="flex flex-col flex-1 min-h-0">
<Header>
{{ showCreate ? "Create Post" : post.title }}
{{ post.title }}
<template #action><CreateToggle v-model="showCreate" /></template>
</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>Created at: {{ new Date(post.createdAt).toLocaleString() }}</small>
@@ -74,6 +68,9 @@ function deletePost() {
>Delete</Button
>
</div>
<Modal v-model="showCreate" max-width="560px">
<CreatePost @done="showCreate = false" @cancel="showCreate = false" />
</Modal>
</div>
</template>
+6 -8
View File
@@ -1,6 +1,7 @@
<script setup>
import { ref, computed, defineAsyncComponent } from "vue";
import Header from "@/components/text/Header.vue";
import Modal from "@/components/util/Modal.vue";
import CreateToggle from "@/components/input/CreateToggle.vue";
import { useHomeDataStore } from "@/stores/homeData";
import { storeToRefs } from "pinia";
@@ -116,17 +117,14 @@ function formatValue(key, val) {
<template>
<div class="flex flex-col h-full overflow-hidden">
<Header>
{{ showCreate ? "Upload Rowing" : "Rowing" }}
Rowing
<template #action><CreateToggle v-model="showCreate" /></template>
</Header>
<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">
<Modal v-model="showCreate">
<CreateRowing @done="showCreate = false" @cancel="showCreate = false" />
</Modal>
<div v-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">