From 2d3d4cd1b8189a1020230bf9cbe00193e18f3587 Mon Sep 17 00:00:00 2001 From: Dylan Will <58506115+ChargrilledChook@users.noreply.github.com> Date: Tue, 2 Jan 2024 12:24:12 +1100 Subject: [PATCH 1/2] Backend: Basic plumbing for bookmark feature Add basic bookmark component Add routes Add title delegator to bookmark model Add basic bookmark controller Add bookmark to lessons controller Add first pass basic bookmark button component Placeholder basic bookmark index page Add bookmark component to lesson buttons Get button working roughly with turbo stream --- .../bookmarks/button_component.html.erb | 10 ++++ app/components/bookmarks/button_component.rb | 29 +++++++++++ app/controllers/lessons_controller.rb | 16 +++++- app/controllers/users/bookmarks_controller.rb | 50 +++++++++++++++++++ app/models/bookmark.rb | 8 +++ app/models/lesson.rb | 1 + app/models/user.rb | 2 + app/views/lessons/_lesson_buttons.html.erb | 1 + app/views/lessons/show.html.erb | 2 +- .../users/bookmarks/create.turbo_stream.erb | 5 ++ .../users/bookmarks/destroy.turbo_stream.erb | 5 ++ app/views/users/bookmarks/index.html.erb | 16 ++++++ config/routes.rb | 1 + db/migrate/20231231013215_create_bookmarks.rb | 12 +++++ db/schema.rb | 14 +++++- spec/factories/bookmarks.rb | 6 +++ spec/models/bookmark_spec.rb | 23 +++++++++ spec/models/lesson_spec.rb | 1 + spec/models/user_spec.rb | 2 + 19 files changed, 200 insertions(+), 4 deletions(-) create mode 100644 app/components/bookmarks/button_component.html.erb create mode 100644 app/components/bookmarks/button_component.rb create mode 100644 app/controllers/users/bookmarks_controller.rb create mode 100644 app/models/bookmark.rb create mode 100644 app/views/users/bookmarks/create.turbo_stream.erb create mode 100644 app/views/users/bookmarks/destroy.turbo_stream.erb create mode 100644 app/views/users/bookmarks/index.html.erb create mode 100644 db/migrate/20231231013215_create_bookmarks.rb create mode 100644 spec/factories/bookmarks.rb create mode 100644 spec/models/bookmark_spec.rb diff --git a/app/components/bookmarks/button_component.html.erb b/app/components/bookmarks/button_component.html.erb new file mode 100644 index 0000000000..771f6a398a --- /dev/null +++ b/app/components/bookmarks/button_component.html.erb @@ -0,0 +1,10 @@ +