Show More
@@ -1,215 +1,215 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <%inherit file="/base/base.html"/> |
|
3 | 3 | |
|
4 | 4 | <%def name="title()"> |
|
5 | 5 | ${_('Edit users group')} ${c.users_group.users_group_name} - ${c.rhodecode_name} |
|
6 | 6 | </%def> |
|
7 | 7 | |
|
8 | 8 | <%def name="breadcrumbs_links()"> |
|
9 | 9 | ${h.link_to(_('Admin'),h.url('admin_home'))} |
|
10 | 10 | » |
|
11 | 11 | ${h.link_to(_('UsersGroups'),h.url('users_groups'))} |
|
12 | 12 | » |
|
13 | 13 | ${_('edit')} "${c.users_group.users_group_name}" |
|
14 | 14 | </%def> |
|
15 | 15 | |
|
16 | 16 | <%def name="page_nav()"> |
|
17 | 17 | ${self.menu('admin')} |
|
18 | 18 | </%def> |
|
19 | 19 | |
|
20 | 20 | <%def name="main()"> |
|
21 | 21 | <div class="box"> |
|
22 | 22 | <!-- box / title --> |
|
23 | 23 | <div class="title"> |
|
24 | 24 | ${self.breadcrumbs()} |
|
25 | 25 | </div> |
|
26 | 26 | <!-- end box / title --> |
|
27 | 27 | ${h.form(url('users_group', id=c.users_group.users_group_id),method='put', id='edit_users_group')} |
|
28 | 28 | <div class="form"> |
|
29 | 29 | <!-- fields --> |
|
30 | 30 | <div class="fields"> |
|
31 | 31 | <div class="field"> |
|
32 | 32 | <div class="label"> |
|
33 | 33 | <label for="users_group_name">${_('Group name')}:</label> |
|
34 | 34 | </div> |
|
35 | 35 | <div class="input"> |
|
36 | 36 | ${h.text('users_group_name',class_='small')} |
|
37 | 37 | </div> |
|
38 | 38 | </div> |
|
39 | 39 | |
|
40 | 40 | <div class="field"> |
|
41 | 41 | <div class="label label-checkbox"> |
|
42 | 42 | <label for="users_group_active">${_('Active')}:</label> |
|
43 | 43 | </div> |
|
44 | 44 | <div class="checkboxes"> |
|
45 | 45 | ${h.checkbox('users_group_active',value=True)} |
|
46 | 46 | </div> |
|
47 | 47 | </div> |
|
48 | 48 | <div class="field"> |
|
49 | 49 | <div class="label"> |
|
50 | 50 | <label for="users_group_active">${_('Members')}:</label> |
|
51 | 51 | </div> |
|
52 | 52 | <div class="select"> |
|
53 | 53 | <table> |
|
54 | 54 | <tr> |
|
55 | 55 | <td> |
|
56 | 56 | <div> |
|
57 | 57 | <div style="float:left"> |
|
58 | 58 | <div class="text" style="padding: 0px 0px 6px;">${_('Choosen group members')}</div> |
|
59 | 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 | 60 | <div id="remove_all_elements" style="cursor:pointer;text-align:center"> |
|
61 | 61 | ${_('Remove all elements')} |
|
62 | <img alt="remove" src="/images/icons/arrow_right.png"> | |
|
62 | <img alt="remove" style="vertical-align:text-bottom" src="/images/icons/arrow_right.png"/> | |
|
63 | 63 | </div> |
|
64 | 64 | </div> |
|
65 | 65 | <div style="float:left;width:20px;padding-top:50px"> |
|
66 | 66 | <img alt="add" id="add_element" |
|
67 | 67 | style="padding:2px;cursor:pointer" |
|
68 | src="/images/icons/arrow_left.png"> | |
|
68 | src="/images/icons/arrow_left.png"/> | |
|
69 | 69 | <br /> |
|
70 | 70 | <img alt="remove" id="remove_element" |
|
71 | 71 | style="padding:2px;cursor:pointer" |
|
72 | src="/images/icons/arrow_right.png"> | |
|
72 | src="/images/icons/arrow_right.png"/> | |
|
73 | 73 | </div> |
|
74 | 74 | <div style="float:left"> |
|
75 | 75 | <div class="text" style="padding: 0px 0px 6px;">${_('Available members')}</div> |
|
76 | 76 | ${h.select('available_members',[],c.available_members,multiple=True,size=8,style="min-width:210px")} |
|
77 | 77 | <div id="add_all_elements" style="cursor:pointer;text-align:center"> |
|
78 | <img alt="add" src="/images/icons/arrow_left.png"> | |
|
78 | <img alt="add" style="vertical-align:text-bottom" src="/images/icons/arrow_left.png"/> | |
|
79 | 79 | ${_('Add all elements')} |
|
80 | 80 | </div> |
|
81 | 81 | </div> |
|
82 | 82 | </div> |
|
83 | 83 | </td> |
|
84 | 84 | </tr> |
|
85 | 85 | </table> |
|
86 | 86 | </div> |
|
87 | 87 | |
|
88 | 88 | </div> |
|
89 | 89 | <div class="buttons"> |
|
90 | 90 | ${h.submit('save','save',class_="ui-button")} |
|
91 | 91 | </div> |
|
92 | 92 | </div> |
|
93 | 93 | </div> |
|
94 | 94 | ${h.end_form()} |
|
95 | 95 | </div> |
|
96 | 96 | |
|
97 | 97 | <script type="text/javascript"> |
|
98 | 98 | YAHOO.util.Event.onDOMReady(function(){ |
|
99 | 99 | var D = YAHOO.util.Dom; |
|
100 | 100 | var E = YAHOO.util.Event; |
|
101 | 101 | |
|
102 | 102 | //definition of containers ID's |
|
103 | 103 | var available_container = 'available_members'; |
|
104 | 104 | var selected_container = 'users_group_members'; |
|
105 | 105 | //form containing containers id |
|
106 | 106 | var form_id = 'edit_users_group'; |
|
107 | 107 | |
|
108 | 108 | //temp container for selected storage. |
|
109 | 109 | var cache = new Array(); |
|
110 | 110 | var c = D.get(selected_container); |
|
111 | 111 | |
|
112 | 112 | //get only selected options for further fullfilment |
|
113 | 113 | for(var i = 0;node =c.options[i];i++){ |
|
114 | 114 | if(node.selected){ |
|
115 | 115 | //push selected to my temp storage left overs :) |
|
116 | 116 | cache.push(node); |
|
117 | 117 | } |
|
118 | 118 | } |
|
119 | 119 | |
|
120 | 120 | //clear 'selected' select |
|
121 | 121 | c.options.length = 0; |
|
122 | 122 | |
|
123 | 123 | //fill it with remembered options |
|
124 | 124 | for(var i = 0;node = cache[i];i++){ |
|
125 | 125 | c.options[i]=new Option(node.text, node.value, false, false); |
|
126 | 126 | } |
|
127 | 127 | |
|
128 | 128 | function prompts_action_callback(e){ |
|
129 | 129 | |
|
130 | 130 | var choosen = D.get(selected_container); |
|
131 | 131 | var available = D.get(available_container); |
|
132 | 132 | |
|
133 | 133 | //get checked and unchecked options from field |
|
134 | 134 | function get_checked(from_field){ |
|
135 | 135 | //temp container for storage. |
|
136 | 136 | var sel_cache = new Array(); |
|
137 | 137 | var oth_cache = new Array(); |
|
138 | 138 | |
|
139 | 139 | for(var i = 0;node = from_field.options[i];i++){ |
|
140 | 140 | if(node.selected){ |
|
141 | 141 | //push selected fields :) |
|
142 | 142 | sel_cache.push(node); |
|
143 | 143 | } |
|
144 | 144 | else{ |
|
145 | 145 | oth_cache.push(node) |
|
146 | 146 | } |
|
147 | 147 | } |
|
148 | 148 | |
|
149 | 149 | return [sel_cache,oth_cache] |
|
150 | 150 | } |
|
151 | 151 | |
|
152 | 152 | //fill the field with given options |
|
153 | 153 | function fill_with(field,options){ |
|
154 | 154 | //clear firtst |
|
155 | 155 | field.options.length=0; |
|
156 | 156 | for(var i = 0;node = options[i];i++){ |
|
157 | 157 | field.options[i]=new Option(node.text, node.value, |
|
158 | 158 | false, false); |
|
159 | 159 | } |
|
160 | 160 | |
|
161 | 161 | } |
|
162 | 162 | //adds to current field |
|
163 | 163 | function add_to(field,options){ |
|
164 | 164 | for(var i = 0;node = options[i];i++){ |
|
165 | 165 | field.appendChild(new Option(node.text, node.value, |
|
166 | 166 | false, false)); |
|
167 | 167 | } |
|
168 | 168 | } |
|
169 | 169 | |
|
170 | 170 | // add action |
|
171 | 171 | if (this.id=='add_element'){ |
|
172 | 172 | var c = get_checked(available); |
|
173 | 173 | add_to(choosen,c[0]); |
|
174 | 174 | fill_with(available,c[1]); |
|
175 | 175 | } |
|
176 | 176 | // remove action |
|
177 | 177 | if (this.id=='remove_element'){ |
|
178 | 178 | var c = get_checked(choosen); |
|
179 | 179 | add_to(available,c[0]); |
|
180 | 180 | fill_with(choosen,c[1]); |
|
181 | 181 | } |
|
182 | 182 | // add all elements |
|
183 | 183 | if(this.id=='add_all_elements'){ |
|
184 | 184 | for(var i=0; node = available.options[i];i++){ |
|
185 | 185 | choosen.appendChild(new Option(node.text, |
|
186 | 186 | node.value, false, false)); |
|
187 | 187 | } |
|
188 | 188 | available.options.length = 0; |
|
189 | 189 | } |
|
190 | 190 | //remove all elements |
|
191 | 191 | if(this.id=='remove_all_elements'){ |
|
192 | 192 | for(var i=0; node = choosen.options[i];i++){ |
|
193 | 193 | available.appendChild(new Option(node.text, |
|
194 | 194 | node.value, false, false)); |
|
195 | 195 | } |
|
196 | 196 | choosen.options.length = 0; |
|
197 | 197 | } |
|
198 | 198 | |
|
199 | 199 | } |
|
200 | 200 | |
|
201 | 201 | |
|
202 | 202 | E.addListener(['add_element','remove_element', |
|
203 | 203 | 'add_all_elements','remove_all_elements'],'click', |
|
204 | 204 | prompts_action_callback) |
|
205 | 205 | |
|
206 | 206 | E.addListener(form_id,'submit',function(){ |
|
207 | 207 | var choosen = D.get(selected_container); |
|
208 | 208 | for (var i = 0; i < choosen.options.length; i++) { |
|
209 | 209 | choosen.options[i].selected = 'selected'; |
|
210 | 210 | } |
|
211 | 211 | }) |
|
212 | 212 | }); |
|
213 | 213 | </script> |
|
214 | 214 | |
|
215 | 215 | </%def> No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now