From 774434b4ad43d3660ae83c22026cd9129e0b6241 Mon Sep 17 00:00:00 2001 From: kienan Date: Wed, 22 Apr 2020 20:19:22 -0400 Subject: [PATCH] Add synchronisation for the is_first_negotiation checkbox --- negotiation.py | 3 ++- templates/negotiation.html | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/negotiation.py b/negotiation.py index 64a56b9..8c18736 100755 --- a/negotiation.py +++ b/negotiation.py @@ -69,7 +69,8 @@ def negotiation_create(): # @TODO Signal to the user that the negotiation already exists and they # are being sent to it instead. return flask.redirect('/negotiations/{}'.format(n)) - nego = Negotiation(name = n, owner = user.id, taker_sway = 1, market_sway = 6) + nego = Negotiation(name = n, owner = user.id, taker_sway = 1, + market_sway = 6, is_first_negotiation = 1) pony.orm.commit() return flask.redirect('/negotiations/{}'.format(n)) diff --git a/templates/negotiation.html b/templates/negotiation.html index 75fcfe3..7598722 100644 --- a/templates/negotiation.html +++ b/templates/negotiation.html @@ -87,6 +87,9 @@ if ('negotiator_name' in e) { $('.negotiator-name').html(e['negotiator_name']); } + if ('is_first_negotiation' in e) { + $('#is-first-negotiation').prop('checked', e['is_first_negotiation'] == true) + } } function swayslot_on_dragstart(event) { var ev = event.originalEvent; @@ -129,7 +132,17 @@ "room": room, }; var id = e.target['id']; - var value = $("#" + id).val(); + console.log($('#' + id)); + var dom_obj = $('#' + id); + var value; + switch (dom_obj.attr('type')) { + case 'checkbox': + value = dom_obj.prop('checked'); + break; + default: + value = dom_obj.val(); + break; + } // Regex is needed, since replace only functions on the first // occurrence otherwise. var key = id.replace(/-/g, '_');