mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-26 09:04:07 +01:00
make adding of todos from sidebar work in context and project grouping
This commit is contained in:
parent
783d4dd774
commit
9c0445fcb7
17 changed files with 528 additions and 389 deletions
|
|
@ -3,7 +3,7 @@ class TodosController < ApplicationController
|
||||||
skip_before_filter :login_required, :only => [:index, :calendar, :tag]
|
skip_before_filter :login_required, :only => [:index, :calendar, :tag]
|
||||||
prepend_before_filter :login_or_feed_token_required, :only => [:index, :calendar, :tag]
|
prepend_before_filter :login_or_feed_token_required, :only => [:index, :calendar, :tag]
|
||||||
append_before_filter :find_and_activate_ready, :only => [:index, :list_deferred]
|
append_before_filter :find_and_activate_ready, :only => [:index, :list_deferred]
|
||||||
append_before_filter :set_group_view_by, :only => [:index, :tag]
|
append_before_filter :set_group_view_by, :only => [:index, :tag, :create, :list_deferred, :destroy, :defer, :update]
|
||||||
|
|
||||||
protect_from_forgery :except => :check_deferred
|
protect_from_forgery :except => :check_deferred
|
||||||
|
|
||||||
|
|
@ -93,6 +93,7 @@ class TodosController < ApplicationController
|
||||||
if p.project_specified_by_name?
|
if p.project_specified_by_name?
|
||||||
project = current_user.projects.where(:name => p.project_name).first_or_create
|
project = current_user.projects.where(:name => p.project_name).first_or_create
|
||||||
@new_project_created = project.new_record_before_save?
|
@new_project_created = project.new_record_before_save?
|
||||||
|
@not_done_todos = [@todo] if @new_project_created
|
||||||
@todo.project_id = project.id
|
@todo.project_id = project.id
|
||||||
elsif !(p.project_id.nil? || p.project_id.blank?)
|
elsif !(p.project_id.nil? || p.project_id.blank?)
|
||||||
project = current_user.projects.where(:id => p.project_id).first
|
project = current_user.projects.where(:id => p.project_id).first
|
||||||
|
|
@ -197,12 +198,11 @@ class TodosController < ApplicationController
|
||||||
|
|
||||||
# first build all todos and check if they would validate on save
|
# first build all todos and check if they would validate on save
|
||||||
params[:todo][:multiple_todos].split("\n").map do |line|
|
params[:todo][:multiple_todos].split("\n").map do |line|
|
||||||
unless line.blank?
|
unless line.blank? #ignore blank lines
|
||||||
@todo = current_user.todos.build(
|
@todo = current_user.todos.build(:description => line)
|
||||||
:description => line)
|
|
||||||
@todo.project_id = @project_id
|
@todo.project_id = @project_id
|
||||||
@todo.context_id = @context_id
|
@todo.context_id = @context_id
|
||||||
validates = false if @todo.invalid?
|
validates &&= @todo.valid?
|
||||||
|
|
||||||
@todos_init << @todo
|
@todos_init << @todo
|
||||||
end
|
end
|
||||||
|
|
@ -358,7 +358,7 @@ class TodosController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js do
|
format.js do
|
||||||
if @saved
|
if @saved
|
||||||
determine_remaining_in_context_count(@todo.context_id)
|
determine_remaining_in_container_count(@todo)
|
||||||
determine_down_count
|
determine_down_count
|
||||||
determine_completed_count
|
determine_completed_count
|
||||||
determine_deferred_tag_count(params['_tag_name']) if source_view_is(:tag)
|
determine_deferred_tag_count(params['_tag_name']) if source_view_is(:tag)
|
||||||
|
|
@ -441,11 +441,12 @@ class TodosController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@todo = current_user.todos.find(params['id'])
|
|
||||||
@source_view = params['_source_view'] || 'todo'
|
@source_view = params['_source_view'] || 'todo'
|
||||||
# init_data_for_sidebar unless mobile?
|
|
||||||
|
|
||||||
cache_attributes_from_before_update
|
@todo = current_user.todos.find(params['id'])
|
||||||
|
@original_item = current_user.todos.build(@todo.attributes) # create a (unsaved) copy of the original todo
|
||||||
|
|
||||||
|
cache_attributes_from_before_update # TODO: remove in favor of @orininal_item
|
||||||
|
|
||||||
update_tags
|
update_tags
|
||||||
update_project
|
update_project
|
||||||
|
|
@ -466,7 +467,7 @@ class TodosController < ApplicationController
|
||||||
update_todo_state_if_project_changed
|
update_todo_state_if_project_changed
|
||||||
|
|
||||||
determine_changes_by_this_update
|
determine_changes_by_this_update
|
||||||
determine_remaining_in_context_count(@context_changed ? @original_item_context_id : @todo.context_id)
|
determine_remaining_in_container_count(@context_changed || @project_changed ? @original_item : @todo)
|
||||||
determine_down_count
|
determine_down_count
|
||||||
determine_deferred_tag_count(params['_tag_name']) if source_view_is(:tag)
|
determine_deferred_tag_count(params['_tag_name']) if source_view_is(:tag)
|
||||||
|
|
||||||
|
|
@ -495,6 +496,7 @@ class TodosController < ApplicationController
|
||||||
@original_item_due = @todo.due
|
@original_item_due = @todo.due
|
||||||
@context_id = @todo.context_id
|
@context_id = @todo.context_id
|
||||||
@project_id = @todo.project_id
|
@project_id = @todo.project_id
|
||||||
|
@todo_was_destroyed = true
|
||||||
@todo_was_destroyed_from_deferred_state = @todo.deferred?
|
@todo_was_destroyed_from_deferred_state = @todo.deferred?
|
||||||
@todo_was_destroyed_from_pending_state = @todo.pending?
|
@todo_was_destroyed_from_pending_state = @todo.pending?
|
||||||
@todo_was_destroyed_from_deferred_or_pending_state = @todo_was_destroyed_from_deferred_state || @todo_was_destroyed_from_pending_state
|
@todo_was_destroyed_from_deferred_or_pending_state = @todo_was_destroyed_from_deferred_state || @todo_was_destroyed_from_pending_state
|
||||||
|
|
@ -540,8 +542,8 @@ class TodosController < ApplicationController
|
||||||
format.js do
|
format.js do
|
||||||
if @saved
|
if @saved
|
||||||
determine_down_count
|
determine_down_count
|
||||||
if source_view_is_one_of(:todo, :deferred, :project, :context)
|
if source_view_is_one_of(:todo, :deferred, :project, :context, :tag)
|
||||||
determine_remaining_in_context_count(@context_id)
|
determine_remaining_in_container_count(@todo)
|
||||||
elsif source_view_is :calendar
|
elsif source_view_is :calendar
|
||||||
@original_item_due_id = get_due_id_for_calendar(@original_item_due)
|
@original_item_due_id = get_due_id_for_calendar(@original_item_due)
|
||||||
@old_due_empty = is_old_due_empty(@original_item_due_id)
|
@old_due_empty = is_old_due_empty(@original_item_due_id)
|
||||||
|
|
@ -656,6 +658,7 @@ class TodosController < ApplicationController
|
||||||
blocked.
|
blocked.
|
||||||
reorder('todos.show_from ASC, todos.created_at DESC').
|
reorder('todos.show_from ASC, todos.created_at DESC').
|
||||||
includes(Todo::DEFAULT_INCLUDES)
|
includes(Todo::DEFAULT_INCLUDES)
|
||||||
|
@todos_without_project = @not_done_todos.select{|t| t.project.nil?}
|
||||||
|
|
||||||
# If you've set no_completed to zero, the completed items box isn't shown on
|
# If you've set no_completed to zero, the completed items box isn't shown on
|
||||||
# the tag page
|
# the tag page
|
||||||
|
|
@ -735,6 +738,8 @@ class TodosController < ApplicationController
|
||||||
numdays = params['days'].to_i
|
numdays = params['days'].to_i
|
||||||
|
|
||||||
@todo = current_user.todos.find(params[:id])
|
@todo = current_user.todos.find(params[:id])
|
||||||
|
@original_item = current_user.todos.build(@todo.attributes) # create a (unsaved) copy of the original todo
|
||||||
|
|
||||||
@original_item_context_id = @todo.context_id
|
@original_item_context_id = @todo.context_id
|
||||||
@todo_deferred_state_changed = true
|
@todo_deferred_state_changed = true
|
||||||
@new_context_created = false
|
@new_context_created = false
|
||||||
|
|
@ -748,7 +753,7 @@ class TodosController < ApplicationController
|
||||||
@status_message = t('todos.action_saved_to_tickler')
|
@status_message = t('todos.action_saved_to_tickler')
|
||||||
|
|
||||||
determine_down_count
|
determine_down_count
|
||||||
determine_remaining_in_context_count(@todo.context_id)
|
determine_remaining_in_container_count(@todo)
|
||||||
source_view do |page|
|
source_view do |page|
|
||||||
page.project {
|
page.project {
|
||||||
@remaining_undone_in_project = current_user.projects.find(@todo.project_id).todos.not_completed.count
|
@remaining_undone_in_project = current_user.projects.find(@todo.project_id).todos.not_completed.count
|
||||||
|
|
@ -886,7 +891,7 @@ class TodosController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_group_view_by
|
def set_group_view_by
|
||||||
@group_view_by = params['group_view_by'] || cookies['group_view_by'] || 'context'
|
@group_view_by = params['_group_view_by'] || cookies['group_view_by'] || 'context'
|
||||||
end
|
end
|
||||||
|
|
||||||
def do_mobile_todo_redirection
|
def do_mobile_todo_redirection
|
||||||
|
|
@ -1005,21 +1010,48 @@ class TodosController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def determine_remaining_in_context_count(context_id = @todo.context_id)
|
def find_todos_in_project_container(todo)
|
||||||
|
if todo.project.nil?
|
||||||
|
# container with todos without project
|
||||||
|
todos_in_container = current_user.todos.where(:project_id => nil).active.not_hidden
|
||||||
|
else
|
||||||
|
todos_in_container = current_user.projects.find(todo.project_id).todos.active.not_hidden
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_todos_in_container_and_target_container(todo, target_todo)
|
||||||
|
if @group_view_by == 'context'
|
||||||
|
todos_in_container = current_user.contexts.find(todo.context_id).todos.active.not_hidden
|
||||||
|
todos_in_target_container = current_user.contexts.find(@todo.context_id).todos.active.not_hidden
|
||||||
|
else
|
||||||
|
todos_in_container = find_todos_in_project_container(todo)
|
||||||
|
todos_in_target_container = find_todos_in_project_container(@todo)
|
||||||
|
end
|
||||||
|
return todos_in_container, todos_in_target_container
|
||||||
|
end
|
||||||
|
|
||||||
|
def determine_remaining_in_container_count(todo = @todo)
|
||||||
source_view do |from|
|
source_view do |from|
|
||||||
from.deferred {
|
from.deferred {
|
||||||
# force reload to todos to get correct count and not a cached one
|
# force reload to todos to get correct count and not a cached one
|
||||||
@remaining_in_context = current_user.contexts.find(context_id).todos.deferred_or_blocked.count
|
@remaining_in_context = current_user.contexts.find(todo.context_id).todos.deferred_or_blocked.count
|
||||||
@target_context_count = current_user.contexts.find(@todo.context_id).todos.deferred_or_blocked.count
|
@target_context_count = current_user.contexts.find(@todo.context_id).todos.deferred_or_blocked.count
|
||||||
}
|
}
|
||||||
|
from.todo {
|
||||||
|
todos_in_container, todos_in_target_container = find_todos_in_container_and_target_container(todo, @todo)
|
||||||
|
@remaining_in_context = todos_in_container.active.not_hidden.count
|
||||||
|
@target_context_count = todos_in_target_container.active.not_hidden.count
|
||||||
|
}
|
||||||
from.tag {
|
from.tag {
|
||||||
tag = Tag.where(:name => params['_tag_name']).first
|
tag = Tag.where(:name => params['_tag_name']).first
|
||||||
tag = Tag.new(:name => params['tag']) if tag.nil?
|
tag = Tag.new(:name => params['tag']) if tag.nil?
|
||||||
|
|
||||||
@remaining_deferred_or_pending_count = current_user.todos.with_tag(tag.id).deferred_or_blocked.count
|
todos_in_container, todos_in_target_container = find_todos_in_container_and_target_container(todo, @todo)
|
||||||
@remaining_in_context = current_user.contexts.find(context_id).todos.active.not_hidden.with_tag(tag.id).count
|
|
||||||
@target_context_count = current_user.contexts.find(@todo.context_id).todos.active.not_hidden.with_tag(tag.id).count
|
@remaining_in_context = todos_in_container.with_tag(tag.id).count
|
||||||
|
@target_context_count = todos_in_target_container.with_tag(tag.id).count
|
||||||
@remaining_hidden_count = current_user.todos.hidden.with_tag(tag.id).count
|
@remaining_hidden_count = current_user.todos.hidden.with_tag(tag.id).count
|
||||||
|
@remaining_deferred_or_pending_count = current_user.todos.with_tag(tag.id).deferred_or_blocked.count
|
||||||
}
|
}
|
||||||
from.project {
|
from.project {
|
||||||
project_id = @project_changed ? @original_item_project_id : @todo.project_id
|
project_id = @project_changed ? @original_item_project_id : @todo.project_id
|
||||||
|
|
@ -1037,7 +1069,7 @@ class TodosController < ApplicationController
|
||||||
@target_context_count = @new_due_id.blank? ? 0 : count_old_due_empty(@new_due_id)
|
@target_context_count = @new_due_id.blank? ? 0 : count_old_due_empty(@new_due_id)
|
||||||
}
|
}
|
||||||
from.context {
|
from.context {
|
||||||
context = current_user.contexts.find(context_id)
|
context = current_user.contexts.find(todo.context_id)
|
||||||
@remaining_deferred_or_pending_count = context.todos.deferred_or_blocked.count
|
@remaining_deferred_or_pending_count = context.todos.deferred_or_blocked.count
|
||||||
|
|
||||||
remaining_actions_in_context = context.todos(true).active
|
remaining_actions_in_context = context.todos(true).active
|
||||||
|
|
@ -1056,8 +1088,6 @@ class TodosController < ApplicationController
|
||||||
@remaining_in_context = DoneTodos.remaining_in_container(current_user, @original_completed_period)
|
@remaining_in_context = DoneTodos.remaining_in_container(current_user, @original_completed_period)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@remaining_in_context = current_user.contexts.find(context_id).todos(true).active.not_hidden.count if @remaining_in_context.nil?
|
|
||||||
@target_context_count = current_user.contexts.find(@todo.context_id).todos(true).active.not_hidden.count if !@target_context_count.nil?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def determine_completed_count
|
def determine_completed_count
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
module TodosHelper
|
module TodosHelper
|
||||||
|
|
||||||
|
# === helpers for rendering container
|
||||||
|
|
||||||
def empty_message_holder(container_name, show, title_param=nil)
|
def empty_message_holder(container_name, show, title_param=nil)
|
||||||
content_tag(:div, :id => "no_todos_in_view", :class => "container #{container_name}", :style => "display:" + (show ? "block" : "none") ) do
|
content_tag(:div, :id => "no_todos_in_view", :class => "container #{container_name}", :style => "display:" + (show ? "block" : "none") ) do
|
||||||
content_tag(:h2) { t("todos.no_actions.title", :param=>title_param) } +
|
content_tag(:h2) { t("todos.no_actions.title", :param=>title_param) } +
|
||||||
|
|
@ -126,6 +128,8 @@ module TodosHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# === helpers for rendering a todo
|
||||||
|
|
||||||
def remote_star_icon(todo=@todo)
|
def remote_star_icon(todo=@todo)
|
||||||
link_to( image_tag_for_star(todo),
|
link_to( image_tag_for_star(todo),
|
||||||
toggle_star_todo_path(todo),
|
toggle_star_todo_path(todo),
|
||||||
|
|
@ -212,6 +216,10 @@ module TodosHelper
|
||||||
:class => "recurring_icon", :title => recurrence_pattern_as_text(todo.recurring_todo))
|
:class => "recurring_icon", :title => recurrence_pattern_as_text(todo.recurring_todo))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def image_tag_for_star(todo)
|
||||||
|
image_tag("blank.png", :title =>t('todos.star_action'), :class => "todo_star"+(todo.starred? ? " starred":""), :id => "star_img_"+todo.id.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
def remote_toggle_checkbox(todo=@todo)
|
def remote_toggle_checkbox(todo=@todo)
|
||||||
check_box_tag("mark_complete_#{todo.id}", toggle_check_todo_path(todo), todo.completed?, :class => 'item-checkbox',
|
check_box_tag("mark_complete_#{todo.id}", toggle_check_todo_path(todo), todo.completed?, :class => 'item-checkbox',
|
||||||
:title => todo.pending? ? t('todos.blocked_by', :predecessors => todo.uncompleted_predecessors.map(&:description).join(', ')) : "", :readonly => todo.pending?)
|
:title => todo.pending? ? t('todos.blocked_by', :predecessors => todo.uncompleted_predecessors.map(&:description).join(', ')) : "", :readonly => todo.pending?)
|
||||||
|
|
@ -348,51 +356,11 @@ module TodosHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def should_show_new_item
|
def date_field_tag(name, id, value = nil, options = {})
|
||||||
source_view do |page|
|
text_field_tag name, value, {"size" => 12, "id" => id, "class" => "Date", "autocomplete" => "off"}.update(options.stringify_keys)
|
||||||
page.todo { return !@todo.hidden? }
|
|
||||||
page.deferred { return @todo.deferred? || @todo.pending? }
|
|
||||||
page.context {
|
|
||||||
return @todo.context_id==@default_context.id && ( (@todo.hidden? && @todo.context.hidden?) || (!@todo.hidden?) )
|
|
||||||
}
|
|
||||||
page.tag {
|
|
||||||
return ( (@todo.pending? && @todo.has_tag?(@tag_name)) ||
|
|
||||||
(@todo.has_tag?(@tag_name)) ||
|
|
||||||
(@todo.starred? && @tag_name == Todo::STARRED_TAG_NAME)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
page.project {
|
|
||||||
return (@todo.active? && @todo.project && @todo.project.id == @default_project.id) ||
|
|
||||||
(@todo.project.hidden? && @todo.project_hidden?) ||
|
|
||||||
( @todo.deferred? && (@todo.project.id == @default_project.id) ) ||
|
|
||||||
@todo.pending?
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def should_make_context_visible
|
# === helpers for default layout
|
||||||
return @todo.active? && (!@todo.hidden? && !source_view_is(:project) )
|
|
||||||
end
|
|
||||||
|
|
||||||
def should_add_new_context
|
|
||||||
return @new_context_created && !source_view_is(:project)
|
|
||||||
end
|
|
||||||
|
|
||||||
def parent_container_type
|
|
||||||
return 'tickler' if source_view_is :deferred
|
|
||||||
return 'project' if source_view_is :project
|
|
||||||
return 'stats' if source_view_is :stats
|
|
||||||
return 'tag' if source_view_is :tag
|
|
||||||
return 'context'
|
|
||||||
end
|
|
||||||
|
|
||||||
def todo_container_is_empty
|
|
||||||
default_container_empty = ( @down_count == 0 )
|
|
||||||
deferred_container_empty = ( @todo.deferred? && @remaining_deferred_count == 0)
|
|
||||||
return default_container_empty || deferred_container_empty
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_contexts_for_autocomplete
|
def default_contexts_for_autocomplete
|
||||||
projects = current_user.projects.uncompleted.includes(:default_context).where('NOT(default_context_id IS NULL)')
|
projects = current_user.projects.uncompleted.includes(:default_context).where('NOT(default_context_id IS NULL)')
|
||||||
|
|
@ -404,6 +372,13 @@ module TodosHelper
|
||||||
Hash[*projects.map{ |p| [escape_javascript(p.name), p.default_tags] }.flatten].to_json
|
Hash[*projects.map{ |p| [escape_javascript(p.name), p.default_tags] }.flatten].to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# === various helpers
|
||||||
|
|
||||||
|
def formatted_pagination(total)
|
||||||
|
s = will_paginate(@todos)
|
||||||
|
(s.gsub(/(<\/[^<]+>)/, '\1 ')).chomp(' ')
|
||||||
|
end
|
||||||
|
|
||||||
def format_ical_notes(notes)
|
def format_ical_notes(notes)
|
||||||
unless notes.nil? || notes.blank?
|
unless notes.nil? || notes.blank?
|
||||||
split_notes = notes.split(/\n/)
|
split_notes = notes.split(/\n/)
|
||||||
|
|
@ -412,145 +387,12 @@ module TodosHelper
|
||||||
joined_notes || ""
|
joined_notes || ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def formatted_pagination(total)
|
def parent_container_type
|
||||||
s = will_paginate(@todos)
|
return 'tickler' if source_view_is :deferred
|
||||||
(s.gsub(/(<\/[^<]+>)/, '\1 ')).chomp(' ')
|
return 'project' if source_view_is :project
|
||||||
end
|
return 'stats' if source_view_is :stats
|
||||||
|
return 'tag' if source_view_is :tag
|
||||||
def date_field_tag(name, id, value = nil, options = {})
|
return 'context'
|
||||||
text_field_tag name, value, {"size" => 12, "id" => id, "class" => "Date", "autocomplete" => "off"}.update(options.stringify_keys)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_needs_to_hide_context
|
|
||||||
return (@remaining_in_context == 0 && (@todo_hidden_state_changed && @todo.hidden?)) ||
|
|
||||||
(@remaining_in_context == 0 && @todo_was_deferred_from_active_state) ||
|
|
||||||
(@remaining_in_context == 0 && @tag_was_removed) ||
|
|
||||||
(@remaining_in_context == 0 && @todo.completed? && !(@original_item_was_deferred || @original_item_was_hidden)) if source_view_is(:tag)
|
|
||||||
|
|
||||||
return false if source_view_is_one_of(:project, :calendar, :done)
|
|
||||||
|
|
||||||
return (@remaining_in_context == 0) && !source_view_is(:context)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_needs_to_remove_todo_from_container
|
|
||||||
source_view do |page|
|
|
||||||
page.context { return @context_changed || @todo_deferred_state_changed || @todo_pending_state_changed || @todo_should_be_hidden }
|
|
||||||
page.project { return @todo_deferred_state_changed || @todo_pending_state_changed || @project_changed}
|
|
||||||
page.deferred { return @context_changed || !(@todo.deferred? || @todo.pending?) }
|
|
||||||
page.calendar { return @due_date_changed || !@todo.due }
|
|
||||||
page.stats { return @todo.completed? }
|
|
||||||
page.tag { return (@context_changed && !@todo.hidden?) || @tag_was_removed || @todo_hidden_state_changed || @todo_deferred_state_changed }
|
|
||||||
page.todo { return @context_changed || @todo.hidden? || @todo.deferred? || @todo.pending?}
|
|
||||||
page.search { return false }
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
def replace_with_updated_todo
|
|
||||||
source_view do |page|
|
|
||||||
page.context { return !update_needs_to_remove_todo_from_container }
|
|
||||||
page.project { return !update_needs_to_remove_todo_from_container }
|
|
||||||
page.deferred { return !@context_changed && (@todo.deferred? || @todo.pending?) }
|
|
||||||
page.calendar { return !@due_date_changed && @todo.due }
|
|
||||||
page.stats { return !@todo.completed? }
|
|
||||||
page.tag { return !update_needs_to_remove_todo_from_container && !@tag_was_removed }
|
|
||||||
page.todo { return !update_needs_to_remove_todo_from_container }
|
|
||||||
page.search { return true }
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
def append_updated_todo
|
|
||||||
source_view do |page|
|
|
||||||
page.context { return @todo_deferred_state_changed || @todo_pending_state_changed }
|
|
||||||
page.project { return @todo_deferred_state_changed || @todo_pending_state_changed }
|
|
||||||
page.deferred { return @context_changed && (@todo.deferred? || @todo.pending?) }
|
|
||||||
page.calendar { return @due_date_changed && @todo.due }
|
|
||||||
page.stats { return false }
|
|
||||||
page.tag { return update_needs_to_remove_todo_from_container && !@tag_was_removed}
|
|
||||||
page.todo { return @context_changed && !(@todo.deferred? || @todo.pending? || @todo.hidden?) }
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
def item_container_id (todo)
|
|
||||||
return "hidden_container_items" if source_view_is(:tag) && todo.hidden?
|
|
||||||
return "c#{todo.context_id}_items" if source_view_is :deferred
|
|
||||||
return @new_due_id if source_view_is :calendar
|
|
||||||
return "deferred_pending_container_items" if !source_view_is(:todo) && (todo.deferred? || todo.pending?)
|
|
||||||
return "completed_container_items" if todo.completed?
|
|
||||||
return "p#{todo.project_id}_items" if source_view_is :project
|
|
||||||
return "c#{todo.context_id}_items"
|
|
||||||
end
|
|
||||||
|
|
||||||
def empty_container_msg_div_id(todo = @todo || @successor)
|
|
||||||
raise Exception.new, "no @todo or @successor set" if !todo
|
|
||||||
|
|
||||||
source_view do |page|
|
|
||||||
page.project {
|
|
||||||
return "deferred_pending_container-empty-d" if empty_criteria_met
|
|
||||||
return "p#{todo.project_id}-empty-d"
|
|
||||||
}
|
|
||||||
page.tag {
|
|
||||||
return "deferred_pending_container-empty-d" if empty_criteria_met
|
|
||||||
return "hidden_container-empty-d" if @todo.hidden?
|
|
||||||
return "c#{todo.context_id}-empty-d"
|
|
||||||
}
|
|
||||||
page.calendar {
|
|
||||||
return "deferred_pending_container-empty-d" if empty_criteria_met
|
|
||||||
return "empty_#{@new_due_id}"
|
|
||||||
}
|
|
||||||
page.context {
|
|
||||||
return "deferred_pending_container-empty-d" if empty_criteria_met
|
|
||||||
return "c#{todo.context_id}-empty-d"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
return "c#{todo.context_id}-empty-d"
|
|
||||||
end
|
|
||||||
|
|
||||||
def empty_criteria_met
|
|
||||||
@todo_was_deferred_from_active_state ||
|
|
||||||
@todo_was_blocked_from_active_state ||
|
|
||||||
@todo_was_destroyed_from_deferred_state ||
|
|
||||||
@todo_was_created_deferred ||
|
|
||||||
@todo_was_blocked_from_completed_state ||
|
|
||||||
@todo_was_created_blocked
|
|
||||||
end
|
|
||||||
|
|
||||||
def todo_was_removed_from_deferred_or_blocked_container
|
|
||||||
return @todo_was_activated_from_deferred_state ||
|
|
||||||
@todo_was_activated_from_pending_state ||
|
|
||||||
@todo_was_destroyed_from_deferred_or_pending_state ||
|
|
||||||
@todo_was_completed_from_deferred_or_blocked_state
|
|
||||||
end
|
|
||||||
|
|
||||||
def show_empty_message_in_source_container
|
|
||||||
container_id = ""
|
|
||||||
source_view do |page|
|
|
||||||
page.project {
|
|
||||||
container_id = "p#{@original_item_project_id}-empty-d" if @remaining_in_context == 0
|
|
||||||
container_id = "deferred_pending_container-empty-d" if todo_was_removed_from_deferred_or_blocked_container && @remaining_deferred_or_pending_count == 0
|
|
||||||
container_id = "completed_container-empty-d" if @completed_count && @completed_count == 0 && !@todo.completed?
|
|
||||||
}
|
|
||||||
page.deferred { container_id = "c#{@original_item_context_id}empty-d" if @remaining_in_context == 0 }
|
|
||||||
page.calendar { container_id = "empty_#{@original_item_due_id}" if @old_due_empty }
|
|
||||||
page.tag {
|
|
||||||
container_id = "hidden_container-empty-d" if (@remaining_hidden_count == 0 && !@todo.hidden? && @todo_hidden_state_changed) ||
|
|
||||||
(@remaining_hidden_count == 0 && @todo.completed? && @original_item_was_hidden)
|
|
||||||
container_id = "deferred_pending_container-empty-d" if (todo_was_removed_from_deferred_or_blocked_container && @remaining_deferred_or_pending_count == 0) ||
|
|
||||||
(@original_item_was_deferred && @remaining_deferred_or_pending_count == 0 && (@todo.completed? || @tag_was_removed))
|
|
||||||
container_id = "completed_container-empty-d" if @completed_count && @completed_count == 0 && !@todo.completed?
|
|
||||||
}
|
|
||||||
page.context {
|
|
||||||
container_id = "c#{@original_item_context_id}-empty-d" if @remaining_in_context == 0
|
|
||||||
container_id = "deferred_pending_container-empty-d" if todo_was_removed_from_deferred_or_blocked_container && @remaining_deferred_or_pending_count == 0
|
|
||||||
container_id = "completed_container-empty-d" if @completed_count && @completed_count == 0 && !@todo.completed?
|
|
||||||
}
|
|
||||||
page.todo { container_id = "c#{@original_item_context_id}-empty-d" if @remaining_in_context == 0 }
|
|
||||||
page.done { container_id = "completed_#{@original_completed_period}_container-empty-d" if @remaining_in_context == 0 }
|
|
||||||
end
|
|
||||||
return container_id.blank? ? "" : "$(\"##{container_id}\").slideDown(100);".html_safe
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_animation(animation)
|
def render_animation(animation)
|
||||||
|
|
@ -587,10 +429,208 @@ module TodosHelper
|
||||||
content_tag(:div, "#{t('common.context')}: #{context_link}")
|
content_tag(:div, "#{t('common.context')}: #{context_link}")
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
# === handle CRUD actions for todos
|
||||||
|
|
||||||
def image_tag_for_star(todo)
|
def show_todo_on_current_context_page
|
||||||
image_tag("blank.png", :title =>t('todos.star_action'), :class => "todo_star"+(todo.starred? ? " starred":""), :id => "star_img_"+todo.id.to_s)
|
return @todo.context_id==@default_context.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def todo_should_not_be_hidden_on_context_page
|
||||||
|
return !@todo.hidden? || # todo is not hidden --> show
|
||||||
|
(@todo.hidden? && @todo.context.hidden?) # todo is hidden, but context is hidden too --> show
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_todo_on_current_project_page
|
||||||
|
return @todo.project.id == @default_project.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def todo_should_not_be_hidden_on_project_page
|
||||||
|
return !@todo.hidden? ||
|
||||||
|
(@todo.project_hidden? && @todo.project.hidden?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def should_show_new_item(todo = @todo)
|
||||||
|
return false if todo.nil?
|
||||||
|
source_view do |page|
|
||||||
|
page.todo { return !todo.hidden? }
|
||||||
|
page.deferred { return todo.deferred? || todo.pending? }
|
||||||
|
page.context { return show_todo_on_current_context_page && todo_should_not_be_hidden_on_context_page }
|
||||||
|
page.tag { return todo.has_tag?(@tag_name) }
|
||||||
|
page.project { return show_todo_on_current_project_page && todo_should_not_be_hidden_on_project_page }
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
def should_make_context_visible
|
||||||
|
return @todo.active? && (!@todo.hidden? && !source_view_is(:project) )
|
||||||
|
end
|
||||||
|
|
||||||
|
def should_add_new_container
|
||||||
|
if @group_view_by == 'project'
|
||||||
|
return @new_project_created && !source_view_is(:context)
|
||||||
|
else
|
||||||
|
return @new_context_created && !source_view_is(:project)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def todo_container_is_empty
|
||||||
|
default_container_empty = ( @down_count == 0 )
|
||||||
|
deferred_container_empty = ( @todo.deferred? && @remaining_deferred_count == 0)
|
||||||
|
return default_container_empty || deferred_container_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
def todo_moved_out_of_container
|
||||||
|
return (@project_changed && @group_view_by=='project') || (@context_changed && @group_view_by='context')
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_needs_to_hide_container
|
||||||
|
return (@remaining_in_context == 0 && todo_moved_out_of_container ) ||
|
||||||
|
(@remaining_in_context == 0 && (@todo_hidden_state_changed && @todo.hidden?)) ||
|
||||||
|
(@remaining_in_context == 0 && @todo_was_deferred_from_active_state) ||
|
||||||
|
(@remaining_in_context == 0 && @tag_was_removed) ||
|
||||||
|
(@remaining_in_context == 0 && @todo_was_destroyed) ||
|
||||||
|
(@remaining_in_context == 0 && @todo.completed? && !(@original_item_was_deferred || @original_item_was_hidden)) if source_view_is(:tag)
|
||||||
|
|
||||||
|
return false if source_view_is_one_of(:project, :calendar, :done)
|
||||||
|
|
||||||
|
return (@remaining_in_context == 0) && !source_view_is(:context)
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_needs_to_remove_todo_from_container
|
||||||
|
source_view do |page|
|
||||||
|
page.context { return @context_changed || @todo_deferred_state_changed || @todo_pending_state_changed || @todo_should_be_hidden }
|
||||||
|
page.project { return @todo_deferred_state_changed || @todo_pending_state_changed || @project_changed}
|
||||||
|
page.deferred { return @context_changed || !(@todo.deferred? || @todo.pending?) }
|
||||||
|
page.calendar { return @due_date_changed || !@todo.due }
|
||||||
|
page.stats { return @todo.completed? }
|
||||||
|
page.tag { return ( (@context_changed | @project_changed) && !@todo.hidden?) || @tag_was_removed || @todo_hidden_state_changed || @todo_deferred_state_changed }
|
||||||
|
page.todo { return todo_moved_out_of_container || @todo.hidden? || @todo.deferred? || @todo.pending?}
|
||||||
|
page.search { return false }
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
def replace_with_updated_todo
|
||||||
|
source_view do |page|
|
||||||
|
page.context { return !update_needs_to_remove_todo_from_container }
|
||||||
|
page.project { return !update_needs_to_remove_todo_from_container }
|
||||||
|
page.deferred { return !@context_changed && (@todo.deferred? || @todo.pending?) }
|
||||||
|
page.calendar { return !@due_date_changed && @todo.due }
|
||||||
|
page.stats { return !@todo.completed? }
|
||||||
|
page.tag { return !update_needs_to_remove_todo_from_container && !@tag_was_removed }
|
||||||
|
page.todo { return !update_needs_to_remove_todo_from_container }
|
||||||
|
page.search { return true }
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
def append_updated_todo
|
||||||
|
source_view do |page|
|
||||||
|
page.context { return @todo_deferred_state_changed || @todo_pending_state_changed }
|
||||||
|
page.project { return @todo_deferred_state_changed || @todo_pending_state_changed }
|
||||||
|
page.deferred { return @context_changed && (@todo.deferred? || @todo.pending?) }
|
||||||
|
page.calendar { return @due_date_changed && @todo.due }
|
||||||
|
page.stats { return false }
|
||||||
|
page.tag { return update_needs_to_remove_todo_from_container && !@tag_was_removed}
|
||||||
|
page.todo { return todo_moved_out_of_container && !(@todo.deferred? || @todo.pending? || @todo.hidden?) }
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
def project_container_id(todo)
|
||||||
|
return "p#{todo.project_id}" unless todo.project.nil?
|
||||||
|
return "without_project_container"
|
||||||
|
end
|
||||||
|
|
||||||
|
def project_container_empty_id(todo)
|
||||||
|
return "p#{todo.project_id}-empty-d" unless todo.project.nil?
|
||||||
|
return "without_project_container-empty-d"
|
||||||
|
end
|
||||||
|
|
||||||
|
def item_container_id (todo)
|
||||||
|
return "hidden_container_items" if source_view_is(:tag) && todo.hidden?
|
||||||
|
return "c#{todo.context_id}_items" if source_view_is :deferred
|
||||||
|
return @new_due_id if source_view_is :calendar
|
||||||
|
return "deferred_pending_container_items" if !source_view_is(:todo) && (todo.deferred? || todo.pending?)
|
||||||
|
return "completed_container_items" if todo.completed?
|
||||||
|
return "p#{todo.project_id}_items" if source_view_is :project
|
||||||
|
return project_container_id(todo) if source_view_is_one_of(:todo, :tag) && @group_view_by == 'project'
|
||||||
|
return "c#{todo.context_id}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def empty_container_msg_div_id(todo = @todo || @successor)
|
||||||
|
raise Exception.new, "no @todo or @successor set" if !todo
|
||||||
|
|
||||||
|
source_view do |page|
|
||||||
|
page.project {
|
||||||
|
return "deferred_pending_container-empty-d" if empty_criteria_met
|
||||||
|
return "p#{todo.project_id}-empty-d"
|
||||||
|
}
|
||||||
|
page.tag {
|
||||||
|
return "deferred_pending_container-empty-d" if empty_criteria_met
|
||||||
|
return "hidden_container-empty-d" if @todo.hidden?
|
||||||
|
return "c#{todo.context_id}-empty-d" if @group_view_by == 'context'
|
||||||
|
return project_container_empty_id(todo)
|
||||||
|
}
|
||||||
|
page.calendar {
|
||||||
|
return "deferred_pending_container-empty-d" if empty_criteria_met
|
||||||
|
return "empty_#{@new_due_id}"
|
||||||
|
}
|
||||||
|
page.context {
|
||||||
|
return "deferred_pending_container-empty-d" if empty_criteria_met
|
||||||
|
return "c#{todo.context_id}-empty-d"
|
||||||
|
}
|
||||||
|
page.todo {
|
||||||
|
return "c#{todo.context_id}-empty-d" if @group_view_by == 'context'
|
||||||
|
return project_container_empty_id(todo)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return "c#{todo.context_id}-empty-d"
|
||||||
|
end
|
||||||
|
|
||||||
|
def empty_criteria_met
|
||||||
|
return @todo_was_deferred_from_active_state ||
|
||||||
|
@todo_was_blocked_from_active_state ||
|
||||||
|
@todo_was_destroyed_from_deferred_state ||
|
||||||
|
@todo_was_created_deferred ||
|
||||||
|
@todo_was_blocked_from_completed_state ||
|
||||||
|
@todo_was_created_blocked
|
||||||
|
end
|
||||||
|
|
||||||
|
def todo_was_removed_from_deferred_or_blocked_container
|
||||||
|
return @todo_was_activated_from_deferred_state ||
|
||||||
|
@todo_was_activated_from_pending_state ||
|
||||||
|
@todo_was_destroyed_from_deferred_or_pending_state ||
|
||||||
|
@todo_was_completed_from_deferred_or_blocked_state
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_empty_message_in_source_container
|
||||||
|
container_id = ""
|
||||||
|
source_view do |page|
|
||||||
|
page.project {
|
||||||
|
container_id = "p#{@original_item_project_id}-empty-d" if @remaining_in_context == 0
|
||||||
|
container_id = "deferred_pending_container-empty-d" if todo_was_removed_from_deferred_or_blocked_container && @remaining_deferred_or_pending_count == 0
|
||||||
|
container_id = "completed_container-empty-d" if @completed_count && @completed_count == 0 && !@todo.completed?
|
||||||
|
}
|
||||||
|
page.deferred { container_id = "c#{@original_item_context_id}empty-d" if @remaining_in_context == 0 }
|
||||||
|
page.calendar { container_id = "empty_#{@original_item_due_id}" if @old_due_empty }
|
||||||
|
page.tag {
|
||||||
|
container_id = "hidden_container-empty-d" if (@remaining_hidden_count == 0 && !@todo.hidden? && @todo_hidden_state_changed) ||
|
||||||
|
(@remaining_hidden_count == 0 && @todo.completed? && @original_item_was_hidden)
|
||||||
|
container_id = "deferred_pending_container-empty-d" if (todo_was_removed_from_deferred_or_blocked_container && @remaining_deferred_or_pending_count == 0) ||
|
||||||
|
(@original_item_was_deferred && @remaining_deferred_or_pending_count == 0 && (@todo.completed? || @tag_was_removed))
|
||||||
|
container_id = "completed_container-empty-d" if @completed_count && @completed_count == 0 && !@todo.completed?
|
||||||
|
}
|
||||||
|
page.context {
|
||||||
|
container_id = "c#{@original_item_context_id}-empty-d" if @remaining_in_context == 0
|
||||||
|
container_id = "deferred_pending_container-empty-d" if todo_was_removed_from_deferred_or_blocked_container && @remaining_deferred_or_pending_count == 0
|
||||||
|
container_id = "completed_container-empty-d" if @completed_count && @completed_count == 0 && !@todo.completed?
|
||||||
|
}
|
||||||
|
page.todo { container_id = "c#{@original_item_context_id}-empty-d" if @remaining_in_context == 0 }
|
||||||
|
page.done { container_id = "completed_#{@original_completed_period}_container-empty-d" if @remaining_in_context == 0 }
|
||||||
|
end
|
||||||
|
return container_id.blank? ? "" : "$(\"##{container_id}\").slideDown(100);".html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
var SOURCE_VIEW = '<%=@source_view%>';
|
var SOURCE_VIEW = '<%=@source_view%>';
|
||||||
var AUTH_TOKEN = '<%= raw(protect_against_forgery? ? form_authenticity_token.inspect : "") %>'
|
var AUTH_TOKEN = '<%= raw(protect_against_forgery? ? form_authenticity_token.inspect : "") %>'
|
||||||
var TAG_NAME = '<%= @tag_name ? @tag_name : "" %>'
|
var TAG_NAME = '<%= @tag_name ? @tag_name : "" %>'
|
||||||
|
var GROUP_VIEW_BY = '<%= @group_view_by ? @group_view_by : "" %>'
|
||||||
var defaultContexts = <%= default_contexts_for_autocomplete.html_safe rescue '{}' %>;
|
var defaultContexts = <%= default_contexts_for_autocomplete.html_safe rescue '{}' %>;
|
||||||
var defaultTags = <%= default_tags_for_autocomplete.html_safe rescue '{}' %>;
|
var defaultTags = <%= default_tags_for_autocomplete.html_safe rescue '{}' %>;
|
||||||
var dateFormat = '<%= date_format_for_date_picker %>';
|
var dateFormat = '<%= date_format_for_date_picker %>';
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,10 @@
|
||||||
# invalidate the cache every day because of staleness or
|
# invalidate the cache every day because of staleness or
|
||||||
# rendering of "due in x days" that change without touching updated at of the todo
|
# rendering of "due in x days" that change without touching updated at of the todo
|
||||||
cache [project, @source_view, current_user.date.strftime("%Y%m%d")] do
|
cache [project, @source_view, current_user.date.strftime("%Y%m%d")] do
|
||||||
%>
|
-%>
|
||||||
<%= render :partial => "project_settings_container", :locals => {:project => project} if source_view_is :project %>
|
<% if source_view_is :project -%>
|
||||||
|
<%= render :partial => "project_settings_container", :locals => {:project => project} %>
|
||||||
|
<% end -%>
|
||||||
<%=
|
<%=
|
||||||
title = source_view_is(:project) ? t('projects.actions_in_project_title') : show_project_name(project)
|
title = source_view_is(:project) ? t('projects.actions_in_project_title') : show_project_name(project)
|
||||||
|
|
||||||
|
|
@ -19,5 +20,4 @@ cache [project, @source_view, current_user.date.strftime("%Y%m%d")] do
|
||||||
:show_empty_containers => settings[:show_empty_containers]
|
:show_empty_containers => settings[:show_empty_containers]
|
||||||
}}
|
}}
|
||||||
%>
|
%>
|
||||||
|
<% end -%>
|
||||||
<% end %>
|
|
||||||
|
|
@ -1,24 +1,32 @@
|
||||||
<% unless @saved -%>
|
<% unless @saved -%>
|
||||||
|
|
||||||
TracksPages.show_errors(html_for_error_messages());
|
TracksPages.show_errors(html_for_error_messages());
|
||||||
|
|
||||||
function html_for_error_messages() {
|
function html_for_error_messages() {
|
||||||
return "<%= escape_javascript(get_list_of_error_messages_for(@todo)) %>";
|
return "<%= escape_javascript(get_list_of_error_messages_for(@todo)) %>";
|
||||||
}
|
}
|
||||||
<% else -%>
|
|
||||||
|
<% else
|
||||||
|
|
||||||
|
animation = []
|
||||||
|
if should_show_new_item
|
||||||
|
if should_add_new_container
|
||||||
|
animation << "insert_new_container_with_new_todo";
|
||||||
|
else
|
||||||
|
animation << "add_todo_to_existing_container";
|
||||||
|
end
|
||||||
|
end
|
||||||
|
animation << "remove_empty_message_container";
|
||||||
|
animation << "update_predecessors";
|
||||||
|
animation << "clear_form";
|
||||||
|
-%>
|
||||||
|
|
||||||
|
<%= render_animation(animation) %>
|
||||||
TracksPages.page_notify('notice', "<%=escape_javascript @status_message%>", 8);
|
TracksPages.page_notify('notice', "<%=escape_javascript @status_message%>", 8);
|
||||||
TracksPages.hide_errors();
|
TracksPages.hide_errors();
|
||||||
TracksPages.set_page_badge(<%= @down_count %>);
|
TracksPages.set_page_badge(<%= @down_count %>);
|
||||||
<% if should_show_new_item -%>
|
|
||||||
<% if should_add_new_context -%>
|
|
||||||
insert_new_context_with_new_todo();
|
|
||||||
<% else -%>
|
|
||||||
add_todo_to_existing_context();
|
|
||||||
<% end -%>
|
|
||||||
<% end -%>
|
|
||||||
update_predecessors();
|
|
||||||
clear_form();
|
|
||||||
|
|
||||||
function clear_form() {
|
function clear_form(next_steps) {
|
||||||
$('#todo-form-new-action').clearForm();
|
$('#todo-form-new-action').clearForm();
|
||||||
$('#todo-form-new-action').clearDeps();
|
$('#todo-form-new-action').clearDeps();
|
||||||
TracksForm.set_context_name('<%=escape_javascript @initial_context_name%>');
|
TracksForm.set_context_name('<%=escape_javascript @initial_context_name%>');
|
||||||
|
|
@ -27,43 +35,55 @@
|
||||||
$('#todo-form-new-action input:text:first').focus();
|
$('#todo-form-new-action input:text:first').focus();
|
||||||
$('#new_todo_starred_link .todo_star').removeClass('starred');
|
$('#new_todo_starred_link .todo_star').removeClass('starred');
|
||||||
$('#new_todo_starred').val('false');
|
$('#new_todo_starred').val('false');
|
||||||
|
next_steps.go();
|
||||||
}
|
}
|
||||||
|
|
||||||
function insert_new_context_with_new_todo() {
|
function insert_new_container_with_new_todo(next_steps) {
|
||||||
<%-
|
<%-
|
||||||
empty_id = '#no_todos_in_view'
|
empty_id = '#no_todos_in_view'
|
||||||
empty_id = '#deferred_pending_container-empty-d' if source_view_is :tickler
|
empty_id = '#deferred_pending_container-empty-d' if source_view_is :tickler
|
||||||
-%>
|
-%>
|
||||||
$('<%=empty_id%>').slideUp(100);
|
$('<%=empty_id%>').slideUp(100, function() {
|
||||||
$('#display_box').prepend(html_for_new_context());
|
$('#display_box').prepend(html_for_new_container());
|
||||||
|
next_steps.go();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_todo_to_existing_context() {
|
function add_todo_to_existing_container(next_steps) {
|
||||||
<% if source_view_is_one_of(:todo, :deferred, :tag) -%>
|
$('#<%= empty_container_msg_div_id %>').hide();
|
||||||
<% unless source_view_is_one_of(:todo, :tag) && (@todo.deferred?||@todo.hidden?) -%>
|
$('#<%= item_container_id(@todo) %>').append(html_for_new_todo());
|
||||||
$('#c<%= @todo.context_id %>').fadeIn(500, function() {});
|
$('#<%= item_container_id(@todo) %>').slideDown(500, function() {
|
||||||
$('#no_todos_in_view').slideUp(100);
|
$('#<%= dom_id(@todo) %>').effect('highlight', {}, 2000 );
|
||||||
<%= "$('#deferred_pending_container-empty-nd').slideUp(100);".html_safe if source_view_is(:deferred) && @todo.deferred? %>
|
next_steps.go();
|
||||||
<% end -%>
|
});
|
||||||
<% end -%>
|
|
||||||
$('#<%=empty_container_msg_div_id%>').hide();
|
|
||||||
$('#<%=item_container_id(@todo)%>').append(html_for_new_todo());
|
|
||||||
$('#<%= dom_id(@todo)%>').effect('highlight', {}, 2000 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_predecessors() {
|
function remove_empty_message_container(next_steps) {
|
||||||
|
$('#no_todos_in_view').slideUp(100, function() { });
|
||||||
|
<%# = "$('#deferred_pending_container-empty-nd').slideUp(100);".html_safe if source_view_is(:deferred) && @todo.deferred? %>
|
||||||
|
next_steps.go();
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_predecessors(next_steps) {
|
||||||
<% @todo.uncompleted_predecessors.each do |p| -%>
|
<% @todo.uncompleted_predecessors.each do |p| -%>
|
||||||
if ($('<%=item_container_id(p)%>')) {
|
if ($('<%=item_container_id(p)%>')) {
|
||||||
$('#<%=dom_id(p)%>').html('<%= escape_javascript(render(:partial => p, :locals => { :parent_container_type => parent_container_type, :source_view => @source_view }))%>');
|
$('#<%=dom_id(p)%>').html('<%= escape_javascript(render(:partial => p, :locals => { :parent_container_type => parent_container_type, :source_view => @source_view }))%>');
|
||||||
}
|
}
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
next_steps.go();
|
||||||
}
|
}
|
||||||
|
|
||||||
function html_for_new_context() {
|
function html_for_new_container() {
|
||||||
return "<%= @saved && @new_context_created ? escape_javascript(render(:partial => @todo.context, :locals => { :settings => {:collapsible => true} })) : "" %>";
|
<%
|
||||||
|
want_render = @group_view_by == 'project' ? @new_project_created : @new_context_created
|
||||||
|
container = @group_view_by == 'project' ? @todo.project : @todo.context
|
||||||
|
js = want_render ? escape_javascript(render(:partial => container, :locals => { :settings => {:collapsible => true} })) : ""
|
||||||
|
%>
|
||||||
|
return "<%= js %>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function html_for_new_todo() {
|
function html_for_new_todo() {
|
||||||
return "<%= @saved ? escape_javascript(render(:partial => @todo, :locals => { :parent_container_type => parent_container_type, :source_view => @source_view })) : "" %>";
|
return "<%= @saved ? escape_javascript(render(:partial => @todo, :locals => { :parent_container_type => parent_container_type, :source_view => @source_view })) : "" %>";
|
||||||
}
|
}
|
||||||
<% end -%>
|
|
||||||
|
<% end -%>
|
||||||
|
|
@ -1,5 +1,21 @@
|
||||||
<% if @saved -%>
|
<% unless @saved -%>
|
||||||
set_notification();
|
TracksPages.show_errors_for_multi_add(html_for_error_messages());
|
||||||
|
|
||||||
|
function html_for_error_messages() {
|
||||||
|
<%
|
||||||
|
# add error about missing todo description that is not available in @todos
|
||||||
|
@multiple_error = content_tag(:div, content_tag(:p, @multiple_error), {:class => 'errorExplanation', :id => 'errorExplanation'}) unless @multiple_error.blank?
|
||||||
|
error_messages = @multiple_error || ""
|
||||||
|
# add errors of individual @todos
|
||||||
|
@todos.each do |todo|
|
||||||
|
error_messages += get_list_of_error_messages_for(todo)
|
||||||
|
end
|
||||||
|
-%>
|
||||||
|
return "<%= escape_javascript(error_messages.html_safe)%>";
|
||||||
|
}
|
||||||
|
|
||||||
|
<% else -%>
|
||||||
|
TracksPages.page_notify('notice', "<%=@status_message%>", 5);
|
||||||
hide_empty_message();
|
hide_empty_message();
|
||||||
TracksPages.hide_errors();
|
TracksPages.hide_errors();
|
||||||
TracksPages.set_page_badge(<%= @down_count %>);
|
TracksPages.set_page_badge(<%= @down_count %>);
|
||||||
|
|
@ -11,67 +27,44 @@
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
clear_form();
|
clear_form();
|
||||||
<% else -%>
|
|
||||||
TracksPages.show_errors_for_multi_add(html_for_error_messages());
|
function clear_form() {
|
||||||
|
$('#todo-form-multi-new-action').clearForm();
|
||||||
|
TracksForm.set_context_name_for_multi_add('<%=escape_javascript @initial_context_name%>');
|
||||||
|
TracksForm.set_project_name_for_multi_add('<%=escape_javascript @initial_project_name%>');
|
||||||
|
TracksForm.set_tag_list_for_multi_add('<%=escape_javascript @initial_tags%>');
|
||||||
|
$('#todo-form-multi-new-action input:text:first').focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function insert_new_context_with_new_todo() {
|
||||||
|
$('#display_box').prepend(html_for_new_context());
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide_empty_message() {
|
||||||
|
<% if (source_view_is :project and @todo.pending?) or (source_view_is :deferred) -%>
|
||||||
|
$('#deferred_pending_container-empty-d').hide();
|
||||||
|
<% else -%>
|
||||||
|
$('#no_todos_in_view').hide();
|
||||||
|
<% end -%>
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_todo_to_existing_context() {
|
||||||
|
<%
|
||||||
|
@todos.each do |todo|
|
||||||
|
if should_show_new_item(todo)
|
||||||
|
html = escape_javascript(render(:partial => todo, :locals => { :parent_container_type => parent_container_type, :source_view => @source_view }))
|
||||||
|
-%>
|
||||||
|
$('#<%= empty_container_msg_div_id(todo) %>').hide();
|
||||||
|
$('#<%= item_container_id(todo) %>').append('<%= html %>');
|
||||||
|
$('#<%= item_container_id(todo) %>').fadeIn(500, function() {
|
||||||
|
$('#<%= dom_id(todo) %>').effect('highlight', {}, 2000 );
|
||||||
|
});
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
}
|
||||||
|
|
||||||
|
function html_for_new_context() {
|
||||||
|
return "<%= @saved && @new_context_created ? escape_javascript(render(:partial => @todo.context, :locals => { :settings => {:collapsible => true} })) : "" %>";
|
||||||
|
}
|
||||||
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<% if @saved
|
|
||||||
# the following functions assume a todo is saved or at least not nil,
|
|
||||||
# so leave them out in case of an error
|
|
||||||
-%>
|
|
||||||
|
|
||||||
function set_notification() {
|
|
||||||
TracksPages.page_notify('notice', "<%=@status_message%>", 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
function clear_form() {
|
|
||||||
$('#todo-form-multi-new-action').clearForm();
|
|
||||||
TracksForm.set_context_name_for_multi_add('<%=escape_javascript @initial_context_name%>');
|
|
||||||
TracksForm.set_project_name_for_multi_add('<%=escape_javascript @initial_project_name%>');
|
|
||||||
TracksForm.set_tag_list_for_multi_add('<%=escape_javascript @initial_tags%>');
|
|
||||||
$('#todo-form-multi-new-action input:text:first').focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
function insert_new_context_with_new_todo() {
|
|
||||||
$('#display_box').prepend(html_for_new_context());
|
|
||||||
}
|
|
||||||
|
|
||||||
function hide_empty_message() {
|
|
||||||
$('#<%=empty_container_msg_div_id%>').hide();
|
|
||||||
<% if (source_view_is :project and @todo.pending?) or (source_view_is :deferred) -%>
|
|
||||||
$('#deferred_pending_container-empty-d').hide();
|
|
||||||
<% end -%>
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_todo_to_existing_context() {
|
|
||||||
<% if source_view_is_one_of(:todo, :deferred, :tag) -%>
|
|
||||||
TodoItemsContainer.ensureVisibleWithEffectAppear("c<%=@todo.context_id%>");
|
|
||||||
<% end
|
|
||||||
show = should_show_new_item # to hide html if not necessary
|
|
||||||
@todos.each do |todo|
|
|
||||||
html = show ? escape_javascript(render(:partial => todo, :locals => { :parent_container_type => parent_container_type, :source_view => @source_view })) : "" -%>
|
|
||||||
$('#<%=item_container_id(todo)%>').append('<%= html %>');
|
|
||||||
$('#<%= dom_id(todo)%>').effect('highlight', {}, 3000);
|
|
||||||
<% end %>
|
|
||||||
}
|
|
||||||
|
|
||||||
function html_for_new_context() {
|
|
||||||
return "<%= @saved && @new_context_created ? escape_javascript(render(:partial => @todo.context, :locals => { :settings => {:collapsible => true} })) : "" %>";
|
|
||||||
}
|
|
||||||
|
|
||||||
<% else # if @saved -%>
|
|
||||||
|
|
||||||
function html_for_error_messages() {
|
|
||||||
<%
|
|
||||||
# add error about missing todo description that is not available in @todos
|
|
||||||
@multiple_error = content_tag(:div, content_tag(:p, @multiple_error), {:class => 'errorExplanation', :id => 'errorExplanation'}) unless @multiple_error.blank?
|
|
||||||
error_messages = @multiple_error || ""
|
|
||||||
# add errors of individual @todos
|
|
||||||
@todos.each do |todo|
|
|
||||||
error_messages += get_list_of_error_messages_for(todo)
|
|
||||||
end
|
|
||||||
-%>
|
|
||||||
return "<%= escape_javascript(error_messages.html_safe)%>";
|
|
||||||
}
|
|
||||||
|
|
||||||
<% end # if @saved -%>
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
<%- if @saved -%>
|
<%- unless @saved -%>
|
||||||
|
TracksPages.page_notify('error', "<%= t('todos.error_deleting_item', :description => @todo.description) %>", 8);
|
||||||
|
<%- else -%>
|
||||||
TracksPages.page_notify('notice', '<%= escape_javascript(t('todos.deleted_success')) %>', 5);
|
TracksPages.page_notify('notice', '<%= escape_javascript(t('todos.deleted_success')) %>', 5);
|
||||||
TracksPages.set_page_badge(<%=@down_count%>);
|
TracksPages.set_page_badge(<%=@down_count%>);
|
||||||
remove_todo_from_page();
|
remove_todo_from_page();
|
||||||
|
|
@ -6,20 +8,14 @@
|
||||||
activate_pending_todos();
|
activate_pending_todos();
|
||||||
update_predecessors();
|
update_predecessors();
|
||||||
show_empty_messages();
|
show_empty_messages();
|
||||||
<%- else -%>
|
|
||||||
TracksPages.page_notify('error', "<%= t('todos.error_deleting_item', :description => @todo.description) %>", 8);
|
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
|
||||||
<% if @saved
|
|
||||||
# do not send the js in case of an error
|
|
||||||
-%>
|
|
||||||
|
|
||||||
function show_empty_messages() {
|
function show_empty_messages() {
|
||||||
<% if @old_due_empty -%>
|
<% if @old_due_empty -%>
|
||||||
$('#empty_<%=@original_item_due_id%>').slideDown(1000);
|
$('#empty_<%=@original_item_due_id%>').slideDown(1000);
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<% if empty_container_msg_div_id && todo_container_is_empty -%>
|
<% if todo_container_is_empty -%>
|
||||||
$('#<%=empty_container_msg_div_id%>').slideDown(1000);
|
$('#<%=empty_container_msg_div_id%>').slideDown(1000);
|
||||||
<% if @down_count == 0 -%>
|
<% if @down_count == 0 -%>
|
||||||
$('#no_todos_in_view').slideDown(1000);
|
$('#no_todos_in_view').slideDown(1000);
|
||||||
|
|
@ -32,10 +28,10 @@ function show_empty_messages() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_todo_from_page() {
|
function remove_todo_from_page() {
|
||||||
<% if (@remaining_in_context == 0) && update_needs_to_hide_context
|
<% if (@remaining_in_context == 0) && update_needs_to_hide_container
|
||||||
# remove context with deleted todo
|
# remove context with deleted todo
|
||||||
-%>
|
-%>
|
||||||
$('#c<%=@todo.context_id%>').fadeOut(400, function() {
|
$('#<%=item_container_id(@todo)%>').fadeOut(400, function() {
|
||||||
$('#<%=dom_id(@todo)%>').remove();
|
$('#<%=dom_id(@todo)%>').remove();
|
||||||
});
|
});
|
||||||
<%= show_empty_message_in_source_container -%>
|
<%= show_empty_message_in_source_container -%>
|
||||||
|
|
@ -104,8 +100,4 @@ function update_predecessors() {
|
||||||
|
|
||||||
function html_for_new_recurring_todo() {
|
function html_for_new_recurring_todo() {
|
||||||
return "<%= @saved && @new_recurring_todo ? escape_javascript(render(:partial => @new_recurring_todo, :locals => { :parent_container_type => parent_container_type })) : "" %>";
|
return "<%= @saved && @new_recurring_todo ? escape_javascript(render(:partial => @new_recurring_todo, :locals => { :parent_container_type => parent_container_type })) : "" %>";
|
||||||
}
|
}
|
||||||
|
|
||||||
<% end
|
|
||||||
# if @saved
|
|
||||||
-%>
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<%= show_grouped_todos %>
|
<%= show_grouped_todos %>
|
||||||
|
|
||||||
<% if @group_view_by == 'project' -%>
|
<% if @group_view_by == 'project' -%>
|
||||||
<%= show_todos_without_project(@todos_without_project) unless @todos_without_project.nil? -%>
|
<%= show_todos_without_project(@todos_without_project) -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<%= show_done_todos(@done, {:parent_container_type => 'home', :collapsible => true}) unless @done.nil? %>
|
<%= show_done_todos(@done, {:parent_container_type => 'home', :collapsible => true}) unless @done.nil? %>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,10 @@
|
||||||
|
|
||||||
<%= show_grouped_todos %>
|
<%= show_grouped_todos %>
|
||||||
|
|
||||||
|
<% if @group_view_by == 'project' -%>
|
||||||
|
<%= show_todos_without_project(@todos_without_project) -%>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
<%= show_deferred_pending_todos(@deferred_todos, @pending_todos, deferred_pending_options) %>
|
<%= show_deferred_pending_todos(@deferred_todos, @pending_todos, deferred_pending_options) %>
|
||||||
|
|
||||||
<%= show_hidden_todos(@hidden_todos, hidden_options) unless @hidden_todos.nil? %>
|
<%= show_hidden_todos(@hidden_todos, hidden_options) unless @hidden_todos.nil? %>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ function redirect_after_complete() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_todo(next_steps) {
|
function remove_todo(next_steps) {
|
||||||
<% if (@remaining_in_context == 0) && update_needs_to_hide_context
|
<% if (@remaining_in_context == 0) && update_needs_to_hide_container
|
||||||
# remove context with deleted todo
|
# remove context with deleted todo
|
||||||
-%>
|
-%>
|
||||||
$('#c<%=@todo.context_id%>').fadeOut(400, function() {
|
$('#c<%=@todo.context_id%>').fadeOut(400, function() {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
<% if !@saved -%>
|
<% unless @saved -%>
|
||||||
TracksPages.show_edit_errors(html_for_error_messages());
|
TracksPages.show_edit_errors(html_for_error_messages());
|
||||||
|
|
||||||
|
function html_for_error_messages() {
|
||||||
|
return "<%= escape_javascript(get_list_of_error_messages_for(@todo)) %>";
|
||||||
|
}
|
||||||
|
|
||||||
<% else
|
<% else
|
||||||
|
|
||||||
# jquery animations are async, so first collect all animation steps that need
|
# jquery animations are async, so first collect all animation steps that need
|
||||||
|
|
@ -13,15 +18,14 @@
|
||||||
elsif append_updated_todo
|
elsif append_updated_todo
|
||||||
animation << (@new_context_created ? "insert_new_context_with_updated_todo" : "add_to_existing_container")
|
animation << (@new_context_created ? "insert_new_context_with_updated_todo" : "add_to_existing_container")
|
||||||
end
|
end
|
||||||
animation << "hide_context" if update_needs_to_hide_context
|
animation << "hide_container" if update_needs_to_hide_container
|
||||||
animation << "highlight_updated_todo"
|
animation << "highlight_updated_todo"
|
||||||
animation << "update_empty_container" if source_view_is_one_of(:tag, :todo, :deferred)
|
animation << "update_empty_container" if source_view_is_one_of(:tag, :todo, :deferred)
|
||||||
animation << "update_predecessors"
|
animation << "update_predecessors"
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<%= render_animation(animation) %>
|
|
||||||
TracksPages.page_notify('notice', '<%=escape_javascript @status_message%>', 5);
|
TracksPages.page_notify('notice', '<%=escape_javascript @status_message%>', 5);
|
||||||
TracksPages.set_page_badge(<%= @down_count %>);
|
TracksPages.set_page_badge(<%= @down_count %>);
|
||||||
|
<%= render_animation(animation) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
function remove_todo(next_steps) {
|
function remove_todo(next_steps) {
|
||||||
|
|
@ -46,7 +50,7 @@ function add_to_existing_container(next_steps) {
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% else -%>
|
<% else -%>
|
||||||
<% unless (@todo_hidden_state_changed && @todo.hidden?) || @todo_was_deferred_from_active_state -%>
|
<% unless (@todo_hidden_state_changed && @todo.hidden?) || @todo_was_deferred_from_active_state -%>
|
||||||
$('#c<%= @todo.context_id %>').fadeIn(500, function() {
|
$('#<%= item_container_id(@todo) %>').fadeIn(500, function() {
|
||||||
next_steps.go();
|
next_steps.go();
|
||||||
<% if @target_context_count==1 -%>
|
<% if @target_context_count==1 -%>
|
||||||
$("#<%= empty_container_msg_div_id %>").slideUp(100);
|
$("#<%= empty_container_msg_div_id %>").slideUp(100);
|
||||||
|
|
@ -69,9 +73,8 @@ function replace_todo(next_steps) {
|
||||||
next_steps.go();
|
next_steps.go();
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide_context(next_steps) {
|
function hide_container(next_steps) {
|
||||||
<% context_id = @context_changed ? @original_item_context_id : @todo.context_id -%>
|
$('#<%= item_container_id(@original_item) %>').fadeOut(400, function(){ next_steps.go(); });
|
||||||
$('#c<%= context_id %>').fadeOut(400, function(){ next_steps.go(); });
|
|
||||||
<%= "$('#deferred_pending_container_empty-nd').slideDown(400);".html_safe if source_view_is(:deferred) && @down_count == 0 %>
|
<%= "$('#deferred_pending_container_empty-nd').slideDown(400);".html_safe if source_view_is(:deferred) && @down_count == 0 %>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,10 +112,6 @@ function html_for_new_context() {
|
||||||
return "<%= @saved && @new_context_created ? escape_javascript(render(:partial => @new_context, :locals => { :settings => {:collapsible => true }})) : "" %>";
|
return "<%= @saved && @new_context_created ? escape_javascript(render(:partial => @new_context, :locals => { :settings => {:collapsible => true }})) : "" %>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function html_for_error_messages() {
|
|
||||||
return "<%= escape_javascript(get_list_of_error_messages_for(@todo)) %>";
|
|
||||||
}
|
|
||||||
|
|
||||||
function update_predecessors(next_steps) {
|
function update_predecessors(next_steps) {
|
||||||
regenerate_predecessor_family();
|
regenerate_predecessor_family();
|
||||||
<% if @removed_predecessors
|
<% if @removed_predecessors
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ Feature: dependencies
|
||||||
Then I should not see "test 1" within the dependencies of "test 2"
|
Then I should not see "test 1" within the dependencies of "test 2"
|
||||||
And I should not see "test 1" in the deferred container
|
And I should not see "test 1" in the deferred container
|
||||||
|
|
||||||
@javascript @wip
|
@javascript
|
||||||
Scenario: Completing a predecessor will activate successors
|
Scenario: Completing a predecessor will activate successors
|
||||||
Given I have a context called "@pc"
|
Given I have a context called "@pc"
|
||||||
And I have a project "dependencies" that has the following todos
|
And I have a project "dependencies" that has the following todos
|
||||||
|
|
|
||||||
|
|
@ -85,21 +85,26 @@ Feature: Add new next action from every page
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario Outline: I can add a todo from several pages
|
Scenario Outline: I can add a todo from several pages
|
||||||
|
Given I have selected the view for group by <grouping>
|
||||||
When I go to the <page>
|
When I go to the <page>
|
||||||
And I submit a new action with description "a new next action"
|
And I submit a new action with description "a new next action"
|
||||||
Then I should <see> the todo "a new next action"
|
Then I should <see> the todo "a new next action"
|
||||||
|
|
||||||
Scenarios:
|
Scenarios:
|
||||||
| page | see |
|
| page | grouping | see |
|
||||||
| home page | see |
|
| home page | context | see |
|
||||||
| tickler page | not see |
|
| home page | project | see |
|
||||||
| "test project" project | see |
|
| tickler page | context | not see |
|
||||||
| context page for "test context" | see |
|
| tickler page | project | not see |
|
||||||
| tag page for "starred" | see |
|
| "test project" project | context | see |
|
||||||
|
| context page for "test context" | context | see |
|
||||||
|
| tag page for "starred" | context | see |
|
||||||
|
| tag page for "starred" | project | see |
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario Outline: I can add multiple todos from several pages
|
Scenario Outline: I can add multiple todos from several pages
|
||||||
Given I have a project "testing" with 1 todos
|
Given I have a project "testing" with 1 todos
|
||||||
|
And I have selected the view for group by <grouping>
|
||||||
When I go to the <page>
|
When I go to the <page>
|
||||||
And I follow "Add multiple next actions"
|
And I follow "Add multiple next actions"
|
||||||
And I submit multiple actions with using
|
And I submit multiple actions with using
|
||||||
|
|
@ -113,15 +118,18 @@ Feature: Add new next action from every page
|
||||||
And the number of actions should be <count>
|
And the number of actions should be <count>
|
||||||
|
|
||||||
Scenarios:
|
Scenarios:
|
||||||
| page | see | badge | count |
|
| page | see | badge | count | grouping |
|
||||||
| home page | see | 3 | 3 |
|
| home page | see | 3 | 3 | context |
|
||||||
| tickler page | not see | 0 | 3 |
|
| home page | see | 3 | 3 | project |
|
||||||
| "testing" project | see | 3 | 3 |
|
| tickler page | not see | 0 | 3 | context |
|
||||||
| context page for "test context" | see | 2 | 3 |
|
| tickler page | not see | 0 | 3 | project |
|
||||||
| tag page for "starred" | not see | 0 | 3 |
|
| "testing" project | see | 3 | 3 | context |
|
||||||
|
| context page for "test context" | see | 2 | 3 | context |
|
||||||
|
| tag page for "starred" | see | 2 | 3 | context |
|
||||||
|
| tag page for "starred" | see | 2 | 3 | project |
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario: Adding a todo to another project does not show the todo
|
Scenario: Adding a todo to another project does not show the todo in project view
|
||||||
Given I have a project called "another project"
|
Given I have a project called "another project"
|
||||||
When I go to the "test project" project
|
When I go to the "test project" project
|
||||||
And I submit a new action with description "can you see me?" to project "another project" in the context "test context"
|
And I submit a new action with description "can you see me?" to project "another project" in the context "test context"
|
||||||
|
|
@ -140,7 +148,7 @@ Feature: Add new next action from every page
|
||||||
Then I should see the todo "another new next action"
|
Then I should see the todo "another new next action"
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario Outline: Adding a todo with a new context shows the new context
|
Scenario Outline: Adding a todo with a new context shows the new context when page groups todos by context
|
||||||
When I go to the <page>
|
When I go to the <page>
|
||||||
And I submit a new <todo> with description "do at new context" and the tags "starred" in the context "New"
|
And I submit a new <todo> with description "do at new context" and the tags "starred" in the context "New"
|
||||||
Then a confirmation for adding a new context "New" should be asked
|
Then a confirmation for adding a new context "New" should be asked
|
||||||
|
|
@ -155,12 +163,29 @@ Feature: Add new next action from every page
|
||||||
| context page for "test context" | action | 1 | not be visible |
|
| context page for "test context" | action | 1 | not be visible |
|
||||||
| tag page for "starred" | action | 1 | be visible |
|
| tag page for "starred" | action | 1 | be visible |
|
||||||
|
|
||||||
|
@javascript
|
||||||
|
Scenario Outline: Adding a todo with a new project shows the new project when page groups todos by project
|
||||||
|
And I have selected the view for group by project
|
||||||
|
When I go to the <page>
|
||||||
|
And I submit a new <todo> with description "do in new project" to project "New" with tags "starred"
|
||||||
|
Then the container for the project "New" should <visible>
|
||||||
|
And the badge should show <badge>
|
||||||
|
|
||||||
|
Scenarios:
|
||||||
|
| page | todo | badge | visible |
|
||||||
|
| home page | action | 1 | be visible |
|
||||||
|
| tickler page | deferred action | 1 | be visible |
|
||||||
|
| "test project" project | action | 1 | not be visible |
|
||||||
|
| context page for "test context" | action | 1 | not be visible |
|
||||||
|
| tag page for "starred" | action | 1 | be visible |
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario Outline: Adding a todo to a hidden project does not show the todo
|
Scenario Outline: Adding a todo to a hidden project does not show the todo
|
||||||
Given I have a hidden project called "hidden project"
|
Given I have a hidden project called "hidden project"
|
||||||
And I have a project called "visible project"
|
And I have a project called "visible project"
|
||||||
And I have a context called "visible context"
|
And I have a context called "visible context"
|
||||||
And I have a context called "other context"
|
And I have a context called "other context"
|
||||||
|
And I have selected the view for group by <grouping>
|
||||||
When I go to the <page>
|
When I go to the <page>
|
||||||
And I submit a new action with description "hidden todo" to project "hidden project" with tags "test" in the context "visible context"
|
And I submit a new action with description "hidden todo" to project "hidden project" with tags "test" in the context "visible context"
|
||||||
Then I should <see_hidden> "hidden todo"
|
Then I should <see_hidden> "hidden todo"
|
||||||
|
|
@ -168,17 +193,21 @@ Feature: Add new next action from every page
|
||||||
Then I should <see_visible> "visible todo"
|
Then I should <see_visible> "visible todo"
|
||||||
|
|
||||||
Scenarios:
|
Scenarios:
|
||||||
| page | see_hidden | see_visible |
|
| page | grouping | see_hidden | see_visible |
|
||||||
| home page | not see | see |
|
| home page | context | not see | see |
|
||||||
| tickler page | not see | not see |
|
| home page | project | not see | see |
|
||||||
| "visible project" project | not see | see |
|
| tickler page | context | not see | not see |
|
||||||
| "hidden project" project | see | not see |
|
| tickler page | project | not see | not see |
|
||||||
| context page for "visible context" | not see | see |
|
| "visible project" project | project | not see | see |
|
||||||
| context page for "other context" | not see | not see |
|
| "hidden project" project | project | see | not see |
|
||||||
| tag page for "starred" | not see | not see |
|
| context page for "visible context" | context | not see | see |
|
||||||
| tag page for "test" | see | see |
|
| context page for "other context" | context | not see | not see |
|
||||||
|
| tag page for "starred" | context | not see | not see |
|
||||||
|
| tag page for "starred" | project | not see | not see |
|
||||||
|
| tag page for "test" | context | see | see |
|
||||||
|
| tag page for "test" | project | see | see |
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario: Adding a todo to a hidden context from home page does not show the todo
|
Scenario: Adding a todo to a hidden context from home page does not show the todo
|
||||||
Given I have a context called "visible context"
|
Given I have a context called "visible context"
|
||||||
And I have a hidden context called "hidden context"
|
And I have a hidden context called "hidden context"
|
||||||
|
|
@ -200,14 +229,21 @@ Feature: Add new next action from every page
|
||||||
Then I should see "another new todo"
|
Then I should see "another new todo"
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario: Adding a todo to an empty container hides the empty message # TODO: make outline
|
Scenario Outline: Adding a todo to an empty container hides the empty message
|
||||||
Given I have a context called "visible context"
|
Given I have a context called "visible context"
|
||||||
|
And I have a project called "visible project"
|
||||||
|
And I have selected the view for group by <grouping>
|
||||||
When I go to the tag page for "test"
|
When I go to the tag page for "test"
|
||||||
Then I should see empty message for todos of tag
|
Then I should see empty message for todos of tag
|
||||||
When I submit a new action with description "a new todo" and the tags "test" in the context "visible context"
|
When I submit a new action with description "a new todo" to project "visible project" with tags "test" in the context "visible context"
|
||||||
Then I should see "a new todo"
|
Then I should see "a new todo"
|
||||||
And I should not see empty message for todos of tag
|
And I should not see empty message for todos of tag
|
||||||
|
|
||||||
|
Scenarios:
|
||||||
|
| grouping |
|
||||||
|
| context |
|
||||||
|
| project |
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario Outline: Adding a dependency to a todo updates the successor
|
Scenario Outline: Adding a dependency to a todo updates the successor
|
||||||
Given I have a <list_type> "test" with 1 todos
|
Given I have a <list_type> "test" with 1 todos
|
||||||
|
|
@ -224,7 +260,7 @@ Feature: Add new next action from every page
|
||||||
| project |
|
| project |
|
||||||
| context |
|
| context |
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario: Adding a dependency to a todo in another project
|
Scenario: Adding a dependency to a todo in another project
|
||||||
Given I have a project "testing" with 1 todos
|
Given I have a project "testing" with 1 todos
|
||||||
And I have a project "another project"
|
And I have a project "another project"
|
||||||
|
|
@ -233,8 +269,9 @@ Feature: Add new next action from every page
|
||||||
Then I should not see "a new todo" in the project container of "another project"
|
Then I should not see "a new todo" in the project container of "another project"
|
||||||
And I should not see empty message for deferred todos of project
|
And I should not see empty message for deferred todos of project
|
||||||
|
|
||||||
@javascript
|
@javascript @wip
|
||||||
Scenario: I can add multiple todos in a new project and a new context
|
Scenario Outline: I can add multiple todos in a new project and a new context
|
||||||
|
Given I have selected the view for group by <grouping>
|
||||||
When I go to the home page
|
When I go to the home page
|
||||||
And I follow "Add multiple next actions"
|
And I follow "Add multiple next actions"
|
||||||
And I fill the multiple actions form with "", "a next project", "@anywhere", "new tag"
|
And I fill the multiple actions form with "", "a next project", "@anywhere", "new tag"
|
||||||
|
|
@ -253,7 +290,13 @@ Feature: Add new next action from every page
|
||||||
And I should see "b"
|
And I should see "b"
|
||||||
And I should see "c"
|
And I should see "c"
|
||||||
|
|
||||||
@javascript
|
Scenarios:
|
||||||
|
| grouping |
|
||||||
|
| project |
|
||||||
|
| context |
|
||||||
|
|
||||||
|
|
||||||
|
@javascript
|
||||||
Scenario: I need to fill in at least one description and a context
|
Scenario: I need to fill in at least one description and a context
|
||||||
When I go to the home page
|
When I go to the home page
|
||||||
And I follow "Add multiple next actions"
|
And I follow "Add multiple next actions"
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ end
|
||||||
|
|
||||||
####### Project #######
|
####### Project #######
|
||||||
|
|
||||||
Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |todo_description, project_name|
|
Then /^I should (see|not see) "([^"]*)" in the project container of "([^"]*)"$/ do |visible, todo_description, project_name|
|
||||||
todo = @current_user.todos.where(:description => todo_description).first
|
todo = @current_user.todos.where(:description => todo_description).first
|
||||||
todo.should_not be_nil
|
todo.should_not be_nil
|
||||||
|
|
||||||
|
|
@ -106,30 +106,20 @@ Then /^I should not see "([^"]*)" in the project container of "([^"]*)"$/ do |to
|
||||||
project.should_not be_nil
|
project.should_not be_nil
|
||||||
|
|
||||||
xpath = "//div[@id='p#{todo.project.id}_items']//div[@id='line_todo_#{todo.id}']"
|
xpath = "//div[@id='p#{todo.project.id}_items']//div[@id='line_todo_#{todo.id}']"
|
||||||
page.should_not have_xpath(xpath)
|
page.send( visible=='see' ? :should : :should_not, have_xpath(xpath))
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "([^"]*)" in project container for "([^"]*)"$/ do |todo_description, project_name|
|
Then(/^I should (see|not see) the project container for "([^"]*)"$/) do |visible, project_name|
|
||||||
todo = @current_user.todos.where(:description => todo_description).first
|
|
||||||
todo.should_not be_nil
|
|
||||||
|
|
||||||
project = @current_user.projects.where(:name => project_name).first
|
|
||||||
project.should_not be_nil
|
|
||||||
|
|
||||||
xpath = "//div[@id='p#{project.id}_items']//div[@id='line_todo_#{todo.id}']"
|
|
||||||
page.should have_xpath(xpath)
|
|
||||||
end
|
|
||||||
|
|
||||||
Then(/^I should see "(.*?)" in the project container for "(.*?)"$/) do |todo_description, project_name|
|
|
||||||
step "I should see \"#{todo_description}\" in project container for \"#{project_name}\""
|
|
||||||
end
|
|
||||||
|
|
||||||
Then /^I should not see the project container for "([^"]*)"$/ do |project_name|
|
|
||||||
project = @current_user.projects.where(:name => project_name).first
|
project = @current_user.projects.where(:name => project_name).first
|
||||||
project.should_not be_nil
|
project.should_not be_nil
|
||||||
|
|
||||||
xpath = "//div[@id='p#{project.id}']"
|
xpath = "//div[@id='p#{project.id}']"
|
||||||
page.should_not have_xpath(xpath, :visible => true)
|
page.send( visible=='see' ? :should : :should_not, have_xpath(xpath, :visible => true))
|
||||||
|
end
|
||||||
|
|
||||||
|
Then(/^the container for the project "(.*?)" should (be visible|not be visible)$/) do |project_name, visible|
|
||||||
|
map = { "be visible" => "see", "not be visible" => "not see"}
|
||||||
|
step("I should #{map[visible]} the project container for \"#{project_name}\"")
|
||||||
end
|
end
|
||||||
|
|
||||||
####### Completed #######
|
####### Completed #######
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ Given /^the date is "(.*?)"$/ do |date|
|
||||||
Timecop.travel(date)
|
Timecop.travel(date)
|
||||||
end
|
end
|
||||||
|
|
||||||
Given(/^I have selected the view for group by project$/) do
|
Given(/^I have selected the view for group by (project|context)$/) do |grouping|
|
||||||
@group_view_by='projects'
|
@group_view_by = grouping
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /the badge should show (.*)/ do |number|
|
Then /the badge should show (.*)/ do |number|
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,23 @@ When /^I submit a new action with description "([^"]*)"$/ do |description|
|
||||||
submit_next_action_form
|
submit_next_action_form
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I submit a new action with description "([^"]*)" in the project "(.*?)"$/ do |description, project_name|
|
||||||
|
within "form#todo-form-new-action" do
|
||||||
|
fill_in "todo[description]", :with => description
|
||||||
|
fill_in "project_name", :with => project_name
|
||||||
|
end
|
||||||
|
submit_next_action_form
|
||||||
|
end
|
||||||
|
|
||||||
|
When(/^I submit a new action with description "([^"]*)" to project "([^"]*)" with tags "([^"]*)"$/) do |description, project_name, tags|
|
||||||
|
within "form#todo-form-new-action" do
|
||||||
|
fill_in "todo[description]", :with => description
|
||||||
|
fill_in "project_name", :with => project_name
|
||||||
|
fill_in "tag_list", :with => tags
|
||||||
|
end
|
||||||
|
submit_next_action_form
|
||||||
|
end
|
||||||
|
|
||||||
When /^I submit a new action with description "([^"]*)" with a dependency on "([^"]*)"$/ do |todo_description, predecessor_description|
|
When /^I submit a new action with description "([^"]*)" with a dependency on "([^"]*)"$/ do |todo_description, predecessor_description|
|
||||||
predecessor = @current_user.todos.where(:description => predecessor_description).first
|
predecessor = @current_user.todos.where(:description => predecessor_description).first
|
||||||
predecessor.should_not be_nil
|
predecessor.should_not be_nil
|
||||||
|
|
@ -287,6 +304,16 @@ When /^I submit a new deferred action with description "([^"]*)" and the tags "(
|
||||||
submit_next_action_form
|
submit_next_action_form
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When(/^I submit a new deferred action with description "([^"]*)" to project "(.*?)" with tags "([^"]*)"$/) do |description, project_name, tags|
|
||||||
|
within "form#todo-form-new-action" do
|
||||||
|
fill_in "todo[description]", :with => description
|
||||||
|
fill_in "todo_project_name", :with => project_name
|
||||||
|
fill_in "tag_list", :with => tags
|
||||||
|
fill_in "todo[show_from]", :with => format_date(@current_user.time + 1.week)
|
||||||
|
end
|
||||||
|
submit_next_action_form
|
||||||
|
end
|
||||||
|
|
||||||
When /^I submit a new deferred action with description "([^"]*)" to project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |description, project_name, tags, context_name|
|
When /^I submit a new deferred action with description "([^"]*)" to project "([^"]*)" with tags "([^"]*)" in the context "([^"]*)"$/ do |description, project_name, tags, context_name|
|
||||||
fill_in "todo[description]", :with => description
|
fill_in "todo[description]", :with => description
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ module NavigationHelpers
|
||||||
options = {}
|
options = {}
|
||||||
options[:format] = :m if @mobile_interface
|
options[:format] = :m if @mobile_interface
|
||||||
options[:locale] = @locale if @locale
|
options[:locale] = @locale if @locale
|
||||||
options[:group_view_by] = @group_view_by if @group_view_by
|
options[:_group_view_by] = @group_view_by if @group_view_by
|
||||||
@source_view = nil
|
@source_view = nil
|
||||||
|
|
||||||
case page_name
|
case page_name
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue