Skip to content

Commit

Permalink
auto-coerce strings of the form "true" to be boolean flags so they ap…
Browse files Browse the repository at this point in the history
…pear in checkboxes #383
  • Loading branch information
jstrachan committed Jul 9, 2013
1 parent b2f0567 commit af19608
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hawtio-web/src/main/webapp/app/forms/js/baseDirectives.ts
Expand Up @@ -376,8 +376,23 @@ module Forms {
if (config.isReadOnly()) {
rc.attr('readonly', 'true');
}

// lets coerce any string values to boolean so that they work properly with the UI
var scope = config.scope;
if (scope) {
function onModelChange() {
var value = Core.pathGet(scope, modelName);
if (value && "true" === value) {
//console.log("coercing String to boolean for " + modelName);
Core.pathSet(scope, modelName, true);
}
}
scope.$watch(modelName, onModelChange);
onModelChange();
}
return rc;
}

}

}

0 comments on commit af19608

Please sign in to comment.