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
This commit is contained in:
Petr Vobornik 2011-12-05 16:23:38 +01:00 committed by Endi S. Dewata
parent c1d0f72c20
commit 0e8b57b089
5 changed files with 45 additions and 8 deletions

View File

@ -40,7 +40,10 @@ IPA.hbac.rule_entity = function(spec) {
search_all: true,
columns: [
'cn',
'ipaenabledflag',
{
name: 'ipaenabledflag',
format: IPA.boolean_format
},
'description'
]
}).

View File

@ -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'
]
});

View File

@ -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
}
]
}).

View File

@ -38,7 +38,10 @@ IPA.sudo.rule_entity = function(spec) {
that.builder.search_facet({
columns: [
'cn',
'ipaenabledflag',
{
name: 'ipaenabledflag',
format: IPA.boolean_format
},
'description'
]
}).

View File

@ -902,6 +902,27 @@ IPA.textarea_widget = function (spec) {
return that;
};
IPA.boolean_format = function(value) {
if (value === undefined || value === null) return '';
if (value instanceof Array) {
value = value[0];
}
var normalized_value = typeof value === 'string' ? value.toLowerCase() : '';
if (value === false || normalized_value === 'false') {
return IPA.messages['false'];
}
if (value === true || normalized_value === 'true') {
return IPA.messages['true'];
}
return value;
};
/*
The entity name must be set in the spec either directly or via entity.name
*/