Skip to content

Firefly III: a personal finances manager

Also in create form.

James Cole7e6ce7c3e80e
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 @@
</form>
{% endblock %}
{% block scripts %}
+ <script type="text/javascript" nonce="{{ JS_NONCE }}">
+ var iAmOwed = '{{ 'i_am_owed_amount'|_|escape('js') }}';
+ var iOwe = '{{ 'i_owe_amount'|_|escape('js') }}';
+ </script>
<script src="v1/lib/leaflet/leaflet.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/lib/jquery-ui.min.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>