Skip to content

Commit

Permalink
ui/bug getodk#159: more NPE/false-assumption bugs with successor logic.
Browse files Browse the repository at this point in the history
* actually resolves getodk#159.
  • Loading branch information
issa-tseng committed Jun 5, 2017
1 parent 9a17eb0 commit 9673385
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion public/javascripts/control.js
Expand Up @@ -110,7 +110,7 @@
_.each(properties, function(property)
{
if (property.bindControlClass != null)
$this.toggleClass(property.bindControlClass, property.value !== false);
$this.toggleClass(property.bindControlClass, ((property.value != null) && (property.value !== false)));
});

// SPECIAL CASE:
Expand Down
11 changes: 6 additions & 5 deletions public/javascripts/property-editor.js
Expand Up @@ -229,15 +229,16 @@
var $select = $editor.find('select');
var update = function()
{
$enable.attr('checked', property.value !== false);
$select.attr('disabled', property.value === false);
var value = (property.value == null) ? false : property.value;
$enable.attr('checked', value);
$select.attr('disabled', value);
updateOptions();
};

var updateOptions = function()
{
var $options = $select.find('option').detach();
var selectedValue = property.value[0]; // default to the saved value.
var selectedValue = (property.value == null) ? undefined : property.value[0]; // default to the saved value.

_.each(optionsProperty.value, function(option)
{
Expand All @@ -246,15 +247,15 @@
selectedValue = option.val;

// on the other hand, if we have no ref yet and we match, grab the ref.
if ((selectedOption == null) && (property.value[0] === option.val))
if ((selectedOption == null) && (selectedValue === option.val))
selectedOption = option;

var existing = _.find($options, function(dom) { return $(dom).data('option') === option; });
existing = (existing == null) ? $('<option/>').data('option', option) : $(existing);
$select.append(existing.text(option.val).attr('value', option.val));
});

if (property.value !== false)
if ((property.value !== false) && (property.value != null))
{
if (selectedValue != null)
{
Expand Down

0 comments on commit 9673385

Please sign in to comment.