summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYingtong Li <runassudo@yingtongli.me>2020-06-16 12:28:07 +1000
committerYingtong Li <runassudo@yingtongli.me>2020-06-16 12:28:07 +1000
commite7e39ef66f8cad2b668989dfb35bb6f1c0728a69 (patch)
tree7687b2e93aa996dba1dcd3416ea2301135c2d8fd
parentb2913eac9d6e42a60c88dde5d2137257be3a94e3 (diff)
Implement BSB lookup on claim edit page
-rw-r--r--sstreasury/jinja2/sstreasury/claim_edit.html16
-rw-r--r--sstreasury/views.py5
2 files changed, 19 insertions, 2 deletions
diff --git a/sstreasury/jinja2/sstreasury/claim_edit.html b/sstreasury/jinja2/sstreasury/claim_edit.html
index 28efb97..6cc60bd 100644
--- a/sstreasury/jinja2/sstreasury/claim_edit.html
+++ b/sstreasury/jinja2/sstreasury/claim_edit.html
@@ -76,10 +76,14 @@
<label class="three wide column">Payee name</label>
<input class="eleven wide column" type="text" name="payee_name" value="{{ claim.payee_name }}">
</div>
- <div class="ui required inline grid field">
+ <div class="ui required inline grid field" style="margin-bottom: 0.5em;">
<label class="three wide column">Payee BSB</label>
<input class="eleven wide column" type="text" name="payee_bsb" value="{{ claim.payee_bsb }}">
</div>
+ <div class="ui inline grid field" style="margin-top: 0.5em;">
+ <div class="three wide column" style="padding-top: 0; padding-bottom: 0;"></div>
+ <div class="eleven wide column" style="padding-top: 0; padding-bottom: 0;" id="bsb_lookedup">{% if bsb_lookedup %}{{ bsb_lookedup }}{% endif %}</div>
+ </div>
<div class="ui required inline grid field">
<label class="three wide column">Payee account number</label>
<input class="eleven wide column" type="text" name="payee_account" value="{{ claim.payee_account }}">
@@ -193,5 +197,15 @@
return el.classList.contains('totalrow');
}
});
+
+ $('input[name="payee_bsb"]').blur(function() {
+ $.get('{{ url('bsb_lookup') }}?bsb=' + this.value, function(data, status, xhr) {
+ if (data.result) {
+ $('#bsb_lookedup').text(data.result);
+ } else {
+ $('#bsb_lookedup').text('');
+ }
+ });
+ })
</script>
{% endblock %}
diff --git a/sstreasury/views.py b/sstreasury/views.py
index af809e0..4cedc83 100644
--- a/sstreasury/views.py
+++ b/sstreasury/views.py
@@ -585,8 +585,11 @@ def claim_edit(request, claim):
else:
return redirect(reverse('claim_edit', kwargs={'id': claim.id}))
else:
+ bsb_lookedup = do_bsb_lookup(claim.payee_bsb)
+
return render(request, 'sstreasury/claim_edit.html', {
- 'claim': claim
+ 'claim': claim,
+ 'bsb_lookedup': bsb_lookedup
})
@login_required
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.