Fixes #634 and #631. The project and context view now checks for the preference of number of completed actions to show being zero and does not show anything in that case. Also fixes label of the preference

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@701 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lrbalt 2008-01-18 21:02:54 +00:00
parent 708ce260ef
commit 327b2e11eb
6 changed files with 128 additions and 116 deletions

View file

@ -36,7 +36,8 @@ class ContextsController < ApplicationController
end end
end end
# Example XML usage: curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' # Example XML usage: curl -H 'Accept: application/xml' -H 'Content-Type:
# application/xml'
# -u username:password # -u username:password
# -d '<request><context><name>new context_name</name></context></request>' # -d '<request><context><name>new context_name</name></context></request>'
# http://our.tracks.host/contexts # http://our.tracks.host/contexts
@ -66,7 +67,7 @@ class ContextsController < ApplicationController
else else
head :created, :location => context_url(@context) head :created, :location => context_url(@context)
end end
end end
end end
end end
@ -91,9 +92,9 @@ class ContextsController < ApplicationController
end end
end end
# Fairly self-explanatory; deletes the context # Fairly self-explanatory; deletes the context If the context contains
# If the context contains actions, you'll get a warning dialogue. # actions, you'll get a warning dialogue. If you choose to go ahead, any
# If you choose to go ahead, any actions in the context will also be deleted. # actions in the context will also be deleted.
def destroy def destroy
@context.destroy @context.destroy
respond_to do |format| respond_to do |format|
@ -113,59 +114,62 @@ class ContextsController < ApplicationController
protected protected
def render_contexts_html def render_contexts_html
lambda do lambda do
@page_title = "TRACKS::List Contexts" @page_title = "TRACKS::List Contexts"
@no_contexts = @contexts.empty? @no_contexts = @contexts.empty?
@count = @contexts.size @count = @contexts.size
render render
end
end
def render_contexts_rss_feed
lambda do
render_rss_feed_for @contexts, :feed => feed_options,
:item => { :description => lambda { |c| c.summary(count_undone_todos_phrase(c)) } }
end
end
def render_contexts_atom_feed
lambda do
render_atom_feed_for @contexts, :feed => feed_options,
:item => { :description => lambda { |c| c.summary(count_undone_todos_phrase(c)) },
:author => lambda { |c| nil } }
end
end
def feed_options
Context.feed_options(current_user)
end
def set_context_from_params
@context = current_user.contexts.find_by_params(params)
rescue
@context = nil
end
def init
@source_view = params['_source_view'] || 'context'
init_data_for_sidebar
end
def init_todos
set_context_from_params
unless @context.nil?
@context.todos.with_scope :find => { :include => [:project, :tags] } do
@done = @context.done_todos
end end
end
def render_contexts_rss_feed @max_completed = current_user.prefs.show_number_completed
lambda do
render_rss_feed_for @contexts, :feed => feed_options,
:item => { :description => lambda { |c| c.summary(count_undone_todos_phrase(c)) } }
end
end
def render_contexts_atom_feed # @not_done_todos = @context.not_done_todos TODO: Temporarily doing this
lambda do # search manually until I can work out a way to do the same thing using
render_atom_feed_for @contexts, :feed => feed_options, # not_done_todos acts_as_todo_container method Hides actions in hidden
:item => { :description => lambda { |c| c.summary(count_undone_todos_phrase(c)) }, # projects from context.
:author => lambda { |c| nil } } @not_done_todos = @context.todos.find(:all, :conditions => ['todos.state = ?', 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [:project, :tags])
end @count = @not_done_todos.size
end @default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
def feed_options
Context.feed_options(current_user)
end
def set_context_from_params
@context = current_user.contexts.find_by_params(params)
rescue
@context = nil
end
def init
@source_view = params['_source_view'] || 'context'
init_data_for_sidebar
end
def init_todos
set_context_from_params
unless @context.nil?
@context.todos.with_scope :find => { :include => [:project, :tags] } do
@done = @context.done_todos
end
# @not_done_todos = @context.not_done_todos
# TODO: Temporarily doing this search manually until I can work out a way
# to do the same thing using not_done_todos acts_as_todo_container method
# Hides actions in hidden projects from context.
@not_done_todos = @context.todos.find(:all, :conditions => ['todos.state = ?', 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [:project, :tags])
@count = @not_done_todos.size
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
end
end end
end
end end

View file

@ -32,6 +32,9 @@ class ProjectsController < ApplicationController
@deferred = @project.deferred_todos.sort_by { |todo| todo.show_from } @deferred = @project.deferred_todos.sort_by { |todo| todo.show_from }
@done = @project.done_todos @done = @project.done_todos
end end
@max_completed = current_user.prefs.show_number_completed
@count = @not_done.size @count = @not_done.size
@next_project = current_user.projects.next_from(@project) @next_project = current_user.projects.next_from(@project)
@previous_project = current_user.projects.previous_from(@project) @previous_project = current_user.projects.previous_from(@project)
@ -42,7 +45,8 @@ class ProjectsController < ApplicationController
end end
end end
# Example XML usage: curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' # Example XML usage: curl -H 'Accept: application/xml' -H 'Content-Type:
# application/xml'
# -u username:password # -u username:password
# -d '<request><project><name>new project_name</name></project></request>' # -d '<request><project><name>new project_name</name></project></request>'
# http://our.tracks.host/projects # http://our.tracks.host/projects
@ -72,7 +76,7 @@ class ProjectsController < ApplicationController
render_failure @project.errors.full_messages.join(', ') render_failure @project.errors.full_messages.join(', ')
else else
head :created, :location => project_url(@project) head :created, :location => project_url(@project)
end end
end end
end end
end end
@ -155,76 +159,76 @@ class ProjectsController < ApplicationController
protected protected
def render_projects_html def render_projects_html
lambda do lambda do
init_project_hidden_todo_counts(['project']) init_project_hidden_todo_counts(['project'])
@page_title = "TRACKS::List Projects" @page_title = "TRACKS::List Projects"
@count = current_user.projects.size @count = current_user.projects.size
@active_projects = @projects.select{ |p| p.active? } @active_projects = @projects.select{ |p| p.active? }
@hidden_projects = @projects.select{ |p| p.hidden? } @hidden_projects = @projects.select{ |p| p.hidden? }
@completed_projects = @projects.select{ |p| p.completed? } @completed_projects = @projects.select{ |p| p.completed? }
@no_projects = @projects.empty? @no_projects = @projects.empty?
@projects.cache_note_counts @projects.cache_note_counts
@new_project = current_user.projects.build @new_project = current_user.projects.build
render render
end
end end
end
def render_rss_feed def render_rss_feed
lambda do lambda do
render_rss_feed_for @projects, :feed => feed_options, render_rss_feed_for @projects, :feed => feed_options,
:item => { :title => :name, :description => lambda { |p| summary(p) } } :item => { :title => :name, :description => lambda { |p| summary(p) } }
end
end end
end
def render_atom_feed def render_atom_feed
lambda do lambda do
render_atom_feed_for @projects, :feed => feed_options, render_atom_feed_for @projects, :feed => feed_options,
:item => { :description => lambda { |p| summary(p) }, :item => { :description => lambda { |p| summary(p) },
:title => :name, :title => :name,
:author => lambda { |p| nil } } :author => lambda { |p| nil } }
end
end end
end
def feed_options def feed_options
Project.feed_options(current_user) Project.feed_options(current_user)
end
def render_text_feed
lambda do
init_project_hidden_todo_counts(['project'])
render :action => 'index_text', :layout => false, :content_type => Mime::TEXT
end end
end
def render_text_feed def set_project_from_params
lambda do @project = current_user.projects.find_by_params(params)
init_project_hidden_todo_counts(['project']) end
render :action => 'index_text', :layout => false, :content_type => Mime::TEXT
end def set_source_view
@source_view = params['_source_view'] || 'project'
end
def default_context_filter
p = params['project']
p = params['request']['project'] if p.nil? && params['request']
p = {} if p.nil?
default_context_name = p['default_context_name']
p.delete('default_context_name')
unless default_context_name.blank?
default_context = Context.find_or_create_by_name(default_context_name)
p['default_context_id'] = default_context.id
end end
end
def set_project_from_params def summary(project)
@project = current_user.projects.find_by_params(params) project_description = ''
end project_description += sanitize(markdown( project.description )) unless project.description.blank?
project_description += "<p>#{count_undone_todos_phrase(p)}. "
def set_source_view project_description += "Project is #{project.state}."
@source_view = params['_source_view'] || 'project' project_description += "</p>"
end project_description
end
def default_context_filter
p = params['project']
p = params['request']['project'] if p.nil? && params['request']
p = {} if p.nil?
default_context_name = p['default_context_name']
p.delete('default_context_name')
unless default_context_name.blank?
default_context = Context.find_or_create_by_name(default_context_name)
p['default_context_id'] = default_context.id
end
end
def summary(project)
project_description = ''
project_description += sanitize(markdown( project.description )) unless project.description.blank?
project_description += "<p>#{count_undone_todos_phrase(p)}. "
project_description += "Project is #{project.state}."
project_description += "</p>"
project_description
end
end end

View file

@ -1,6 +1,8 @@
<div id="display_box"> <div id="display_box">
<%= render :partial => "contexts/context", :locals => { :context => @context, :collapsible => false } %> <%= render :partial => "contexts/context", :locals => { :context => @context, :collapsible => false } %>
<%= render :partial => "todos/completed", :locals => { :done => @done, :suppress_context => true, :collapsible => false, :append_descriptor => "in this context (last #{prefs.show_number_completed})" } %> <% unless @max_completed==0 -%>
<%= render :partial => "todos/completed", :locals => { :done => @done, :suppress_context => true, :collapsible => false, :append_descriptor => "in this context (last #{prefs.show_number_completed})" } %>
<% end -%>
</div><!-- [end:display_box] --> </div><!-- [end:display_box] -->

View file

@ -15,7 +15,7 @@
<li><strong>admin email:</strong> email address for the admin user of Tracks (displayed on the signup page for users to contact to obtain an account)</li> <li><strong>admin email:</strong> email address for the admin user of Tracks (displayed on the signup page for users to contact to obtain an account)</li>
<% end %> <% end %>
<li><strong>staleness starts:</strong> the number of days before items with no due date get marked as stale (with a yellow highlight)</li> <li><strong>staleness starts:</strong> the number of days before items with no due date get marked as stale (with a yellow highlight)</li>
<li><strong>show number completed:</strong> number of completed actions to show on the home page. If you set this to zero, the completed actions box will not be shown on the home page or on the individual context or project pages. You can still see all your completed items by clicking the 'Done' link in the navigation bar at the top of each page.</li> <li><strong>show number completed:</strong> number of completed actions to show on the page. If you set this to zero, the completed actions box will not be shown on the home page or on the individual context or project pages. You can still see all your completed items by clicking the 'Done' link in the navigation bar at the top of each page.</li>
<li><strong>refresh:</strong> automatic refresh interval for each of the pages (in minutes)</li> <li><strong>refresh:</strong> automatic refresh interval for each of the pages (in minutes)</li>
<li><strong>verbose action descriptor:</strong> when true, show project/context name in action listing; when false show [P]/[C] with tool tips</li> <li><strong>verbose action descriptor:</strong> when true, show project/context name in action listing; when false show [P]/[C] with tool tips</li>
<li><strong>mobile todos per page:</strong> the maximum number of actions to show on a single page in the mobile view</li> <li><strong>mobile todos per page:</strong> the maximum number of actions to show on a single page in the mobile view</li>

View file

@ -9,7 +9,7 @@
<li>Title date format: <span class="highlight"><%= prefs.title_date_format %></span> Your current title date: <%= user_time.strftime(prefs.title_date_format) %></li> <li>Title date format: <span class="highlight"><%= prefs.title_date_format %></span> Your current title date: <%= user_time.strftime(prefs.title_date_format) %></li>
<li>Time zone: <span class="highlight"><%= prefs.tz %></span> Your current time: <%= user_time.strftime('%I:%M %p') %></li> <li>Time zone: <span class="highlight"><%= prefs.tz %></span> Your current time: <%= user_time.strftime('%I:%M %p') %></li>
<li>Week starts on: <span class="highlight"><%= Preference.day_number_to_name_map[prefs.week_starts] %></span></li> <li>Week starts on: <span class="highlight"><%= Preference.day_number_to_name_map[prefs.week_starts] %></span></li>
<li>Show the last <span class="highlight"><%= prefs.show_number_completed %></span> completed items on the home page</li> <li>Show the last <span class="highlight"><%= prefs.show_number_completed %></span> completed items</li>
<li>Show completed projects in sidebar: <span class="highlight"><%= prefs.show_completed_projects_in_sidebar %></span></li> <li>Show completed projects in sidebar: <span class="highlight"><%= prefs.show_completed_projects_in_sidebar %></span></li>
<li>Show hidden projects in sidebar: <span class="highlight"><%= prefs.show_hidden_projects_in_sidebar %></span></li> <li>Show hidden projects in sidebar: <span class="highlight"><%= prefs.show_hidden_projects_in_sidebar %></span></li>
<li>Show hidden contexts in sidebar: <span class="highlight"><%= prefs.show_hidden_contexts_in_sidebar %></span></li> <li>Show hidden contexts in sidebar: <span class="highlight"><%= prefs.show_hidden_contexts_in_sidebar %></span></li>

View file

@ -5,7 +5,9 @@
<%= render :partial => "projects/project", :locals => { :project => @project, :collapsible => false } %> <%= render :partial => "projects/project", :locals => { :project => @project, :collapsible => false } %>
<%= render :partial => "todos/deferred", :locals => { :deferred => @deferred, :collapsible => false, :append_descriptor => "in this project" } %> <%= render :partial => "todos/deferred", :locals => { :deferred => @deferred, :collapsible => false, :append_descriptor => "in this project" } %>
<%= render :partial => "todos/completed", :locals => { :done => @done, :collapsible => false, :suppress_project => true, :append_descriptor => "in this project" } %> <% unless @max_completed==0 -%>
<%= render :partial => "todos/completed", :locals => { :done => @done, :collapsible => false, :suppress_project => true, :append_descriptor => "in this project" } %>
<% end -%>
<div class="container"> <div class="container">
<div id="notes"> <div id="notes">