Commit 902c65765ba9ee137244d1cc3f7b33560b21f3ed
1 parent
014ef91e
Exists in
master
Ajustes no arquétipo
Showing
6 changed files
with
26 additions
and
8 deletions
Show diff stats
archetype/html-rest/src/main/resources/archetype-resources/src/main/java/rest/BookmarkREST.java
| ... | ... | @@ -88,6 +88,13 @@ public class BookmarkREST { |
| 88 | 88 | bc.delete(id); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | + @DELETE | |
| 92 | + @LoggedIn | |
| 93 | + @Transactional | |
| 94 | + public void delete(List<Long> ids) { | |
| 95 | + bc.delete(ids); | |
| 96 | + } | |
| 97 | + | |
| 91 | 98 | private void checkId(Bookmark entity) { |
| 92 | 99 | if (entity.getId() != null) { |
| 93 | 100 | throw new BadRequestException(); | ... | ... |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-list.html
| ... | ... | @@ -38,6 +38,7 @@ |
| 38 | 38 | <script src="js/lib/bootstrap.min.js"></script> |
| 39 | 39 | <script src="js/lib/jquery.dataTables.js"></script> |
| 40 | 40 | <script src="js/lib/datatables.js" type="text/javascript"></script> |
| 41 | + <script src="js/proxy/auth.js" type="text/javascript"></script> | |
| 41 | 42 | <script src="js/proxy/bookmark.js" type="text/javascript"></script> |
| 42 | 43 | <script src="js/controller/bookmark-list.js" type="text/javascript"></script> |
| 43 | 44 | </body> | ... | ... |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/index.html
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-list.js
| ... | ... | @@ -23,10 +23,7 @@ $(function() { |
| 23 | 23 | if (ids.length == 0) { |
| 24 | 24 | alert('Nenhum registro selecionado'); |
| 25 | 25 | } else if (confirm('Tem certeza que deseja apagar?')) { |
| 26 | - $.each(ids, function(key, id){ | |
| 27 | - BookmarkProxy.remove(id, removeOk); | |
| 28 | - }) | |
| 29 | - | |
| 26 | + BookmarkProxy.remove(ids, removeOk, removeFailed); | |
| 30 | 27 | } |
| 31 | 28 | }); |
| 32 | 29 | }); |
| ... | ... | @@ -34,7 +31,6 @@ $(function() { |
| 34 | 31 | var oTable; |
| 35 | 32 | |
| 36 | 33 | function findAllOk(data) { |
| 37 | - | |
| 38 | 34 | oTable = $('#resultList').dataTable({ |
| 39 | 35 | "aoColumns" : [ { |
| 40 | 36 | "aTargets" : [ 0 ], |
| ... | ... | @@ -78,3 +74,14 @@ function findAllOk(data) { |
| 78 | 74 | function removeOk() { |
| 79 | 75 | BookmarkProxy.findAll(findAllOk); |
| 80 | 76 | } |
| 77 | + | |
| 78 | +function removeFailed(request) { | |
| 79 | + switch (request.status) { | |
| 80 | + case 401: | |
| 81 | + alert('Você não está autenticado.'); | |
| 82 | + break; | |
| 83 | + | |
| 84 | + default: | |
| 85 | + break; | |
| 86 | + } | |
| 87 | +} | ... | ... |
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) { |
| 48 | 48 | }); |
| 49 | 49 | }; |
| 50 | 50 | |
| 51 | -BookmarkProxy.remove = function($id, $success, $error) { | |
| 51 | +BookmarkProxy.remove = function($ids, $success, $error) { | |
| 52 | 52 | $.ajax({ |
| 53 | 53 | type : "DELETE", |
| 54 | - url : this.url + "/" + $id, | |
| 54 | + url : this.url, | |
| 55 | + data : JSON.stringify($ids), | |
| 56 | + contentType : "application/json", | |
| 55 | 57 | success : $success, |
| 56 | 58 | error : $error, |
| 57 | 59 | beforeSend: function (xhr) { | ... | ... |