James Cole 2024-04-19 19:58:32 +02:00
parent 8a5cecd2a0
commit 36915cdace
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
2 changed files with 8 additions and 93 deletions

View File

@ -22,95 +22,10 @@ var count = 0;
$(document).ready(function () {
updateListButtons();
addSort();
$('.clone-transaction').click(cloneTransaction);
$('.clone-transaction-and-edit').click(cloneTransactionAndEdit);
});
var fixHelper = function (e, tr) {
"use strict";
var $originals = tr.children();
var $helper = tr.clone();
$helper.children().each(function (index) {
// Set helper cell sizes to match the original sizes
$(this).width($originals.eq(index).width());
});
return $helper;
};
/**
*
*/
function addSort() {
if (typeof $(".table-sortable>tbody").sortable !== "undefined") {
$('.table-sortable>tbody').sortable(
{
items: "tr:not(.unsortable)",
handle: '.object-handle',
stop: sortStop,
start: function (event, ui) {
// Build a placeholder cell that spans all the cells in the row
var cellCount = 0;
$('td, th', ui.helper).each(function () {
// For each TD or TH try and get it's colspan attribute, and add that or 1 to the total
var colspan = 1;
var colspanAttr = $(this).attr('colspan');
if (colspanAttr > 1) {
colspan = colspanAttr;
}
cellCount += colspan;
});
// Add the placeholder UI - note that this is the item's content, so TD rather than TR
ui.placeholder.html('<td colspan="' + cellCount + '">&nbsp;</td>');
}
}
);
}
}
/**
*
* @param event
* @param ui
* @returns {boolean|undefined}
*/
function sortStop(event, ui) {
"use strict";
var current = $(ui.item);
var thisDate = current.data('date');
var originalBG = current.css('backgroundColor');
if (current.prev().data('date') !== thisDate && current.next().data('date') !== thisDate) {
// animate something with color:
current.animate({backgroundColor: "#d9534f"}, 200, function () {
$(this).animate({backgroundColor: originalBG}, 200);
return undefined;
});
return false;
}
//return false;
// do update
var list = $('tr[data-date="' + thisDate + '"]');
var submit = [];
$.each(list, function (i, v) {
var row = $(v);
var id = row.data('id');
submit.push(id);
});
// do extra animation when done?
$.post('transactions/reorder', {items: submit, date: thisDate, _token: token});
current.animate({backgroundColor: "#5cb85c"}, 200, function () {
$(this).animate({backgroundColor: originalBG}, 200);
return undefined;
});
return undefined;
}
/**
*

View File

@ -1,4 +1,4 @@
<table class="table table-condensed table-hover table-responsive table-sortable">
<table class="table table-condensed table-hover table-responsive">
<thead>
<tr>
{% if showCategory or showBudget %}
@ -49,7 +49,7 @@
<tbody>
{% for group in groups %}
{% if group.count > 1 %}
<tr style="border-top:1px #aaa solid;" class="unsortable">
<tr style="border-top:1px #aaa solid;">
<td colspan="2" style="border-top:1px #aaa solid;">
<small><strong>
<a href="{{ route('transactions.show', [group.id]) }}"
@ -104,29 +104,29 @@
data-id="{{ group.id }}">
<td style=" {{ style|raw }}" class="hidden-xs">
{% if transaction.transaction_type_type == 'Withdrawal' %}
<span class="object-handle fa fa-long-arrow-left fa-fw"
<span class="fa fa-long-arrow-left fa-fw"
title="{{ trans('firefly.Withdrawal') }}"></span>
{% endif %}
{% if transaction.transaction_type_type == 'Deposit' %}
<span class="object-handle fa fa-long-arrow-right fa-fw"
<span class="fa fa-long-arrow-right fa-fw"
title="{{ trans('firefly.Deposit') }}"></span>
{% endif %}
{% if transaction.transaction_type_type == 'Transfer' %}
<span class="object-handle fa fa-exchange fa-fw" title="{{ trans('firefly.Transfer') }}"></span>
<span class="fa fa-exchange fa-fw" title="{{ trans('firefly.Transfer') }}"></span>
{% endif %}
{% if transaction.transaction_type_type == 'Reconciliation' %}
<span class="object-handle fa-fw fa fa-calculator"
<span class="fa-fw fa fa-calculator"
title="{{ trans('firefly.reconciliation_transaction') }}"></span>
{% endif %}
{% if transaction.transaction_type_type == 'Opening balance' %}
<span class="object-handle fa-fw fa fa-star-o"
<span class="fa-fw fa fa-star-o"
title="{{ trans('firefly.Opening balance') }}"></span>
{% endif %}
{% if transaction.transaction_type_type == 'Liability credit' %}
<span class="object-handle fa-fw fa fa-star-o"
<span class="fa-fw fa fa-star-o"
title="{{ trans('firefly.Liability credit') }}"></span>
{% endif %}