This commit is contained in:
James Cole
2018-04-28 21:54:48 +02:00
parent 7f459df9e9
commit fdc9467218
7 changed files with 79 additions and 38 deletions

View File

@@ -63,6 +63,10 @@ function checkJobStatus() {
*/
function reportFailedJob(jqxhr, textStatus, error) {
console.log('In reportFailedJob()');
// cancel refresh
clearTimeout(timeOutId);
// hide all possible boxes:
$('.statusbox').hide();
@@ -133,6 +137,7 @@ function reportOnJobStatus(data) {
$('#import-status-more-info').html(data.finishedText);
break;
case "error":
clearTimeout(timeOutId);
console.log('Job reports ERROR.');
// hide all possible boxes:
$('.statusbox').hide();

View File

@@ -83,13 +83,36 @@ function removeMoney(e) {
function stopSorting() {
"use strict";
$('.loadSpin').addClass('fa fa-refresh fa-spin');
var order = [];
$.each($('#sortable-piggy>tbody>tr'), function (i, v) {
var holder = $(v);
var position = parseInt(holder.data('position'));
var originalOrder = parseInt(holder.data('order'));
var id = holder.data('id');
order.push(id);
});
$.post('piggy-banks/sort', {order: order, _token: token}).done(function () {
$('.loadSpin').removeClass('fa fa-refresh fa-spin');
console.log('Now at row ' + i);
var newOrder;
if (position === i) {
return;
}
if (position < i) {
console.log('Row ' + i + ' has moved up!');
// update position:
holder.data('position', i);
newOrder = originalOrder + 1;
}
if (position > i) {
console.log('Row ' + i + ' has moved down!');
// update position:
holder.data('position', i);
newOrder = originalOrder - 1;
}
$.post('piggy-banks/set-order/' + id, {order: newOrder, _token: token})
});
$('.loadSpin').removeClass('fa fa-refresh fa-spin');
}