Merge branch 'jquery' of epall/tracks

This concludes the transition from Prototype to
jQuery throughout Tracks. Closes #944.
This commit is contained in:
Eric Allen 2009-11-04 22:08:13 -05:00
commit 45d9ab60bf
185 changed files with 3856 additions and 14123 deletions

View file

@ -27,6 +27,7 @@ class ApplicationController < ActionController::Base
helper_method :current_user, :prefs
layout proc{ |controller| controller.mobile? ? "mobile" : "standard" }
exempt_from_layout /\.js\.erb$/
before_filter :set_session_expiration
before_filter :set_time_zone
@ -129,14 +130,6 @@ class ApplicationController < ActionController::Base
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
def build_default_project_tags_map(projects)
Hash[*projects.reject{ |p| p.default_tags.nil? }.map{ |p| [p.name, p.default_tags] }.flatten].to_json
end
# Here's the concept behind this "mobile content negotiation" hack: In
# addition to the main, AJAXy Web UI, Tracks has a lightweight low-feature
# 'mobile' version designed to be suitablef or use from a phone or PDA. It

View file

@ -92,7 +92,7 @@ class ContextsController < ApplicationController
if @context.save
if boolean_param('wants_render')
@context_state_changed = (@orgininal_context_hidden != @context.hidden?)
@context_state_changed = (@original_context_hidden != @context.hidden?)
@new_state = (@context.hidden? ? "hidden" : "active") if @context_state_changed
respond_to do |format|
format.js
@ -110,6 +110,13 @@ class ContextsController < ApplicationController
end
end
def edit
@context = Context.find(params[:id])
respond_to do |format|
format.js
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.
@ -124,11 +131,12 @@ class ContextsController < ApplicationController
# Methods for changing the sort order of the contexts in the list
#
def order
list = params["list-contexts-hidden"] || params["list-contexts-active"]
list.each_with_index do |id, position|
current_user.contexts.update(id, :position => position + 1)
end
context_ids = params["container_context"]
@projects = current_user.contexts.update_positions( context_ids )
render :nothing => true
rescue
notify :error, $!
redirect_to :action => 'index'
end
protected
@ -218,8 +226,6 @@ class ContextsController < ApplicationController
@projects = current_user.projects
@count = @not_done_todos.size
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
@default_project_tags_map = build_default_project_tags_map(@projects).to_json
end
end

View file

@ -53,8 +53,7 @@ class ProjectsController < ApplicationController
@down_count = @count + @deferred.size
@next_project = current_user.projects.next_from(@project)
@previous_project = current_user.projects.previous_from(@project)
@default_project_context_name_map = build_default_project_context_name_map(current_user.projects).to_json
@default_project_tags_map = build_default_project_tags_map(current_user.projects).to_json
@default_tags = @project.default_tags
respond_to do |format|
format.html
format.m &render_project_mobile
@ -127,6 +126,7 @@ class ProjectsController < ApplicationController
@active_projects_count = current_user.projects.active.count
@hidden_projects_count = current_user.projects.hidden.count
@completed_projects_count = current_user.projects.completed.count
init_data_for_sidebar
render :template => 'projects/update.js.rjs'
return
elsif boolean_param('update_status')
@ -173,7 +173,7 @@ class ProjectsController < ApplicationController
end
def order
project_ids = params["list-active-projects"] || params["list-hidden-projects"] || params["list-completed-projects"]
project_ids = params["container_project"]
@projects = current_user.projects.update_positions( project_ids )
render :nothing => true
rescue
@ -186,6 +186,7 @@ class ProjectsController < ApplicationController
@projects = current_user.projects.alphabetize(:state => @state) if @state
@contexts = current_user.contexts
init_not_done_counts(['project'])
init_project_hidden_todo_counts(['project']) if @state == 'hidden'
end
def actionize
@ -193,6 +194,7 @@ class ProjectsController < ApplicationController
@projects = current_user.projects.actionize(current_user.id, :state => @state) if @state
@contexts = current_user.contexts
init_not_done_counts(['project'])
init_project_hidden_todo_counts(['project']) if @state == 'hidden'
end
protected

View file

@ -251,8 +251,6 @@ class RecurringTodosController < ApplicationController
@xth_day = [['first',1],['second',2],['third',3],['fourth',4],['last',5]]
@projects = current_user.projects.find(:all, :include => [:default_context])
@contexts = current_user.contexts.find(:all)
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
@default_project_tags_map = build_default_project_tags_map(@projects).to_json
end
def get_recurring_todo_from_param
@ -265,4 +263,4 @@ class RecurringTodosController < ApplicationController
recurring_todos.each { |rt| rt.toggle_completion! if rt.todos.not_completed.count == 0}
end
end
end

View file

@ -95,6 +95,7 @@ class TodosController < ApplicationController
@projects = current_user.projects.find(:all) if @new_project_created
@initial_context_name = params['default_context_name']
@initial_project_name = params['default_project_name']
@default_tags = @todo.project.default_tags unless @todo.project.nil?
render :action => 'create'
end
format.xml do
@ -358,8 +359,6 @@ class TodosController < ApplicationController
@not_done_todos = current_user.deferred_todos
@count = @not_done_todos.size
@down_count = @count
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
@default_project_tags_map = build_default_project_tags_map(@projects).to_json
respond_to do |format|
format.html
@ -434,10 +433,7 @@ class TodosController < ApplicationController
@down_count = @count
respond_to do |format|
format.html {
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
@default_project_tags_map = build_default_project_tags_map(@projects).to_json
}
format.html
format.m {
cookies[:mobile_url]= {:value => request.request_uri, :secure => SITE_CONFIG['secure_cookies']}
render :action => "mobile_tag"
@ -471,8 +467,6 @@ class TodosController < ApplicationController
@page_title = "TRACKS::Calendar"
@projects = current_user.projects.find(:all)
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
@default_project_tags_map = build_default_project_tags_map(@projects).to_json
due_today_date = Time.zone.now
due_this_week_date = Time.zone.now.end_of_week
@ -757,9 +751,6 @@ class TodosController < ApplicationController
end
end
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
@default_project_tags_map = build_default_project_tags_map(@projects).to_json
render
end
end