fix #1255. Context view now has seperate container for pending and deferred todos

This commit is contained in:
Reinier Balt 2012-03-23 14:04:55 +01:00
parent e1c0ff0683
commit dd957f0feb
10 changed files with 475 additions and 431 deletions

View file

@ -277,10 +277,13 @@ class ContextsController < ApplicationController
# search manually until I can work out a way to do the same thing using
# not_done_todos acts_as_todo_container method Hides actions in hidden
# projects from context.
@not_done_todos = @context.todos.not_completed(
@not_done_todos = @context.todos.active(
:order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC",
:include => Todo::DEFAULT_INCLUDES)
@deferred = @context.todos.deferred(:include => Todo::DEFAULT_INCLUDES)
@pending = @context.todos.pending(:include => Todo::DEFAULT_INCLUDES)
@projects = current_user.projects
@count = @not_done_todos.size

View file

@ -529,7 +529,7 @@ class TodosController < ApplicationController
format.js do
if @saved
determine_down_count
if source_view_is_one_of(:todo, :deferred, :project)
if source_view_is_one_of(:todo, :deferred, :project, :context)
determine_remaining_in_context_count(@context_id)
elsif source_view_is :calendar
@original_item_due_id = get_due_id_for_calendar(@original_item_due)
@ -1136,13 +1136,18 @@ class TodosController < ApplicationController
}
from.context {
context = current_user.contexts.find(context_id)
@remaining_deferred_or_pending_count = context.todos.deferred_or_blocked.count
remaining_actions_in_context = context.todos(true).active
remaining_actions_in_context = remaining_actions_in_context.not_hidden if !context.hide?
@remaining_in_context = remaining_actions_in_context.count
actions_in_target = current_user.contexts.find(@todo.context_id).todos(true).active
actions_in_target = actions_in_target.not_hidden if !context.hide?
if @todo_was_deferred_or_blocked
actions_in_target = current_user.contexts.find(@todo.context_id).todos(true).active
actions_in_target = actions_in_target.not_hidden if !context.hide?
else
actions_in_target = @todo.context.todos.deferred_or_blocked
end
@target_context_count = actions_in_target.count
}
end

View file

@ -311,7 +311,7 @@ module TodosHelper
def update_needs_to_remove_todo_from_container
source_view do |page|
page.context { return @context_changed || @todo.deferred? || @todo.pending? || @todo_should_be_hidden }
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 }
@ -339,7 +339,7 @@ module TodosHelper
def append_updated_todo
source_view do |page|
page.context { return false }
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 }
@ -380,13 +380,31 @@ module TodosHelper
@todo_was_blocked_from_active_state ||
@todo_was_destroyed_from_deferred_state ||
@todo_was_created_deferred ||
@todo_was_blocked_from_completed_state
@todo_was_blocked_from_completed_state ||
@todo_was_created_blocked
return "hidden-empty-nd" if @todo.hidden?
return "c#{todo.context_id}empty-nd"
}
page.calendar {
return "tickler-empty-nd" if
@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
return "empty_#{@new_due_id}"
}
page.context {
return "tickler-empty-nd" if
@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
return "c#{todo.context_id}empty-nd"
}
end
return "c#{todo.context_id}empty-nd"
@ -418,6 +436,7 @@ module TodosHelper
}
page.context {
container_id = "c#{@original_item_context_id}empty-nd" if @remaining_in_context == 0
container_id = "tickler-empty-nd" if todo_was_removed_from_deferred_or_blocked_container && @remaining_deferred_or_pending_count == 0
container_id = "empty-d" if @completed_count && @completed_count == 0 && !@todo.completed?
}
page.todo { container_id = "c#{@original_item_context_id}empty-nd" if @remaining_in_context == 0 }

View file

@ -16,5 +16,5 @@
<div class="message"><p><%= t 'contexts.no_actions' %></p></div>
</div>
<%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "context" } %>
</div><!-- [end:items] -->
</div><!-- [end:c<%= context.id %>] -->
</div>
</div>

View file

@ -1,5 +1,6 @@
<div id="display_box">
<%= render :partial => "contexts/context", :object => @context, :locals => { :collapsible => false } %>
<%= render :partial => "todos/deferred", :object => @deferred, :locals => { :collapsible => false, :append_descriptor => t('contexts.todos_append'), :parent_container_type => 'context', :pending => @pending } %>
<% unless @max_completed==0 -%>
<%= render :partial => "todos/completed", :object => @done, :locals => { :suppress_context => true, :collapsible => false, :append_descriptor => t('contexts.last_completed_in_context', :number=>prefs.show_number_completed) } %>
<% end -%>

View file

@ -9,7 +9,7 @@
remove_successor_from_page();
replace_updated_predecessor();
regenerate_predecessor_family();
<%= "show_in_tickler_box();" if source_view_is_one_of :project, :tag %>
<%= "show_in_tickler_box();" if source_view_is_one_of :project, :tag, :context %>
TracksPages.page_notify('notice', "<%= @status_message %>", 5);
function remove_successor_from_page() {

View file

@ -26,7 +26,7 @@ function regenerate_predecessor_family() {
function update_successor() {
<%
if @successor.active? -%>
<%= "remove_successor();" unless source_view_is_one_of(:todo, :context) %>
<%= "remove_successor();" unless source_view_is(:todo) %>
<%= "hide_empty_message();" unless empty_container_msg_div_id.nil? %>
<%= "show_empty_deferred_message(); " if @remaining_deferred_or_pending_count == 0 %>
<% if source_view_is_one_of(:todo, :deferred, :tag) -%>

View file

@ -54,7 +54,10 @@ function add_to_existing_container(next_steps) {
});
<% else -%>
next_steps.go();
<% if (@target_context_count==1) || (@todo.deferred? && @remaining_deferred_or_pending_count == 1) || (@todo.hidden? && @remaining_hidden_count == 1) -%>
<% if (@target_context_count==1) ||
( (@todo.deferred? || @todo.pending?) && @remaining_deferred_or_pending_count == 1) ||
( @todo.hidden? && @remaining_hidden_count == 1)
-%>
$("#<%= empty_container_msg_div_id %>").slideUp(100);
<% end -%>
<% end -%>

View file

@ -877,6 +877,7 @@ en:
no_contexts_hidden: Currently there are no hidden contexts
new_context_pre: New context '
status_hidden: Context is hidden
todos_append: in this context
login:
login_cas: go to the CAS
sign_in: Sign in

File diff suppressed because it is too large Load diff