mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-14 08:26:16 +01:00
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:
parent
708ce260ef
commit
327b2e11eb
6 changed files with 128 additions and 116 deletions
|
|
@ -36,11 +36,12 @@ 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
|
||||||
#
|
#
|
||||||
def create
|
def create
|
||||||
if params[:format] == 'application/xml' && params['exception']
|
if params[:format] == 'application/xml' && params['exception']
|
||||||
render_failure "Expected post format is valid xml like so: <request><context><name>context name</name></context></request>.", 400
|
render_failure "Expected post format is valid xml like so: <request><context><name>context name</name></context></request>.", 400
|
||||||
|
|
@ -66,12 +67,12 @@ 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
|
||||||
|
|
||||||
# Edit the details of the context
|
# Edit the details of the context
|
||||||
#
|
#
|
||||||
def update
|
def update
|
||||||
params['context'] ||= {}
|
params['context'] ||= {}
|
||||||
success_text = if params['field'] == 'name' && params['value']
|
success_text = if params['field'] == 'name' && params['value']
|
||||||
|
|
@ -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|
|
||||||
|
|
@ -103,7 +104,7 @@ class ContextsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# Methods for changing the sort order of the contexts in the list
|
# Methods for changing the sort order of the contexts in the list
|
||||||
#
|
#
|
||||||
def order
|
def order
|
||||||
params["list-contexts"].each_with_index do |id, position|
|
params["list-contexts"].each_with_index do |id, position|
|
||||||
current_user.contexts.update(id, :position => position + 1)
|
current_user.contexts.update(id, :position => position + 1)
|
||||||
|
|
@ -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
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def render_contexts_rss_feed
|
def render_contexts_rss_feed
|
||||||
lambda do
|
lambda do
|
||||||
render_rss_feed_for @contexts, :feed => feed_options,
|
render_rss_feed_for @contexts, :feed => feed_options,
|
||||||
:item => { :description => lambda { |c| c.summary(count_undone_todos_phrase(c)) } }
|
:item => { :description => lambda { |c| c.summary(count_undone_todos_phrase(c)) } }
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def render_contexts_atom_feed
|
def render_contexts_atom_feed
|
||||||
lambda do
|
lambda do
|
||||||
render_atom_feed_for @contexts, :feed => feed_options,
|
render_atom_feed_for @contexts, :feed => feed_options,
|
||||||
:item => { :description => lambda { |c| c.summary(count_undone_todos_phrase(c)) },
|
:item => { :description => lambda { |c| c.summary(count_undone_todos_phrase(c)) },
|
||||||
:author => lambda { |c| nil } }
|
:author => lambda { |c| nil } }
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def feed_options
|
def feed_options
|
||||||
Context.feed_options(current_user)
|
Context.feed_options(current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_context_from_params
|
def set_context_from_params
|
||||||
@context = current_user.contexts.find_by_params(params)
|
@context = current_user.contexts.find_by_params(params)
|
||||||
rescue
|
rescue
|
||||||
@context = nil
|
@context = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def init
|
def init
|
||||||
@source_view = params['_source_view'] || 'context'
|
@source_view = params['_source_view'] || 'context'
|
||||||
init_data_for_sidebar
|
init_data_for_sidebar
|
||||||
end
|
end
|
||||||
|
|
||||||
def init_todos
|
def init_todos
|
||||||
set_context_from_params
|
set_context_from_params
|
||||||
unless @context.nil?
|
unless @context.nil?
|
||||||
@context.todos.with_scope :find => { :include => [:project, :tags] } do
|
@context.todos.with_scope :find => { :include => [:project, :tags] } do
|
||||||
@done = @context.done_todos
|
@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
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -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,11 +45,12 @@ 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
|
||||||
#
|
#
|
||||||
def create
|
def create
|
||||||
if params[:format] == 'application/xml' && params['exception']
|
if params[:format] == 'application/xml' && params['exception']
|
||||||
render_failure "Expected post format is valid xml like so: <request><project><name>project name</name></project></request>."
|
render_failure "Expected post format is valid xml like so: <request><project><name>project name</name></project></request>."
|
||||||
|
|
@ -72,13 +76,13 @@ 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
|
||||||
|
|
||||||
# Edit the details of the project
|
# Edit the details of the project
|
||||||
#
|
#
|
||||||
def update
|
def update
|
||||||
params['project'] ||= {}
|
params['project'] ||= {}
|
||||||
if params['project']['state']
|
if params['project']['state']
|
||||||
|
|
@ -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
|
end
|
||||||
|
|
||||||
def render_text_feed
|
def render_text_feed
|
||||||
lambda do
|
lambda do
|
||||||
init_project_hidden_todo_counts(['project'])
|
init_project_hidden_todo_counts(['project'])
|
||||||
render :action => 'index_text', :layout => false, :content_type => Mime::TEXT
|
render :action => 'index_text', :layout => false, :content_type => Mime::TEXT
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def set_project_from_params
|
def set_project_from_params
|
||||||
@project = current_user.projects.find_by_params(params)
|
@project = current_user.projects.find_by_params(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_source_view
|
def set_source_view
|
||||||
@source_view = params['_source_view'] || 'project'
|
@source_view = params['_source_view'] || 'project'
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_context_filter
|
def default_context_filter
|
||||||
p = params['project']
|
p = params['project']
|
||||||
p = params['request']['project'] if p.nil? && params['request']
|
p = params['request']['project'] if p.nil? && params['request']
|
||||||
p = {} if p.nil?
|
p = {} if p.nil?
|
||||||
default_context_name = p['default_context_name']
|
default_context_name = p['default_context_name']
|
||||||
p.delete('default_context_name')
|
p.delete('default_context_name')
|
||||||
|
|
||||||
unless default_context_name.blank?
|
unless default_context_name.blank?
|
||||||
default_context = Context.find_or_create_by_name(default_context_name)
|
default_context = Context.find_or_create_by_name(default_context_name)
|
||||||
p['default_context_id'] = default_context.id
|
p['default_context_id'] = default_context.id
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def summary(project)
|
def summary(project)
|
||||||
project_description = ''
|
project_description = ''
|
||||||
project_description += sanitize(markdown( project.description )) unless project.description.blank?
|
project_description += sanitize(markdown( project.description )) unless project.description.blank?
|
||||||
project_description += "<p>#{count_undone_todos_phrase(p)}. "
|
project_description += "<p>#{count_undone_todos_phrase(p)}. "
|
||||||
project_description += "Project is #{project.state}."
|
project_description += "Project is #{project.state}."
|
||||||
project_description += "</p>"
|
project_description += "</p>"
|
||||||
project_description
|
project_description
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -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] -->
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue