Implement bookmark delete on frontend.
This commit is contained in:
		
							parent
							
								
									8447fb3343
								
							
						
					
					
						commit
						fd23b563cf
					
				
					 2 changed files with 25 additions and 0 deletions
				
			
		|  | @ -63,3 +63,10 @@ def post_bookmarks_create(): | ||||||
|     response = etiquette.jsonify.bookmark(bookmark) |     response = etiquette.jsonify.bookmark(bookmark) | ||||||
|     response = jsonify.make_json_response(response) |     response = jsonify.make_json_response(response) | ||||||
|     return 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({}) | ||||||
|  |  | ||||||
|  | @ -70,8 +70,19 @@ | ||||||
|                 > |                 > | ||||||
|                     {{-bookmark.url-}} |                     {{-bookmark.url-}} | ||||||
|                 </a> |                 </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> |             </div> | ||||||
|             {% endfor %} |             {% endfor %} | ||||||
|  | 
 | ||||||
|             <div class="new_bookmark_card"> |             <div class="new_bookmark_card"> | ||||||
|                 <input id="new_bookmark_title" type="text" placeholder="title (optional)"> |                 <input id="new_bookmark_title" type="text" placeholder="title (optional)"> | ||||||
|                 <input id="new_bookmark_url" type="text" placeholder="url"> |                 <input id="new_bookmark_url" type="text" placeholder="url"> | ||||||
|  | @ -107,6 +118,13 @@ function create_bookmark(url, title) | ||||||
|     common.post(api_url, data, callback); |     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) | function on_open(ed, edit_element_map) | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue