diff options
author | Petr VobornÃk <pvoborni@redhat.com> | 2012-02-22 17:12:11 +0100 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2012-02-29 13:07:22 +0100 |
commit | e4564ab33b73d6c1d8004ebe34c573919b443d6d (patch) | |
tree | ae6db60354dce09541ed5113fdfc40959b53e6f7 | |
parent | 0ec8b421ec8f2dfa4572f3d3253a0888c58c6fb0 (diff) | |
download | freeipa.git-e4564ab33b73d6c1d8004ebe34c573919b443d6d.tar.gz freeipa.git-e4564ab33b73d6c1d8004ebe34c573919b443d6d.tar.xz freeipa.git-e4564ab33b73d6c1d8004ebe34c573919b443d6d.zip |
Moved is_empty method from field to IPA object
is_empty method represents IPA UI standard of evaluating whether value is empty. Therefore is should be placed in IPA object instead of IPA.field to allow reuse in different locations.
https://fedorahosted.org/freeipa/ticket/2351
-rw-r--r-- | install/ui/dns.js | 4 | ||||
-rw-r--r-- | install/ui/field.js | 26 | ||||
-rw-r--r-- | install/ui/ipa.js | 16 |
3 files changed, 23 insertions, 23 deletions
diff --git a/install/ui/dns.js b/install/ui/dns.js index c849eeca..8125f9d3 100644 --- a/install/ui/dns.js +++ b/install/ui/dns.js @@ -1845,8 +1845,8 @@ IPA.dns.netaddr_field = function(spec) { var values = that.field_save(); //check for empty value: null, [''], '', [] - var orig_empty = that.is_empty(that.values); - var new_empty= that.is_empty(values); + var orig_empty = IPA.is_empty(that.values); + var new_empty= IPA.is_empty(values); if (orig_empty && new_empty) return false; if (orig_empty != new_empty) return true; diff --git a/install/ui/field.js b/install/ui/field.js index b821fd92..d5e3fe34 100644 --- a/install/ui/field.js +++ b/install/ui/field.js @@ -103,7 +103,7 @@ IPA.field = function(spec) { that.validate_required = function() { var values = that.save(); - if (that.is_empty(values) && that.is_required() && that.enabled) { + if (IPA.is_empty(values) && that.is_required() && that.enabled) { that.valid = false; that.show_error(IPA.messages.widget.validation.required); return false; @@ -124,7 +124,7 @@ IPA.field = function(spec) { var values = that.save(); - if (that.is_empty(values)) { + if (IPA.is_empty(values)) { return that.valid; } @@ -268,8 +268,8 @@ IPA.field = function(spec) { var values = that.save(); //check for empty value: null, [''], '', [] - var orig_empty = that.is_empty(that.values); - var new_empty= that.is_empty(values); + var orig_empty = IPA.is_empty(that.values); + var new_empty= IPA.is_empty(values); if (orig_empty && new_empty) return false; if (orig_empty != new_empty) return true; @@ -296,22 +296,6 @@ IPA.field = function(spec) { return true; }; - that.is_empty = function(value) { - - var empty = false; - - if (!value) empty = true; - - if (value instanceof Array) { - empty = empty || value.length === 0 || - (value.length === 1) && (value[0] === ''); - } - - if (value === '') empty = true; - - return empty; - }; - /** * This function compares the original values and the * values entered in the UI. If the values have changed @@ -561,7 +545,7 @@ IPA.multivalued_field = function(spec) { that.hide_error(); that.valid = true; - if (that.is_empty(values)) { + if (IPA.is_empty(values)) { return that.valid; } diff --git a/install/ui/ipa.js b/install/ui/ipa.js index 433d7fe6..441e6468 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -1207,6 +1207,22 @@ IPA.create_options = function(labels, values) { return options; }; +IPA.is_empty = function(value) { + + var empty = false; + + if (!value) empty = true; + + if (value instanceof Array) { + empty = empty || value.length === 0 || + (value.length === 1) && (value[0] === ''); + } + + if (value === '') empty = true; + + return empty; +}; + IPA.config = { default_priority: 500 }; |