mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-12 18:34:22 +01:00
make sure toggle_check and deleting of todos, recurring_todos and projects work in the new done views
This commit is contained in:
parent
35f947ec57
commit
6e97541ab3
10 changed files with 88 additions and 41 deletions
|
|
@ -7,7 +7,7 @@ class RecurringTodosController < ApplicationController
|
|||
|
||||
def index
|
||||
@page_title = t('todos.recurring_actions_title')
|
||||
|
||||
@source_view = params['_source_view'] || 'recurring_todo'
|
||||
find_and_inactivate
|
||||
@recurring_todos = current_user.recurring_todos.active
|
||||
@completed_recurring_todos = current_user.recurring_todos.completed.find(:all, :limit => 10)
|
||||
|
|
@ -27,6 +27,7 @@ class RecurringTodosController < ApplicationController
|
|||
|
||||
def done
|
||||
@page_title = t('todos.completed_recurring_actions_title')
|
||||
@source_view = params['_source_view'] || 'recurring_todo'
|
||||
items_per_page = 20
|
||||
page = params[:page] || 1
|
||||
@completed_recurring_todos = current_user.recurring_todos.completed.paginate :page => params[:page], :per_page => items_per_page
|
||||
|
|
@ -141,7 +142,6 @@ class RecurringTodosController < ApplicationController
|
|||
end
|
||||
|
||||
def destroy
|
||||
|
||||
# remove all references to this recurring todo
|
||||
@todos = @recurring_todo.todos
|
||||
@number_of_todos = @todos.size
|
||||
|
|
@ -186,7 +186,6 @@ class RecurringTodosController < ApplicationController
|
|||
@completed_remaining = current_user.recurring_todos.completed.count
|
||||
|
||||
# from completed back to active -> check if there is an active todo
|
||||
# current_user.todos.count(:all, {:conditions => ["state = ? AND recurring_todo_id = ?", 'active',params[:id]]})
|
||||
@active_todos = @recurring_todo.todos.active.count
|
||||
# create todo if there is no active todo belonging to the activated
|
||||
# recurring_todo
|
||||
|
|
|
|||
|
|
@ -282,15 +282,11 @@ class TodosController < ApplicationController
|
|||
# check if this todo has a related recurring_todo. If so, create next todo
|
||||
@new_recurring_todo = check_for_next_todo(@todo) if @saved
|
||||
|
||||
if @todo.completed?
|
||||
@pending_to_activate = @todo.pending_to_activate
|
||||
@pending_to_activate.each do |t|
|
||||
t.activate!
|
||||
end
|
||||
else
|
||||
@active_to_block = @todo.active_to_block
|
||||
@active_to_block.each do |t|
|
||||
t.block!
|
||||
if @saved
|
||||
if @todo.completed?
|
||||
@pending_to_activate = @todo.activate_pending_todos
|
||||
else
|
||||
@active_to_block = @todo.block_successors
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1214,17 +1210,13 @@ class TodosController < ApplicationController
|
|||
def update_completed_state
|
||||
if params['done'] == '1' && !@todo.completed?
|
||||
@todo.complete!
|
||||
@todo.pending_to_activate.each do |t|
|
||||
t.activate!
|
||||
end
|
||||
@todo.activate_pending_todos
|
||||
end
|
||||
# strange. if checkbox is not checked, there is no 'done' in params.
|
||||
# Therefore I've used the negation
|
||||
if !(params['done'] == '1') && @todo.completed?
|
||||
@todo.activate!
|
||||
@todo.active_to_block.each do |t|
|
||||
t.block!
|
||||
end
|
||||
@todo.block_successors
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -702,13 +702,7 @@ class RecurringTodo < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def toggle_completion!
|
||||
saved = false
|
||||
if completed?
|
||||
saved = activate!
|
||||
else
|
||||
saved = complete!
|
||||
end
|
||||
return saved
|
||||
return completed? ? activate! : complete!
|
||||
end
|
||||
|
||||
def toggle_star!
|
||||
|
|
|
|||
|
|
@ -210,13 +210,7 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def toggle_completion!
|
||||
saved = false
|
||||
if completed?
|
||||
saved = activate!
|
||||
else
|
||||
saved = complete!
|
||||
end
|
||||
return saved
|
||||
return completed? ? activate! : complete!
|
||||
end
|
||||
|
||||
def show_from
|
||||
|
|
@ -287,14 +281,18 @@ class Todo < ActiveRecord::Base
|
|||
@predecessor_array << t
|
||||
end
|
||||
|
||||
# Return todos that should be activated if the current todo is completed
|
||||
def pending_to_activate
|
||||
return successors.find_all {|t| t.uncompleted_predecessors.empty?}
|
||||
# activate todos that should be activated if the current todo is completed
|
||||
def activate_pending_todos
|
||||
pending_todos = successors.find_all {|t| t.uncompleted_predecessors.empty?}
|
||||
pending_todos.each {|t| t.activate! }
|
||||
return pending_todos
|
||||
end
|
||||
|
||||
# Return todos that should be blocked if the current todo is undone
|
||||
def active_to_block
|
||||
return successors.find_all {|t| t.active? or t.deferred?}
|
||||
def block_successors
|
||||
active_successors = successors.find_all {|t| t.active? or t.deferred?}
|
||||
active_successors.each {|t| t.block!}
|
||||
return active_successors
|
||||
end
|
||||
|
||||
def raw_notes=(value)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<%- if @saved -%>
|
||||
show_empty_messages();
|
||||
TracksPages.page_notify('notice', '<%= escape_javascript(t('todos.recurring_deleted_success') + t(:todo_removed, :count => @number_of_todos)) %>', 5);
|
||||
TracksPages.page_notify('notice', '<%= escape_javascript(t('todos.recurring_deleted_success') + t('todos.recurring_pattern_removed', :count => pluralize(@number_of_todos,t('common.todo')))) %>', 5);
|
||||
remove_recurring_todo_from_page();
|
||||
<%- else -%>
|
||||
TracksPages.page_notify('error', '<%= t('todos.error_deleting_recurring', :description => @recurring_todo.description) %>', 8);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
animation << "activate_pending_todos"
|
||||
animation << "remove_source_container"
|
||||
else
|
||||
animation << "add_todo_to_context"
|
||||
animation << "add_todo_to_context" unless source_view_is(:done)
|
||||
animation << "block_predecessors"
|
||||
end
|
||||
animation << "update_empty_container" if source_view_is_one_of(:tag, :todo) -%>
|
||||
|
|
@ -161,7 +161,7 @@ function remove_source_container(next_steps) {
|
|||
}
|
||||
|
||||
function html_for_todo() {
|
||||
return "<%= @saved ? escape_javascript(render(:partial => @todo, :locals => {
|
||||
return "<%= @saved && !source_view_is(:done) ? escape_javascript(render(:partial => @todo, :locals => {
|
||||
:parent_container_type => parent_container_type,
|
||||
:suppress_project => source_view_is(:project),
|
||||
:suppress_context => source_view_is(:context)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue