This commit is contained in:
James Cole 2017-09-03 10:51:02 +02:00
parent 816b291ed3
commit 6b09466819
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 30 additions and 2 deletions

View File

@ -21,6 +21,7 @@ use FireflyIII\Events\UpdatedTransactionJournal;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\JournalFormRequest; use FireflyIII\Http\Requests\JournalFormRequest;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
@ -143,7 +144,7 @@ class SingleController extends Controller
{ {
$what = strtolower($what); $what = strtolower($what);
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size'))); $uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
$assetAccounts = ExpandedForm::makeSelectList($this->accounts->getActiveAccountsByType([AccountType::DEFAULT, AccountType::ASSET])); $assetAccounts = $this->groupedAccountList();
$budgets = ExpandedForm::makeSelectListWithEmpty($this->budgets->getActiveBudgets()); $budgets = ExpandedForm::makeSelectListWithEmpty($this->budgets->getActiveBudgets());
$piggyBanks = $this->piggyBanks->getPiggyBanksWithAmount(); $piggyBanks = $this->piggyBanks->getPiggyBanksWithAmount();
$piggies = ExpandedForm::makeSelectListWithEmpty($piggyBanks); $piggies = ExpandedForm::makeSelectListWithEmpty($piggyBanks);
@ -239,7 +240,7 @@ class SingleController extends Controller
} }
$what = strtolower($journal->transactionTypeStr()); $what = strtolower($journal->transactionTypeStr());
$assetAccounts = ExpandedForm::makeSelectList($this->accounts->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])); $assetAccounts = $this->groupedAccountList();
$budgetList = ExpandedForm::makeSelectListWithEmpty($this->budgets->getBudgets()); $budgetList = ExpandedForm::makeSelectListWithEmpty($this->budgets->getBudgets());
// view related code // view related code
@ -409,6 +410,26 @@ class SingleController extends Controller
return redirect($this->getPreviousUri('transactions.edit.uri')); return redirect($this->getPreviousUri('transactions.edit.uri'));
} }
/**
* @return array
*/
private function groupedAccountList(): array
{
$accounts = $this->accounts->getActiveAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$return = [];
/** @var Account $account */
foreach ($accounts as $account) {
$type = $account->getMeta('accountRole');
if (strlen($type) === 0) {
$type = 'no_account_type';
}
$key = strval(trans('firefly.opt_group_' . $type));
$return[$key][$account->id] = $account->name;
}
return $return;
}
/** /**
* @param TransactionJournal $journal * @param TransactionJournal $journal
* *

View File

@ -37,6 +37,7 @@ $(document).ready(function () {
// when user selects different currency, // when user selects different currency,
$('.currency-option').on('click', selectsForeignCurrency); $('.currency-option').on('click', selectsForeignCurrency);
$('#ffInput_description').focus();
}); });
/** /**
@ -84,6 +85,7 @@ function updateDescription() {
$.getJSON('json/transaction-journals/' + what).done(function (data) { $.getJSON('json/transaction-journals/' + what).done(function (data) {
$('input[name="description"]').typeahead('destroy').typeahead({source: data}); $('input[name="description"]').typeahead('destroy').typeahead({source: data});
}); });
$('#ffInput_description').focus();
} }
/** /**

View File

@ -624,6 +624,11 @@ return [
'perm-delete-many' => 'Deleting many items in one go can be very disruptive. Please be cautious.', 'perm-delete-many' => 'Deleting many items in one go can be very disruptive. Please be cautious.',
'mass_deleted_transactions_success' => 'Deleted :amount transaction(s).', 'mass_deleted_transactions_success' => 'Deleted :amount transaction(s).',
'mass_edited_transactions_success' => 'Updated :amount transaction(s)', 'mass_edited_transactions_success' => 'Updated :amount transaction(s)',
'opt_group_no_account_type' => '(no account type)',
'opt_group_defaultAsset' => 'Default asset accounts',
'opt_group_savingAsset' => 'Savings accounts',
'opt_group_sharedAsset' => 'Shared asset accounts',
'opt_group_ccAsset' => 'Credit cards',
// new user: // new user: