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
This commit is contained in:
Petr Voborník 2012-02-10 11:25:41 +01:00 committed by Petr Vobornik
parent a66d8d51b6
commit 7c392cb9a8

View File

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