diff --git a/rhodecode/templates/admin/users_groups/users_group_edit.html b/rhodecode/templates/admin/users_groups/users_group_edit.html --- a/rhodecode/templates/admin/users_groups/users_group_edit.html +++ b/rhodecode/templates/admin/users_groups/users_group_edit.html @@ -46,17 +46,21 @@
-
${_('Group members')}
+ ${_('Choosen group members')}
${h.select('users_group_members',[x[0] for x in c.group_members],c.group_members,multiple=True,size=8,style="min-width:210px")}
+
+ ${_('Remove all elements')}
+
+
-
${_('Available members')}
+ ${_('Available members')}
${h.select('available_members',[],c.available_members,multiple=True,size=8,style="min-width:210px")}
+
+
+ ${_('Add all elements')}
+
|
@@ -97,7 +105,7 @@
//form containing containers id
var form_id = 'edit_users_group';
- //temp container for storage.
+ //temp container for selected storage.
var cache = new Array();
var c = D.get(selected_container);
@@ -120,39 +128,80 @@
function prompts_action_callback(e){
var choosen = D.get(selected_container);
- var availible = D.get(available_container);
-
- if (this.id=='add_element'){
- for(var i=0; node = availible.options[i];i++){
+ var available = D.get(available_container);
+
+ //get checked and unchecked options from field
+ function get_checked(from_field){
+ //temp container for storage.
+ var sel_cache = new Array();
+ var oth_cache = new Array();
+
+ for(var i = 0;node = from_field.options[i];i++){
if(node.selected){
- choosen.appendChild(new Option(node.text, node.value, false, false));
+ //push selected fields :)
+ sel_cache.push(node);
+ }
+ else{
+ oth_cache.push(node)
}
+ }
+
+ return [sel_cache,oth_cache]
+ }
+
+ //fill the field with given options
+ function fill_with(field,options){
+ //clear firtst
+ field.options.length=0;
+ for(var i = 0;node = options[i];i++){
+ field.options[i]=new Option(node.text, node.value,
+ false, false);
+ }
+
+ }
+ //adds to current field
+ function add_to(field,options){
+ for(var i = 0;node = options[i];i++){
+ field.appendChild(new Option(node.text, node.value,
+ false, false));
}
}
- else if (this.id=='remove_element'){
-
- //temp container for storage.
- cache = new Array();
-
- for(var i = 0;node = choosen.options[i];i++){
- if(!node.selected){
- //push left overs :)
- cache.push(node);
- }
+
+ // add action
+ if (this.id=='add_element'){
+ var c = get_checked(available);
+ add_to(choosen,c[0]);
+ fill_with(available,c[1]);
+ }
+ // remove action
+ if (this.id=='remove_element'){
+ var c = get_checked(choosen);
+ add_to(available,c[0]);
+ fill_with(choosen,c[1]);
+ }
+ // add all elements
+ if(this.id=='add_all_elements'){
+ for(var i=0; node = available.options[i];i++){
+ choosen.appendChild(new Option(node.text,
+ node.value, false, false));
}
- //clear select
- choosen.options.length = 0;
- for(var i = 0;node = cache[i];i++){
- choosen.options[i]=new Option(node.text, node.value, false, false);
- }
- }
- else{
-
+ available.options.length = 0;
}
+ //remove all elements
+ if(this.id=='remove_all_elements'){
+ for(var i=0; node = choosen.options[i];i++){
+ available.appendChild(new Option(node.text,
+ node.value, false, false));
+ }
+ choosen.options.length = 0;
+ }
+
}
- E.addListener(['add_element','remove_element'],'click',prompts_action_callback)
+ E.addListener(['add_element','remove_element',
+ 'add_all_elements','remove_all_elements'],'click',
+ prompts_action_callback)
E.addListener(form_id,'submit',function(){
var choosen = D.get(selected_container);