Add places / things-to-do list with admin management
Deploy with Docker Compose / deploy (push) Successful in 16m21s
Deploy with Docker Compose / deploy (push) Successful in 16m21s
Backend: new Place GORM model (title, location, notes, image, category, cost, priority, done) with auto-migration, a place.graphql schema, and resolvers for the places query plus admin-only create/update/delete. Regenerate gqlgen output against gqlgen v0.17.95, which requires Go 1.26 — bump go.mod and the builder image to match. Frontend: a places Pinia store, a CreatePlace admin form, and a PlacesTable rendered as a new tab in the Collage cell, with inline done-toggle and delete for admins. Rework the Admin page into a sidebar-navigated panel layout (picking up the previously unreachable CreateBookmark form) and give Login proper field labels, submit state, and error feedback. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KcFtkisHcKJuTZAnv3fVzA
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { gql } from "@/graphql";
|
||||
|
||||
const PLACE_FIELDS = `
|
||||
id
|
||||
title
|
||||
location
|
||||
notes
|
||||
imageUrl
|
||||
category
|
||||
cost
|
||||
priority
|
||||
done
|
||||
createdAt
|
||||
updatedAt
|
||||
`;
|
||||
|
||||
export const usePlacesStore = defineStore("places", () => {
|
||||
const places = ref([]);
|
||||
const loaded = ref(false);
|
||||
const loading = ref(false);
|
||||
const error = ref(null);
|
||||
|
||||
async function fetch() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await gql(`query Places { places { ${PLACE_FIELDS} } }`);
|
||||
places.value = data.places || [];
|
||||
loaded.value = true;
|
||||
error.value = null;
|
||||
} catch (err) {
|
||||
error.value = err;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function create(input) {
|
||||
const data = await gql(
|
||||
`mutation CreatePlace($input: CreatePlaceInput!) {
|
||||
createPlace(input: $input) { ${PLACE_FIELDS} }
|
||||
}`,
|
||||
{ input },
|
||||
);
|
||||
places.value = [data.createPlace, ...places.value];
|
||||
return data.createPlace;
|
||||
}
|
||||
|
||||
async function update(id, input) {
|
||||
const data = await gql(
|
||||
`mutation UpdatePlace($id: ID!, $input: UpdatePlaceInput!) {
|
||||
updatePlace(id: $id, input: $input) { ${PLACE_FIELDS} }
|
||||
}`,
|
||||
{ id, input },
|
||||
);
|
||||
const idx = places.value.findIndex((p) => p.id === id);
|
||||
if (idx >= 0) places.value[idx] = data.updatePlace;
|
||||
return data.updatePlace;
|
||||
}
|
||||
|
||||
async function toggleDone(place) {
|
||||
return update(place.id, { done: !place.done });
|
||||
}
|
||||
|
||||
async function remove(id) {
|
||||
await gql(
|
||||
`mutation DeletePlace($id: ID!) { deletePlace(id: $id) { id } }`,
|
||||
{ id },
|
||||
);
|
||||
places.value = places.value.filter((p) => p.id !== id);
|
||||
}
|
||||
|
||||
return {
|
||||
places,
|
||||
loaded,
|
||||
loading,
|
||||
error,
|
||||
fetch,
|
||||
create,
|
||||
update,
|
||||
toggleDone,
|
||||
remove,
|
||||
};
|
||||
});
|
||||
@@ -1,23 +1,147 @@
|
||||
<script setup>
|
||||
import { ref, computed } from "vue";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import Button from "@/components/input/Button.vue";
|
||||
|
||||
import CreateUser from "./CreateUser.vue";
|
||||
import CreatePost from "./CreatePost.vue";
|
||||
import CreateFavorite from "./CreateFavorite.vue";
|
||||
import CreateActivity from "./CreateActivity.vue";
|
||||
import CreateRowing from "./CreateRowing.vue";
|
||||
import CreateBookmark from "./CreateBookmark.vue";
|
||||
import CreatePlace from "./CreatePlace.vue";
|
||||
import ManageUsers from "./ManageUsers.vue";
|
||||
import ManageRadio from "./ManageRadio.vue";
|
||||
|
||||
const auth = useAuthStore();
|
||||
|
||||
const sections = [
|
||||
{ id: "user", label: "User", component: CreateUser },
|
||||
{ id: "post", label: "Post", component: CreatePost },
|
||||
{ id: "favorite", label: "Favorite", component: CreateFavorite },
|
||||
{ id: "activity", label: "Activity", component: CreateActivity },
|
||||
{ id: "rowing", label: "Rowing", component: CreateRowing },
|
||||
{ id: "bookmark", label: "Bookmark", component: CreateBookmark },
|
||||
{ id: "place", label: "Place / Thing To Do", component: CreatePlace },
|
||||
{ id: "users", label: "Manage Users", component: ManageUsers },
|
||||
{ id: "radio", label: "Manage Radio", component: ManageRadio },
|
||||
];
|
||||
|
||||
const active = ref("place");
|
||||
const activeSection = computed(() =>
|
||||
sections.find((s) => s.id === active.value),
|
||||
);
|
||||
|
||||
function handleLogout() {
|
||||
auth.logOut();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="justify-center flex flex-row w-full h-full">
|
||||
<div class="bdr-1 flex flex-col">
|
||||
<CreateUser class="bdr-2 bg-surface" />
|
||||
<CreatePost class="bdr-2 bg-surface" />
|
||||
<CreateFavorite class="bdr-2 bg-surface" />
|
||||
<CreateActivity class="bdr-2 bg-surface" />
|
||||
<CreateRowing class="bdr-2 bg-surface" />
|
||||
<ManageUsers class="bdr-2 bg-surface" />
|
||||
<ManageRadio class="bdr-2 bg-surface" />
|
||||
<main class="admin-page">
|
||||
<div class="admin-shell bdr-1">
|
||||
<header class="admin-header">
|
||||
<div class="flex flex-col">
|
||||
<h1>Admin</h1>
|
||||
<small v-if="auth.user?.username">
|
||||
signed in as {{ auth.user.username }}
|
||||
</small>
|
||||
</div>
|
||||
<Button @click="handleLogout">Log Out</Button>
|
||||
</header>
|
||||
|
||||
<div class="admin-body">
|
||||
<nav class="admin-nav">
|
||||
<button
|
||||
v-for="section in sections"
|
||||
:key="section.id"
|
||||
class="admin-nav-link"
|
||||
:class="{ 'is-active': active === section.id }"
|
||||
@click="active = section.id"
|
||||
>
|
||||
{{ section.label }}
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<section class="admin-panel bdr-2 bg-surface">
|
||||
<component :is="activeSection.component" />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.admin-page {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.admin-shell {
|
||||
width: 100%;
|
||||
max-width: 900px;
|
||||
background-color: var(--color-surface);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.admin-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 6px 12px;
|
||||
border-bottom: 1px solid var(--color-quaternary);
|
||||
}
|
||||
|
||||
.admin-body {
|
||||
display: grid;
|
||||
grid-template-columns: 200px 1fr;
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.admin-nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.admin-nav-link {
|
||||
text-align: left;
|
||||
padding: 6px 10px;
|
||||
color: var(--color-primary);
|
||||
background-color: var(--color-link-bg);
|
||||
border: 1px solid transparent;
|
||||
font-family: var(--font-heading);
|
||||
letter-spacing: 0.025em;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background-color 120ms ease,
|
||||
border-color 120ms ease,
|
||||
color 120ms ease;
|
||||
}
|
||||
.admin-nav-link:hover {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
.admin-nav-link.is-active {
|
||||
border-color: var(--color-primary);
|
||||
color: var(--color-tertiary);
|
||||
background-color: var(--color-surface-tint);
|
||||
}
|
||||
|
||||
.admin-panel {
|
||||
padding: 12px;
|
||||
min-height: 300px;
|
||||
}
|
||||
.admin-panel :deep(h1) {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.admin-body {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<script setup>
|
||||
import Button from "@/components/input/Button.vue";
|
||||
import { ref } from "vue";
|
||||
import { usePlacesStore } from "@/stores/places";
|
||||
|
||||
const emit = defineEmits(["done", "cancel"]);
|
||||
const places = usePlacesStore();
|
||||
|
||||
const title = ref("");
|
||||
const location = ref("");
|
||||
const category = ref("");
|
||||
const cost = ref("");
|
||||
const priority = ref(0);
|
||||
const imageUrl = ref("");
|
||||
const notes = ref("");
|
||||
const done = ref(false);
|
||||
const error = ref("");
|
||||
|
||||
async function submit() {
|
||||
if (!title.value.trim()) {
|
||||
error.value = "Title is required";
|
||||
return;
|
||||
}
|
||||
error.value = "";
|
||||
try {
|
||||
await places.create({
|
||||
title: title.value.trim(),
|
||||
location: location.value.trim() || null,
|
||||
category: category.value.trim() || null,
|
||||
cost: cost.value.trim() || null,
|
||||
priority: Number(priority.value) || 0,
|
||||
imageUrl: imageUrl.value.trim() || null,
|
||||
notes: notes.value.trim() || null,
|
||||
done: done.value,
|
||||
});
|
||||
title.value = "";
|
||||
location.value = "";
|
||||
category.value = "";
|
||||
cost.value = "";
|
||||
priority.value = 0;
|
||||
imageUrl.value = "";
|
||||
notes.value = "";
|
||||
done.value = false;
|
||||
emit("done");
|
||||
} catch (err) {
|
||||
error.value = err?.message || "Failed to save";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col">
|
||||
<h1>Add Place / Thing To Do</h1>
|
||||
<input
|
||||
type="text"
|
||||
v-model="title"
|
||||
placeholder="Title (required)"
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
v-model="location"
|
||||
placeholder="Location"
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
v-model="category"
|
||||
placeholder="Category (place, activity, food…)"
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
v-model="cost"
|
||||
placeholder="Cost (e.g. £20 pp)"
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
v-model="priority"
|
||||
placeholder="Priority (higher = sooner)"
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
v-model="imageUrl"
|
||||
placeholder="Image URL"
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
<textarea class="h-25" v-model="notes" placeholder="Notes"></textarea>
|
||||
<label class="flex flex-row items-center gap-2 p-2 text-primary">
|
||||
<input type="checkbox" v-model="done" class="w-auto" />
|
||||
Already done
|
||||
</label>
|
||||
<small v-if="error" class="p-1">{{ error }}</small>
|
||||
<Button @click="submit">Upload</Button>
|
||||
<Button @click="emit('cancel')">Cancel</Button>
|
||||
</div>
|
||||
</template>
|
||||
+119
-26
@@ -10,11 +10,23 @@ const router = useRouter();
|
||||
const route = useRoute();
|
||||
const username = ref("");
|
||||
const password = ref("");
|
||||
const submitting = ref(false);
|
||||
const errorMsg = ref("");
|
||||
|
||||
async function handleLogin() {
|
||||
await auth.logIn(username.value, password.value);
|
||||
if (auth.loggedIn && route.query.redirect) {
|
||||
router.push(route.query.redirect);
|
||||
if (submitting.value) return;
|
||||
submitting.value = true;
|
||||
errorMsg.value = "";
|
||||
try {
|
||||
await auth.logIn(username.value, password.value);
|
||||
if (auth.loggedIn) {
|
||||
const dest = route.query.redirect || "/admin";
|
||||
router.push(dest);
|
||||
} else {
|
||||
errorMsg.value = "Invalid username or password";
|
||||
}
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,27 +36,108 @@ function handleLogout() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="auth.loggedIn" class="flex flex-col">
|
||||
<h1>Logged in</h1>
|
||||
<p>{{ auth.user.id }}</p>
|
||||
<p>{{ auth.user.username }}</p>
|
||||
<p>{{ auth.user.admin }}</p>
|
||||
<Button @click="handleLogout">Log Out</Button>
|
||||
</div>
|
||||
<div v-else class="flex flex-col">
|
||||
<h1>Login</h1>
|
||||
<input
|
||||
type="text"
|
||||
v-model="username"
|
||||
placeholder="Username"
|
||||
@keyup.enter="handleLogin"
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
v-model="password"
|
||||
placeholder="Password"
|
||||
@keyup.enter="handleLogin"
|
||||
/>
|
||||
<Button @click="handleLogin">Log In</Button>
|
||||
</div>
|
||||
<main class="login-page">
|
||||
<div v-if="auth.loggedIn" class="login-card bdr-1">
|
||||
<h1>Already signed in</h1>
|
||||
<p>You're logged in as <code>{{ auth.user.username }}</code>.</p>
|
||||
<div class="login-actions">
|
||||
<Button @click="router.push('/admin')">Open Admin</Button>
|
||||
<Button @click="handleLogout">Log Out</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="login-card bdr-1">
|
||||
<h1>Login</h1>
|
||||
<small class="login-hint">
|
||||
Admin access is required beyond this point.
|
||||
</small>
|
||||
|
||||
<label class="login-field">
|
||||
<span>Username</span>
|
||||
<input
|
||||
type="text"
|
||||
v-model="username"
|
||||
autocomplete="username"
|
||||
placeholder="Username"
|
||||
@keyup.enter="handleLogin"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="login-field">
|
||||
<span>Password</span>
|
||||
<input
|
||||
type="password"
|
||||
v-model="password"
|
||||
autocomplete="current-password"
|
||||
placeholder="Password"
|
||||
@keyup.enter="handleLogin"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<small v-if="errorMsg" class="login-error">{{ errorMsg }}</small>
|
||||
|
||||
<Button @click="handleLogin" :disabled="submitting">
|
||||
{{ submitting ? "Signing in…" : "Log In" }}
|
||||
</Button>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.login-page {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 70vh;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: 100%;
|
||||
max-width: 380px;
|
||||
background-color: var(--color-surface);
|
||||
padding: 18px 20px 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.login-hint {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.login-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
.login-field span {
|
||||
font-family: var(--font-heading);
|
||||
color: var(--color-primary);
|
||||
letter-spacing: 0.05em;
|
||||
padding-left: 2px;
|
||||
}
|
||||
.login-field input {
|
||||
transition:
|
||||
border-color 120ms ease,
|
||||
box-shadow 120ms ease,
|
||||
background-color 120ms ease;
|
||||
}
|
||||
.login-field input:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-tertiary);
|
||||
box-shadow: 0 0 0 2px var(--color-quaternary);
|
||||
background-color: var(--color-surface-tint);
|
||||
}
|
||||
|
||||
.login-error {
|
||||
color: var(--color-tertiary);
|
||||
border: 1px dashed var(--color-tertiary);
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.login-actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,15 +1,137 @@
|
||||
<script setup>
|
||||
import { ref, computed } from "vue";
|
||||
import Slideshow from "@/components/util/Slideshow.vue";
|
||||
import PlacesTable from "./PlacesTable.vue";
|
||||
import CreatePlace from "@/views/admin/CreatePlace.vue";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
const images = [
|
||||
{ url: "/img/memes/pidgeon.gif", comment: "鸟" },
|
||||
// { url: "/img/memes/no_slip.png" },
|
||||
// { url: "/img/memes/epic.jpeg" },
|
||||
// { url: "/img/bedroom/img2.png", comment: "办公桌" },
|
||||
// { url: "/img/bedroom/img1.png", comment: "床" },
|
||||
const images = [{ url: "/img/memes/pidgeon.gif", comment: "鸟" }];
|
||||
|
||||
const tabs = [
|
||||
{ id: "collage", label: "鸟" },
|
||||
{ id: "places", label: "Places" },
|
||||
];
|
||||
|
||||
const activeTab = ref("collage");
|
||||
const showAdd = ref(false);
|
||||
|
||||
const auth = useAuthStore();
|
||||
const isAdmin = computed(() => !!auth.user?.admin);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Slideshow :images="images" />
|
||||
<div class="collage-cell">
|
||||
<div class="tabs">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:key="tab.id"
|
||||
class="tab"
|
||||
:class="{ 'is-active': activeTab === tab.id }"
|
||||
@click="activeTab = tab.id"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</button>
|
||||
<div class="tab-spacer" />
|
||||
<button
|
||||
v-if="isAdmin && activeTab === 'places'"
|
||||
class="tab add-btn"
|
||||
title="Add a place / thing to do"
|
||||
@click="showAdd = true"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="tab-body">
|
||||
<Slideshow v-if="activeTab === 'collage'" :images="images" />
|
||||
<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>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.collage-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 2px;
|
||||
padding: 2px;
|
||||
border-bottom: 1px solid var(--color-quaternary);
|
||||
background-color: var(--color-surface-deep);
|
||||
}
|
||||
|
||||
.tab {
|
||||
background-color: var(--color-link-bg);
|
||||
color: var(--color-primary);
|
||||
border: 1px solid transparent;
|
||||
padding: 2px 8px;
|
||||
font-family: var(--font-heading);
|
||||
letter-spacing: 0.05em;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background-color 120ms ease,
|
||||
border-color 120ms ease,
|
||||
color 120ms ease;
|
||||
}
|
||||
.tab:hover {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
.tab.is-active {
|
||||
border-color: var(--color-primary);
|
||||
color: var(--color-tertiary);
|
||||
background-color: var(--color-surface-tint);
|
||||
}
|
||||
|
||||
.tab-spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
min-width: 24px;
|
||||
padding: 0 6px;
|
||||
}
|
||||
|
||||
.tab-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
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>
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
<script setup>
|
||||
import { computed, onMounted } from "vue";
|
||||
import { usePlacesStore } from "@/stores/places";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
const places = usePlacesStore();
|
||||
const auth = useAuthStore();
|
||||
const isAdmin = computed(() => !!auth.user?.admin);
|
||||
|
||||
onMounted(() => {
|
||||
if (!places.loaded && !places.loading) places.fetch();
|
||||
});
|
||||
|
||||
async function toggleDone(place) {
|
||||
if (!isAdmin.value) return;
|
||||
try {
|
||||
await places.toggleDone(place);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(place) {
|
||||
if (!isAdmin.value) return;
|
||||
if (!confirm(`Delete "${place.title}"?`)) return;
|
||||
try {
|
||||
await places.remove(place.id);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="places-table">
|
||||
<p v-if="!places.loaded && places.loading" class="places-empty">
|
||||
Loading…
|
||||
</p>
|
||||
<p v-else-if="places.error" class="places-empty">
|
||||
Couldn't load places.
|
||||
</p>
|
||||
<p v-else-if="!places.places.length" class="places-empty">
|
||||
Nothing here yet — add somewhere to go.
|
||||
</p>
|
||||
<table v-else class="places">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th class="col-loc">Where</th>
|
||||
<th class="col-cat">Type</th>
|
||||
<th class="col-cost">Cost</th>
|
||||
<th v-if="isAdmin" class="col-act"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="place in places.places"
|
||||
:key="place.id"
|
||||
:class="{ 'is-done': place.done }"
|
||||
>
|
||||
<td>
|
||||
<div class="title-cell">
|
||||
<button
|
||||
v-if="isAdmin"
|
||||
class="done-toggle"
|
||||
:title="place.done ? 'Mark as pending' : 'Mark as done'"
|
||||
@click="toggleDone(place)"
|
||||
>
|
||||
{{ place.done ? "✓" : "○" }}
|
||||
</button>
|
||||
<span class="title-text">{{ place.title }}</span>
|
||||
</div>
|
||||
<small v-if="place.notes" class="notes">{{ place.notes }}</small>
|
||||
</td>
|
||||
<td class="col-loc">{{ place.location || "—" }}</td>
|
||||
<td class="col-cat">{{ place.category || "—" }}</td>
|
||||
<td class="col-cost">{{ place.cost || "—" }}</td>
|
||||
<td v-if="isAdmin" class="col-act">
|
||||
<button class="row-action" @click="remove(place)" title="Delete">
|
||||
×
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.places-table {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.places-empty {
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
color: var(--color-muted);
|
||||
}
|
||||
|
||||
table.places {
|
||||
width: 100%;
|
||||
border: none;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
table.places th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background-color: var(--color-surface);
|
||||
border-right: 1px dotted var(--color-tertiary);
|
||||
border-bottom: 1px solid var(--color-primary);
|
||||
padding: 4px 6px;
|
||||
text-align: left;
|
||||
font-family: var(--font-heading);
|
||||
}
|
||||
|
||||
table.places td {
|
||||
padding: 4px 6px;
|
||||
vertical-align: top;
|
||||
border-bottom: 1px dotted var(--color-quaternary);
|
||||
}
|
||||
|
||||
.title-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.title-text {
|
||||
color: var(--color-primary);
|
||||
font-family: var(--font-heading);
|
||||
}
|
||||
|
||||
.notes {
|
||||
display: block;
|
||||
color: var(--color-muted);
|
||||
font-size: 0.75rem;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
tr.is-done .title-text {
|
||||
text-decoration: line-through;
|
||||
color: var(--color-muted);
|
||||
}
|
||||
|
||||
.done-toggle,
|
||||
.row-action {
|
||||
background-color: transparent;
|
||||
color: var(--color-primary);
|
||||
border: 1px solid var(--color-quaternary);
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
font-family: var(--font-heading);
|
||||
padding: 0;
|
||||
}
|
||||
.done-toggle:hover,
|
||||
.row-action:hover {
|
||||
border-color: var(--color-tertiary);
|
||||
color: var(--color-tertiary);
|
||||
}
|
||||
|
||||
.col-cost,
|
||||
.col-cat {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.col-cost,
|
||||
.col-cat {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user