From f8024b747e436c2eacaec8b5e3a477316db9f0c4 Mon Sep 17 00:00:00 2001 From: koksnuss Date: Sat, 9 May 2020 16:58:53 +0200 Subject: [PATCH] fix checkbox #found behaviour --- coinmanager/coinc/static/coinc/main.js | 34 +++++++++++++++---- .../coinc/templates/coinc/controlbar.html | 1 + 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/coinmanager/coinc/static/coinc/main.js b/coinmanager/coinc/static/coinc/main.js index b2f646e..e071291 100644 --- a/coinmanager/coinc/static/coinc/main.js +++ b/coinmanager/coinc/static/coinc/main.js @@ -64,6 +64,11 @@ $(document).ready(function() { // Misc // + // checkbox #found + $('#found').change(function() { + render_found(); + }); + // checkbox #exists $('input#exists').change(function() { @@ -106,14 +111,10 @@ $(document).ready(function() { $(this).prop('disabled', ''); }); - } - }); + // do post processing + render_found(); - // datepicker TODO make it nicer - $.datepicker.setDefaults( $.datepicker.regional['de'] ); - $('input[name=found_on]').datepicker({ - defaultDate: new Date(), - dateFormat: 'dd.mm.yy' + } }); // select username on change @@ -123,6 +124,13 @@ $(document).ready(function() { render_login(this.value, color); }); + // datepicker TODO make it nicer + $.datepicker.setDefaults( $.datepicker.regional['de'] ); + $('input[name=found_on]').datepicker({ + defaultDate: new Date(), + dateFormat: 'dd.mm.yy' + }); + // // Functions @@ -157,6 +165,18 @@ $(document).ready(function() { } } + function render_found() { + let checked = $('#found').prop('checked'); + console.log(checked); + $('#found_by, #found_on').each(function() { + if (checked) { + $(this).prop('disabled', ''); + } else { + $(this).prop('disabled', 'disabled'); + } + }); + } + // // Modals diff --git a/coinmanager/coinc/templates/coinc/controlbar.html b/coinmanager/coinc/templates/coinc/controlbar.html index 856d5aa..e87dd6c 100644 --- a/coinmanager/coinc/templates/coinc/controlbar.html +++ b/coinmanager/coinc/templates/coinc/controlbar.html @@ -65,6 +65,7 @@
+