[Freeipa-devel] [PATCH] 051 Search facets show translated boolean values

2011-12-05 Thread Petr Vobornik
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 
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

Re: [Freeipa-devel] [PATCH] 051 Search facets show translated boolean values

2011-12-05 Thread Endi Sukma Dewata

On 12/5/2011 9:37 AM, Petr Vobornik wrote:

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


The patch works, so it's ACKed. There are a few suggestions but they can 
be done later:


1. It might be better to name the function IPA.boolean_format because we 
can use it for other things too, not just inside a column.


2. The value can be normalized using toLowerCase() before comparison.

3. If the value doesn't match true/false it can return the original 
value instead of empty string.


--
Endi S. Dewata

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


Re: [Freeipa-devel] [PATCH] 051 Search facets show translated boolean values

2011-12-05 Thread Adam Young

On 12/05/2011 12:27 PM, Endi Sukma Dewata wrote:

On 12/5/2011 9:37 AM, Petr Vobornik wrote:

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


The patch works, so it's ACKed. There are a few suggestions but they 
can be done later:


1. It might be better to name the function IPA.boolean_format because 
we can use it for other things too, not just inside a column.


2. The value can be normalized using toLowerCase() before comparison.

3. If the value doesn't match true/false it can return the original 
value instead of empty string.





Can we make this the default handling for boolean columns?


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


Re: [Freeipa-devel] [PATCH] 051 Search facets show translated boolean values

2011-12-07 Thread Petr Vobornik

On 12/05/2011 06:27 PM, Endi Sukma Dewata wrote:

On 12/5/2011 9:37 AM, Petr Vobornik wrote:

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


The patch works, so it's ACKed.


New version attached.


There are a few suggestions but they can
be done later:

1. It might be better to name the function IPA.boolean_format because we
can use it for other things too, not just inside a column.


Renamed


2. The value can be normalized using toLowerCase() before comparison.


Done, but using normalized value only for comparison because of #3.


3. If the value doesn't match true/false it can return the original
value instead of empty string


Done. Returning empty string if null or undefined.

Newly used in HBAC test page.

--
Petr Vobornik
From 663e2d4ec6f951a8fde29d9fb17b5f7521fe51a8 Mon Sep 17 00:00:00 2001
From: Petr Vobornik 
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_format.

Used in hosts, sudo rules, hbac rules and hbac test.

https://fedorahosted.org/freeipa/ticket/2027
---
 install/ui/hbac.js |5 -
 install/ui/hbactest.js |   19 ++-
 install/ui/host.js |3 ++-
 install/ui/sudo.js |5 -
 install/ui/widget.js   |   21 +
 5 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/install/ui/hbac.js b/install/ui/hbac.js
index 21333fa7b9a7ceb9f21857d52a44494c66da89af..3d2124e40647d9146e1a328afaf7c58fd59bb6e2 100644
--- a/install/ui/hbac.js
+++ b/install/ui/hbac.js
@@ -40,7 +40,10 @@ IPA.hbac.rule_entity = function(spec) {
 search_all: true,
 columns: [
 'cn',
-'ipaenabledflag',
+{
+name: 'ipaenabledflag',
+format: IPA.boolean_format
+},
 'description'
 ]
 }).
diff --git a/install/ui/hbactest.js b/install/ui/hbactest.js
index 57ded45bab74185fe8bb097956cc62a951e5586a..d9a854f11f3e7d7e92d305589e28142aadf0df99 100644
--- a/install/ui/hbactest.js
+++ b/install/ui/hbactest.js
@@ -61,7 +61,8 @@ IPA.hbac.test_entity = function(spec) {
 'description',
 {
 name: 'has_keytab',
-label: IPA.messages.objects.host.enrolled
+label: IPA.messages.objects.host.enrolled,
+format: IPA.boolean_format
 }
 ]
 }).
@@ -89,7 +90,8 @@ IPA.hbac.test_entity = function(spec) {
 'description',
 {
 name: 'has_keytab',
-label: IPA.messages.objects.host.enrolled
+label: IPA.messages.objects.host.enrolled,
+format: IPA.boolean_format
 }
 ]
 }).
@@ -102,7 +104,10 @@ IPA.hbac.test_entity = function(spec) {
 facet_group: 'default',
 columns: [
 'cn',
-'ipaenabledflag',
+{
+name: 'ipaenabledflag',
+format: IPA.boolean_format
+},
 'description'
 ]
 }).
@@ -118,9 +123,13 @@ IPA.hbac.test_entity = function(spec) {
 'cn',
 {
 name: 'matched',
-label: IPA.messages.objects.hbactest.matched
+label: IPA.messages.objects.hbactest.matched,
+format: IPA.boolean_format
+},
+{
+name: 'ipaenabledflag',
+format: IPA.boolean_format
 },
-'ipaenabledflag',
 'description'
 ]
 });
diff --git a/install/ui/host.js b/install/ui/host.js
index 94dd6465f6c9e4c432328d1cb32fa58fbfc38b87..7427a9b1673a323fa3127105f53ef873ad1e6146 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -39,7 +39,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_format
 }
 ]
 }).
diff --git a/install/ui/sudo.js b/install/ui/sudo.js
index 2d3baf95ea834a69956216568f63034244d4df9d..5e1dedc7eaafe48c01c8e5b8ad90158cc4d9f976 100644
--- a/install/ui/sudo.js
+++ b/install/ui/sudo.js
@@ -38,7 +38,10 @@ IPA.sudo.rule_entity = function(spec) {
 that.builder.search_facet({
 columns: [
 'cn',
-'ipaenabledflag',
+{
+name: 'ipaenab

Re: [Freeipa-devel] [PATCH] 051 Search facets show translated boolean values

2011-12-07 Thread Endi Sukma Dewata

On 12/7/2011 10:00 AM, Petr Vobornik wrote:

New version attached.


ACK and pushed to master.

--
Endi S. Dewata

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