mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-16 01:06:32 +01:00
Implemented a feature that give a project and optional default context. When set,
this context will be pre-populated when creating an action from the project's page. When creating an action from the home page, the context will be auto-selected when the project is selected if the context field has not yet been entered. This implementation is a combination of the great patch submitted by James Kebinger (thanks James!) and some of my modifications and additions. Don't forget to rake db:migrate. Fixes #162, originally suggested by Rolf one year ago! Also in this commit: * Tweaked selenium tags test * Tweaked formatting of next/previous project HTML * Implemented Null Object pattern for context to support a Project having no default context * Removed tickler.rhtml, no longer in use * applying z-index values to project sortable list items (otherwise context autocomplete was appearing below next list item) * Swapped order of project and context in new action form (setting default context makes more sense this way) * Removed CSS width of for form elements, so form could be used in content area without being too narrow git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@480 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
11ed78abe2
commit
38b2e336a8
21 changed files with 189 additions and 75 deletions
|
|
@ -111,6 +111,10 @@ class ApplicationController < ActionController::Base
|
|||
def markdown(text)
|
||||
RedCloth.new(text).to_html
|
||||
end
|
||||
|
||||
def build_default_project_context_name_map(projects)
|
||||
Hash[*projects.reject{ |p| p.default_context.nil? }.map{ |p| [p.name, p.default_context.name] }.flatten].to_json
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ class ContextsController < ApplicationController
|
|||
# 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)
|
||||
@count = @not_done_todos.size
|
||||
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ class ProjectsController < ApplicationController
|
|||
helper :application, :todos, :notes
|
||||
before_filter :init, :except => [:create, :destroy, :order]
|
||||
before_filter :check_user_set_project, :only => [:update, :destroy, :show]
|
||||
before_filter :default_context_filter, :only => [:create,:update]
|
||||
skip_before_filter :login_required, :only => [:index]
|
||||
prepend_before_filter :login_or_feed_token_required, :only => [:index]
|
||||
session :off, :only => :index, :if => Proc.new { |req| ['rss','atom','txt'].include?(req.parameters[:format]) }
|
||||
|
|
@ -28,6 +29,7 @@ class ProjectsController < ApplicationController
|
|||
@count = @not_done.size
|
||||
@next_project = @user.projects.next_from(@project)
|
||||
@previous_project = @user.projects.previous_from(@project)
|
||||
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
|
||||
end
|
||||
|
||||
# Example XML usage: curl -H 'Accept: application/xml' -H 'Content-Type: application/xml'
|
||||
|
|
@ -50,6 +52,7 @@ class ProjectsController < ApplicationController
|
|||
@saved = @project.save
|
||||
@project_not_done_counts = { @project.id => 0 }
|
||||
@active_projects_count = @user.projects.count(:conditions => "state = 'active'")
|
||||
@contexts = @user.contexts
|
||||
respond_to do |wants|
|
||||
wants.js
|
||||
wants.xml do
|
||||
|
|
@ -93,6 +96,8 @@ class ProjectsController < ApplicationController
|
|||
render
|
||||
elsif boolean_param('update_status')
|
||||
render :action => 'update_status'
|
||||
elsif boolean_param('update_default_context')
|
||||
render :action => 'update_default_context'
|
||||
else
|
||||
render :text => success_text || 'Success'
|
||||
end
|
||||
|
|
@ -181,6 +186,19 @@ class ProjectsController < ApplicationController
|
|||
@done = @user.todos.find_in_state(:all, :completed, :order => "completed_at DESC")
|
||||
init_data_for_sidebar
|
||||
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 = ''
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ class TodosController < ApplicationController
|
|||
@page_title = "TRACKS::Tickler"
|
||||
@tickles = @user.deferred_todos
|
||||
@count = @tickles.size
|
||||
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
|
||||
end
|
||||
|
||||
# Check for any due tickler items, activate them
|
||||
|
|
@ -262,6 +263,7 @@ class TodosController < ApplicationController
|
|||
@done = @user.completed_todos.find(:all, :limit => max_completed, :include => [ :context, :project, :tags ]) unless max_completed == 0
|
||||
# Set count badge to number of items with this tag
|
||||
@not_done_todos.empty? ? @count = 0 : @count = @not_done_todos.size
|
||||
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -421,7 +423,9 @@ class TodosController < ApplicationController
|
|||
|
||||
# Set count badge to number of not-done, not hidden context items
|
||||
@count = @todos.reject { |x| !x.active? || x.context.hide? }.size
|
||||
|
||||
|
||||
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
|
||||
|
||||
render
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue