Update views and JS for create (single) transaction.

This commit is contained in:
James Cole 2017-01-15 19:07:31 +01:00
parent b118635abd
commit 582398e7f6
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 54 additions and 8 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -223,8 +223,7 @@
</script>
<script type="text/javascript" src="js/lib/bootstrap3-typeahead.min.js"></script>
<script type="text/javascript" src="js/lib/bootstrap-tagsinput.min.js"></script>
<script type="text/javascript" src="js/ff/transactions/create-edit.js"></script>
<script type="text/javascript" src="js/ff/transactions/create.js"></script>
<script type="text/javascript" src="js/ff/transactions/single/create.js"></script>
{% endblock %}
{% block styles %}