summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-09-17 10:48:24 +0200
committerPetr Viktorin <pviktori@redhat.com>2014-03-12 17:29:27 +0100
commit9e6cc48be6185a0fdd85cef45a33438355e11e1a (patch)
tree5646c6e6874f7d063861ecb30bb9896903343edf
parentd6a7923f71eb69bac53d6ff904086a9abd103dbc (diff)
downloadfreeipa-9e6cc48be6185a0fdd85cef45a33438355e11e1a.tar.gz
freeipa-9e6cc48be6185a0fdd85cef45a33438355e11e1a.tar.xz
freeipa-9e6cc48be6185a0fdd85cef45a33438355e11e1a.zip
Added empty value meaning to boolean formatter
Boolean object properties can have different default meaning for not defined value. This patch allows to defined this meaning to `boolean_formatter` by introduction of `emty_value` property. `boolean_state_evaluator` was modified to leverage it as well. Reviewed-By: Adam Misnyovszki <amisnyov@redhat.com>
-rw-r--r--install/ui/src/freeipa/details.js10
-rw-r--r--install/ui/src/freeipa/widget.js14
2 files changed, 20 insertions, 4 deletions
diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js
index 00134a23d..907eae47c 100644
--- a/install/ui/src/freeipa/details.js
+++ b/install/ui/src/freeipa/details.js
@@ -1490,17 +1490,21 @@ exp.boolean_state_evaluator = IPA.boolean_state_evaluator = function(spec) {
that.false_state = spec.false_state || that.field_name + '-false';
/**
- * Inverted logic
+ * Inverts evaluation logic
+ *
+ * NOTE: is ignored when custom parser is set
+ *
* @property {boolean}
*/
that.invert_value = spec.invert_value;
/**
* Value parser
+ *
* @property {IPA.boolean_formatter}
*/
- that.parser = IPA.build({
- $factory: spec.parser || IPA.boolean_formatter,
+ that.parser = IPA.build(spec.parser || {
+ $factory: IPA.boolean_formatter,
invert_value: that.invert_value
});
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 9ea5ea0e0..b3ea3a838 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -1838,14 +1838,26 @@ IPA.boolean_formatter = function(spec) {
that.show_false = spec.show_false;
/** Parse return inverted value */
that.invert_value = spec.invert_value;
+ /**
+ * Result of parse of `undefined` or `null` value will be `empty_value`
+ * if set.
+ * @property {boolean|undefined}
+ */
+ that.empty_value = spec.empty_value;
/**
* Convert string boolean value into real boolean value, or keep
* the original value
+ *
+ * @param {Mixed} value Value to parse
+ * @return {boolean|""}
*/
that.parse = function(value) {
- if (value === undefined || value === null) return '';
+ if (value === undefined || value === null) {
+ if (that.empty_value !== undefined) value = that.empty_value;
+ else return '';
+ }
if (value instanceof Array) {
value = value[0];