summaryrefslogtreecommitdiffstats
path: root/install/ui/widget.js
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2012-01-05 09:10:11 -0600
committerPetr Vobornik <pvoborni@redhat.com>2012-01-06 15:25:43 +0100
commit2a00393712eb490b23604399ea8318b3b4cca118 (patch)
tree53af8579d526130441e018fa1e7a13de823e8b40 /install/ui/widget.js
parent1b1aad2b02e57988b2e91a29305bd45f2059b91a (diff)
downloadfreeipa.git-2a00393712eb490b23604399ea8318b3b4cca118.tar.gz
freeipa.git-2a00393712eb490b23604399ea8318b3b4cca118.tar.xz
freeipa.git-2a00393712eb490b23604399ea8318b3b4cca118.zip
Added account status into user search facet.
The user search facet has been modified to show the account status. The IPA.boolean_format has been converted into a class to allow behavior customization. Ticket #1996
Diffstat (limited to 'install/ui/widget.js')
-rw-r--r--install/ui/widget.js72
1 files changed, 57 insertions, 15 deletions
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 38646c99..9ae308ca 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -927,25 +927,67 @@ IPA.textarea_widget = function (spec) {
return that;
};
-IPA.boolean_format = function(value) {
+IPA.format = function(spec) {
- if (value === undefined || value === null) return '';
+ spec = spec || {};
- if (value instanceof Array) {
- value = value[0];
- }
+ var that = {};
- var normalized_value = typeof value === 'string' ? value.toLowerCase() : '';
+ that.format = function(value) {
+ return value;
+ };
- if (value === false || normalized_value === 'false') {
- return IPA.messages['false'];
- }
+ return that;
+};
- if (value === true || normalized_value === 'true') {
- return IPA.messages['true'];
- }
+IPA.boolean_format = function(spec) {
+
+ spec = spec || {};
+
+ var that = IPA.format(spec);
+
+ that.true_value = spec.true_value || IPA.messages['true'];
+ that.false_value = spec.false_value || IPA.messages['false'];
+ that.show_false = spec.show_false;
+ that.invert_value = spec.invert_value;
+
+ that.format = function(value) {
+
+ if (value === undefined || value === null) return '';
+
+ if (value instanceof Array) {
+ value = value[0];
+ }
+
+ if (typeof value === 'string') {
+ value = value.toLowerCase();
+
+ if (value === 'true') {
+ value = true;
+ } else if (value === 'false') {
+ value = false;
+ } // leave other values unchanged
+ }
- return value;
+ if (typeof value === 'boolean') {
+ if (that.invert_value) value = !value;
+
+ if (value) {
+ value = that.true_value;
+
+ } else {
+ if (that.show_false) {
+ value = that.false_value;
+ } else {
+ value = '';
+ }
+ }
+ }
+
+ return value;
+ };
+
+ return that;
};
/*
@@ -978,8 +1020,8 @@ IPA.column = function (spec) {
container.empty();
var value = record[that.name];
- if (that.format && value) {
- value = that.format(value);
+ if (that.format) {
+ value = that.format.format(value);
}
value = value ? value.toString() : '';