From 0e8b57b08988f0121348e30a6d8aafe2aad07759 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Mon, 5 Dec 2011 16:23:38 +0100 Subject: 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/widget.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'install/ui/widget.js') diff --git a/install/ui/widget.js b/install/ui/widget.js index ef2c6eb6..a8ad5cd8 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -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 */ -- cgit