diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php
index 555935fe01..91b35ddfce 100644
--- a/app/Http/Controllers/Transaction/SplitController.php
+++ b/app/Http/Controllers/Transaction/SplitController.php
@@ -112,7 +112,7 @@ class SplitController extends Controller
Session::forget('transactions.edit-split.fromUpdate');
return view(
- 'transactions.edit-split',
+ 'transactions.split.edit',
compact(
'subTitleIcon', 'currencies', 'optionalFields',
'preFilled', 'subTitle', 'amount', 'sourceAccounts', 'uploadSize', 'destinationAccounts', 'assetAccounts',
diff --git a/public/js/ff/transactions/create-edit.js b/public/js/ff/transactions/create-edit.js
index 4684f71a45..08b876979e 100644
--- a/public/js/ff/transactions/create-edit.js
+++ b/public/js/ff/transactions/create-edit.js
@@ -33,7 +33,9 @@ $(document).ready(function () {
var opt = {
typeahead: {
source: data,
- afterSelect: function(val) { this.$element.val(""); }
+ afterSelect: function () {
+ this.$element.val("");
+ }
}
};
$('input[name="tags"]').tagsinput(
@@ -94,6 +96,4 @@ $(document).ready(function () {
}
-
-
});
\ No newline at end of file
diff --git a/public/js/ff/transactions/edit.js b/public/js/ff/transactions/edit.js
index 63390bc3e6..ee5149b3b3 100644
--- a/public/js/ff/transactions/edit.js
+++ b/public/js/ff/transactions/edit.js
@@ -10,5 +10,48 @@
$(document).ready(function () {
"use strict";
- // no special JS for edit transaction.
+
+ // withdrawal specific fields
+ if (what == 'withdrawal') {
+
+ $.getJSON('json/expense-accounts').done(function (data) {
+ $('input[name="destination_account_name"]').typeahead({source: data});
+ });
+ }
+
+ // deposit specific fields:
+ if (what == 'deposit') {
+ $.getJSON('json/revenue-accounts').done(function (data) {
+ $('input[name="source_account_name"]').typeahead({source: data});
+ });
+ }
+
+ // tags are always present:
+ 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
+ );
+ });
+ }
+
+ // description
+ $.getJSON('json/transaction-journals/' + what).done(function (data) {
+ $('input[name="description"]').typeahead({source: data});
+ });
+
+ // category (always there)
+ $.getJSON('json/categories').done(function (data) {
+ $('input[name="category"]').typeahead({source: data});
+ });
+
});
diff --git a/public/js/ff/split/journal/from-store.js b/public/js/ff/transactions/split/edit.js
similarity index 83%
rename from public/js/ff/split/journal/from-store.js
rename to public/js/ff/transactions/split/edit.js
index a7323a12a6..83ef63d57d 100644
--- a/public/js/ff/split/journal/from-store.js
+++ b/public/js/ff/transactions/split/edit.js
@@ -1,19 +1,20 @@
/*
- * from-store.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.
+ * edit.js
+ * 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.
*/
+
/** global: originalSum, accounting */
var destAccounts = {};
var srcAccounts = {};
var categories = {};
-$(function () {
+var descriptions = {};
+
+$(document).ready(function () {
"use strict";
$('.btn-do-split').click(cloneRow);
$('.remove-current-split').click(removeRow);
@@ -33,13 +34,32 @@ $(function () {
$('input[name$="category]"]').typeahead({source: categories});
});
+ $.getJSON('json/transaction-journals/' + what).done(function (data) {
+ descriptions = data;
+ $('input[name="journal_description"]').typeahead({source: descriptions});
+ $('input[name$="description]"]').typeahead({source: descriptions});
+ });
+
+ $.getJSON('json/tags').done(function (data) {
+
+ var opt = {
+ typeahead: {
+ source: data,
+ afterSelect: function () {
+ this.$element.val("");
+ }
+ }
+ };
+ $('input[name="tags"]').tagsinput(
+ opt
+ );
+ });
+
+
$('input[name$="][amount]"]').on('input', calculateSum);
-
- // add auto complete:
-
-
});
+
function removeRow(e) {
"use strict";
var rows = $('table.split-table tbody tr');
@@ -75,6 +95,9 @@ function cloneRow() {
if (categories.length > 0) {
source.find('input[name$="category]"]').typeahead({source: categories});
}
+ if (descriptions.length > 0) {
+ source.find('input[name$="description]"]').typeahead({source: descriptions});
+ }
$('.split-table tbody').append(source);
diff --git a/resources/views/transactions/edit-split.twig b/resources/views/transactions/split/edit.twig
similarity index 98%
rename from resources/views/transactions/edit-split.twig
rename to resources/views/transactions/split/edit.twig
index f47ec11af3..d811f4798e 100644
--- a/resources/views/transactions/edit-split.twig
+++ b/resources/views/transactions/split/edit.twig
@@ -307,6 +307,5 @@
-
-
+
{% endblock %}