summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-09-17 10:48:24 +0200
committerAlexander Bokovoy <abokovoy@redhat.com>2014-02-11 15:02:51 +0200
commit0da0fc4322bd2be03f3889312dd3f9d256f493a3 (patch)
tree29fef5bdbd877319ae4d782458440fb667bce3c8
parente8c425b2b46bd762389c1071aaa472ba6ca4e503 (diff)
downloadfreeipa-0da0fc4322bd2be03f3889312dd3f9d256f493a3.tar.gz
freeipa-0da0fc4322bd2be03f3889312dd3f9d256f493a3.tar.xz
freeipa-0da0fc4322bd2be03f3889312dd3f9d256f493a3.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.
-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];