diff options
author | Adam Young <ayoung@redhat.com> | 2011-01-27 20:30:22 -0500 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2011-01-28 10:37:49 -0500 |
commit | c75f332af9225da285c54f0b09d87f28e3a2185b (patch) | |
tree | 9e705bfd3dba21dd92d77fc994392d1bbcc8d119 /install/ui/aci.js | |
parent | ffcf10c832de5f99dd96d1c77713b875ed1e2760 (diff) | |
download | freeipa-c75f332af9225da285c54f0b09d87f28e3a2185b.tar.gz freeipa-c75f332af9225da285c54f0b09d87f28e3a2185b.tar.xz freeipa-c75f332af9225da285c54f0b09d87f28e3a2185b.zip |
aci rights widget
Fixes is_dirty and save
https://fedorahosted.org/freeipa/ticket/77
https://fedorahosted.org/freeipa/ticket/667
Diffstat (limited to 'install/ui/aci.js')
-rw-r--r-- | install/ui/aci.js | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/install/ui/aci.js b/install/ui/aci.js index 01f6ce297..742a52c78 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -222,10 +222,40 @@ IPA.rights_widget = function(spec){ }; var values = []; + function get_selector(){ + return '.'+ that.entity_name +"_"+ that.name; + } + + that.is_dirty = function(){ + + var checkboxes = $(get_selector()); + var checked = {}; + + checkboxes.each(function (){ + checked[this.id] = this.checked; + }); + + for (var i = 0; i < values.length; i +=1){ + var key = values[i]; + + if ( !checked[key] ){ + return true; + } + checked[key] = false; + } + + for (key in checked){ + if (checked[key] ){ + return true; + } + } + + return false; + }; + that.reset = function(){ - var selector = '.'+ that.entity_name +"_"+ that.name; - var checkboxes = $(selector); + var checkboxes = $(get_selector()); for (var i = 0; i < checkboxes.length; i +=1){ checkboxes.attr('checked',''); @@ -233,7 +263,7 @@ IPA.rights_widget = function(spec){ for (var j = 0; j < values.length; j +=1){ var value = values[j]; - var cb = $('#'+value+ selector); + var cb = $('#'+value+ get_selector()); cb.attr('checked', 'checked'); } @@ -245,7 +275,7 @@ IPA.rights_widget = function(spec){ }; that.save = function(){ - var rights_input = $('.'+ that.entity_name +"_"+ that.name); + var rights_input = $(get_selector()+":checked"); var retval = ""; for (var i =0; i < rights_input.length; i+=1){ if (i > 0) { @@ -592,7 +622,7 @@ IPA.entity_factories.permission = function () { input({ name: 'description'})). section(IPA.rights_section()). section(IPA.target_section())); - return that; + }; |