From 7e6ce7c3e80ebe3a61468319ec7509fc5d86de03 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 15 Jan 2023 07:21:51 +0100 Subject: [PATCH] Also in create form. --- public/v1/js/ff/accounts/create.js | 17 +++++++++++++++++ resources/views/accounts/create.twig | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/public/v1/js/ff/accounts/create.js b/public/v1/js/ff/accounts/create.js index 7940fe5cc7..2cc44b873f 100644 --- a/public/v1/js/ff/accounts/create.js +++ b/public/v1/js/ff/accounts/create.js @@ -30,4 +30,21 @@ $(document).ready(function () { } ); } + // change the 'ffInput_opening_balance' text based on the + // selection of the direction. + $("#ffInput_liability_direction").change(triggerDirection); + triggerDirection(); }); + + +function triggerDirection() { + let obj = $("#ffInput_liability_direction"); + let direction = obj.val(); + console.log('Direction is now ' + direction); + if('credit' === direction) { + $('label[for="ffInput_opening_balance"]').text(iAmOwed); + } + if('debit' === direction) { + $('label[for="ffInput_opening_balance"]').text(iOwe); + } +} diff --git a/resources/views/accounts/create.twig b/resources/views/accounts/create.twig index 87bef950f5..b83bb08dcc 100644 --- a/resources/views/accounts/create.twig +++ b/resources/views/accounts/create.twig @@ -84,6 +84,10 @@ {% endblock %} {% block scripts %} +