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

@@ -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
*/