diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/rest/BookmarkREST.java b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/rest/BookmarkREST.java index 957099f..4122fe2 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/rest/BookmarkREST.java +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/java/rest/BookmarkREST.java @@ -88,6 +88,13 @@ public class BookmarkREST { bc.delete(id); } + @DELETE + @LoggedIn + @Transactional + public void delete(List ids) { + bc.delete(ids); + } + private void checkId(Bookmark entity) { if (entity.getId() != null) { throw new BadRequestException(); diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-list.html b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-list.html index a16e65c..aa43f24 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-list.html +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-list.html @@ -38,6 +38,7 @@ + diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/index.html b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/index.html index 4360f94..db6afcc 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/index.html +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/index.html @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js index 75d4b55..02838b8 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js @@ -66,6 +66,7 @@ function saveFailed(request) { case 401: alert('Você não está autenticado.'); break; + case 412: $($("form input").get().reverse()).each(function() { var id = $(this).attr('id'); diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-list.js b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-list.js index 96bf09f..97a490c 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-list.js +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-list.js @@ -23,10 +23,7 @@ $(function() { if (ids.length == 0) { alert('Nenhum registro selecionado'); } else if (confirm('Tem certeza que deseja apagar?')) { - $.each(ids, function(key, id){ - BookmarkProxy.remove(id, removeOk); - }) - + BookmarkProxy.remove(ids, removeOk, removeFailed); } }); }); @@ -34,7 +31,6 @@ $(function() { var oTable; function findAllOk(data) { - oTable = $('#resultList').dataTable({ "aoColumns" : [ { "aTargets" : [ 0 ], @@ -78,3 +74,14 @@ function findAllOk(data) { function removeOk() { BookmarkProxy.findAll(findAllOk); } + +function removeFailed(request) { + switch (request.status) { + case 401: + alert('Você não está autenticado.'); + break; + + default: + break; + } +} diff --git a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/proxy/bookmark.js b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/proxy/bookmark.js index 50be893..c178efc 100644 --- a/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/proxy/bookmark.js +++ b/archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/proxy/bookmark.js @@ -48,10 +48,12 @@ BookmarkProxy.update = function($id, $form, $success, $error) { }); }; -BookmarkProxy.remove = function($id, $success, $error) { +BookmarkProxy.remove = function($ids, $success, $error) { $.ajax({ type : "DELETE", - url : this.url + "/" + $id, + url : this.url, + data : JSON.stringify($ids), + contentType : "application/json", success : $success, error : $error, beforeSend: function (xhr) { -- libgit2 0.21.2