mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-29 02:11:12 -06:00
Better redirection for new transactions.
This commit is contained in:
parent
e000fb5d80
commit
8f0fa02107
@ -16,7 +16,7 @@ use Response;
|
||||
use Session;
|
||||
use View;
|
||||
use URL;
|
||||
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class TransactionController
|
||||
@ -62,6 +62,12 @@ class TransactionController extends Controller
|
||||
}
|
||||
Session::put('preFilled', $preFilled);
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if(Session::get('transactions.create.fromStore') !== true) {
|
||||
Session::put('transactions.create.url', URL::previous());
|
||||
}
|
||||
Session::forget('transactions.create.fromStore');
|
||||
|
||||
asort($piggies);
|
||||
|
||||
|
||||
@ -165,6 +171,12 @@ class TransactionController extends Controller
|
||||
$preFilled['account_from_id'] = $transactions[1]->account->id;
|
||||
$preFilled['account_to_id'] = $transactions[0]->account->id;
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if(Session::get('transactions.create.fromUpdate') !== true) {
|
||||
Session::put('transactions.edit.url', URL::previous());
|
||||
}
|
||||
Session::forget('transactions.create.fromUpdate');
|
||||
|
||||
|
||||
return View::make('transactions.edit', compact('journal', 'accounts', 'what', 'budgets', 'piggies', 'subTitle'))->with('data', $preFilled);
|
||||
}
|
||||
@ -273,6 +285,7 @@ class TransactionController extends Controller
|
||||
*/
|
||||
public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
|
||||
{
|
||||
|
||||
$journalData = $request->getJournalData();
|
||||
$journal = $repository->store($journalData);
|
||||
|
||||
@ -290,10 +303,13 @@ class TransactionController extends Controller
|
||||
Session::flash('success', 'New transaction "' . $journal->description . '" stored!');
|
||||
|
||||
if (intval(Input::get('create_another')) === 1) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
Session::put('transactions.create.fromStore',true);
|
||||
return Redirect::route('transactions.create', $request->input('what'))->withInput();
|
||||
}
|
||||
|
||||
return Redirect::to(URL::previous());
|
||||
// redirect to previous URL.
|
||||
return Redirect::to(Session::get('transactions.create.url'));
|
||||
|
||||
}
|
||||
|
||||
@ -316,11 +332,13 @@ class TransactionController extends Controller
|
||||
Session::flash('success', 'Transaction "' . e($journalData['description']) . '" updated.');
|
||||
|
||||
if (intval(Input::get('return_to_edit')) === 1) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
Session::put('transactions.create.fromUpdate',true);
|
||||
return Redirect::route('transactions.edit', $journal->id);
|
||||
}
|
||||
|
||||
|
||||
return Redirect::to(URL::previous());
|
||||
// redirect to previous URL.
|
||||
return Redirect::to(Session::get('transactions.edit.url'));
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user