summaryrefslogtreecommitdiff
path: root/public/static/js/travelynx-actions.js
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-04-23 18:08:07 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-04-23 18:08:07 +0200
commite168d9cd39c38b8e5a1994c8bf11376d26e9ea77 (patch)
treedee321d330a8fc9c106c18863db179972c9abac6 /public/static/js/travelynx-actions.js
parent812be4f0cbeb74db379a2c931ceb2c88bd9fabf7 (diff)
Use one row per journey instead of split checkin/checkout entries
Whether a user is in transit or not is now determined by an entry in the in_transit table instead of a dangling checkin. All completed journeys are stored in the "journeys" table. This does most of the work needed for automatic checkout. However, note that the corresponding worker process is not implemented yet.
Diffstat (limited to 'public/static/js/travelynx-actions.js')
-rw-r--r--public/static/js/travelynx-actions.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/public/static/js/travelynx-actions.js b/public/static/js/travelynx-actions.js
index 3f1eb89..583c806 100644
--- a/public/static/js/travelynx-actions.js
+++ b/public/static/js/travelynx-actions.js
@@ -1,11 +1,11 @@
-function tvly_run(link, req, redir, err_callback) {
+function tvly_run(link, req, err_callback) {
var error_icon = '<i class="material-icons">error</i>';
var progressbar = $('<div class="progress"><div class="indeterminate"></div></div>');
link.hide();
link.after(progressbar);
$.post('/action', req, function(data) {
if (data.success) {
- $(location).attr('href', redir);
+ $(location).attr('href', data.redirect_to);
} else {
M.toast({html: error_icon + ' ' + data.error});
progressbar.remove();
@@ -25,7 +25,7 @@ $(document).ready(function() {
station: link.data('station'),
train: link.data('train'),
};
- tvly_run(link, req, '/');
+ tvly_run(link, req);
});
$('.action-checkout').click(function() {
var link = $(this);
@@ -34,7 +34,7 @@ $(document).ready(function() {
station: link.data('station'),
force: link.data('force'),
};
- tvly_run(link, req, '/s/' + req.station, function() {
+ tvly_run(link, req, function() {
link.append(' – Ohne Echtzeitdaten auschecken?')
link.data('force', true);
});
@@ -45,7 +45,7 @@ $(document).ready(function() {
action: 'undo',
undo_id: link.data('id'),
};
- tvly_run(link, req, '/');
+ tvly_run(link, req);
});
$('.action-cancelled-from').click(function() {
var link = $(this);
@@ -54,7 +54,7 @@ $(document).ready(function() {
station: link.data('station'),
train: link.data('train'),
};
- tvly_run(link, req, '/');
+ tvly_run(link, req);
});
$('.action-cancelled-to').click(function() {
var link = $(this);
@@ -63,19 +63,19 @@ $(document).ready(function() {
station: link.data('station'),
force: true,
};
- tvly_run(link, req, '/');
+ tvly_run(link, req);
});
$('.action-delete').click(function() {
var link = $(this);
var req = {
action: 'delete',
- ids: link.data('id'),
+ id: link.data('id'),
checkin: link.data('checkin'),
checkout: link.data('checkout'),
};
really_delete = confirm("Diese Zugfahrt wirklich löschen? Der Eintrag wird sofort aus der Datenbank entfernt und kann nicht wiederhergestellt werden.");
if (really_delete) {
- tvly_run(link, req, '/history');
+ tvly_run(link, req);
}
});
});