From 7c392cb9a85e1534bd1133c4e0c9c3831058b4e7 Mon Sep 17 00:00:00 2001 From: Petr Voborník Date: Fri, 10 Feb 2012 11:25:41 +0100 Subject: New checkboxes option: Mutual exclusive Problem: UI doesn't have a control for selecting one or none value from given set of values. Solution: Attribute mutex was added to checkboxes_widget. When it is set, checking some value causes that all other values are unchecked. https://fedorahosted.org/freeipa/ticket/2351 --- install/ui/widget.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'install/ui/widget.js') diff --git a/install/ui/widget.js b/install/ui/widget.js index 3201dad7..cc5f4f78 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -665,6 +665,7 @@ IPA.checkboxes_widget = function (spec) { that.options = spec.options || []; that.direction = spec.direction || 'vertical'; + that.mutex = spec.mutex; that.create = function(container) { @@ -699,6 +700,15 @@ IPA.checkboxes_widget = function (spec) { var input = $('input[name="'+that.name+'"]', that.container); input.change(function() { + + var checkbox = $(this); + var checked = checkbox.is(':checked'); + + if (that.mutex && checked) { + that.clear(); + checkbox.attr('checked', true); + } + that.value_changed.notify([that.save()], that); }); -- cgit