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,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user