File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 <link rel =" stylesheet" href =" webjars/bootstrap/4.6.2/css/bootstrap.min.css" >
1212 <link rel =" stylesheet" href =" webjars/noty/3.1.4/demo/font-awesome/css/font-awesome.min.css" >
1313 <link rel =" stylesheet" href =" webjars/datatables/1.13.5/css/dataTables.bootstrap4.min.css" >
14+ <link rel =" stylesheet" href =" webjars/noty/3.1.4/lib/noty.css" />
1415 <link rel =" shortcut icon" href =" resources/images/icon-meal.png" >
1516
1617 <%-- http://stackoverflow.com/a/24070373/548473--%>
1718 <script src =" webjars/jquery/3.7.1/jquery.min.js" defer ></script >
1819 <script src =" webjars/bootstrap/4.6.2/js/bootstrap.min.js" defer ></script >
1920 <script src =" webjars/datatables/1.13.5/js/jquery.dataTables.min.js" defer ></script >
2021 <script src =" webjars/datatables/1.13.5/js/dataTables.bootstrap4.min.js" defer ></script >
22+ <script src =" webjars/noty/3.1.4/lib/noty.min.js" defer ></script >
2123</head >
Original file line number Diff line number Diff line change 5050 <div class =" modal-content" >
5151 <div class =" modal-header" >
5252 <h4 class =" modal-title" ><spring:message code =" user.add" /></h4 >
53- <button type =" button" class =" close" data-dismiss =" modal" >× ; </button >
53+ <button type =" button" class =" close" data-dismiss =" modal" onclick = " closeNoty() " >× ; </button >
5454 </div >
5555 <div class =" modal-body" >
5656 <form id =" detailsForm" >
7676 </form >
7777 </div >
7878 <div class =" modal-footer" >
79- <button type =" button" class =" btn btn-secondary" data-dismiss =" modal" >
79+ <button type =" button" class =" btn btn-secondary" data-dismiss =" modal" onclick = " closeNoty() " >
8080 <span class =" fa fa-close" ></span >
8181 <spring:message code =" common.cancel" />
8282 </button >
Original file line number Diff line number Diff line change @@ -8,6 +8,13 @@ function makeEditable(datatableApi) {
88 deleteRow ( $ ( this ) . closest ( 'tr' ) . attr ( "id" ) ) ;
99 }
1010 } ) ;
11+
12+ $ ( document ) . ajaxError ( function ( event , jqXHR , options , jsExc ) {
13+ failNoty ( jqXHR ) ;
14+ } ) ;
15+
16+ // solve problem with cache in IE: https://stackoverflow.com/a/4303862/548473
17+ $ . ajaxSetup ( { cache : false } ) ;
1118}
1219
1320function add ( ) {
@@ -21,6 +28,7 @@ function deleteRow(id) {
2128 type : "DELETE"
2229 } ) . done ( function ( ) {
2330 updateTable ( ) ;
31+ successNoty ( "Deleted" ) ;
2432 } ) ;
2533}
2634
@@ -38,5 +46,35 @@ function save() {
3846 } ) . done ( function ( ) {
3947 $ ( "#editRow" ) . modal ( "hide" ) ;
4048 updateTable ( ) ;
49+ successNoty ( "Saved" ) ;
50+ } ) ;
51+ }
52+
53+ let failedNote ;
54+
55+ function closeNoty ( ) {
56+ if ( failedNote ) {
57+ failedNote . close ( ) ;
58+ failedNote = undefined ;
59+ }
60+ }
61+
62+ function successNoty ( text ) {
63+ closeNoty ( ) ;
64+ new Noty ( {
65+ text : "<span class='fa fa-lg fa-check'></span> " + text ,
66+ type : 'success' ,
67+ layout : "bottomRight" ,
68+ timeout : 1000
69+ } ) . show ( ) ;
70+ }
71+
72+ function failNoty ( jqXHR ) {
73+ closeNoty ( ) ;
74+ failedNote = new Noty ( {
75+ text : "<span class='fa fa-lg fa-exclamation-circle'></span> Error status: " + jqXHR . status ,
76+ type : "error" ,
77+ layout : "bottomRight"
4178 } ) ;
79+ failedNote . show ( )
4280}
You can’t perform that action at this time.
0 commit comments