mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Thing with order and should fix Travis.
This commit is contained in:
parent
f80de12cb5
commit
6dddd6629d
@ -210,6 +210,15 @@ class TransactionController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reorder transactions (which all must have the same date)
|
||||||
|
*/
|
||||||
|
public function reorder()
|
||||||
|
{
|
||||||
|
$ids = Input::get('items');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
*
|
*
|
||||||
|
@ -366,6 +366,7 @@ Route::group(
|
|||||||
);
|
);
|
||||||
Route::post('/transaction/update/{tj}', ['uses' => 'TransactionController@update', 'as' => 'transactions.update']);
|
Route::post('/transaction/update/{tj}', ['uses' => 'TransactionController@update', 'as' => 'transactions.update']);
|
||||||
Route::post('/transaction/destroy/{tj}', ['uses' => 'TransactionController@destroy', 'as' => 'transactions.destroy']);
|
Route::post('/transaction/destroy/{tj}', ['uses' => 'TransactionController@destroy', 'as' => 'transactions.destroy']);
|
||||||
|
Route::post('/transaction/reorder', ['uses' => 'TransactionController@reorder', 'as' => 'transactions.reorder']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auth\Auth Controller
|
* Auth\Auth Controller
|
||||||
|
@ -80,18 +80,36 @@ class FireflyValidator extends Validator
|
|||||||
public function validateUniqueAccountForUser($attribute, $value, $parameters)
|
public function validateUniqueAccountForUser($attribute, $value, $parameters)
|
||||||
{
|
{
|
||||||
// get account type from data, we must have this:
|
// get account type from data, we must have this:
|
||||||
$type = isset($this->data['what']) ? $this->data['what'] : Input::get('what');
|
$type = isset($this->data['what']) ? $this->data['what'] : null;
|
||||||
$longType = Config::get('firefly.accountTypeByIdentifier.' . $type);
|
// some fallback:
|
||||||
$dbType = AccountType::whereType($longType)->first();
|
if(is_null($type)) {
|
||||||
if (!$dbType) {
|
$type = Input::get('what');
|
||||||
|
}
|
||||||
|
// still null?
|
||||||
|
if(is_null($type)) {
|
||||||
|
// find by other field:
|
||||||
|
$type = isset($this->data['account_type_id']) ? $this->data['account_type_id'] : 0;
|
||||||
|
$dbType = AccountType::find($type);
|
||||||
|
} else {
|
||||||
|
$longType = Config::get('firefly.accountTypeByIdentifier.' . $type);
|
||||||
|
$dbType = AccountType::whereType($longType)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($dbType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$query = DB::table('accounts')->where('name', $value)->where('account_type_id', $dbType->id)->where('user_id', Auth::user()->id);
|
|
||||||
|
// user id?
|
||||||
|
$userId = Auth::check() ? Auth::user()->id : $this->data['user_id'];
|
||||||
|
|
||||||
|
$query = DB::table('accounts')->where('name', $value)->where('account_type_id', $dbType->id)->where('user_id', $userId);
|
||||||
|
|
||||||
if (isset($parameters[0])) {
|
if (isset($parameters[0])) {
|
||||||
$query->where('id', '!=', $parameters[0]);
|
$query->where('id', '!=', $parameters[0]);
|
||||||
}
|
}
|
||||||
$count = $query->count();
|
$count = $query->count();
|
||||||
if ($count == 0) {
|
if ($count == 0) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
database/migrations/2015_03_27_061038_changes_for_v333.php
Normal file
33
database/migrations/2015_03_27_061038_changes_for_v333.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class ChangesForV333 extends Migration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table(
|
||||||
|
'transaction_journals', function (Blueprint $table) {
|
||||||
|
$table->smallInteger('order',false,true)->default(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -31,45 +31,23 @@ $(document).ready(function () {
|
|||||||
$(".sortable-table tbody").sortable(
|
$(".sortable-table tbody").sortable(
|
||||||
{
|
{
|
||||||
helper: fixHelper,
|
helper: fixHelper,
|
||||||
connectWith: '.sortable-table tbody',
|
|
||||||
//stop: stopSorting,
|
|
||||||
items: 'tr:not(.ignore)',
|
items: 'tr:not(.ignore)',
|
||||||
stop: sortStop,
|
stop: sortStop,
|
||||||
handle: '.handle'
|
handle: '.handle',
|
||||||
//revert: 'invalid'
|
revert: 'invalid'
|
||||||
}
|
}
|
||||||
).disableSelection();
|
).disableSelection();
|
||||||
});
|
});
|
||||||
|
|
||||||
function sortChange() {
|
|
||||||
//console.log("change");
|
|
||||||
}
|
|
||||||
|
|
||||||
function sortSort(event, ui) {
|
|
||||||
//var current = $(ui.item);
|
|
||||||
//var thisDate = current.data('date');
|
|
||||||
|
|
||||||
//if(current.prev().data('date') != thisDate && current.next().data('date') != thisDate) {
|
|
||||||
// console.log('FALSE ['+current.prev().data('date')+'] ['+thisDate+'] ['+current.next().data('date')+'] ('+current.index()+')');
|
|
||||||
// return true;
|
|
||||||
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
//console.log('TRUE ['+current.prev().data('date')+'] ['+thisDate+'] ['+current.next().data('date')+'] ('+current.index()+')');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function sortStop(event, ui) {
|
function sortStop(event, ui) {
|
||||||
console.log("stop");
|
|
||||||
var current = $(ui.item);
|
var current = $(ui.item);
|
||||||
var thisDate = current.data('date');
|
var thisDate = current.data('date');
|
||||||
var originalBG = current.css('backgroundColor');
|
var originalBG = current.css('backgroundColor');
|
||||||
|
|
||||||
|
|
||||||
if (current.prev().data('date') != thisDate && current.next().data('date') != thisDate) {
|
if (current.prev().data('date') != thisDate && current.next().data('date') != thisDate) {
|
||||||
console.log('False!');
|
//console.log('False!');
|
||||||
console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']');
|
//console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']');
|
||||||
|
|
||||||
// animate something with color:
|
// animate something with color:
|
||||||
current.animate({
|
current.animate({
|
||||||
backgroundColor: "#d9534f"
|
backgroundColor: "#d9534f"
|
||||||
@ -79,13 +57,23 @@ function sortStop(event, ui) {
|
|||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// fade back to original
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
console.log('TRUE!');
|
|
||||||
console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']');
|
// 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);
|
||||||
|
});
|
||||||
|
|
||||||
|
$.post('/transaction/reorder',{items: submit,_token:token});
|
||||||
|
console.log(submit);
|
||||||
|
|
||||||
|
//console.log('TRUE!');
|
||||||
|
//console.log('[' + current.prev().data('date') + '] [' + thisDate + '] [' + current.next().data('date') + ']');
|
||||||
|
|
||||||
current.animate({
|
current.animate({
|
||||||
backgroundColor: "#5cb85c"
|
backgroundColor: "#5cb85c"
|
||||||
@ -95,6 +83,9 @@ function sortStop(event, ui) {
|
|||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//else update some order thing bla bla.
|
//else update some order thing bla bla.
|
||||||
//check if the item above OR under this one have the same date
|
//check if the item above OR under this one have the same date
|
||||||
//if not. return false
|
//if not. return false
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
<i class="fa fa-repeat fa-fw"></i> Transactions
|
<i class="fa fa-repeat fa-fw"></i> Transactions
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@include('list.journals-full')
|
@include('list.journals-full',['sorting' => false])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
Connected transaction journals
|
Connected transaction journals
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@include('list.journals-full')
|
@include('list.journals-full',['sorting' => false])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
{{{$subTitle}}}
|
{{{$subTitle}}}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@include('list.journals-full',['journals' => $list])
|
@include('list.journals-full',['journals' => $list,'sorting' => false])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
Transactions
|
Transactions
|
||||||
</div>
|
</div>
|
||||||
@include('list.journals-full')
|
@include('list.journals-full',['sorting' => false])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-3 col-md-3 col-sm-5">
|
<div class="col-lg-3 col-md-3 col-sm-5">
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
{{{$subTitle}}}
|
{{{$subTitle}}}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@include('list.journals-full',['journals' => $list])
|
@include('list.journals-full',['journals' => $list,'sorting' => false])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
Transactions
|
Transactions
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@include('list.journals-full')
|
@include('list.journals-full',['sorting' => false])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,10 +32,12 @@
|
|||||||
<td colspan="7"><em>Invalid journal: Found {{$journal->transactions()->count()}} transaction(s)</td>
|
<td colspan="7"><em>Invalid journal: Found {{$journal->transactions()->count()}} transaction(s)</td>
|
||||||
</tr>
|
</tr>
|
||||||
@else
|
@else
|
||||||
<tr class="drag" data-date="{{$journal->date->format('Y-m-d')}}">
|
<tr class="drag" data-date="{{$journal->date->format('Y-m-d')}}" data-id="{{$journal->id}}">
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group btn-group-xs">
|
<div class="btn-group btn-group-xs">
|
||||||
<a href="#" class="handle btn btn-default btn-xs"><i class="fa fa-fw fa-arrows-v"></i></a>
|
@if($sorting === true)
|
||||||
|
<a href="#" class="handle btn btn-default btn-xs"><i class="fa fa-fw fa-arrows-v"></i></a>
|
||||||
|
@endif
|
||||||
<a href="{{route('transactions.edit',$journal->id)}}" class="btn btn-xs btn-default"><i class="fa fa-fw fa-pencil"></i></a>
|
<a href="{{route('transactions.edit',$journal->id)}}" class="btn btn-xs btn-default"><i class="fa fa-fw fa-pencil"></i></a>
|
||||||
<a href="{{route('transactions.delete',$journal->id)}}" class="btn btn-xs btn-danger"><i class="fa fa-fw fa-trash-o"></i></a>
|
<a href="{{route('transactions.delete',$journal->id)}}" class="btn btn-xs btn-danger"><i class="fa fa-fw fa-trash-o"></i></a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<h4 class="modal-title">No budget bla bla.</h4>
|
<h4 class="modal-title">No budget bla bla.</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
@include('list.journals-full')
|
@include('list.journals-full',['sorting' => false])
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<i class="fa {{$subTitleIcon}}"></i> {{{$subTitle}}}
|
<i class="fa {{$subTitleIcon}}"></i> {{{$subTitle}}}
|
||||||
</div>
|
</div>
|
||||||
@include('list.journals-full')
|
@include('list.journals-full',['sorting' => true])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
@stop
|
@stop
|
||||||
@section('scripts')
|
@section('scripts')
|
||||||
|
<script type="text/javascript">
|
||||||
|
var token = "{{csrf_token()}}";
|
||||||
|
</script>
|
||||||
<script src="js/jquery-ui.min.js" type="text/javascript"></script>
|
<script src="js/jquery-ui.min.js" type="text/javascript"></script>
|
||||||
<script src="js/transactions.js" type="text/javascript"></script>
|
<script src="js/transactions.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user