mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-03 14:31:47 +01:00
Added number of notes to project listing page. Fixes #128.
Interested in feedback on this... Which is higher value: the simplicity of only showing the number of actions or the utility of showing the number of notes as well? git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@485 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
8dba728577
commit
5d63400fca
3 changed files with 14 additions and 1 deletions
|
|
@ -136,6 +136,13 @@ class ProjectsController < ApplicationController
|
|||
@active_projects = @projects.select{ |p| p.active? }
|
||||
@hidden_projects = @projects.select{ |p| p.hidden? }
|
||||
@completed_projects = @projects.select{ |p| p.completed? }
|
||||
project_note_counts = Note.count(:group => 'project_id')
|
||||
@projects.each do |project|
|
||||
#define a singlton method "notes_count" on each project object
|
||||
class << project; self end.send(:define_method, :notes_count) do
|
||||
project_note_counts[project.id] || 0
|
||||
end
|
||||
end
|
||||
@new_project = @user.projects.build
|
||||
render
|
||||
end
|
||||
|
|
|
|||
|
|
@ -97,6 +97,12 @@ module ApplicationHelper
|
|||
def count_undone_todos_phrase_text(todos_parent, string="actions")
|
||||
count_undone_todos_phrase(todos_parent, string).gsub(" "," ")
|
||||
end
|
||||
|
||||
def count_undone_todos_and_notes_phrase(project, string="actions")
|
||||
s = count_undone_todos_phrase(project, string)
|
||||
s += ", #{pluralize(project.notes_count, 'note')}" unless project.notes_count == 0
|
||||
s
|
||||
end
|
||||
|
||||
def link_to_context(context, descriptor = sanitize(context.name))
|
||||
link_to( descriptor, context_path(context), :title => "View context: #{context.name}" )
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<span class="handle">DRAG</span>
|
||||
</div>
|
||||
<div class="data">
|
||||
<%= link_to_project( project ) %><%= " (" + count_undone_todos_phrase(project,"actions") + ")" %>
|
||||
<%= link_to_project( project ) %><%= " (" + count_undone_todos_and_notes_phrase(project,"actions") + ")" %>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<span class="grey"><%= project.current_state.to_s.upcase %></span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue