Commit 902c65765ba9ee137244d1cc3f7b33560b21f3ed

Authored by Cleverson Sacramento
1 parent 014ef91e
Exists in master

Ajustes no arquétipo

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
1 1 <html>
2 2 <head>
3   -<meta http-equiv="Refresh" content="0; URL=login.html">
  3 +<meta http-equiv="Refresh" content="0; URL=bookmark-list.html">
4 4 </head>
5 5 </html>
6 6 \ No newline at end of file
... ...
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js
... ... @@ -66,6 +66,7 @@ function saveFailed(request) {
66 66 case 401:
67 67 alert('Você não está autenticado.');
68 68 break;
  69 +
69 70 case 412:
70 71 $($("form input").get().reverse()).each(function() {
71 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 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) {
... ...