Also cleaned up the roles display.
Signed-off-by: Darryl L. Pierce <mcpierce(a)gmail.com>
---
app/controllers/application.rb | 2 +-
app/models/product_role.rb | 2 +-
app/views/roles/_list.html.erb | 113 ++++++++++++----------------------------
app/views/roles/index.html.erb | 12 +++--
app/views/roles/show.html.erb | 97 ++++++++++++++--------------------
app/views/users/_user.html.erb | 18 ------
app/views/users/index.html.erb | 2 +
app/views/users/roles.html.erb | 13 +++--
app/views/users/show.html.erb | 3 +
9 files changed, 98 insertions(+), 164 deletions(-)
delete mode 100644 app/views/users/_user.html.erb
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index 2c796f2..dacc8a1 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -59,7 +59,7 @@ class ApplicationController < ActionController::Base
yield
rescue Exception => error
logger.error("EXCEPTION: #{error.message}")
- # puts error.backtrace
+ puts error.backtrace
erase_results
@title = "An Error Has Occurred."
flash[:error] = "The following error has occurred: #{error.message}"
diff --git a/app/models/product_role.rb b/app/models/product_role.rb
index 77104e7..38164a3 100644
--- a/app/models/product_role.rb
+++ b/app/models/product_role.rb
@@ -52,6 +52,6 @@ class ProductRole < ActiveRecord::Base
# Returns whether the user can delete this role.
def can_delete?(user)
- user && user.id == product.owner_id
+ (user != nil) && (user.id == product.owner_id)
end
end
diff --git a/app/views/roles/_list.html.erb b/app/views/roles/_list.html.erb
index efb09de..c3a1b87 100644
--- a/app/views/roles/_list.html.erb
+++ b/app/views/roles/_list.html.erb
@@ -1,82 +1,35 @@
-<% columns = 4 - (@this_user ? 1 : 0) + (@product ? 0 : 1) + (@product &&
@product.can_approve_roles?(@user) ? 1 : 0) %>
-
-<table class="list">
- <colgroup>
- <col class="row_id" />
- <% unless @this_user %>
- <col class="user" />
- <% end %>
- <% unless @product %>
- <col class="name" />
- <% end %>
- <col class="description" />
- <col class="date" />
-
- <% if @product && @product.can_approve_roles?(@user) %>
- <col class="actions" />
- <% end %>
- </colgroup>
-
- <thead>
- <tr>
- <th class="title" colspan="<%= columns %>">
- Product Roles
- </th>
- </tr>
- <tr>
- <th>#</th>
-
- <% unless @this_user %>
- <th>User</th>
+<div class="content">
+ <table class="main-list">
+ <caption>
+ <% if @product %>
+ <%= "Product Roles For #{(a)product.name}" %>
+ <% else %>
+ <%= title %>
<% end %>
-
- <% unless @product %>
- <th>Product</th>
- <% end %>
-
- <th>Role</th>
- <th>Since</th>
- <% if @product && @product.can_approve_roles?(@user) %>
- <th>Actions</th>
- <% end %>
- </tr>
- </thead>
-
- <tbody>
- <% @product_roles.each_with_index do |role, index| %>
- <% row_class = index%2 == 0 ? 'even' : 'odd' %>
- <tr class="<%= row_class %>">
- <td><%= "#{role.id}" %>
-
- <% unless @this_user %>
- <td><%= link_to role.user.display_name,roles_user_path(role.user)
%></td>
- <% end %>
-
- <% unless @product %>
- <td><%= link_to role.product.name, product_roles_path(role.product)
%>
- <% end %>
-
- <td><%= role.role.name %></td>
- <td><%= show_date role.created_at %></td>
- <% if @product && @product.can_approve_roles?(@user) %>
- <td>
- <%= link_to(image_tag("icons/user.png", :title => "View
this role..."),
- product_role_path(role.product, role)) %>
- <% if role.pending %>
- <% form_for(:product_role, role, :url =>
product_role_path(role.product,role),
- :html => {:method => :put}) do |form| %>
- <%= form.radio_button :approved, true %>Approve
- <%= form.radio_button :approved, false %>Deny
- <%= submit_tag "Update" %>
- <% end %>
- <% else %>
- <%= link_to(image_tag("icons/role_delete.png", :title =>
"Delete this role..."),
- product_role_path(role.product, role), :method => :delete,
- :confirm => "Delete? Are you sure?") if
role.can_delete?(@user) %>
- <% end %>
- <% end %>
- </td>
+ </caption>
+ <thead>
+ <tr>
+ <th scope="col">#</th>
+ <th scope="col" class="name">User</th>
+ <th scope="col">Project</th>
+ <th scope="col">Since</th>
</tr>
- <% end %>
- </tbody>
-</table>
+ </thead>
+ <tbody>
+ <% product_roles.each do |product_role| %>
+ <tr class="<%= cycle('odd', 'even') %>">
+ <td><%= product_role.id %></td>
+ <td class="name">
+ <% if product_role.user.avatar_url %>
+ <div class="small-icon"><%= image_tag product_role.user.avatar_url
%></div>
+ <% end %>
+ <%= link_to product_role.user.display_name, user_path(product_role.user) %>
+ <%= link_to product_role.role.name, product_role_path(product_role.product,
product_role) %>
+ </td>
+ <td><%= link_to product_role.product.name,
product_roles_path(product_role.product) %></td>
+ <td><%= show_date(product_role.created_at) %></td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+</div>
diff --git a/app/views/roles/index.html.erb b/app/views/roles/index.html.erb
index ce6b86a..66d922a 100644
--- a/app/views/roles/index.html.erb
+++ b/app/views/roles/index.html.erb
@@ -1,4 +1,8 @@
-<%= render :partial => 'products/product', :object => @product %>
-
-<%= will_paginate @product_roles %>
-<%= render :partial => 'list' %>
+<div id="content">
+ <div>
+ <%= will_paginate @product_roles %>
+ </div>
+ <div>
+ <%= render :partial => 'roles/list', :locals => {:product_roles
=> @product_roles} %>
+ </div>
+</div>
diff --git a/app/views/roles/show.html.erb b/app/views/roles/show.html.erb
index fca78ab..a019417 100644
--- a/app/views/roles/show.html.erb
+++ b/app/views/roles/show.html.erb
@@ -1,56 +1,41 @@
-<table class="detail">
- <colgroup>
- <col class="label" />
- <col class="value" />
- </colgroup>
-
- <thead>
- <tr>
- <th class="title" colspan="2">
- <%= "#{(a)product_role.role.name} for #{(a)product_role.product.name}"
%>
- </th>
- </tr>
- </thead>
-
- <tbody>
- <tr>
- <td class="label">Product:</td>
- <td class="value"><%= @product_role.product.name
%></td>
- </tr>
-
- <tr>
- <td class="label">User:</td>
- <td class="value"><%= @product_role.user.display_name
%></td>
- </tr>
-
- <tr>
- <td class="label">Role:</td>
- <td class="value"><%= @product_role.role.name %></td>
- </tr>
-
- <tr>
- <td class="label">Since:</td>
- <td class="value"><%= show_date((a)product_role.created_at)
%></td>
- </tr>
-
- <tr>
- <td class="buttons" colspan="2">
- <% if @product_role.pending %>
- <% form_for(:product_role, @product_role,
- :url => product_role_path(@product_role.product,(a)product_role),
- :html => {:method => :put}) do |form| %>
- <%= form.radio_button :approved, true %>Approve
- <%= form.radio_button :approved, false %>Deny
- <%= submit_tag "Update" %>
- <% end %>
- <% else %>
- <% form_for(:product_role, @product_role,
- :url => product_role_path(@product_role.product,(a)product_role),
- :html => {:method => :delete}) do |form| %>
- <%= submit_tag "Delete", :confirm => "Are you
sure?" %>
- <% end %>
- <% end %>
- </td>
- </tr>
- </tbody>
-</table>
+<div id="content">
+ <div id="page-details">
+ <dl>
+ <dt><%= "For #{(a)product_role.product.name}" %></dt>
+ <dd><%= "#{(a)product_role.user.display_name} has been a
#{(a)product_role.role.name} since #{show_date((a)product_role.created_at)}."
%></dd>
+ </dl>
+ </div>
+</div>
+
+<% render :layout => 'home/sidebar', :locals => {:title =>
'Product Role Commands'} do %>
+ <%= link_to "View this user's other roles",
+ roles_user_path((a)product_role.user), :class => "command" %>
+
+ <%= link_to "View this product's other members",
+ product_roles_path((a)product_role.product), :class => "command" %>
+
+ <% if @product_role.can_delete?(@user) %>
+
+ <% if @product_role.pending? %>
+
+ <%= link_to "Approve this role...",
+ product_role_path((a)product_role.product, @product_role, :approved => true),
+ :confirm => "Approve this role? Are you sure?", :method => :post,
+ :class => "command" %>
+
+ <%= link_to "Delete this role...",
+ product_role_path((a)product_role.product, @product_role, :approved => false),
+ :confirm => "Decline this role? Are you sure?", :method => :post,
+ :class => "command" %>
+
+ <% end %>
+
+ <% unless @product_role.pending? %>
+ <%= link_to "Revoke this role...",
+ product_role_path((a)product_role.product, @product_role),
+ :confirm => "Revoke this role? Are you sure?", :method => :delete,
+ :class => "command" %>
+ <% end %>
+
+ <% end %>
+<% end %>
diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb
deleted file mode 100644
index 974ba3e..0000000
--- a/app/views/users/_user.html.erb
+++ /dev/null
@@ -1,18 +0,0 @@
-<table class="detail">
- <colgroup>
- <col class="label" />
- <col class="value" />
- </colgroup>
-
- <thead>
- <tr>
- <th class="title" colspan="2"><%=
"#{user.display_name} (#{user.email})" %></th>
- </tr>
- </thead>
-
- <tbody>
- <tr>
- <td class="text" colspan="2"><%=
RedCloth.new(user.introduction).to_html %></td>
- </tr>
- </tbody>
-</table>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
index 2e8c466..83b2a48 100644
--- a/app/views/users/index.html.erb
+++ b/app/views/users/index.html.erb
@@ -8,6 +8,7 @@
<tr>
<th scope="col">#</th>
<th scope="col" class="name">Name</th>
+ <th scopes="col">Roles</th>
<th scope="col">Backlog</th>
<th scope="col">Since</th>
</tr>
@@ -23,6 +24,7 @@
<%= link_to user.display_name, user_path(user) %>
<%= RedCloth.new(get_first_sentence(user.introduction)).to_html %>
</td>
+ <td><%= link_to "#{user.product_roles.size}", roles_user_path(user)
%></td>
<td><%= link_to "#{user.backlog.size}", backlog_user_path(user)
%></td>
<td><%= show_date user.created_at %></td>
</tr>
diff --git a/app/views/users/roles.html.erb b/app/views/users/roles.html.erb
index 4aaef1f..a71b38d 100644
--- a/app/views/users/roles.html.erb
+++ b/app/views/users/roles.html.erb
@@ -1,4 +1,9 @@
-<%= render :partial => 'user', :object => @this_user %>
-
-<%= will_paginate @product_roles %>
-<%= render :partial => 'roles/list' %>
+<div id="content">
+ <div>
+ <%= will_paginate @product_roles %>
+ </div>
+ <div>
+ <%= render :partial => 'roles/list',
+ :locals => {:product_roles => @product_roles, :title => "Roles For
#{(a)this_user.display_name}"} %>
+ </div>
+</div>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index 6762daa..67edf4a 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -35,4 +35,7 @@
<%= link_to "Change password",
password_user_path(@this_user), :class => "command" %>
<% end %>
+
+ <%= link_to "View user roles",
+ roles_user_path(@this_user), :class => "command" %>
<% end %>
--
1.6.0.6