Show inline error messages when checkin/checkout fails
This commit is contained in:
parent
2cdd176b94
commit
6afef992f1
3 changed files with 38 additions and 30 deletions
29
public/static/css/materialize.min.css
vendored
29
public/static/css/materialize.min.css
vendored
File diff suppressed because one or more lines are too long
16
public/static/js/materialize.min.js
vendored
16
public/static/js/materialize.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,5 @@
|
|||
$(document).ready(function() {
|
||||
var error_icon = '<i class="material-icons">error</i>';
|
||||
$('.action-checkin').click(function() {
|
||||
var link = $(this);
|
||||
req = {
|
||||
|
@ -6,9 +7,16 @@ $(document).ready(function() {
|
|||
station: link.data('station'),
|
||||
train: link.data('train'),
|
||||
};
|
||||
link.replaceWith('<div class="progress"><div class="indeterminate"></div></div>');
|
||||
progressbar = $('<div class="progress"><div class="indeterminate"></div></div>');
|
||||
link.replaceWith(progressbar);
|
||||
$.post('/action', req, function(data) {
|
||||
$(location).attr('href', '/');
|
||||
if (data.success) {
|
||||
$(location).attr('href', '/');
|
||||
} else {
|
||||
M.toast({html: error_icon + ' ' + data.error});
|
||||
link.append(' ' + error_icon);
|
||||
progressbar.replaceWith(link);
|
||||
}
|
||||
});
|
||||
});
|
||||
$('.action-checkout').click(function() {
|
||||
|
@ -18,9 +26,16 @@ $(document).ready(function() {
|
|||
station: link.data('station'),
|
||||
force: link.data('force'),
|
||||
};
|
||||
link.replaceWith('<div class="progress"><div class="indeterminate"></div></div>');
|
||||
progressbar = $('<div class="progress"><div class="indeterminate"></div></div>');
|
||||
link.replaceWith(progressbar);
|
||||
$.post('/action', req, function(data) {
|
||||
$(location).attr('href', '/' + req.station);
|
||||
if (data.success) {
|
||||
$(location).attr('href', '/' + req.station);
|
||||
} else {
|
||||
M.toast({html: error_icon + ' ' + data.error});
|
||||
link.append(' ' + error_icon);
|
||||
progressbar.replaceWith(link);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue