mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 20:54:31 +08:00
6fb0f36ce1
We now show an options gear icon next to the bookmark name. When expanded we show the "delete bookmark when reminder sent" option. The value of this checkbox is saved in local storage for the user. If this is ticked, when a reminder is sent for the bookmark the bookmark itself is deleted. This is so people can use the reminder functionality by itself. Also remove the blue alert reminder section from the "Edit Bookmark" modal as it just added clutter, because the user can already see they had a reminder set: Adds a default false boolean column `delete_when_reminder_sent` to bookmarks.
54 lines
1.4 KiB
Ruby
54 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class BookmarksController < ApplicationController
|
|
requires_login
|
|
|
|
def create
|
|
params.require(:post_id)
|
|
|
|
bookmark_manager = BookmarkManager.new(current_user)
|
|
bookmark = bookmark_manager.create(
|
|
post_id: params[:post_id],
|
|
name: params[:name],
|
|
reminder_type: params[:reminder_type],
|
|
reminder_at: params[:reminder_at],
|
|
options: {
|
|
delete_when_reminder_sent: params[:delete_when_reminder_sent]
|
|
}
|
|
)
|
|
|
|
if bookmark_manager.errors.empty?
|
|
return render json: success_json.merge(id: bookmark.id)
|
|
end
|
|
|
|
render json: failed_json.merge(errors: bookmark_manager.errors.full_messages), status: 400
|
|
end
|
|
|
|
def destroy
|
|
params.require(:id)
|
|
result = BookmarkManager.new(current_user).destroy(params[:id])
|
|
render json: success_json.merge(result)
|
|
end
|
|
|
|
def update
|
|
params.require(:id)
|
|
|
|
bookmark_manager = BookmarkManager.new(current_user)
|
|
bookmark_manager.update(
|
|
bookmark_id: params[:id],
|
|
name: params[:name],
|
|
reminder_type: params[:reminder_type],
|
|
reminder_at: params[:reminder_at],
|
|
options: {
|
|
delete_when_reminder_sent: params[:delete_when_reminder_sent]
|
|
}
|
|
)
|
|
|
|
if bookmark_manager.errors.empty?
|
|
return render json: success_json
|
|
end
|
|
|
|
render json: failed_json.merge(errors: bookmark_manager.errors.full_messages), status: 400
|
|
end
|
|
end
|