Implement bookmark delete on frontend.

This commit is contained in:
voussoir 2018-07-29 00:36:50 -07:00
parent 8447fb3343
commit fd23b563cf
2 changed files with 25 additions and 0 deletions

View file

@ -63,3 +63,10 @@ def post_bookmarks_create():
response = etiquette.jsonify.bookmark(bookmark)
response = jsonify.make_json_response(response)
return response
@site.route('/bookmark/<bookmark_id>/delete', methods=['POST'])
@decorators.catch_etiquette_exception
def post_bookmark_delete(bookmark_id):
bookmark = common.P_bookmark(bookmark_id, response_type='json')
bookmark.delete()
return jsonify.make_json_response({})

View file

@ -70,8 +70,19 @@
>
{{-bookmark.url-}}
</a>
<button
class="red_button button_with_confirm"
data-onclick="delete_bookmark('{{bookmark.id}}')"
data-prompt="Delete Bookmark?"
data-confirm-class="red_button"
data-cancel-class="gray_button"
>
Delete
</button>
</div>
{% endfor %}
<div class="new_bookmark_card">
<input id="new_bookmark_title" type="text" placeholder="title (optional)">
<input id="new_bookmark_url" type="text" placeholder="url">
@ -107,6 +118,13 @@ function create_bookmark(url, title)
common.post(api_url, data, callback);
}
function delete_bookmark(bookmark_id)
{
var url = `/bookmark/${bookmark_id}/delete`
var callback = function(){location.reload();};
common.post(url, null, callback);
}
function on_open(ed, edit_element_map)
{