From 625d2a2af198a82134db21daafa1ebda1b5cfbe2 Mon Sep 17 00:00:00 2001 From: Arthur Lefebvre Date: Fri, 3 Apr 2026 22:57:45 +0200 Subject: [PATCH] Add a view to see all books in a collection --- demodata.sql | 2 +- front/src/CollectionForm.vue | 51 ++++++++++++++++ front/src/CollectionFormBookItem.vue | 37 ++++++++++++ front/src/CollectionListElement.vue | 14 ++++- front/src/api.js | 5 ++ front/src/locales/en.json | 5 +- front/src/locales/fr.json | 3 + front/src/router.js | 2 + internal/adapter/adapter.go | 26 +++++++-- internal/apitest/fetchallcollections_test.go | 4 +- internal/apitest/get_book_test.go | 21 +------ internal/apitest/get_collection_test.go | 34 +++++++++++ internal/dto/out.go | 7 +++ internal/i18nresource/locale.en.toml | 4 +- internal/i18nresource/locale.fr.toml | 4 +- internal/query/query.go | 27 ++++++--- internal/routes/collectionget.go | 61 ++++++++++++++++++++ internal/routes/collectionsget.go | 2 +- internal/setup/setup.go | 3 + internal/testutils/testutils.go | 17 ++++++ 20 files changed, 285 insertions(+), 44 deletions(-) create mode 100644 front/src/CollectionForm.vue create mode 100644 front/src/CollectionFormBookItem.vue create mode 100644 internal/apitest/get_collection_test.go create mode 100644 internal/routes/collectionget.go diff --git a/demodata.sql b/demodata.sql index ac493ef..da6a9b1 100644 --- a/demodata.sql +++ b/demodata.sql @@ -129,7 +129,7 @@ INSERT INTO user_books(created_at, user_id, book_id, start_read_date, rating) VA -- collections INSERT INTO collections(name, user_id) VALUES ('Littérature française',(SELECT id FROM users WHERE name = 'demo')); INSERT INTO collections(name, user_id) VALUES ('Nouvelles',(SELECT id FROM users WHERE name = 'demo')); -INSERT INTO collections(name, user_id) VALUES ('Non fiction',(SELECT id FROM users WHERE name = 'demo')); +INSERT INTO collections(name, user_id) VALUES ('Non fiction',(SELECT id FROM users WHERE name = 'demo2')); INSERT INTO collection_books(collection_id, book_id) VALUES ((SELECT id FROM collections WHERE name = 'Littérature française'), (SELECT id FROM books WHERE title = 'Nord')); INSERT INTO collection_books(collection_id, book_id) VALUES ((SELECT id FROM collections WHERE name = 'Littérature française'), (SELECT id FROM books WHERE title = 'Gargantua')); diff --git a/front/src/CollectionForm.vue b/front/src/CollectionForm.vue new file mode 100644 index 0000000..7636d01 --- /dev/null +++ b/front/src/CollectionForm.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/front/src/CollectionFormBookItem.vue b/front/src/CollectionFormBookItem.vue new file mode 100644 index 0000000..57e9fca --- /dev/null +++ b/front/src/CollectionFormBookItem.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/front/src/CollectionListElement.vue b/front/src/CollectionListElement.vue index b513a14..1689024 100644 --- a/front/src/CollectionListElement.vue +++ b/front/src/CollectionListElement.vue @@ -1,26 +1,36 @@ + +