Created format method for getting translated messages for boolean values - IPA.boolean_column_format.

Used in hosts, sudo rules, hbac rules.

https://fedorahosted.org/freeipa/ticket/2027
--
Petr Vobornik
From df21f935ae6ce05ed0a4709aade99d9e94d2f810 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 5 Dec 2011 16:23:38 +0100
Subject: [PATCH] Search facets show translated boolean values

Created format method for getting translated messages for boolean values - IPA.boolean_column_format.

Used in hosts, sudo rules, hbac rules.

https://fedorahosted.org/freeipa/ticket/2027
---
 install/ui/hbac.js   |    5 ++++-
 install/ui/host.js   |    3 ++-
 install/ui/sudo.js   |    5 ++++-
 install/ui/widget.js |   17 +++++++++++++++++
 4 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/install/ui/hbac.js b/install/ui/hbac.js
index cf13e459ee2128aefd0e539ac4e4aa86950c069b..82d92c5c53a19fffb8b8bf6a52bb340c32b85d85 100644
--- a/install/ui/hbac.js
+++ b/install/ui/hbac.js
@@ -39,7 +39,10 @@ IPA.hbac.rule_entity = function(spec) {
             search_all: true,
             columns: [
                 'cn',
-                'ipaenabledflag',
+                {
+                    name: 'ipaenabledflag',
+                    format: IPA.boolean_column_format
+                },
                 'description'
             ]
         }).
diff --git a/install/ui/host.js b/install/ui/host.js
index 654b34de1ad99c3b80429b31c943d5d831940d6d..4da22df6fde52c6c9974edf1eefe263c62716df4 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -38,7 +38,8 @@ IPA.host.entity = function(spec) {
                 'description',
                 {
                     name: 'has_keytab',
-                    label: IPA.messages.objects.host.enrolled
+                    label: IPA.messages.objects.host.enrolled,
+                    format: IPA.boolean_column_format
                 }
             ]
         }).
diff --git a/install/ui/sudo.js b/install/ui/sudo.js
index 6e7aeca26792ccc19268b436ece2ddf12b4812b0..5163d152621bb09c66571f5efe15f4039c9f6cda 100644
--- a/install/ui/sudo.js
+++ b/install/ui/sudo.js
@@ -37,7 +37,10 @@ IPA.sudo.rule_entity = function(spec) {
         params.builder.search_facet({
             columns: [
                 'cn',
-                'ipaenabledflag',
+                {
+                    name: 'ipaenabledflag',
+                    format: IPA.boolean_column_format
+                },
                 'description'
             ]
         }).
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 5b50d8f16d339aaee499e1e00280eefe20a51545..b8fcbdeb0a17b96678bb5cbca9b88a4688d864bc 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -902,6 +902,23 @@ IPA.textarea_widget = function (spec) {
     return that;
 };
 
+IPA.boolean_column_format = function(value) {
+
+    if (value instanceof Array) {
+        value = value[0];
+    }
+
+    if (value === false || value === 'FALSE' || value === 'false') {
+        return IPA.messages['false'];
+    }
+
+    if (value === true || value === 'TRUE' || value === 'true') {
+        return IPA.messages['true'];
+    }
+
+    return '';
+};
+
 /*
   The entity name must be set in the spec either directly or via entity.name
 */
-- 
1.7.6.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to