Show More
@@ -1,251 +1,250 | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """ |
|
3 | 3 | rhodecode.controllers.admin.repos_groups |
|
4 | 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
5 | 5 | |
|
6 | 6 | repos groups controller for RhodeCode |
|
7 | 7 | |
|
8 | 8 | :created_on: Mar 23, 2010 |
|
9 | 9 | :author: marcink |
|
10 | 10 | :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
|
11 | 11 | :license: GPLv3, see COPYING for more details. |
|
12 | 12 | """ |
|
13 | 13 | # This program is free software: you can redistribute it and/or modify |
|
14 | 14 | # it under the terms of the GNU General Public License as published by |
|
15 | 15 | # the Free Software Foundation, either version 3 of the License, or |
|
16 | 16 | # (at your option) any later version. |
|
17 | 17 | # |
|
18 | 18 | # This program is distributed in the hope that it will be useful, |
|
19 | 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 | 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 | 21 | # GNU General Public License for more details. |
|
22 | 22 | # |
|
23 | 23 | # You should have received a copy of the GNU General Public License |
|
24 | 24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
25 | 25 | |
|
26 | 26 | import logging |
|
27 | 27 | import traceback |
|
28 | 28 | import formencode |
|
29 | 29 | |
|
30 | 30 | from formencode import htmlfill |
|
31 | 31 | |
|
32 | 32 | from pylons import request, response, session, tmpl_context as c, url |
|
33 | 33 | from pylons.controllers.util import abort, redirect |
|
34 | 34 | from pylons.i18n.translation import _ |
|
35 | 35 | |
|
36 | 36 | from sqlalchemy.exc import IntegrityError |
|
37 | 37 | |
|
38 | 38 | from rhodecode.lib import helpers as h |
|
39 | 39 | from rhodecode.lib.auth import LoginRequired, HasPermissionAnyDecorator |
|
40 | 40 | from rhodecode.lib.base import BaseController, render |
|
41 | 41 | from rhodecode.model.db import RepoGroup |
|
42 | 42 | from rhodecode.model.repos_group import ReposGroupModel |
|
43 | 43 | from rhodecode.model.forms import ReposGroupForm |
|
44 | 44 | from rhodecode.model.meta import Session |
|
45 | 45 | |
|
46 | 46 | log = logging.getLogger(__name__) |
|
47 | 47 | |
|
48 | 48 | |
|
49 | 49 | class ReposGroupsController(BaseController): |
|
50 | 50 | """REST Controller styled on the Atom Publishing Protocol""" |
|
51 | 51 | # To properly map this controller, ensure your config/routing.py |
|
52 | 52 | # file has a resource setup: |
|
53 | 53 | # map.resource('repos_group', 'repos_groups') |
|
54 | 54 | |
|
55 | 55 | @LoginRequired() |
|
56 | 56 | def __before__(self): |
|
57 | 57 | super(ReposGroupsController, self).__before__() |
|
58 | 58 | |
|
59 | 59 | def __load_defaults(self): |
|
60 | 60 | c.repo_groups = RepoGroup.groups_choices() |
|
61 | 61 | c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) |
|
62 | 62 | |
|
63 | 63 | def __load_data(self, group_id): |
|
64 | 64 | """ |
|
65 | 65 | Load defaults settings for edit, and update |
|
66 | 66 | |
|
67 | 67 | :param group_id: |
|
68 | 68 | """ |
|
69 | 69 | self.__load_defaults() |
|
70 | 70 | |
|
71 | 71 | repo_group = RepoGroup.get(group_id) |
|
72 | 72 | |
|
73 | 73 | data = repo_group.get_dict() |
|
74 | 74 | |
|
75 | 75 | data['group_name'] = repo_group.name |
|
76 | 76 | |
|
77 | 77 | return data |
|
78 | 78 | |
|
79 | 79 | @HasPermissionAnyDecorator('hg.admin') |
|
80 | 80 | def index(self, format='html'): |
|
81 | 81 | """GET /repos_groups: All items in the collection""" |
|
82 | 82 | # url('repos_groups') |
|
83 | 83 | |
|
84 | 84 | sk = lambda g: g.parents[0].group_name if g.parents else g.group_name |
|
85 | 85 | c.groups = sorted(RepoGroup.query().all(), key=sk) |
|
86 | 86 | return render('admin/repos_groups/repos_groups_show.html') |
|
87 | 87 | |
|
88 | 88 | @HasPermissionAnyDecorator('hg.admin') |
|
89 | 89 | def create(self): |
|
90 | 90 | """POST /repos_groups: Create a new item""" |
|
91 | 91 | # url('repos_groups') |
|
92 | 92 | self.__load_defaults() |
|
93 | 93 | repos_group_form = ReposGroupForm(available_groups = |
|
94 | 94 | c.repo_groups_choices)() |
|
95 | 95 | try: |
|
96 | 96 | form_result = repos_group_form.to_python(dict(request.POST)) |
|
97 | 97 | ReposGroupModel().create(form_result) |
|
98 | 98 | Session.commit() |
|
99 | 99 | h.flash(_('created repos group %s') \ |
|
100 | 100 | % form_result['group_name'], category='success') |
|
101 | 101 | #TODO: in futureaction_logger(, '', '', '', self.sa) |
|
102 | 102 | except formencode.Invalid, errors: |
|
103 | 103 | |
|
104 | 104 | return htmlfill.render( |
|
105 | 105 | render('admin/repos_groups/repos_groups_add.html'), |
|
106 | 106 | defaults=errors.value, |
|
107 | 107 | errors=errors.error_dict or {}, |
|
108 | 108 | prefix_error=False, |
|
109 | 109 | encoding="UTF-8") |
|
110 | 110 | except Exception: |
|
111 | 111 | log.error(traceback.format_exc()) |
|
112 | 112 | h.flash(_('error occurred during creation of repos group %s') \ |
|
113 | 113 | % request.POST.get('group_name'), category='error') |
|
114 | 114 | |
|
115 | 115 | return redirect(url('repos_groups')) |
|
116 | 116 | |
|
117 | 117 | @HasPermissionAnyDecorator('hg.admin') |
|
118 | 118 | def new(self, format='html'): |
|
119 | 119 | """GET /repos_groups/new: Form to create a new item""" |
|
120 | 120 | # url('new_repos_group') |
|
121 | 121 | self.__load_defaults() |
|
122 | 122 | return render('admin/repos_groups/repos_groups_add.html') |
|
123 | 123 | |
|
124 | 124 | @HasPermissionAnyDecorator('hg.admin') |
|
125 | 125 | def update(self, id): |
|
126 | 126 | """PUT /repos_groups/id: Update an existing item""" |
|
127 | 127 | # Forms posted to this method should contain a hidden field: |
|
128 | 128 | # <input type="hidden" name="_method" value="PUT" /> |
|
129 | 129 | # Or using helpers: |
|
130 | 130 | # h.form(url('repos_group', id=ID), |
|
131 | 131 | # method='put') |
|
132 | 132 | # url('repos_group', id=ID) |
|
133 | 133 | |
|
134 | 134 | self.__load_defaults() |
|
135 | 135 | c.repos_group = RepoGroup.get(id) |
|
136 | 136 | |
|
137 | 137 | repos_group_form = ReposGroupForm(edit=True, |
|
138 | 138 | old_data=c.repos_group.get_dict(), |
|
139 | 139 | available_groups= |
|
140 | 140 | c.repo_groups_choices)() |
|
141 | 141 | try: |
|
142 | 142 | form_result = repos_group_form.to_python(dict(request.POST)) |
|
143 | 143 | ReposGroupModel().update(id, form_result) |
|
144 | 144 | Session.commit() |
|
145 | 145 | h.flash(_('updated repos group %s') \ |
|
146 | 146 | % form_result['group_name'], category='success') |
|
147 | 147 | #TODO: in futureaction_logger(, '', '', '', self.sa) |
|
148 | 148 | except formencode.Invalid, errors: |
|
149 | 149 | |
|
150 | 150 | return htmlfill.render( |
|
151 | 151 | render('admin/repos_groups/repos_groups_edit.html'), |
|
152 | 152 | defaults=errors.value, |
|
153 | 153 | errors=errors.error_dict or {}, |
|
154 | 154 | prefix_error=False, |
|
155 | 155 | encoding="UTF-8") |
|
156 | 156 | except Exception: |
|
157 | 157 | log.error(traceback.format_exc()) |
|
158 | 158 | h.flash(_('error occurred during update of repos group %s') \ |
|
159 | 159 | % request.POST.get('group_name'), category='error') |
|
160 | 160 | |
|
161 | 161 | return redirect(url('repos_groups')) |
|
162 | 162 | |
|
163 | ||
|
164 | 163 | @HasPermissionAnyDecorator('hg.admin') |
|
165 | 164 | def delete(self, id): |
|
166 | 165 | """DELETE /repos_groups/id: Delete an existing item""" |
|
167 | 166 | # Forms posted to this method should contain a hidden field: |
|
168 | 167 | # <input type="hidden" name="_method" value="DELETE" /> |
|
169 | 168 | # Or using helpers: |
|
170 | 169 | # h.form(url('repos_group', id=ID), |
|
171 | 170 | # method='delete') |
|
172 | 171 | # url('repos_group', id=ID) |
|
173 | 172 | |
|
174 | 173 | gr = RepoGroup.get(id) |
|
175 | 174 | repos = gr.repositories.all() |
|
176 | 175 | if repos: |
|
177 | 176 | h.flash(_('This group contains %s repositores and cannot be ' |
|
178 | 177 | 'deleted' % len(repos)), |
|
179 | 178 | category='error') |
|
180 | 179 | return redirect(url('repos_groups')) |
|
181 | 180 | |
|
182 | 181 | try: |
|
183 | 182 | ReposGroupModel().delete(id) |
|
184 | 183 | Session.commit() |
|
185 | 184 | h.flash(_('removed repos group %s' % gr.group_name), category='success') |
|
186 | 185 | #TODO: in future action_logger(, '', '', '', self.sa) |
|
187 | 186 | except IntegrityError, e: |
|
188 | 187 | if e.message.find('groups_group_parent_id_fkey') != -1: |
|
189 | 188 | log.error(traceback.format_exc()) |
|
190 | 189 | h.flash(_('Cannot delete this group it still contains ' |
|
191 | 190 | 'subgroups'), |
|
192 | 191 | category='warning') |
|
193 | 192 | else: |
|
194 | 193 | log.error(traceback.format_exc()) |
|
195 | 194 | h.flash(_('error occurred during deletion of repos ' |
|
196 | 195 | 'group %s' % gr.group_name), category='error') |
|
197 | 196 | |
|
198 | 197 | except Exception: |
|
199 | 198 | log.error(traceback.format_exc()) |
|
200 | 199 | h.flash(_('error occurred during deletion of repos ' |
|
201 | 200 | 'group %s' % gr.group_name), category='error') |
|
202 | 201 | |
|
203 | 202 | return redirect(url('repos_groups')) |
|
204 | 203 | |
|
205 | 204 | def show_by_name(self, group_name): |
|
206 | 205 | id_ = RepoGroup.get_by_group_name(group_name).group_id |
|
207 | 206 | return self.show(id_) |
|
208 | 207 | |
|
209 | 208 | def show(self, id, format='html'): |
|
210 | 209 | """GET /repos_groups/id: Show a specific item""" |
|
211 | 210 | # url('repos_group', id=ID) |
|
212 | 211 | |
|
213 | 212 | c.group = RepoGroup.get(id) |
|
214 | 213 | |
|
215 | 214 | if c.group: |
|
216 | 215 | c.group_repos = c.group.repositories.all() |
|
217 | 216 | else: |
|
218 | 217 | return redirect(url('home')) |
|
219 | 218 | |
|
220 | 219 | #overwrite our cached list with current filter |
|
221 | 220 | gr_filter = c.group_repos |
|
222 | 221 | c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter) |
|
223 | 222 | |
|
224 | 223 | c.repos_list = c.cached_repo_list |
|
225 | 224 | |
|
226 | 225 | c.repo_cnt = 0 |
|
227 | 226 | |
|
228 | 227 | c.groups = self.sa.query(RepoGroup).order_by(RepoGroup.group_name)\ |
|
229 | 228 | .filter(RepoGroup.group_parent_id == id).all() |
|
230 | 229 | |
|
231 | 230 | return render('admin/repos_groups/repos_groups.html') |
|
232 | 231 | |
|
233 | 232 | @HasPermissionAnyDecorator('hg.admin') |
|
234 | 233 | def edit(self, id, format='html'): |
|
235 | 234 | """GET /repos_groups/id/edit: Form to edit an existing item""" |
|
236 | 235 | # url('edit_repos_group', id=ID) |
|
237 | 236 | |
|
238 | 237 | id_ = int(id) |
|
239 | 238 | |
|
240 | 239 | c.repos_group = RepoGroup.get(id_) |
|
241 | 240 | defaults = self.__load_data(id_) |
|
242 | 241 | |
|
243 | 242 | # we need to exclude this group from the group list for editing |
|
244 | 243 | c.repo_groups = filter(lambda x:x[0] != id_, c.repo_groups) |
|
245 | 244 | |
|
246 | 245 | return htmlfill.render( |
|
247 | 246 | render('admin/repos_groups/repos_groups_edit.html'), |
|
248 | 247 | defaults=defaults, |
|
249 | 248 | encoding="UTF-8", |
|
250 | 249 | force_defaults=False |
|
251 | 250 | ) |
@@ -1,224 +1,224 | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <%inherit file="/base/base.html"/> |
|
3 | 3 | |
|
4 | 4 | <%def name="title()"> |
|
5 | 5 | ${_('Edit repository')} ${c.repo_info.repo_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(_('Repositories'),h.url('repos'))} |
|
12 | 12 | » |
|
13 | 13 | ${_('edit')} » ${h.link_to(c.repo_info.just_name,h.url('summary_home',repo_name=c.repo_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 box-left"> |
|
22 | 22 | <!-- box / title --> |
|
23 | 23 | <div class="title"> |
|
24 | 24 | ${self.breadcrumbs()} |
|
25 | 25 | </div> |
|
26 | 26 | ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='put')} |
|
27 | 27 | <div class="form"> |
|
28 | 28 | <!-- fields --> |
|
29 | 29 | <div class="fields"> |
|
30 | 30 | <div class="field"> |
|
31 | 31 | <div class="label"> |
|
32 | 32 | <label for="repo_name">${_('Name')}:</label> |
|
33 | 33 | </div> |
|
34 | 34 | <div class="input"> |
|
35 | 35 | ${h.text('repo_name',class_="medium")} |
|
36 | 36 | </div> |
|
37 | 37 | </div> |
|
38 | 38 | <div class="field"> |
|
39 | 39 | <div class="label"> |
|
40 | 40 | <label for="clone_uri">${_('Clone uri')}:</label> |
|
41 | 41 | </div> |
|
42 | 42 | <div class="input"> |
|
43 | 43 | ${h.text('clone_uri',class_="medium")} |
|
44 | 44 | </div> |
|
45 | 45 | </div> |
|
46 | 46 | <div class="field"> |
|
47 | 47 | <div class="label"> |
|
48 | 48 | <label for="repo_group">${_('Repository group')}:</label> |
|
49 | 49 | </div> |
|
50 | 50 | <div class="input"> |
|
51 | 51 | ${h.select('repo_group','',c.repo_groups,class_="medium")} |
|
52 | 52 | </div> |
|
53 | 53 | </div> |
|
54 | 54 | <div class="field"> |
|
55 | 55 | <div class="label"> |
|
56 | 56 | <label for="repo_type">${_('Type')}:</label> |
|
57 | 57 | </div> |
|
58 | 58 | <div class="input"> |
|
59 | 59 | ${h.select('repo_type','hg',c.backends,class_="medium")} |
|
60 | 60 | </div> |
|
61 | 61 | </div> |
|
62 | 62 | <div class="field"> |
|
63 | 63 | <div class="label label-textarea"> |
|
64 | 64 | <label for="description">${_('Description')}:</label> |
|
65 | 65 | </div> |
|
66 | 66 | <div class="textarea text-area editor"> |
|
67 | 67 | ${h.textarea('description',cols=23,rows=5)} |
|
68 | 68 | </div> |
|
69 | 69 | </div> |
|
70 | 70 | |
|
71 | 71 | <div class="field"> |
|
72 | 72 | <div class="label label-checkbox"> |
|
73 | 73 | <label for="private">${_('Private')}:</label> |
|
74 | 74 | </div> |
|
75 | 75 | <div class="checkboxes"> |
|
76 | 76 | ${h.checkbox('private',value="True")} |
|
77 | 77 | </div> |
|
78 | 78 | </div> |
|
79 | 79 | <div class="field"> |
|
80 | 80 | <div class="label label-checkbox"> |
|
81 | 81 | <label for="enable_statistics">${_('Enable statistics')}:</label> |
|
82 | 82 | </div> |
|
83 | 83 | <div class="checkboxes"> |
|
84 | 84 | ${h.checkbox('enable_statistics',value="True")} |
|
85 | 85 | </div> |
|
86 | 86 | </div> |
|
87 | 87 | <div class="field"> |
|
88 | 88 | <div class="label label-checkbox"> |
|
89 | 89 | <label for="enable_downloads">${_('Enable downloads')}:</label> |
|
90 | 90 | </div> |
|
91 | 91 | <div class="checkboxes"> |
|
92 | 92 | ${h.checkbox('enable_downloads',value="True")} |
|
93 | 93 | </div> |
|
94 | 94 | </div> |
|
95 | 95 | <div class="field"> |
|
96 | 96 | <div class="label"> |
|
97 | 97 | <label for="user">${_('Owner')}:</label> |
|
98 | 98 | </div> |
|
99 | 99 | <div class="input input-small ac"> |
|
100 | 100 | <div class="perm_ac"> |
|
101 | 101 | ${h.text('user',class_='yui-ac-input')} |
|
102 | 102 | <div id="owner_container"></div> |
|
103 | 103 | </div> |
|
104 | 104 | </div> |
|
105 | 105 | </div> |
|
106 | 106 | |
|
107 | 107 | <div class="field"> |
|
108 | 108 | <div class="label"> |
|
109 | 109 | <label for="input">${_('Permissions')}:</label> |
|
110 | 110 | </div> |
|
111 | 111 | <div class="input"> |
|
112 | 112 | <%include file="repo_edit_perms.html"/> |
|
113 | 113 | </div> |
|
114 | 114 | |
|
115 | <div class="buttons"> | |
|
116 | ${h.submit('save','Save',class_="ui-button")} | |
|
117 | ${h.reset('reset','Reset',class_="ui-button")} | |
|
115 | <div class="buttons"> | |
|
116 | ${h.submit('save','Save',class_="ui-button")} | |
|
117 | ${h.reset('reset','Reset',class_="ui-button")} | |
|
118 | </div> | |
|
118 | 119 | </div> |
|
119 | </div> | |
|
120 | 120 | </div> |
|
121 | 121 | </div> |
|
122 | 122 | ${h.end_form()} |
|
123 | 123 | </div> |
|
124 | 124 | |
|
125 | 125 | <div class="box box-right"> |
|
126 | 126 | <div class="title"> |
|
127 | 127 | <h5>${_('Administration')}</h5> |
|
128 | 128 | </div> |
|
129 | 129 | |
|
130 | 130 | <h3>${_('Statistics')}</h3> |
|
131 | 131 | ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')} |
|
132 | 132 | <div class="form"> |
|
133 | 133 | <div class="fields"> |
|
134 | 134 | ${h.submit('reset_stats_%s' % c.repo_info.repo_name,_('Reset current statistics'),class_="ui-btn",onclick="return confirm('"+_('Confirm to remove current statistics')+"');")} |
|
135 | 135 | <div class="field" style="border:none;color:#888"> |
|
136 | 136 | <ul> |
|
137 | 137 | <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li> |
|
138 | 138 | <li>${_('Percentage of stats gathered')}: ${c.stats_percentage} %</li> |
|
139 | 139 | </ul> |
|
140 | 140 | </div> |
|
141 | 141 | </div> |
|
142 | 142 | </div> |
|
143 | 143 | ${h.end_form()} |
|
144 | 144 | |
|
145 | 145 | %if c.repo_info.clone_uri: |
|
146 | 146 | <h3>${_('Remote')}</h3> |
|
147 | 147 | ${h.form(url('repo_pull', repo_name=c.repo_info.repo_name),method='put')} |
|
148 | 148 | <div class="form"> |
|
149 | 149 | <div class="fields"> |
|
150 | 150 | ${h.submit('remote_pull_%s' % c.repo_info.repo_name,_('Pull changes from remote location'),class_="ui-btn",onclick="return confirm('"+_('Confirm to pull changes from remote side')+"');")} |
|
151 | 151 | <div class="field" style="border:none"> |
|
152 | 152 | <ul> |
|
153 | 153 | <li><a href="${c.repo_info.clone_uri}">${c.repo_info.clone_uri}</a></li> |
|
154 | 154 | </ul> |
|
155 | 155 | </div> |
|
156 | 156 | </div> |
|
157 | 157 | </div> |
|
158 | 158 | ${h.end_form()} |
|
159 | 159 | %endif |
|
160 | 160 | |
|
161 | 161 | <h3>${_('Cache')}</h3> |
|
162 | 162 | ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')} |
|
163 | 163 | <div class="form"> |
|
164 | 164 | <div class="fields"> |
|
165 | 165 | ${h.submit('reset_cache_%s' % c.repo_info.repo_name,_('Invalidate repository cache'),class_="ui-btn",onclick="return confirm('"+_('Confirm to invalidate repository cache')+"');")} |
|
166 | 166 | </div> |
|
167 | 167 | </div> |
|
168 | 168 | ${h.end_form()} |
|
169 | 169 | |
|
170 | 170 | <h3>${_('Public journal')}</h3> |
|
171 | 171 | ${h.form(url('repo_public_journal', repo_name=c.repo_info.repo_name),method='put')} |
|
172 | 172 | <div class="form"> |
|
173 | 173 | ${h.hidden('auth_token',str(h.get_token()))} |
|
174 | 174 | <div class="field"> |
|
175 | 175 | %if c.in_public_journal: |
|
176 | 176 | ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Remove from public journal'),class_="ui-btn")} |
|
177 | 177 | %else: |
|
178 | 178 | ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Add to public journal'),class_="ui-btn")} |
|
179 | 179 | %endif |
|
180 | 180 | </div> |
|
181 | 181 | <div class="field" style="border:none;color:#888"> |
|
182 | 182 | <ul> |
|
183 | 183 | <li>${_('''All actions made on this repository will be accessible to everyone in public journal''')} |
|
184 | 184 | </li> |
|
185 | 185 | </ul> |
|
186 | 186 | </div> |
|
187 | 187 | </div> |
|
188 | 188 | ${h.end_form()} |
|
189 | 189 | |
|
190 | 190 | <h3>${_('Delete')}</h3> |
|
191 | 191 | ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='delete')} |
|
192 | 192 | <div class="form"> |
|
193 | 193 | <div class="fields"> |
|
194 | 194 | ${h.submit('remove_%s' % c.repo_info.repo_name,_('Remove this repository'),class_="ui-btn red",onclick="return confirm('"+_('Confirm to delete this repository')+"');")} |
|
195 | 195 | </div> |
|
196 | 196 | <div class="field" style="border:none;color:#888"> |
|
197 | 197 | <ul> |
|
198 | 198 | <li>${_('''This repository will be renamed in a special way in order to be unaccesible for RhodeCode and VCS systems. |
|
199 | 199 | If you need fully delete it from filesystem please do it manually''')} |
|
200 | 200 | </li> |
|
201 | 201 | </ul> |
|
202 | 202 | </div> |
|
203 | 203 | </div> |
|
204 | 204 | ${h.end_form()} |
|
205 | 205 | |
|
206 | 206 | <h3>${_('Set as fork')}</h3> |
|
207 | 207 | ${h.form(url('repo_as_fork', repo_name=c.repo_info.repo_name),method='put')} |
|
208 | 208 | <div class="form"> |
|
209 | 209 | <div class="fields"> |
|
210 | 210 | ${h.select('id_fork_of','',c.repos_list,class_="medium")} |
|
211 | 211 | ${h.submit('set_as_fork_%s' % c.repo_info.repo_name,_('set'),class_="ui-btn",)} |
|
212 | 212 | </div> |
|
213 | 213 | <div class="field" style="border:none;color:#888"> |
|
214 | 214 | <ul> |
|
215 | 215 | <li>${_('''Manually set this repository as a fork of another''')}</li> |
|
216 | 216 | </ul> |
|
217 | 217 | </div> |
|
218 | 218 | </div> |
|
219 | 219 | ${h.end_form()} |
|
220 | 220 | |
|
221 | 221 | </div> |
|
222 | 222 | |
|
223 | 223 | |
|
224 | 224 | </%def> |
@@ -1,190 +1,190 | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <%inherit file="/base/base.html"/> |
|
3 | 3 | |
|
4 | 4 | <%def name="title()"> |
|
5 | 5 | ${_('My account')} ${c.rhodecode_user.username} - ${c.rhodecode_name} |
|
6 | 6 | </%def> |
|
7 | 7 | |
|
8 | 8 | <%def name="breadcrumbs_links()"> |
|
9 | 9 | ${_('My Account')} |
|
10 | 10 | </%def> |
|
11 | 11 | |
|
12 | 12 | <%def name="page_nav()"> |
|
13 | 13 | ${self.menu('admin')} |
|
14 | 14 | </%def> |
|
15 | 15 | |
|
16 | 16 | <%def name="main()"> |
|
17 | 17 | |
|
18 | 18 | <div class="box box-left"> |
|
19 | 19 | <!-- box / title --> |
|
20 | 20 | <div class="title"> |
|
21 | 21 | ${self.breadcrumbs()} |
|
22 | 22 | </div> |
|
23 | 23 | <!-- end box / title --> |
|
24 | 24 | <div> |
|
25 | 25 | ${h.form(url('admin_settings_my_account_update'),method='put')} |
|
26 | 26 | <div class="form"> |
|
27 | 27 | |
|
28 | 28 | <div class="field"> |
|
29 | 29 | <div class="gravatar_box"> |
|
30 | 30 | <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(c.user.email)}"/></div> |
|
31 | 31 | <p> |
|
32 | 32 | %if c.use_gravatar: |
|
33 | 33 | <strong>${_('Change your avatar at')} <a href="http://gravatar.com">gravatar.com</a></strong> |
|
34 | 34 | <br/>${_('Using')} ${c.user.email} |
|
35 | 35 | %else: |
|
36 | 36 | <br/>${c.user.email} |
|
37 | 37 | %endif |
|
38 | 38 | </p> |
|
39 | 39 | </div> |
|
40 | 40 | </div> |
|
41 | 41 | <div class="field"> |
|
42 | 42 | <div class="label"> |
|
43 | 43 | <label>${_('API key')}</label> ${c.user.api_key} |
|
44 | 44 | </div> |
|
45 | 45 | </div> |
|
46 | 46 | <div class="fields"> |
|
47 | 47 | <div class="field"> |
|
48 | 48 | <div class="label"> |
|
49 | 49 | <label for="username">${_('Username')}:</label> |
|
50 | 50 | </div> |
|
51 | 51 | <div class="input"> |
|
52 | 52 | ${h.text('username',class_="medium")} |
|
53 | 53 | </div> |
|
54 | 54 | </div> |
|
55 | 55 | |
|
56 | 56 | <div class="field"> |
|
57 | 57 | <div class="label"> |
|
58 | 58 | <label for="new_password">${_('New password')}:</label> |
|
59 | 59 | </div> |
|
60 | 60 | <div class="input"> |
|
61 | 61 | ${h.password('new_password',class_="medium",autocomplete="off")} |
|
62 | 62 | </div> |
|
63 | 63 | </div> |
|
64 | 64 | |
|
65 | 65 | <div class="field"> |
|
66 | 66 | <div class="label"> |
|
67 | 67 | <label for="password_confirmation">${_('New password confirmation')}:</label> |
|
68 | 68 | </div> |
|
69 | 69 | <div class="input"> |
|
70 | 70 | ${h.password('password_confirmation',class_="medium",autocomplete="off")} |
|
71 | 71 | </div> |
|
72 | 72 | </div> |
|
73 | 73 | |
|
74 | 74 | <div class="field"> |
|
75 | 75 | <div class="label"> |
|
76 | 76 | <label for="name">${_('First Name')}:</label> |
|
77 | 77 | </div> |
|
78 | 78 | <div class="input"> |
|
79 | 79 | ${h.text('name',class_="medium")} |
|
80 | 80 | </div> |
|
81 | 81 | </div> |
|
82 | 82 | |
|
83 | 83 | <div class="field"> |
|
84 | 84 | <div class="label"> |
|
85 | 85 | <label for="lastname">${_('Last Name')}:</label> |
|
86 | 86 | </div> |
|
87 | 87 | <div class="input"> |
|
88 | 88 | ${h.text('lastname',class_="medium")} |
|
89 | 89 | </div> |
|
90 | 90 | </div> |
|
91 | 91 | |
|
92 | 92 | <div class="field"> |
|
93 | 93 | <div class="label"> |
|
94 | 94 | <label for="email">${_('Email')}:</label> |
|
95 | 95 | </div> |
|
96 | 96 | <div class="input"> |
|
97 | 97 | ${h.text('email',class_="medium")} |
|
98 | 98 | </div> |
|
99 | 99 | </div> |
|
100 | 100 | |
|
101 | 101 | <div class="buttons"> |
|
102 | 102 | ${h.submit('save',_('Save'),class_="ui-button")} |
|
103 | 103 | ${h.reset('reset',_('Reset'),class_="ui-button")} |
|
104 | 104 | </div> |
|
105 | 105 | </div> |
|
106 | 106 | </div> |
|
107 | 107 | ${h.end_form()} |
|
108 | 108 | </div> |
|
109 | 109 | </div> |
|
110 | 110 | |
|
111 | 111 | <div class="box box-right"> |
|
112 | 112 | <!-- box / title --> |
|
113 | 113 | <div class="title"> |
|
114 | 114 | <h5> |
|
115 | 115 | <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/> |
|
116 | 116 | ${_('My repositories')} |
|
117 | 117 | </h5> |
|
118 | 118 | %if h.HasPermissionAny('hg.admin','hg.create.repository')(): |
|
119 | 119 | <ul class="links"> |
|
120 | 120 | <li> |
|
121 | 121 | <span>${h.link_to(_('ADD REPOSITORY'),h.url('admin_settings_create_repository'))}</span> |
|
122 | 122 | </li> |
|
123 | 123 | </ul> |
|
124 | 124 | %endif |
|
125 | 125 | </div> |
|
126 | 126 | <!-- end box / title --> |
|
127 | 127 | <div class="table"> |
|
128 | 128 | <table> |
|
129 | 129 | <thead> |
|
130 | 130 | <tr> |
|
131 | 131 | <th class="left">${_('Name')}</th> |
|
132 | 132 | <th class="left">${_('revision')}</th> |
|
133 | 133 | <th colspan="2" class="left">${_('action')}</th> |
|
134 | 134 | </thead> |
|
135 | 135 | <tbody> |
|
136 | 136 | %if c.user_repos: |
|
137 | 137 | %for repo in c.user_repos: |
|
138 | 138 | <tr> |
|
139 | 139 | <td> |
|
140 |
%if repo['dbrepo']['repo_type'] |
|
|
140 | %if h.is_hg(repo['dbrepo']['repo_type']): | |
|
141 | 141 | <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/> |
|
142 |
%elif repo['dbrepo']['repo_type'] |
|
|
142 | %elif h.is_git(repo['dbrepo']['repo_type']): | |
|
143 | 143 | <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/> |
|
144 | 144 | %else: |
|
145 | 145 | |
|
146 | 146 | %endif |
|
147 | 147 | %if repo['dbrepo']['private']: |
|
148 | 148 | <img class="icon" alt="${_('private')}" src="${h.url('/images/icons/lock.png')}"/> |
|
149 | 149 | %else: |
|
150 | 150 | <img class="icon" alt="${_('public')}" src="${h.url('/images/icons/lock_open.png')}"/> |
|
151 | 151 | %endif |
|
152 | 152 | |
|
153 | 153 | ${h.link_to(repo['name'], h.url('summary_home',repo_name=repo['name']),class_="repo_name")} |
|
154 | 154 | %if repo['dbrepo_fork']: |
|
155 | 155 | <a href="${h.url('summary_home',repo_name=repo['dbrepo_fork']['repo_name'])}"> |
|
156 | 156 | <img class="icon" alt="${_('public')}" |
|
157 | 157 | title="${_('Fork of')} ${repo['dbrepo_fork']['repo_name']}" |
|
158 | 158 | src="${h.url('/images/icons/arrow_divide.png')}"/></a> |
|
159 | 159 | %endif |
|
160 | 160 | </td> |
|
161 | 161 | <td><span class="tooltip" title="${repo['last_change']}">${("r%s:%s") % (repo['rev'],h.short_id(repo['tip']))}</span></td> |
|
162 | 162 | <td><a href="${h.url('repo_settings_home',repo_name=repo['name'])}" title="${_('edit')}"><img class="icon" alt="${_('private')}" src="${h.url('/images/icons/application_form_edit.png')}"/></a></td> |
|
163 | 163 | <td> |
|
164 | 164 | ${h.form(url('repo_settings_delete', repo_name=repo['name']),method='delete')} |
|
165 | 165 | ${h.submit('remove_%s' % repo['name'],'',class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository: %s') % repo['name']+"');")} |
|
166 | 166 | ${h.end_form()} |
|
167 | 167 | </td> |
|
168 | 168 | </tr> |
|
169 | 169 | %endfor |
|
170 | 170 | %else: |
|
171 | 171 | <div style="padding:5px 0px 10px 0px;"> |
|
172 | 172 | ${_('No repositories yet')} |
|
173 | 173 | %if h.HasPermissionAny('hg.admin','hg.create.repository')(): |
|
174 | 174 | ${h.link_to(_('create one now'),h.url('admin_settings_create_repository'),class_="ui-btn")} |
|
175 | 175 | %endif |
|
176 | 176 | </div> |
|
177 | 177 | %endif |
|
178 | 178 | </tbody> |
|
179 | 179 | </table> |
|
180 | 180 | </div> |
|
181 | 181 | </div> |
|
182 | 182 | <script type="text/javascript"> |
|
183 | 183 | var nodes = YUQ('div.table tr td a.repo_name'); |
|
184 | 184 | var target = 'q_filter'; |
|
185 | 185 | var func = function(node){ |
|
186 | 186 | return node.parentNode.parentNode; |
|
187 | 187 | } |
|
188 | 188 | q_filter(target,nodes,func); |
|
189 | 189 | </script> |
|
190 | 190 | </%def> |
@@ -1,290 +1,280 | |||
|
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 box-left"> |
|
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 | 62 | <img alt="remove" style="vertical-align:text-bottom" src="${h.url('/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 | 68 | src="${h.url('/images/icons/arrow_left.png')}"/> |
|
69 | 69 | <br /> |
|
70 | 70 | <img alt="remove" id="remove_element" |
|
71 | 71 | style="padding:2px;cursor:pointer" |
|
72 | 72 | src="${h.url('/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 | 78 | <img alt="add" style="vertical-align:text-bottom" src="${h.url('/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 | <div class="box box-right"> |
|
98 | 98 | <!-- box / title --> |
|
99 | 99 | <div class="title"> |
|
100 | 100 | <h5>${_('Permissions')}</h5> |
|
101 | 101 | </div> |
|
102 | 102 | ${h.form(url('users_group_perm', id=c.users_group.users_group_id), method='put')} |
|
103 | 103 | <div class="form"> |
|
104 | 104 | <!-- fields --> |
|
105 | 105 | <div class="fields"> |
|
106 | 106 | <div class="field"> |
|
107 | 107 | <div class="label label-checkbox"> |
|
108 | 108 | <label for="create_repo_perm">${_('Create repositories')}:</label> |
|
109 | 109 | </div> |
|
110 | 110 | <div class="checkboxes"> |
|
111 | 111 | ${h.checkbox('create_repo_perm',value=True)} |
|
112 | 112 | </div> |
|
113 | 113 | </div> |
|
114 | 114 | <div class="buttons"> |
|
115 | 115 | ${h.submit('save',_('Save'),class_="ui-button")} |
|
116 | 116 | ${h.reset('reset',_('Reset'),class_="ui-button")} |
|
117 | 117 | </div> |
|
118 | 118 | </div> |
|
119 | 119 | </div> |
|
120 | 120 | ${h.end_form()} |
|
121 | 121 | </div> |
|
122 | 122 | |
|
123 | 123 | <div class="box box-right"> |
|
124 | 124 | <!-- box / title --> |
|
125 | 125 | <div class="title"> |
|
126 | 126 | <h5>${_('Group members')}</h5> |
|
127 | 127 | </div> |
|
128 | 128 | <div class="group_members_wrap"> |
|
129 | 129 | <ul class="group_members"> |
|
130 | 130 | %for user in c.group_members_obj: |
|
131 | 131 | <li> |
|
132 | 132 | <div class="group_member"> |
|
133 | 133 | <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(user.email,24)}"/> </div> |
|
134 | 134 | <div>${user.username}</div> |
|
135 | 135 | <div>${user.full_name}</div> |
|
136 | 136 | </div> |
|
137 | 137 | </li> |
|
138 | 138 | %endfor |
|
139 | 139 | </ul> |
|
140 | 140 | </div> |
|
141 | 141 | </div> |
|
142 | 142 | <script type="text/javascript"> |
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 | ||
|
147 | //definition of containers ID's | |
|
148 | var available_container = 'available_members'; | |
|
149 | var selected_container = 'users_group_members'; | |
|
143 | YAHOO.util.Event.onDOMReady(function(){ | |
|
144 | var D = YAHOO.util.Dom; | |
|
145 | var E = YAHOO.util.Event; | |
|
150 | 146 | |
|
151 | //form containing containers id | |
|
152 | var form_id = 'edit_users_group'; | |
|
147 | //definition of containers ID's | |
|
148 | var available_container = 'available_members'; | |
|
149 | var selected_container = 'users_group_members'; | |
|
153 | 150 | |
|
154 | //temp container for selected storage. | |
|
155 | var cache = new Array(); | |
|
156 | var av_cache = new Array(); | |
|
157 | var c = D.get(selected_container); | |
|
158 | var ac = D.get(available_container); | |
|
151 | //form containing containers id | |
|
152 | var form_id = 'edit_users_group'; | |
|
159 | 153 | |
|
160 | //get only selected options for further fullfilment | |
|
161 | for(var i = 0;node =c.options[i];i++){ | |
|
162 | if(node.selected){ | |
|
163 | //push selected to my temp storage left overs :) | |
|
164 | cache.push(node); | |
|
165 | } | |
|
166 | } | |
|
154 | //temp container for selected storage. | |
|
155 | var cache = new Array(); | |
|
156 | var av_cache = new Array(); | |
|
157 | var c = D.get(selected_container); | |
|
158 | var ac = D.get(available_container); | |
|
167 | 159 | |
|
168 | //clear 'selected' select | |
|
169 | //c.options.length = 0; | |
|
160 | //get only selected options for further fullfilment | |
|
161 | for(var i = 0;node =c.options[i];i++){ | |
|
162 | if(node.selected){ | |
|
163 | //push selected to my temp storage left overs :) | |
|
164 | cache.push(node); | |
|
165 | } | |
|
166 | } | |
|
170 | 167 | |
|
171 | //fill it with remembered options | |
|
172 |
|
|
|
173 | // c.options[i]=new Option(node.text, node.value, false, false); | |
|
174 | //} | |
|
175 | ||
|
168 | //get all available options to cache | |
|
169 | for(var i = 0;node =ac.options[i];i++){ | |
|
170 | //push selected to my temp storage left overs :) | |
|
171 | av_cache.push(node); | |
|
172 | } | |
|
176 | 173 | |
|
177 | //get all available options to cache | |
|
178 | for(var i = 0;node =ac.options[i];i++){ | |
|
179 | //push selected to my temp storage left overs :) | |
|
180 | av_cache.push(node); | |
|
181 | } | |
|
182 | ||
|
183 | //fill available only with those not in choosen | |
|
184 | ac.options.length=0; | |
|
185 | tmp_cache = new Array(); | |
|
174 | //fill available only with those not in choosen | |
|
175 | ac.options.length=0; | |
|
176 | tmp_cache = new Array(); | |
|
186 | 177 | |
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
|
194 | } | |
|
195 |
|
|
|
196 |
|
|
|
197 | } | |
|
198 | } | |
|
178 | for(var i = 0;node = av_cache[i];i++){ | |
|
179 | var add = true; | |
|
180 | for(var i2 = 0;node_2 = cache[i2];i2++){ | |
|
181 | if(node.value == node_2.value){ | |
|
182 | add=false; | |
|
183 | break; | |
|
184 | } | |
|
185 | } | |
|
186 | if(add){ | |
|
187 | tmp_cache.push(new Option(node.text, node.value, false, false)); | |
|
188 | } | |
|
189 | } | |
|
199 | 190 | |
|
200 |
|
|
|
201 |
|
|
|
202 | } | |
|
191 | for(var i = 0;node = tmp_cache[i];i++){ | |
|
192 | ac.options[i] = node; | |
|
193 | } | |
|
203 | 194 | |
|
204 |
|
|
|
195 | function prompts_action_callback(e){ | |
|
205 | 196 | |
|
206 |
|
|
|
207 |
|
|
|
197 | var choosen = D.get(selected_container); | |
|
198 | var available = D.get(available_container); | |
|
208 | 199 | |
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
|
200 | //get checked and unchecked options from field | |
|
201 | function get_checked(from_field){ | |
|
202 | //temp container for storage. | |
|
203 | var sel_cache = new Array(); | |
|
204 | var oth_cache = new Array(); | |
|
214 | 205 | |
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
206 | for(var i = 0;node = from_field.options[i];i++){ | |
|
207 | if(node.selected){ | |
|
208 | //push selected fields :) | |
|
209 | sel_cache.push(node); | |
|
210 | } | |
|
211 | else{ | |
|
212 | oth_cache.push(node) | |
|
213 | } | |
|
214 | } | |
|
224 | 215 | |
|
225 |
|
|
|
226 | } | |
|
216 | return [sel_cache,oth_cache] | |
|
217 | } | |
|
227 | 218 | |
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
|
219 | //fill the field with given options | |
|
220 | function fill_with(field,options){ | |
|
221 | //clear firtst | |
|
222 | field.options.length=0; | |
|
223 | for(var i = 0;node = options[i];i++){ | |
|
224 | field.options[i]=new Option(node.text, node.value, | |
|
225 | false, false); | |
|
226 | } | |
|
236 | 227 | |
|
237 | } | |
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
|
244 | } | |
|
228 | } | |
|
229 | //adds to current field | |
|
230 | function add_to(field,options){ | |
|
231 | for(var i = 0;node = options[i];i++){ | |
|
232 | field.appendChild(new Option(node.text, node.value, | |
|
233 | false, false)); | |
|
234 | } | |
|
235 | } | |
|
245 | 236 | |
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
|
251 | } | |
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
257 | } | |
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
|
265 | } | |
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
|
272 |
|
|
|
273 | } | |
|
237 | // add action | |
|
238 | if (this.id=='add_element'){ | |
|
239 | var c = get_checked(available); | |
|
240 | add_to(choosen,c[0]); | |
|
241 | fill_with(available,c[1]); | |
|
242 | } | |
|
243 | // remove action | |
|
244 | if (this.id=='remove_element'){ | |
|
245 | var c = get_checked(choosen); | |
|
246 | add_to(available,c[0]); | |
|
247 | fill_with(choosen,c[1]); | |
|
248 | } | |
|
249 | // add all elements | |
|
250 | if(this.id=='add_all_elements'){ | |
|
251 | for(var i=0; node = available.options[i];i++){ | |
|
252 | choosen.appendChild(new Option(node.text, | |
|
253 | node.value, false, false)); | |
|
254 | } | |
|
255 | available.options.length = 0; | |
|
256 | } | |
|
257 | //remove all elements | |
|
258 | if(this.id=='remove_all_elements'){ | |
|
259 | for(var i=0; node = choosen.options[i];i++){ | |
|
260 | available.appendChild(new Option(node.text, | |
|
261 | node.value, false, false)); | |
|
262 | } | |
|
263 | choosen.options.length = 0; | |
|
264 | } | |
|
274 | 265 | |
|
275 | } | |
|
276 | ||
|
266 | } | |
|
277 | 267 | |
|
278 |
|
|
|
279 |
|
|
|
280 |
|
|
|
268 | E.addListener(['add_element','remove_element', | |
|
269 | 'add_all_elements','remove_all_elements'],'click', | |
|
270 | prompts_action_callback) | |
|
281 | 271 | |
|
282 |
|
|
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
|
286 | } | |
|
287 | }) | |
|
288 | }); | |
|
272 | E.addListener(form_id,'submit',function(){ | |
|
273 | var choosen = D.get(selected_container); | |
|
274 | for (var i = 0; i < choosen.options.length; i++) { | |
|
275 | choosen.options[i].selected = 'selected'; | |
|
276 | } | |
|
277 | }); | |
|
278 | }); | |
|
289 | 279 | </script> |
|
290 | 280 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now