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,6 +88,13 @@ public class BookmarkREST { | ||
88 | bc.delete(id); | 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 | private void checkId(Bookmark entity) { | 98 | private void checkId(Bookmark entity) { |
92 | if (entity.getId() != null) { | 99 | if (entity.getId() != null) { |
93 | throw new BadRequestException(); | 100 | throw new BadRequestException(); |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/bookmark-list.html
@@ -38,6 +38,7 @@ | @@ -38,6 +38,7 @@ | ||
38 | <script src="js/lib/bootstrap.min.js"></script> | 38 | <script src="js/lib/bootstrap.min.js"></script> |
39 | <script src="js/lib/jquery.dataTables.js"></script> | 39 | <script src="js/lib/jquery.dataTables.js"></script> |
40 | <script src="js/lib/datatables.js" type="text/javascript"></script> | 40 | <script src="js/lib/datatables.js" type="text/javascript"></script> |
41 | + <script src="js/proxy/auth.js" type="text/javascript"></script> | ||
41 | <script src="js/proxy/bookmark.js" type="text/javascript"></script> | 42 | <script src="js/proxy/bookmark.js" type="text/javascript"></script> |
42 | <script src="js/controller/bookmark-list.js" type="text/javascript"></script> | 43 | <script src="js/controller/bookmark-list.js" type="text/javascript"></script> |
43 | </body> | 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
@@ -66,6 +66,7 @@ function saveFailed(request) { | @@ -66,6 +66,7 @@ function saveFailed(request) { | ||
66 | case 401: | 66 | case 401: |
67 | alert('Você não está autenticado.'); | 67 | alert('Você não está autenticado.'); |
68 | break; | 68 | break; |
69 | + | ||
69 | case 412: | 70 | case 412: |
70 | $($("form input").get().reverse()).each(function() { | 71 | $($("form input").get().reverse()).each(function() { |
71 | var id = $(this).attr('id'); | 72 | var id = $(this).attr('id'); |
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-list.js
@@ -23,10 +23,7 @@ $(function() { | @@ -23,10 +23,7 @@ $(function() { | ||
23 | if (ids.length == 0) { | 23 | if (ids.length == 0) { |
24 | alert('Nenhum registro selecionado'); | 24 | alert('Nenhum registro selecionado'); |
25 | } else if (confirm('Tem certeza que deseja apagar?')) { | 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,7 +31,6 @@ $(function() { | ||
34 | var oTable; | 31 | var oTable; |
35 | 32 | ||
36 | function findAllOk(data) { | 33 | function findAllOk(data) { |
37 | - | ||
38 | oTable = $('#resultList').dataTable({ | 34 | oTable = $('#resultList').dataTable({ |
39 | "aoColumns" : [ { | 35 | "aoColumns" : [ { |
40 | "aTargets" : [ 0 ], | 36 | "aTargets" : [ 0 ], |
@@ -78,3 +74,14 @@ function findAllOk(data) { | @@ -78,3 +74,14 @@ function findAllOk(data) { | ||
78 | function removeOk() { | 74 | function removeOk() { |
79 | BookmarkProxy.findAll(findAllOk); | 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,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 | $.ajax({ | 52 | $.ajax({ |
53 | type : "DELETE", | 53 | type : "DELETE", |
54 | - url : this.url + "/" + $id, | 54 | + url : this.url, |
55 | + data : JSON.stringify($ids), | ||
56 | + contentType : "application/json", | ||
55 | success : $success, | 57 | success : $success, |
56 | error : $error, | 58 | error : $error, |
57 | beforeSend: function (xhr) { | 59 | beforeSend: function (xhr) { |