Added an application helper method, show_date. All views now
call this method to show a date field.
Signed-off-by: Darryl L. Pierce <mcpierce(a)gmail.com>
---
app/helpers/application_helper.rb | 9 +++++++++
app/views/projects/index.html.erb | 2 +-
app/views/sprints/_list.html.erb | 4 ++--
app/views/sprints/show.html.erb | 4 ++--
app/views/tasks/_list.html.erb | 2 +-
app/views/users/_list.html.erb | 2 +-
6 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index c944b8b..9e81b48 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -35,6 +35,15 @@ module ApplicationHelper
:alt => sprint.healthy? ? "Sprint is healthy" : "Sprint is not
healthy")
end
+ # Displays a date or date and time.
+ def show_date(datetime, include_time = false)
+ if include_time
+ datetime.strftime("%m/%d/%Y %I:%M:%S %P")
+ else
+ datetime.strftime("%m/%d/%Y")
+ end
+ end
+
# Creates a link to a backlog item.
#
def link_to_backlog_item(backlog_item, options = {})
diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb
index 8bb062b..d091f66 100644
--- a/app/views/projects/index.html.erb
+++ b/app/views/projects/index.html.erb
@@ -41,7 +41,7 @@
<td><%= project.name %></td>
<td><%= get_first_sentence project.description %></td>
<td><%= link_to project.owner.display_name, user_path(project.owner)
%></td>
- <td><%= project.created_at.to_s(:date) %></td>
+ <td><%= show_date(project.created_at) %></td>
<td>
<%= link_to(
image_tag("icons/view.png", :alt => "View"),
diff --git a/app/views/sprints/_list.html.erb b/app/views/sprints/_list.html.erb
index 1c8cbff..bf34f56 100644
--- a/app/views/sprints/_list.html.erb
+++ b/app/views/sprints/_list.html.erb
@@ -35,8 +35,8 @@
<td><%= link_to "#{sprint.id}",
product_sprint_path(@product, sprint) %></td>
<td><%= sprint.title %></td>
<td><%= sprint.status_text %></td>
- <td><%= sprint.start %></td>
- <td><%= "#{sprint.end_date} (#{sprint.duration} days)"
%></td>
+ <td><%= show_date(sprint.start) %></td>
+ <td><%= "#{show_date(sprint.end_date)} (#{sprint.duration}
days)" %></td>
<td><%= show_hours_as_ear(sprint) %></td>
<td>
<%= link_to(image_tag("icons/view.png"),
product_sprint_path(@product, sprint)) %>
diff --git a/app/views/sprints/show.html.erb b/app/views/sprints/show.html.erb
index 823c718..df475c5 100644
--- a/app/views/sprints/show.html.erb
+++ b/app/views/sprints/show.html.erb
@@ -42,12 +42,12 @@
<tr>
<td class="label">Starts:</td>
- <td class="value"><%= @sprint.start.to_s(:date)
%></td>
+ <td class="value"><%= show_date((a)sprint.start) %></td>
</tr>
<tr>
<td class="label">Ends:</td>
- <td class="value"><%= @sprint.end_date.to_s(:date) %>
+ <td class="value"><%= "#{show_date((a)sprint.end_date)}
(#{(a)sprint.duration} days)" %>
</tr>
<tr>
diff --git a/app/views/tasks/_list.html.erb b/app/views/tasks/_list.html.erb
index 7f591ae..31f5a8c 100644
--- a/app/views/tasks/_list.html.erb
+++ b/app/views/tasks/_list.html.erb
@@ -29,7 +29,7 @@
<% row_class = index%2 == 0 ? 'even' : 'odd' %>
<tr class="<%= row_class %>">
<td><%= link_to "#{task.id}", user_task_path(task.primary,
task) %></td>
- <td><%= task.when_entered %></td>
+ <td><%= show_date(task.when_entered) %></td>
<td><%= simple_format task.description %></td>
<td><%= link_to(task.primary.display_name, user_path(task.primary)) if
task.primary %></td>
<td><%= link_to(task.backup, user_path(task.backup)) if task.backup
%></td>
diff --git a/app/views/users/_list.html.erb b/app/views/users/_list.html.erb
index 5210f50..9fc055e 100644
--- a/app/views/users/_list.html.erb
+++ b/app/views/users/_list.html.erb
@@ -34,7 +34,7 @@
<td><%= link_to user.email, "mailto:#{user.email}"
%></td>
<td><%= link_to "#{user.backlog.size} items",
backlog_user_path(user) %>
<td><%= "#{user.product_roles.size} roles" %></td>
- <td><%= user.created_at.to_s(:date) %></td>
+ <td><%= show_date(user.created_at) %></td>
<td>
<%= link_to(image_tag("icons/view.png", :alt => "View
user..."), user_path(user)) %>
<%= link_to(image_tag("icons/edit.png", :alt =>
"Edit"),
--
1.5.6.5
Show replies by date