Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Commit

Permalink
detail view of hours added to projects view
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Maximini committed Feb 21, 2012
1 parent 7360e41 commit b27406c
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 9 deletions.
5 changes: 5 additions & 0 deletions app/assets/javascripts/projects.js.coffee
@@ -1,3 +1,8 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

jQuery ->
$('.hour_details .detail_link').each ->
$(this).click ->
$(this).next().slideToggle()
49 changes: 49 additions & 0 deletions app/assets/stylesheets/projects.css.scss
Expand Up @@ -39,6 +39,55 @@

}

.hours_detail_table {

margin-top: 20px;
width: 500px;

table {
border: 1px solid;
border-collapse: collapse;
}

tr {
border: 1px solid;
border-collapse: collapse;
}


th, td {
text-align:left;
white-space: no-wrap;
border: 1px solid;
border-collapse: collapse;
padding: 2px 10px;
min-width: 100px;
}

.user_hours {
display: none;

table {
width: 350px;
margin: 10px;
border: 0;

td, th {
min-width: 0;
width: auto;
}

}

.table_total td{
font-weight: bold;

}

}

}

.subtitle {
font-size: 16px;

Expand Down
5 changes: 5 additions & 0 deletions app/models/project.rb
Expand Up @@ -61,6 +61,11 @@ def total_hours(user=nil, extra = false)
hours.to_a.sum { |hour| hour.amount }
end

# return an array of hours that a given user booked on this project
def user_hours(user)
hours = self.hours.where(:user_id => user).order(:date)
end

# returns a list of all user ids that booked hours on this project
def project_users
user_list = []
Expand Down
37 changes: 36 additions & 1 deletion app/presenters/project_presenter.rb
Expand Up @@ -76,7 +76,42 @@ def hours_spent
str.html_safe
end
end


def hour_details
handle_none project.hours do
str = '<div class="subtitle">Time spent on this project</div>'
str += '<div class="hours_detail_table"><table>'
str += '<tr><th>Name</th><th>Hours</th><th>Extra Hours</th></tr>'
project.project_users.each do |u|
profile = Profile.find_by_user_id(u)
str += '<tr>'
str += "<td>#{link_to profile.name, profile}</td><td>#{project.total_hours(u)}</td><td>#{project.total_hours(u, true)}</td><td class='hour_details'><a class='detail_link' href='#'>details</a>"

#adding a detailed table

str += '<div class="user_hours"><table>'
# add detailed overview per user
str += "<tr><th>date</th><th>hours</th><th>extra</th><th>description</th><th>task</th></tr>"
project.user_hours(u).each do |h|
str += "<tr><td>#{link_to h.date.strftime('%d.%m.%y'), edit_hour_path(h)}</td><td>#{h.amount}</td><td>#{h.extra? ? 'yes' : 'no' }</td><td>#{h.description}</td><td>#{h.task.name}</td></tr>"
end

str += "</table>"

str += '</td>'



str += '</tr>'
end
str += '<tr class="table_total">'
str += "<td><b>Summe</b></td><td><b>#{project.total_hours}</b></td><td><b>#{project.total_hours(nil, true)}</b></td>"
str += "</tr></table>"
str.html_safe
end
end


private


Expand Down
24 changes: 17 additions & 7 deletions app/views/projects/show.html.haml
Expand Up @@ -6,15 +6,14 @@
%span.projectname= project_presenter.title

#project.content_window.fullsize
.header= link_to "Project Details", "javascript:void(0)", :class => 'open', :title => "open / close"
.header= link_to "Project Overview", "javascript:void(0)", :class => 'open', :title => "open / close"

.inner
.column
.subtitle Description
.subcontent
.description= markdown(project_presenter.description)
.hours_spent
= project_presenter.hours_spent


.column
.subtitle Involved People
Expand All @@ -27,14 +26,25 @@
.tasks= project_presenter.tasks

%br.clear



.edit_links
-if can? :update, @project
= link_to 'Edit', edit_project_path(@project)
\|
= link_to 'Back', projects_path
= link_to 'Back', projects_path


#project_statistics.content_window.fullsize
.header= link_to "Project Details", "javascript:void(0)", :class => 'open', :title => "open / close"

.inner
.column
.hour_details= project_presenter.hour_details

%br.clear







2 changes: 1 addition & 1 deletion solr/pids/development/sunspot-solr-development.pid
@@ -1 +1 @@
27381
2193

0 comments on commit b27406c

Please sign in to comment.