diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-05-10 10:54:31 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-05-10 10:54:31 +0000 |
commit | 7dccf9fda6f30d8f4b0c5eaad9f6e2a1e67cd643 (patch) | |
tree | ba6a18abff6ca69af528b3d295263d049a22266f /app/views | |
parent | 814e138c2a1105f8d9d10c4362a889dd71aff32d (diff) | |
download | redmine-7dccf9fda6f30d8f4b0c5eaad9f6e2a1e67cd643.tar.gz redmine-7dccf9fda6f30d8f4b0c5eaad9f6e2a1e67cd643.zip |
Allows multiple roles on the same project (#706). Prerequisite for user groups feature.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2726 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/account/show.rhtml | 2 | ||||
-rw-r--r-- | app/views/projects/settings/_members.rhtml | 40 | ||||
-rw-r--r-- | app/views/queries/_form.rhtml | 2 | ||||
-rw-r--r-- | app/views/users/_memberships.rhtml | 60 | ||||
-rw-r--r-- | app/views/workflows/edit.rhtml | 2 |
5 files changed, 66 insertions, 40 deletions
diff --git a/app/views/account/show.rhtml b/app/views/account/show.rhtml index 6b70c5f86..c97da7f97 100644 --- a/app/views/account/show.rhtml +++ b/app/views/account/show.rhtml @@ -25,7 +25,7 @@ <ul> <% for membership in @memberships %> <li><%= link_to(h(membership.project.name), :controller => 'projects', :action => 'show', :id => membership.project) %> - (<%=h membership.role.name %>, <%= format_date(membership.created_on) %>)</li> + (<%=h membership.roles.collect(&:to_s).join(', ') %>, <%= format_date(membership.created_on) %>)</li> <% end %> </ul> <% end %> diff --git a/app/views/projects/settings/_members.rhtml b/app/views/projects/settings/_members.rhtml index 312403993..a6bdd9504 100644 --- a/app/views/projects/settings/_members.rhtml +++ b/app/views/projects/settings/_members.rhtml @@ -1,36 +1,43 @@ <%= error_messages_for 'member' %> <% roles = Role.find_all_givable - members = @project.members.find(:all, :include => [:role, :user]).sort %> + members = @project.members.find(:all, :include => [:roles, :user]).sort %> <div class="splitcontentleft"> <% if members.any? %> -<table class="list"> +<table class="list members"> <thead> <th><%= l(:label_user) %></th> - <th><%= l(:label_role) %></th> + <th><%= l(:label_role_plural) %></th> <th style="width:15%"></th> <%= call_hook(:view_projects_settings_members_table_header, :project => @project) %> </thead> <tbody> <% members.each do |member| %> <% next if member.new_record? %> - <tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %>"> - <td><%=h member.name %></td> - <td align="center"> + <tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %> member"> + <td class="user"><%= link_to_user member.user %></td> + <td class="roles"> + <span id="member-<%= member.id %>-roles"><%=h member.roles.sort.collect(&:to_s).join(', ') %></span> <% if authorize_for('members', 'edit') %> - <% remote_form_for(:member, member, :url => {:controller => 'members', :action => 'edit', :id => member}, :method => :post) do |f| %> - <%= f.select :role_id, roles.collect{|role| [role.name, role.id]}, {}, :class => "small" %> - <%= submit_tag l(:button_change), :class => "small" %> + <% remote_form_for(:member, member, :url => {:controller => 'members', :action => 'edit', :id => member}, + :method => :post, + :html => { :id => "member-#{member.id}-roles-form", :style => 'display:none;' }) do |f| %> + <p><% roles.each do |role| %> + <label><%= check_box_tag 'member[role_ids][]', role.id, member.roles.include?(role) %> <%=h role %></label><br /> + <% end %></p> + <p><%= submit_tag l(:button_change), :class => "small" %> + <%= link_to_function l(:button_cancel), "$('member-#{member.id}-roles').show(); $('member-#{member.id}-roles-form').hide(); return false;" %></p> <% end %> <% end %> - </td> - <td align="center"> + </td> + <td class="buttons"> + <%= link_to_function l(:button_edit), "$('member-#{member.id}-roles').hide(); $('member-#{member.id}-roles-form').show(); return false;", :class => 'icon icon-edit' %> <%= link_to_remote l(:button_delete), { :url => {:controller => 'members', :action => 'destroy', :id => member}, :method => :post }, :title => l(:button_delete), :class => 'icon icon-del' %> - </td> - <%= call_hook(:view_projects_settings_members_table_row, { :project => @project, :member => member}) %> + </td> + <%= call_hook(:view_projects_settings_members_table_row, { :project => @project, :member => member}) %> </tr> </tbody> <% end; reset_cycle %> @@ -58,8 +65,11 @@ <% end -%> </div> <% end %> - <p><%= l(:label_role) %>: <%= f.select :role_id, roles.collect{|role| [role.name, role.id]}, :selected => nil %> - <%= submit_tag l(:button_add) %></p> + <p><%= l(:label_role_plural) %>: + <% roles.each do |role| %> + <label><%= check_box_tag 'member[role_ids][]', role.id %> <%=h role %></label> + <% end %></p> + <p><%= submit_tag l(:button_add) %></p> </fieldset> <% end %> <% end %> diff --git a/app/views/queries/_form.rhtml b/app/views/queries/_form.rhtml index 28faba177..577699d70 100644 --- a/app/views/queries/_form.rhtml +++ b/app/views/queries/_form.rhtml @@ -6,7 +6,7 @@ <p><label for="query_name"><%=l(:field_name)%></label> <%= text_field 'query', 'name', :size => 80 %></p> -<% if User.current.admin? || (@project && current_role.allowed_to?(:manage_public_queries)) %> +<% if User.current.admin? || User.current.allowed_to?(:manage_public_queries, @project) %> <p><label for="query_is_public"><%=l(:field_is_public)%></label> <%= check_box 'query', 'is_public', :onchange => (User.current.admin? ? nil : 'if (this.checked) {$("query_is_for_all").checked = false; $("query_is_for_all").disabled = true;} else {$("query_is_for_all").disabled = false;}') %></p> diff --git a/app/views/users/_memberships.rhtml b/app/views/users/_memberships.rhtml index d1657fb98..8b458e0b2 100644 --- a/app/views/users/_memberships.rhtml +++ b/app/views/users/_memberships.rhtml @@ -1,24 +1,36 @@ -<% if @memberships.any? %> +<% roles = Role.find_all_givable %> +<% projects = Project.active.find(:all, :order => 'lft') %> + +<div class="splitcontentleft"> +<% if @user.memberships.any? %> <table class="list memberships"> <thead> <th><%= l(:label_project) %></th> - <th><%= l(:label_role) %></th> + <th><%= l(:label_role_plural) %></th> <th style="width:15%"></th> </thead> <tbody> - <% @memberships.each do |membership| %> + <% @user.memberships.each do |membership| %> <% next if membership.new_record? %> - <tr class="<%= cycle 'odd', 'even' %>"> - <td><%=h membership.project %></td> - <td align="center"> - <% form_tag({ :action => 'edit_membership', :id => @user, :membership_id => membership }) do %> - <%= select_tag 'membership[role_id]', options_from_collection_for_select(@roles, "id", "name", membership.role_id) %> - <%= submit_tag l(:button_change), :class => "small" %> + <tr id="member-<%= membership.id %>" class="<%= cycle 'odd', 'even' %> class"> + <td class="project"><%=h membership.project %></td> + <td class="roles"> + <span id="member-<%= membership.id %>-roles"><%=h membership.roles.sort.collect(&:to_s).join(', ') %></span> + <% remote_form_for(:membership, :url => { :action => 'edit_membership', :id => @user, :membership_id => membership }, + :html => { :id => "member-#{membership.id}-roles-form", :style => 'display:none;'}) do %> + <p><% roles.each do |role| %> + <label><%= check_box_tag 'membership[role_ids][]', role.id, membership.roles.include?(role) %> <%=h role %></label><br /> + <% end %></p> + <p><%= submit_tag l(:button_change) %> + <%= link_to_function l(:button_cancel), "$('member-#{membership.id}-roles').show(); $('member-#{membership.id}-roles-form').hide(); return false;" %></p> <% end %> - </td> - <td align="center"> - <%= link_to l(:button_delete), {:action => 'destroy_membership', :id => @user, :membership_id => membership }, :method => :post, :class => 'icon icon-del' %> - </td> + </td> + <td class="buttons"> + <%= link_to_function l(:button_edit), "$('member-#{membership.id}-roles').hide(); $('member-#{membership.id}-roles-form').show(); return false;", :class => 'icon icon-edit' %> + <%= link_to_remote l(:button_delete), { :url => { :controller => 'users', :action => 'destroy_membership', :id => @user, :membership_id => membership }, + :method => :post }, + :class => 'icon icon-del' %> + </td> </tr> </tbody> <% end; reset_cycle %> @@ -26,15 +38,19 @@ <% else %> <p class="nodata"><%= l(:label_no_data) %></p> <% end %> +</div> -<% if @projects.any? %> -<p> -<label><%=l(:label_project_new)%></label><br/> -<% form_tag({ :action => 'edit_membership', :id => @user }) do %> -<%= select_tag 'membership[project_id]', options_for_membership_project_select(@user, @projects) %> -<%= l(:label_role) %>: -<%= select_tag 'membership[role_id]', options_from_collection_for_select(@roles, "id", "name") %> -<%= submit_tag l(:button_add) %> +<div class="splitcontentright"> +<% if projects.any? %> +<fieldset><legend><%=l(:label_project_new)%></legend> +<% remote_form_for(:membership, :url => { :action => 'edit_membership', :id => @user }) do %> +<%= select_tag 'membership[project_id]', options_for_membership_project_select(@user, projects) %> +<p><%= l(:label_role_plural) %>: +<% roles.each do |role| %> + <label><%= check_box_tag 'membership[role_ids][]', role.id %> <%=h role %></label> +<% end %></p> +<p><%= submit_tag l(:button_add) %></p> <% end %> -</p> +</fieldset> <% end %> +</div> diff --git a/app/views/workflows/edit.rhtml b/app/views/workflows/edit.rhtml index 1aef8eb7e..134dfb3e7 100644 --- a/app/views/workflows/edit.rhtml +++ b/app/views/workflows/edit.rhtml @@ -43,7 +43,7 @@ <% for old_status in @statuses %> <tr class="<%= cycle("odd", "even") %>"> <td><%= old_status.name %></td> - <% new_status_ids_allowed = old_status.find_new_statuses_allowed_to(@role, @tracker).collect(&:id) -%> + <% new_status_ids_allowed = old_status.find_new_statuses_allowed_to([@role], @tracker).collect(&:id) -%> <% for new_status in @statuses -%> <td align="center"> <input type="checkbox" |