Add reminder about unread bookmarks
This commit is contained in:
15
slices/admin/actions/bookmarks/mark_read.rb
Normal file
15
slices/admin/actions/bookmarks/mark_read.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Admin
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class MarkRead < Action
|
||||
include Deps["repos.bookmark_repo"]
|
||||
|
||||
def handle(req, res)
|
||||
bookmark_id = req.params[:id]
|
||||
|
||||
bookmark_repo.mark_read(id: bookmark_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
15
slices/admin/actions/bookmarks/mark_unread.rb
Normal file
15
slices/admin/actions/bookmarks/mark_unread.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Admin
|
||||
module Actions
|
||||
module Bookmarks
|
||||
class MarkUnread < Action
|
||||
include Deps["repos.bookmark_repo"]
|
||||
|
||||
def handle(req, res)
|
||||
bookmark_id = req.params[:id]
|
||||
|
||||
bookmark_repo.mark_unread(id: bookmark_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -42,6 +42,8 @@ module Admin
|
||||
post "/bookmarks/cache/:id", to: Auth.call(action: "bookmarks.cache")
|
||||
post "/bookmarks/:id/archive", to: Auth.call(action: "bookmarks.archive")
|
||||
post "/bookmarks/:id/publish", to: Auth.call(action: "bookmarks.publish")
|
||||
post "/bookmarks/:id/mark_read", to: Auth.call(action: "bookmarks.mark_read")
|
||||
post "/bookmarks/:id/mark_unread", to: Auth.call(action: "bookmarks.mark_unread")
|
||||
|
||||
get "/posts", to: Auth.call(action: "posts.index")
|
||||
delete "/posts/:id", to: Auth.call(action: "posts.delete")
|
||||
|
@@ -34,6 +34,14 @@ module Admin
|
||||
def update(id:, params:)
|
||||
posts.where(id: id).update(params)
|
||||
end
|
||||
|
||||
def mark_read(id:)
|
||||
posts.where(id: id).update(is_read: true)
|
||||
end
|
||||
|
||||
def mark_unread(id:)
|
||||
posts.where(id: id).update(is_read: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -13,7 +13,7 @@ div class="max-w-prose mx-auto" x-data="{ activeTab: 0 }"
|
||||
thead
|
||||
th Details
|
||||
th Date
|
||||
th colspan="2" Actions
|
||||
th colspan="3" Actions
|
||||
tbody class="{ 'active': activeTab === 0 }" x-show.transition.in.opacity.duration.600="activeTab === 0"
|
||||
- published_bookmarks.each do |bookmark|
|
||||
tr id="bookmark-#{bookmark.id}"
|
||||
@@ -36,6 +36,11 @@ div class="max-w-prose mx-auto" x-data="{ activeTab: 0 }"
|
||||
button class="text-red-600" hx-delete="/admin/bookmarks/#{bookmark.id}" hx-target="#bookmark-#{bookmark.id}" delete
|
||||
td
|
||||
button hx-post="/admin/bookmarks/#{bookmark.id}/archive" archive
|
||||
td
|
||||
- if bookmark.is_read
|
||||
button hx-post="/admin/bookmarks/#{bookmark.id}/mark_unread" mark unread
|
||||
- else
|
||||
button hx-post="/admin/bookmarks/#{bookmark.id}/mark_read" mark read
|
||||
tbody class="{ 'active': activeTab === 1 }" x-show.transition.in.opacity.duration.600="activeTab === 1"
|
||||
- unpublished_bookmarks.each do |bookmark|
|
||||
tr id="bookmark-#{bookmark.id}"
|
||||
|
Reference in New Issue
Block a user