@@ -1,37 +1,51 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | module UsersHelper |
|
18 | module UsersHelper | |
19 | def status_options_for_select(selected) |
|
19 | def status_options_for_select(selected) | |
20 | options_for_select([[l(:label_all), ''], |
|
20 | options_for_select([[l(:label_all), ''], | |
21 | [l(:status_active), 1], |
|
21 | [l(:status_active), 1], | |
22 | [l(:status_registered), 2], |
|
22 | [l(:status_registered), 2], | |
23 | [l(:status_locked), 3]], selected) |
|
23 | [l(:status_locked), 3]], selected) | |
24 | end |
|
24 | end | |
25 |
|
25 | |||
|
26 | # Options for the new membership projects combo-box | |||
|
27 | def projects_options_for_select(projects) | |||
|
28 | options = content_tag('option', "--- #{l(:actionview_instancetag_blank_option)} ---") | |||
|
29 | projects_by_root = projects.group_by(&:root) | |||
|
30 | projects_by_root.keys.sort.each do |root| | |||
|
31 | options << content_tag('option', h(root.name), :value => root.id, :disabled => (!projects.include?(root))) | |||
|
32 | projects_by_root[root].sort.each do |project| | |||
|
33 | next if project == root | |||
|
34 | options << content_tag('option', '» ' + h(project.name), :value => project.id) | |||
|
35 | end | |||
|
36 | end | |||
|
37 | options | |||
|
38 | end | |||
|
39 | ||||
26 | def change_status_link(user) |
|
40 | def change_status_link(user) | |
27 | url = {:action => 'edit', :id => user, :page => params[:page], :status => params[:status]} |
|
41 | url = {:action => 'edit', :id => user, :page => params[:page], :status => params[:status]} | |
28 |
|
42 | |||
29 | if user.locked? |
|
43 | if user.locked? | |
30 | link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock' |
|
44 | link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock' | |
31 | elsif user.registered? |
|
45 | elsif user.registered? | |
32 | link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock' |
|
46 | link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock' | |
33 | else |
|
47 | else | |
34 | link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock' |
|
48 | link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock' | |
35 | end |
|
49 | end | |
36 | end |
|
50 | end | |
37 | end |
|
51 | end |
@@ -1,29 +1,29 | |||||
1 | <div class="box" style="margin-top: 16px;"> |
|
1 | <div class="box" style="margin-top: 16px;"> | |
2 | <h3><%= l(:label_project_plural) %></h3> |
|
2 | <h3><%= l(:label_project_plural) %></h3> | |
3 |
|
3 | |||
4 | <% @user.memberships.each do |membership| %> |
|
4 | <% @user.memberships.each do |membership| %> | |
5 | <% form_tag({ :action => 'edit_membership', :id => @user, :membership_id => membership }, :class => "tabular") do %> |
|
5 | <% form_tag({ :action => 'edit_membership', :id => @user, :membership_id => membership }, :class => "tabular") do %> | |
6 | <p style="margin:0;padding-top:0;"> |
|
6 | <p style="margin:0;padding-top:0;"> | |
7 | <label><%= membership.project.name %></label> |
|
7 | <label><%= membership.project.name %></label> | |
8 | <select name="membership[role_id]"> |
|
8 | <select name="membership[role_id]"> | |
9 | <%= options_from_collection_for_select @roles, "id", "name", membership.role_id %> |
|
9 | <%= options_from_collection_for_select @roles, "id", "name", membership.role_id %> | |
10 | </select> |
|
10 | </select> | |
11 | <%= submit_tag l(:button_change), :class => "button-small" %> |
|
11 | <%= submit_tag l(:button_change), :class => "button-small" %> | |
12 | <%= link_to l(:button_delete), {:action => 'destroy_membership', :id => @user, :membership_id => membership }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> |
|
12 | <%= link_to l(:button_delete), {:action => 'destroy_membership', :id => @user, :membership_id => membership }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> | |
13 | </p> |
|
13 | </p> | |
14 | <% end %> |
|
14 | <% end %> | |
15 | <% end %> |
|
15 | <% end %> | |
|
16 | ||||
|
17 | <% if @projects.any? %> | |||
16 | <hr /> |
|
18 | <hr /> | |
17 | <p> |
|
19 | <p> | |
18 | <label><%=l(:label_project_new)%></label><br/> |
|
20 | <label><%=l(:label_project_new)%></label><br/> | |
19 | <% form_tag({ :action => 'edit_membership', :id => @user }) do %> |
|
21 | <% form_tag({ :action => 'edit_membership', :id => @user }) do %> | |
20 | <select name="membership[project_id]"> |
|
22 | <%= select_tag 'membership[project_id]', projects_options_for_select(@projects) %> | |
21 | <%= options_from_collection_for_select @projects, "id", "name", @membership.project_id %> |
|
23 | <%= l(:label_role) %>: | |
22 | </select> |
|
24 | <%= select_tag 'membership[role_id]', options_from_collection_for_select(@roles, "id", "name") %> | |
23 | <select name="membership[role_id]"> |
|
|||
24 | <%= options_from_collection_for_select @roles, "id", "name", @membership.role_id %> |
|
|||
25 | </select> |
|
|||
26 | <%= submit_tag l(:button_add) %> |
|
25 | <%= submit_tag l(:button_add) %> | |
27 | <% end %> |
|
26 | <% end %> | |
28 | </p> |
|
27 | </p> | |
|
28 | <% end %> | |||
29 | </div> No newline at end of file |
|
29 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now