summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/users_controller.rb13
-rw-r--r--app/helpers/users_helper.rb6
-rw-r--r--app/views/users/_form.rhtml1
-rw-r--r--app/views/users/_general.rhtml4
-rw-r--r--app/views/users/_memberships.rhtml43
-rw-r--r--app/views/users/edit.rhtml27
6 files changed, 63 insertions, 31 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 48fc6fade..c37709661 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -91,23 +91,20 @@ class UsersController < ApplicationController
@roles = Role.find_all_givable
@projects = Project.find(:all, :order => 'name', :conditions => "status=#{Project::STATUS_ACTIVE}") - @user.projects
@membership ||= Member.new
+ @memberships = @user.memberships
end
def edit_membership
@user = User.find(params[:id])
@membership = params[:membership_id] ? Member.find(params[:membership_id]) : Member.new(:user => @user)
@membership.attributes = params[:membership]
- if request.post? and @membership.save
- flash[:notice] = l(:notice_successful_update)
- end
- redirect_to :action => 'edit', :id => @user and return
+ @membership.save if request.post?
+ redirect_to :action => 'edit', :id => @user, :tab => 'memberships'
end
def destroy_membership
@user = User.find(params[:id])
- if request.post? and Member.find(params[:membership_id]).destroy
- flash[:notice] = l(:notice_successful_update)
- end
- redirect_to :action => 'edit', :id => @user and return
+ Member.find(params[:membership_id]).destroy if request.post?
+ redirect_to :action => 'edit', :id => @user, :tab => 'memberships'
end
end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 0fe1755eb..6976d021b 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -48,4 +48,10 @@ module UsersHelper
link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock'
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
diff --git a/app/views/users/_form.rhtml b/app/views/users/_form.rhtml
index ff4278c1f..6ca167a59 100644
--- a/app/views/users/_form.rhtml
+++ b/app/views/users/_form.rhtml
@@ -2,7 +2,6 @@
<!--[form:user]-->
<div class="box">
-<h3><%=l(:label_information_plural)%></h3>
<p><%= f.text_field :login, :required => true, :size => 25 %></p>
<p><%= f.text_field :firstname, :required => true %></p>
<p><%= f.text_field :lastname, :required => true %></p>
diff --git a/app/views/users/_general.rhtml b/app/views/users/_general.rhtml
new file mode 100644
index 000000000..80615ff6c
--- /dev/null
+++ b/app/views/users/_general.rhtml
@@ -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 %>
diff --git a/app/views/users/_memberships.rhtml b/app/views/users/_memberships.rhtml
index 44d74ef7b..94b49159e 100644
--- a/app/views/users/_memberships.rhtml
+++ b/app/views/users/_memberships.rhtml
@@ -1,21 +1,33 @@
-<div class="box" style="margin-top: 16px;">
-<h3><%= l(:label_project_plural) %></h3>
-
-<% @user.memberships.each do |membership| %>
-<% form_tag({ :action => 'edit_membership', :id => @user, :membership_id => membership }, :class => "tabular") do %>
-<p style="margin:0;padding-top:0;">
- <label><%= membership.project.name %></label>
- <select name="membership[role_id]">
- <%= options_from_collection_for_select @roles, "id", "name", membership.role_id %>
- </select>
- <%= submit_tag l(:button_change), :class => "button-small" %>
- <%= 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' %>
-</p>
-<% end %>
+<% if @memberships.any? %>
+<table class="list memberships">
+ <thead>
+ <th><%= l(:label_project) %></th>
+ <th><%= l(:label_role) %></th>
+ <th style="width:15%"></th>
+ </thead>
+ <tbody>
+ <% @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" %>
+ <% 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 %>
<% if @projects.any? %>
-<hr />
<p>
<label><%=l(:label_project_new)%></label><br/>
<% form_tag({ :action => 'edit_membership', :id => @user }) do %>
@@ -26,4 +38,3 @@
<% end %>
</p>
<% end %>
-</div> \ No newline at end of file
diff --git a/app/views/users/edit.rhtml b/app/views/users/edit.rhtml
index 0da99d0d2..a4d0b2e5b 100644
--- a/app/views/users/edit.rhtml
+++ b/app/views/users/edit.rhtml
@@ -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| %>
-<%= render :partial => 'form', :locals => { :f => f } %>
-<%= submit_tag l(:button_save) %>
-<% end %>
+<% selected_tab = params[:tab] ? params[:tab].to_s : user_settings_tabs.first[:name] %>
-<%= render :partial => 'memberships' %> \ No newline at end of file
+<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)) -%>