Add synchronisation for the is_first_negotiation checkbox

This commit is contained in:
kienan 2020-04-22 20:19:22 -04:00
parent 9e6ffb0174
commit 774434b4ad
2 changed files with 16 additions and 2 deletions

View File

@ -69,7 +69,8 @@ def negotiation_create():
# @TODO Signal to the user that the negotiation already exists and they # @TODO Signal to the user that the negotiation already exists and they
# are being sent to it instead. # are being sent to it instead.
return flask.redirect('/negotiations/{}'.format(n)) 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() pony.orm.commit()
return flask.redirect('/negotiations/{}'.format(n)) return flask.redirect('/negotiations/{}'.format(n))

View File

@ -87,6 +87,9 @@
if ('negotiator_name' in e) { if ('negotiator_name' in e) {
$('.negotiator-name').html(e['negotiator_name']); $('.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) { function swayslot_on_dragstart(event) {
var ev = event.originalEvent; var ev = event.originalEvent;
@ -129,7 +132,17 @@
"room": room, "room": room,
}; };
var id = e.target['id']; 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 // Regex is needed, since replace only functions on the first
// occurrence otherwise. // occurrence otherwise.
var key = id.replace(/-/g, '_'); var key = id.replace(/-/g, '_');