##// END OF EJS Templates
extended functionality on users groups select box
marcink -
r985:4e38b2bc beta
parent child Browse files
Show More
@@ -46,17 +46,21 b''
46 </div>
46 </div>
47 </div>
47 </div>
48 <div class="field">
48 <div class="field">
49 <div class="label label-checkbox">
49 <div class="label">
50 <label for="users_group_active">${_('Members')}:</label>
50 <label for="users_group_active">${_('Members')}:</label>
51 </div>
51 </div>
52 <div class="checkboxes">
52 <div class="select">
53 <table>
53 <table>
54 <tr>
54 <tr>
55 <td>
55 <td>
56 <div>
56 <div>
57 <div style="float:left">
57 <div style="float:left">
58 <div class="text">${_('Group members')}</div>
58 <div class="text" style="padding: 0px 0px 6px;">${_('Choosen group members')}</div>
59 ${h.select('users_group_members',[x[0] for x in c.group_members],c.group_members,multiple=True,size=8,style="min-width:210px")}
59 ${h.select('users_group_members',[x[0] for x in c.group_members],c.group_members,multiple=True,size=8,style="min-width:210px")}
60 <div id="remove_all_elements" style="cursor:pointer;text-align:center">
61 ${_('Remove all elements')}
62 <img alt="remove" src="/images/icons/arrow_right.png">
63 </div>
60 </div>
64 </div>
61 <div style="float:left;width:20px;padding-top:50px">
65 <div style="float:left;width:20px;padding-top:50px">
62 <img alt="add" id="add_element"
66 <img alt="add" id="add_element"
@@ -68,8 +72,12 b''
68 src="/images/icons/arrow_right.png">
72 src="/images/icons/arrow_right.png">
69 </div>
73 </div>
70 <div style="float:left">
74 <div style="float:left">
71 <div class="text">${_('Available members')}</div>
75 <div class="text" style="padding: 0px 0px 6px;">${_('Available members')}</div>
72 ${h.select('available_members',[],c.available_members,multiple=True,size=8,style="min-width:210px")}
76 ${h.select('available_members',[],c.available_members,multiple=True,size=8,style="min-width:210px")}
77 <div id="add_all_elements" style="cursor:pointer;text-align:center">
78 <img alt="add" src="/images/icons/arrow_left.png">
79 ${_('Add all elements')}
80 </div>
73 </div>
81 </div>
74 </div>
82 </div>
75 </td>
83 </td>
@@ -97,7 +105,7 b''
97 //form containing containers id
105 //form containing containers id
98 var form_id = 'edit_users_group';
106 var form_id = 'edit_users_group';
99
107
100 //temp container for storage.
108 //temp container for selected storage.
101 var cache = new Array();
109 var cache = new Array();
102 var c = D.get(selected_container);
110 var c = D.get(selected_container);
103
111
@@ -120,39 +128,80 b''
120 function prompts_action_callback(e){
128 function prompts_action_callback(e){
121
129
122 var choosen = D.get(selected_container);
130 var choosen = D.get(selected_container);
123 var availible = D.get(available_container);
131 var available = D.get(available_container);
124
132
125 if (this.id=='add_element'){
133 //get checked and unchecked options from field
126 for(var i=0; node = availible.options[i];i++){
134 function get_checked(from_field){
135 //temp container for storage.
136 var sel_cache = new Array();
137 var oth_cache = new Array();
138
139 for(var i = 0;node = from_field.options[i];i++){
127 if(node.selected){
140 if(node.selected){
128 choosen.appendChild(new Option(node.text, node.value, false, false));
141 //push selected fields :)
142 sel_cache.push(node);
143 }
144 else{
145 oth_cache.push(node)
129 }
146 }
147 }
148
149 return [sel_cache,oth_cache]
150 }
151
152 //fill the field with given options
153 function fill_with(field,options){
154 //clear firtst
155 field.options.length=0;
156 for(var i = 0;node = options[i];i++){
157 field.options[i]=new Option(node.text, node.value,
158 false, false);
159 }
160
161 }
162 //adds to current field
163 function add_to(field,options){
164 for(var i = 0;node = options[i];i++){
165 field.appendChild(new Option(node.text, node.value,
166 false, false));
130 }
167 }
131 }
168 }
132 else if (this.id=='remove_element'){
169
133
170 // add action
134 //temp container for storage.
171 if (this.id=='add_element'){
135 cache = new Array();
172 var c = get_checked(available);
136
173 add_to(choosen,c[0]);
137 for(var i = 0;node = choosen.options[i];i++){
174 fill_with(available,c[1]);
138 if(!node.selected){
175 }
139 //push left overs :)
176 // remove action
140 cache.push(node);
177 if (this.id=='remove_element'){
141 }
178 var c = get_checked(choosen);
179 add_to(available,c[0]);
180 fill_with(choosen,c[1]);
181 }
182 // add all elements
183 if(this.id=='add_all_elements'){
184 for(var i=0; node = available.options[i];i++){
185 choosen.appendChild(new Option(node.text,
186 node.value, false, false));
142 }
187 }
143 //clear select
188 available.options.length = 0;
144 choosen.options.length = 0;
145 for(var i = 0;node = cache[i];i++){
146 choosen.options[i]=new Option(node.text, node.value, false, false);
147 }
148 }
149 else{
150
151 }
189 }
190 //remove all elements
191 if(this.id=='remove_all_elements'){
192 for(var i=0; node = choosen.options[i];i++){
193 available.appendChild(new Option(node.text,
194 node.value, false, false));
195 }
196 choosen.options.length = 0;
197 }
198
152 }
199 }
153
200
154
201
155 E.addListener(['add_element','remove_element'],'click',prompts_action_callback)
202 E.addListener(['add_element','remove_element',
203 'add_all_elements','remove_all_elements'],'click',
204 prompts_action_callback)
156
205
157 E.addListener(form_id,'submit',function(){
206 E.addListener(form_id,'submit',function(){
158 var choosen = D.get(selected_container);
207 var choosen = D.get(selected_container);
General Comments 0
You need to be logged in to leave comments. Login now