Split user edit screen into tabs.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1404 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7a969dafac
commit
63951812a1
|
@ -91,23 +91,20 @@ class UsersController < ApplicationController
|
||||||
@roles = Role.find_all_givable
|
@roles = Role.find_all_givable
|
||||||
@projects = Project.find(:all, :order => 'name', :conditions => "status=#{Project::STATUS_ACTIVE}") - @user.projects
|
@projects = Project.find(:all, :order => 'name', :conditions => "status=#{Project::STATUS_ACTIVE}") - @user.projects
|
||||||
@membership ||= Member.new
|
@membership ||= Member.new
|
||||||
|
@memberships = @user.memberships
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_membership
|
def edit_membership
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
@membership = params[:membership_id] ? Member.find(params[:membership_id]) : Member.new(:user => @user)
|
@membership = params[:membership_id] ? Member.find(params[:membership_id]) : Member.new(:user => @user)
|
||||||
@membership.attributes = params[:membership]
|
@membership.attributes = params[:membership]
|
||||||
if request.post? and @membership.save
|
@membership.save if request.post?
|
||||||
flash[:notice] = l(:notice_successful_update)
|
redirect_to :action => 'edit', :id => @user, :tab => 'memberships'
|
||||||
end
|
|
||||||
redirect_to :action => 'edit', :id => @user and return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_membership
|
def destroy_membership
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
if request.post? and Member.find(params[:membership_id]).destroy
|
Member.find(params[:membership_id]).destroy if request.post?
|
||||||
flash[:notice] = l(:notice_successful_update)
|
redirect_to :action => 'edit', :id => @user, :tab => 'memberships'
|
||||||
end
|
|
||||||
redirect_to :action => 'edit', :id => @user and return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,4 +48,10 @@ module UsersHelper
|
||||||
link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock'
|
link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_settings_tabs
|
||||||
|
tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
|
||||||
|
{:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
|
||||||
|
]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
<!--[form:user]-->
|
<!--[form:user]-->
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<h3><%=l(:label_information_plural)%></h3>
|
|
||||||
<p><%= f.text_field :login, :required => true, :size => 25 %></p>
|
<p><%= f.text_field :login, :required => true, :size => 25 %></p>
|
||||||
<p><%= f.text_field :firstname, :required => true %></p>
|
<p><%= f.text_field :firstname, :required => true %></p>
|
||||||
<p><%= f.text_field :lastname, :required => true %></p>
|
<p><%= f.text_field :lastname, :required => true %></p>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<% labelled_tabular_form_for :user, @user, :url => { :action => "edit" } do |f| %>
|
||||||
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||||
|
<%= submit_tag l(:button_save) %>
|
||||||
|
<% end %>
|
|
@ -1,21 +1,33 @@
|
||||||
<div class="box" style="margin-top: 16px;">
|
<% if @memberships.any? %>
|
||||||
<h3><%= l(:label_project_plural) %></h3>
|
<table class="list memberships">
|
||||||
|
<thead>
|
||||||
<% @user.memberships.each do |membership| %>
|
<th><%= l(:label_project) %></th>
|
||||||
<% form_tag({ :action => 'edit_membership', :id => @user, :membership_id => membership }, :class => "tabular") do %>
|
<th><%= l(:label_role) %></th>
|
||||||
<p style="margin:0;padding-top:0;">
|
<th style="width:15%"></th>
|
||||||
<label><%= membership.project.name %></label>
|
</thead>
|
||||||
<select name="membership[role_id]">
|
<tbody>
|
||||||
<%= options_from_collection_for_select @roles, "id", "name", membership.role_id %>
|
<% @memberships.each do |membership| %>
|
||||||
</select>
|
<% next if membership.new_record? %>
|
||||||
<%= submit_tag l(:button_change), :class => "button-small" %>
|
<tr class="<%= cycle 'odd', 'even' %>">
|
||||||
<%= 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' %>
|
<td><%=h membership.project %></td>
|
||||||
</p>
|
<td align="center">
|
||||||
<% end %>
|
<% 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" %>
|
||||||
|
<% 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>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<% end; reset_cycle %>
|
||||||
|
</table>
|
||||||
|
<% else %>
|
||||||
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @projects.any? %>
|
<% if @projects.any? %>
|
||||||
<hr />
|
|
||||||
<p>
|
<p>
|
||||||
<label><%=l(:label_project_new)%></label><br/>
|
<label><%=l(:label_project_new)%></label><br/>
|
||||||
<% form_tag({ :action => 'edit_membership', :id => @user }) do %>
|
<% form_tag({ :action => 'edit_membership', :id => @user }) do %>
|
||||||
|
@ -26,4 +38,3 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
|
|
@ -1,8 +1,23 @@
|
||||||
<h2><%=l(:label_user)%></h2>
|
<h2><%=l(:label_user)%>: <%=h @user.login %></h2>
|
||||||
|
|
||||||
<% labelled_tabular_form_for :user, @user, :url => { :action => "edit" } do |f| %>
|
<% selected_tab = params[:tab] ? params[:tab].to_s : user_settings_tabs.first[:name] %>
|
||||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
|
||||||
<%= submit_tag l(:button_save) %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= render :partial => 'memberships' %>
|
<div class="tabs">
|
||||||
|
<ul>
|
||||||
|
<% user_settings_tabs.each do |tab| -%>
|
||||||
|
<li><%= link_to l(tab[:label]), { :tab => tab[:name] },
|
||||||
|
:id => "tab-#{tab[:name]}",
|
||||||
|
:class => (tab[:name] != selected_tab ? nil : 'selected'),
|
||||||
|
:onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
|
||||||
|
<% end -%>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% user_settings_tabs.each do |tab| -%>
|
||||||
|
<%= content_tag('div', render(:partial => tab[:partial]),
|
||||||
|
:id => "tab-content-#{tab[:name]}",
|
||||||
|
:style => (tab[:name] != selected_tab ? 'display:none' : nil),
|
||||||
|
:class => 'tab-content') %>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
<% html_title(l(:label_user), @user.login, l(:label_administration)) -%>
|
||||||
|
|
Loading…
Reference in New Issue