2009-05-10 14:54:31 +04:00
|
|
|
<% roles = Role.find_all_givable %>
|
|
|
|
<% projects = Project.active.find(:all, :order => 'lft') %>
|
|
|
|
|
|
|
|
<div class="splitcontentleft">
|
|
|
|
<% if @user.memberships.any? %>
|
2008-05-02 19:21:21 +04:00
|
|
|
<table class="list memberships">
|
2011-09-18 03:11:25 +04:00
|
|
|
<thead><tr>
|
|
|
|
<th><%= l(:label_project) %></th>
|
|
|
|
<th><%= l(:label_role_plural) %></th>
|
|
|
|
<th style="width:15%"></th>
|
2009-08-01 22:14:39 +04:00
|
|
|
<%= call_hook(:view_users_memberships_table_header, :user => @user )%>
|
2011-09-18 03:11:25 +04:00
|
|
|
</tr></thead>
|
|
|
|
<tbody>
|
|
|
|
<% @user.memberships.each do |membership| %>
|
|
|
|
<% next if membership.new_record? %>
|
|
|
|
<tr id="member-<%= membership.id %>" class="<%= cycle 'odd', 'even' %> class">
|
2010-08-05 00:41:32 +04:00
|
|
|
<td class="project">
|
2010-08-08 11:07:20 +04:00
|
|
|
<%= link_to_project membership.project %>
|
2010-08-05 00:41:32 +04:00
|
|
|
</td>
|
2009-05-10 14:54:31 +04:00
|
|
|
<td class="roles">
|
|
|
|
<span id="member-<%= membership.id %>-roles"><%=h membership.roles.sort.collect(&:to_s).join(', ') %></span>
|
2012-04-25 21:17:49 +04:00
|
|
|
<%= form_for(:membership, :remote => true,
|
|
|
|
:url => user_membership_path(@user, membership), :method => :put,
|
|
|
|
:html => {:id => "member-#{membership.id}-roles-form",
|
|
|
|
:style => 'display:none;'}) do %>
|
2011-09-18 03:11:25 +04:00
|
|
|
<p><% roles.each do |role| %>
|
2009-09-12 12:36:46 +04:00
|
|
|
<label><%= check_box_tag 'membership[role_ids][]', role.id, membership.roles.include?(role),
|
2011-09-18 03:11:25 +04:00
|
|
|
:disabled => membership.member_roles.detect {|mr| mr.role_id == role.id && !mr.inherited_from.nil?} %> <%=h role %></label><br />
|
2009-05-10 14:54:31 +04:00
|
|
|
<% end %></p>
|
2009-09-12 12:36:46 +04:00
|
|
|
<%= hidden_field_tag 'membership[role_ids][]', '' %>
|
2009-05-10 14:54:31 +04:00
|
|
|
<p><%= submit_tag l(:button_change) %>
|
2012-01-10 12:43:32 +04:00
|
|
|
<%= link_to_function l(:button_cancel),
|
2012-07-22 17:29:26 +04:00
|
|
|
"$('#member-#{membership.id}-roles').show(); $('#member-#{membership.id}-roles-form').hide(); return false;"
|
2012-01-10 12:43:32 +04:00
|
|
|
%></p>
|
2008-05-02 19:21:21 +04:00
|
|
|
<% end %>
|
2009-05-10 14:54:31 +04:00
|
|
|
</td>
|
|
|
|
<td class="buttons">
|
2012-01-10 12:43:32 +04:00
|
|
|
<%= link_to_function l(:button_edit),
|
2012-07-22 17:29:26 +04:00
|
|
|
"$('#member-#{membership.id}-roles').hide(); $('#member-#{membership.id}-roles-form').show(); return false;",
|
2012-01-10 12:43:32 +04:00
|
|
|
:class => 'icon icon-edit'
|
|
|
|
%>
|
2012-07-18 20:28:07 +04:00
|
|
|
<%= delete_link user_membership_path(@user, membership), :remote => true if membership.deletable? %>
|
2009-05-10 14:54:31 +04:00
|
|
|
</td>
|
2009-08-01 22:14:39 +04:00
|
|
|
<%= call_hook(:view_users_memberships_table_row, :user => @user, :membership => membership, :roles => roles, :projects => projects )%>
|
2011-09-18 03:11:25 +04:00
|
|
|
</tr>
|
2010-12-13 00:21:57 +03:00
|
|
|
<% end; reset_cycle %>
|
2011-09-18 03:11:25 +04:00
|
|
|
</tbody>
|
2008-05-02 19:21:21 +04:00
|
|
|
</table>
|
|
|
|
<% else %>
|
|
|
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
2007-03-12 20:59:02 +03:00
|
|
|
<% end %>
|
2009-05-10 14:54:31 +04:00
|
|
|
</div>
|
2008-05-01 17:50:39 +04:00
|
|
|
|
2009-05-10 14:54:31 +04:00
|
|
|
<div class="splitcontentright">
|
|
|
|
<% if projects.any? %>
|
|
|
|
<fieldset><legend><%=l(:label_project_new)%></legend>
|
2012-04-25 21:17:49 +04:00
|
|
|
<%= form_for(:membership, :remote => true, :url => user_memberships_path(@user)) do %>
|
2009-05-10 14:54:31 +04:00
|
|
|
<%= 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>
|
2007-03-12 20:59:02 +03:00
|
|
|
<% end %>
|
2009-05-10 14:54:31 +04:00
|
|
|
</fieldset>
|
2008-05-01 17:50:39 +04:00
|
|
|
<% end %>
|
2009-05-10 14:54:31 +04:00
|
|
|
</div>
|