diff --git a/tracks/app/controllers/contexts_controller.rb b/tracks/app/controllers/contexts_controller.rb index 1bd6889e..86855c78 100644 --- a/tracks/app/controllers/contexts_controller.rb +++ b/tracks/app/controllers/contexts_controller.rb @@ -36,11 +36,12 @@ class ContextsController < ApplicationController 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 # -d 'new context_name' # http://our.tracks.host/contexts - # + # def create if params[:format] == 'application/xml' && params['exception'] render_failure "Expected post format is valid xml like so: context name.", 400 @@ -66,12 +67,12 @@ class ContextsController < ApplicationController else head :created, :location => context_url(@context) end - end + end end end # Edit the details of the context - # + # def update params['context'] ||= {} success_text = if params['field'] == 'name' && params['value'] @@ -91,9 +92,9 @@ class ContextsController < ApplicationController end end - # Fairly self-explanatory; deletes the context - # If the context contains actions, you'll get a warning dialogue. - # If you choose to go ahead, any actions in the context will also be deleted. + # Fairly self-explanatory; deletes the context If the context contains + # actions, you'll get a warning dialogue. If you choose to go ahead, any + # actions in the context will also be deleted. def destroy @context.destroy respond_to do |format| @@ -103,7 +104,7 @@ class ContextsController < ApplicationController end # Methods for changing the sort order of the contexts in the list - # + # def order params["list-contexts"].each_with_index do |id, position| current_user.contexts.update(id, :position => position + 1) @@ -113,59 +114,62 @@ class ContextsController < ApplicationController protected - def render_contexts_html - lambda do - @page_title = "TRACKS::List Contexts" - @no_contexts = @contexts.empty? - @count = @contexts.size - render - end + def render_contexts_html + lambda do + @page_title = "TRACKS::List Contexts" + @no_contexts = @contexts.empty? + @count = @contexts.size + 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 + 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 + 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 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 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 + @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 + def init_todos + set_context_from_params + unless @context.nil? + @context.todos.with_scope :find => { :include => [:project, :tags] } do + @done = @context.done_todos end + + @max_completed = current_user.prefs.show_number_completed + + # @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 diff --git a/tracks/app/controllers/projects_controller.rb b/tracks/app/controllers/projects_controller.rb index 110857f4..80843000 100644 --- a/tracks/app/controllers/projects_controller.rb +++ b/tracks/app/controllers/projects_controller.rb @@ -32,6 +32,9 @@ class ProjectsController < ApplicationController @deferred = @project.deferred_todos.sort_by { |todo| todo.show_from } @done = @project.done_todos end + + @max_completed = current_user.prefs.show_number_completed + @count = @not_done.size @next_project = current_user.projects.next_from(@project) @previous_project = current_user.projects.previous_from(@project) @@ -42,11 +45,12 @@ class ProjectsController < ApplicationController 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 # -d 'new project_name' # http://our.tracks.host/projects - # + # def create if params[:format] == 'application/xml' && params['exception'] render_failure "Expected post format is valid xml like so: project name." @@ -72,13 +76,13 @@ class ProjectsController < ApplicationController render_failure @project.errors.full_messages.join(', ') else head :created, :location => project_url(@project) - end + end end end end # Edit the details of the project - # + # def update params['project'] ||= {} if params['project']['state'] @@ -155,76 +159,76 @@ class ProjectsController < ApplicationController protected - def render_projects_html - lambda do - init_project_hidden_todo_counts(['project']) - @page_title = "TRACKS::List Projects" - @count = current_user.projects.size - @active_projects = @projects.select{ |p| p.active? } - @hidden_projects = @projects.select{ |p| p.hidden? } - @completed_projects = @projects.select{ |p| p.completed? } - @no_projects = @projects.empty? - @projects.cache_note_counts - @new_project = current_user.projects.build - render - end + def render_projects_html + lambda do + init_project_hidden_todo_counts(['project']) + @page_title = "TRACKS::List Projects" + @count = current_user.projects.size + @active_projects = @projects.select{ |p| p.active? } + @hidden_projects = @projects.select{ |p| p.hidden? } + @completed_projects = @projects.select{ |p| p.completed? } + @no_projects = @projects.empty? + @projects.cache_note_counts + @new_project = current_user.projects.build + render end + end - def render_rss_feed - lambda do - render_rss_feed_for @projects, :feed => feed_options, - :item => { :title => :name, :description => lambda { |p| summary(p) } } - end + def render_rss_feed + lambda do + render_rss_feed_for @projects, :feed => feed_options, + :item => { :title => :name, :description => lambda { |p| summary(p) } } end + end - def render_atom_feed - lambda do - render_atom_feed_for @projects, :feed => feed_options, - :item => { :description => lambda { |p| summary(p) }, - :title => :name, - :author => lambda { |p| nil } } - end + def render_atom_feed + lambda do + render_atom_feed_for @projects, :feed => feed_options, + :item => { :description => lambda { |p| summary(p) }, + :title => :name, + :author => lambda { |p| nil } } end + end - def feed_options - Project.feed_options(current_user) - end + def feed_options + 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 + def render_text_feed + lambda do + init_project_hidden_todo_counts(['project']) + render :action => 'index_text', :layout => false, :content_type => Mime::TEXT end + end - def set_project_from_params - @project = current_user.projects.find_by_params(params) - end + def set_project_from_params + @project = current_user.projects.find_by_params(params) + end - def set_source_view - @source_view = params['_source_view'] || 'project' - 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') + 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 + 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 += "

#{count_undone_todos_phrase(p)}. " - project_description += "Project is #{project.state}." - project_description += "

" - project_description - end + def summary(project) + project_description = '' + project_description += sanitize(markdown( project.description )) unless project.description.blank? + project_description += "

#{count_undone_todos_phrase(p)}. " + project_description += "Project is #{project.state}." + project_description += "

" + project_description + end end diff --git a/tracks/app/views/contexts/show.rhtml b/tracks/app/views/contexts/show.rhtml index a269d379..eded894d 100644 --- a/tracks/app/views/contexts/show.rhtml +++ b/tracks/app/views/contexts/show.rhtml @@ -1,6 +1,8 @@
<%= 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 -%>
diff --git a/tracks/app/views/preferences/edit.rhtml b/tracks/app/views/preferences/edit.rhtml index ee9ab1e4..86bbac6e 100644 --- a/tracks/app/views/preferences/edit.rhtml +++ b/tracks/app/views/preferences/edit.rhtml @@ -15,7 +15,7 @@
  • admin email: email address for the admin user of Tracks (displayed on the signup page for users to contact to obtain an account)
  • <% end %>
  • staleness starts: the number of days before items with no due date get marked as stale (with a yellow highlight)
  • -
  • show number completed: 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.
  • +
  • show number completed: 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.
  • refresh: automatic refresh interval for each of the pages (in minutes)
  • verbose action descriptor: when true, show project/context name in action listing; when false show [P]/[C] with tool tips
  • mobile todos per page: the maximum number of actions to show on a single page in the mobile view
  • diff --git a/tracks/app/views/preferences/index.rhtml b/tracks/app/views/preferences/index.rhtml index 49026ca8..c0c72586 100644 --- a/tracks/app/views/preferences/index.rhtml +++ b/tracks/app/views/preferences/index.rhtml @@ -9,7 +9,7 @@
  • Title date format: <%= prefs.title_date_format %> Your current title date: <%= user_time.strftime(prefs.title_date_format) %>
  • Time zone: <%= prefs.tz %> Your current time: <%= user_time.strftime('%I:%M %p') %>
  • Week starts on: <%= Preference.day_number_to_name_map[prefs.week_starts] %>
  • -
  • Show the last <%= prefs.show_number_completed %> completed items on the home page
  • +
  • Show the last <%= prefs.show_number_completed %> completed items
  • Show completed projects in sidebar: <%= prefs.show_completed_projects_in_sidebar %>
  • Show hidden projects in sidebar: <%= prefs.show_hidden_projects_in_sidebar %>
  • Show hidden contexts in sidebar: <%= prefs.show_hidden_contexts_in_sidebar %>
  • diff --git a/tracks/app/views/projects/show.rhtml b/tracks/app/views/projects/show.rhtml index cc9501cf..e23dc109 100644 --- a/tracks/app/views/projects/show.rhtml +++ b/tracks/app/views/projects/show.rhtml @@ -5,7 +5,9 @@ <%= 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/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 -%>