From e434de72a3c55f1cc3710e2edf790c1f88abb1a9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 26 Jul 2016 20:40:46 +0200 Subject: [PATCH] Expand fields. --- public/js/ff/split/journal/from-store.js | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/public/js/ff/split/journal/from-store.js b/public/js/ff/split/journal/from-store.js index 4cbb57d3d7..5c8b0ca708 100644 --- a/public/js/ff/split/journal/from-store.js +++ b/public/js/ff/split/journal/from-store.js @@ -8,9 +8,28 @@ /* globals globalSum */ +var destAccounts = {}; +var srcAccounts = {}; +var categories = {}; $(function () { "use strict"; $('.btn-do-split').click(cloneRow); + + $.getJSON('json/expense-accounts').done(function (data) { + destAccounts = data; + console.log('destAccounts length is now ' + destAccounts.length); + }); + + $.getJSON('json/revenue-accounts').done(function (data) { + srcAccounts = data; + console.log('srcAccounts length is now ' + srcAccounts.length); + }); + + $.getJSON('json/categories').done(function (data) { + categories = data; + console.log('categories length is now ' + categories.length); + }); + $('input[name="amount[]"]').on('input', calculateSum) }); @@ -21,6 +40,19 @@ function cloneRow() { source.removeClass('initial-row'); source.find('.count').text('#' + count); source.find('input[name="amount[]"]').val("").on('input', calculateSum); + if (destAccounts.length > 0) { + console.log('Will be able to extend dest-accounts.'); + source.find('input[name="destination_account_name[]"]').typeahead({source: destAccounts}); + } + + if (destAccounts.length > 0) { + console.log('Will be able to extend src-accounts.'); + source.find('input[name="source_account_name[]"]').typeahead({source: srcAccounts}); + } + if(categories.length > 0) { + console.log('Will be able to extend categories.'); + source.find('input[name="category[]"]').typeahead({source: categories}); + } $('.split-table tbody').append(source);