diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php index 83f3b93dc9..b887c26d07 100644 --- a/app/Http/Controllers/Transaction/SingleController.php +++ b/app/Http/Controllers/Transaction/SingleController.php @@ -113,7 +113,9 @@ class SingleController extends Controller asort($piggies); - return view('transactions.create', compact('assetAccounts', 'subTitleIcon', 'uploadSize', 'budgets', 'what', 'piggies', 'subTitle', 'optionalFields')); + return view( + 'transactions.single.create', compact('assetAccounts', 'subTitleIcon', 'uploadSize', 'budgets', 'what', 'piggies', 'subTitle', 'optionalFields') + ); } /** @@ -317,7 +319,7 @@ class SingleController extends Controller $data = $request->getJournalData(); $journal = $repository->update($journal, $data); /** @var array $files */ - $files = $request->hasFile('attachments') ? $request->file('attachments') : null; + $files = $request->hasFile('attachments') ? $request->file('attachments') : null; $this->attachments->saveAttachmentsForModel($journal, $files); // flash errors diff --git a/public/js/ff/transactions/create.js b/public/js/ff/transactions/single/create.js similarity index 72% rename from public/js/ff/transactions/create.js rename to public/js/ff/transactions/single/create.js index aaed65207a..a4b8f5e551 100644 --- a/public/js/ff/transactions/create.js +++ b/public/js/ff/transactions/single/create.js @@ -1,9 +1,7 @@ /* * create.js - * Copyright (C) 2016 thegrumpydictator@gmail.com - * - * This software may be modified and distributed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International License. + * Copyright (c) 2017 thegrumpydictator@gmail.com + * This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License. * * See the LICENSE file for details. */ @@ -19,11 +17,57 @@ $(document).ready(function () { updateButtons(); updateForm(); updateLayout(); + updateDescription(); } + // get JSON things: + getJSONautocomplete(); }); +function updateDescription() { + $.getJSON('json/transaction-journals/' + what).done(function (data) { + $('input[name="description"]').typeahead('destroy'); + $('input[name="description"]').typeahead({source: data}); + }); +} + +function getJSONautocomplete() { + + // for withdrawals + $.getJSON('json/expense-accounts').done(function (data) { + $('input[name="destination_account_name"]').typeahead({source: data}); + }); + + // for tags: + if ($('input[name="tags"]').length > 0) { + $.getJSON('json/tags').done(function (data) { + + var opt = { + typeahead: { + source: data, + afterSelect: function () { + this.$element.val(""); + } + } + }; + $('input[name="tags"]').tagsinput( + opt + ); + }); + } + + // for deposits + $.getJSON('json/revenue-accounts').done(function (data) { + $('input[name="source_account_name"]').typeahead({source: data}); + }); + + $.getJSON('json/categories').done(function (data) { + $('input[name="category"]').typeahead({source: data}); + }); + +} + function updateLayout() { "use strict"; $('#subTitle').text(title[what]); @@ -131,6 +175,7 @@ function clickButton(e) { updateButtons(); updateForm(); updateLayout(); + updateDescription(); } return false; } \ No newline at end of file diff --git a/resources/views/transactions/create.twig b/resources/views/transactions/single/create.twig similarity index 98% rename from resources/views/transactions/create.twig rename to resources/views/transactions/single/create.twig index f978027d70..2b4f3aaaff 100644 --- a/resources/views/transactions/create.twig +++ b/resources/views/transactions/single/create.twig @@ -223,8 +223,7 @@ - - + {% endblock %} {% block styles %}