mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
committed by
Petr Viktorin
parent
d6a7923f71
commit
9e6cc48be6
@@ -1490,17 +1490,21 @@ exp.boolean_state_evaluator = IPA.boolean_state_evaluator = function(spec) {
|
|||||||
that.false_state = spec.false_state || that.field_name + '-false';
|
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}
|
* @property {boolean}
|
||||||
*/
|
*/
|
||||||
that.invert_value = spec.invert_value;
|
that.invert_value = spec.invert_value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value parser
|
* Value parser
|
||||||
|
*
|
||||||
* @property {IPA.boolean_formatter}
|
* @property {IPA.boolean_formatter}
|
||||||
*/
|
*/
|
||||||
that.parser = IPA.build({
|
that.parser = IPA.build(spec.parser || {
|
||||||
$factory: spec.parser || IPA.boolean_formatter,
|
$factory: IPA.boolean_formatter,
|
||||||
invert_value: that.invert_value
|
invert_value: that.invert_value
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1838,14 +1838,26 @@ IPA.boolean_formatter = function(spec) {
|
|||||||
that.show_false = spec.show_false;
|
that.show_false = spec.show_false;
|
||||||
/** Parse return inverted value */
|
/** Parse return inverted value */
|
||||||
that.invert_value = spec.invert_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
|
* Convert string boolean value into real boolean value, or keep
|
||||||
* the original value
|
* the original value
|
||||||
|
*
|
||||||
|
* @param {Mixed} value Value to parse
|
||||||
|
* @return {boolean|""}
|
||||||
*/
|
*/
|
||||||
that.parse = function(value) {
|
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) {
|
if (value instanceof Array) {
|
||||||
value = value[0];
|
value = value[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user