mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-18 05:08:09 +01:00
Remove 'project_hidden' state
Compute it using project/context state Notable change: todo.hidden? now also returns true if the todo is completed
This commit is contained in:
parent
543f49ed8a
commit
ed3bca22a4
12 changed files with 66 additions and 106 deletions
|
|
@ -75,7 +75,9 @@ class ApplicationController < ActionController::Base
|
|||
if todos_parent.nil?
|
||||
count = 0
|
||||
elsif (todos_parent.is_a?(Project) && todos_parent.hidden?)
|
||||
count = @project_project_hidden_todo_counts[todos_parent.id]
|
||||
count = @project_hidden_todo_counts[todos_parent.id]
|
||||
elsif (todos_parent.is_a?(Context) && todos_parent.hidden?)
|
||||
count = @context_hidden_todo_counts[todos_parent.id]
|
||||
else
|
||||
count = eval "@#{todos_parent.class.to_s.downcase}_not_done_counts[#{todos_parent.id}]"
|
||||
end
|
||||
|
|
@ -200,7 +202,10 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
init_not_done_counts
|
||||
if prefs.show_hidden_projects_in_sidebar
|
||||
init_project_hidden_todo_counts(['project'])
|
||||
init_hidden_todo_counts(['project'])
|
||||
end
|
||||
if prefs.show_hidden_contexts_in_sidebar
|
||||
init_hidden_todo_counts(['context'])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -211,9 +216,9 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def init_project_hidden_todo_counts(parents = ['project','context'])
|
||||
def init_hidden_todo_counts(parents = ['project', 'context'])
|
||||
parents.each do |parent|
|
||||
eval("@#{parent}_project_hidden_todo_counts ||= current_user.todos.active_or_hidden.count_by_group('#{parent}_id')")
|
||||
eval("@#{parent}_hidden_todo_counts ||= current_user.todos.active_or_hidden.count_by_group('#{parent}_id')")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ class ContextsController < ApplicationController
|
|||
@active_contexts = current_user.contexts.active
|
||||
@hidden_contexts = current_user.contexts.hidden
|
||||
@closed_contexts = current_user.contexts.closed
|
||||
init_not_done_counts(['context']) unless request.format == :autocomplete
|
||||
unless request.format == :autocomplete
|
||||
init_not_done_counts(['context'])
|
||||
init_hidden_todo_counts(['context'])
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html &render_contexts_html
|
||||
|
|
@ -37,7 +40,7 @@ class ContextsController < ApplicationController
|
|||
unless @context.nil?
|
||||
@max_completed = current_user.prefs.show_number_completed
|
||||
@done = @context.todos.completed.limit(@max_completed).reorder("todos.completed_at DESC, todos.created_at DESC").includes(Todo::DEFAULT_INCLUDES)
|
||||
@not_done_todos = @context.todos.active.reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC").includes(Todo::DEFAULT_INCLUDES)
|
||||
@not_done_todos = @context.todos.active_or_hidden.not_project_hidden.reorder('todos.due IS NULL, todos.due ASC, todos.created_at ASC').includes(Todo::DEFAULT_INCLUDES)
|
||||
@todos_without_project = @not_done_todos.select{|t| t.project.nil?}
|
||||
|
||||
@deferred_todos = @context.todos.deferred.includes(Todo::DEFAULT_INCLUDES)
|
||||
|
|
@ -77,6 +80,7 @@ class ContextsController < ApplicationController
|
|||
format.js do
|
||||
@down_count = current_user.contexts.size
|
||||
init_not_done_counts
|
||||
init_hidden_todo_counts(['context'])
|
||||
end
|
||||
format.xml do
|
||||
if @context.new_record?
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class ProjectsController < ApplicationController
|
|||
else
|
||||
@contexts = current_user.contexts
|
||||
init_not_done_counts(['project'])
|
||||
init_project_hidden_todo_counts(['project'])
|
||||
init_hidden_todo_counts(['project'])
|
||||
if params[:only_active_with_no_next_actions]
|
||||
@projects = current_user.projects.active.select { |p| count_undone_todos(p) == 0 }
|
||||
else
|
||||
|
|
@ -64,7 +64,7 @@ class ProjectsController < ApplicationController
|
|||
@current_projects = projects.uncompleted.select { |p| not (p.needs_review?(current_user)) }.sort_by { |p| p.last_reviewed || Time.zone.at(0) }
|
||||
|
||||
init_not_done_counts(['project'])
|
||||
init_project_hidden_todo_counts(['project'])
|
||||
init_hidden_todo_counts(['project'])
|
||||
current_user.projects.cache_note_counts
|
||||
|
||||
@page_title = t('projects.list_reviews')
|
||||
|
|
@ -220,7 +220,7 @@ class ProjectsController < ApplicationController
|
|||
@contexts = current_user.contexts
|
||||
update_state_counts
|
||||
init_data_for_sidebar
|
||||
init_project_hidden_todo_counts(['project'])
|
||||
init_hidden_todo_counts(['project'])
|
||||
|
||||
template = 'projects/update'
|
||||
|
||||
|
|
@ -292,7 +292,7 @@ class ProjectsController < ApplicationController
|
|||
@projects = current_user.projects.alphabetize(:state => @state) if @state
|
||||
@contexts = current_user.contexts
|
||||
init_not_done_counts(['project'])
|
||||
init_project_hidden_todo_counts(['project']) if @state == 'hidden'
|
||||
init_hidden_todo_counts(['project']) if @state == 'hidden'
|
||||
end
|
||||
|
||||
def actionize
|
||||
|
|
@ -300,7 +300,7 @@ class ProjectsController < ApplicationController
|
|||
@projects = current_user.projects.actionize(:state => @state) if @state
|
||||
@contexts = current_user.contexts
|
||||
init_not_done_counts(['project'])
|
||||
init_project_hidden_todo_counts(['project']) if @state == 'hidden'
|
||||
init_hidden_todo_counts(['project']) if @state == 'hidden'
|
||||
end
|
||||
|
||||
def done_todos
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class SearchController < ApplicationController
|
|||
@count = searcher.number_of_finds
|
||||
|
||||
init_not_done_counts
|
||||
init_project_hidden_todo_counts
|
||||
init_hidden_todo_counts
|
||||
end
|
||||
|
||||
def index
|
||||
|
|
|
|||
|
|
@ -99,8 +99,7 @@ class TodosController < ApplicationController
|
|||
@todo.add_predecessor_list(p.predecessor_list)
|
||||
@saved = @todo.save
|
||||
@todo.tag_with(tag_list) if @saved && tag_list.present?
|
||||
@todo.update_state_from_project if @saved
|
||||
@todo.block! if @todo.should_be_blocked?
|
||||
@todo.block! if @todo.uncompleted_predecessors?
|
||||
else
|
||||
@saved = false
|
||||
end
|
||||
|
|
@ -448,7 +447,9 @@ class TodosController < ApplicationController
|
|||
@todo.reload # refresh context and project object too (not only their id's)
|
||||
|
||||
update_dependency_state
|
||||
update_todo_state_if_project_changed
|
||||
if @project_changed
|
||||
@remaining_undone_in_project = current_user.projects.find(@original_item_project_id).todos.active.count if source_view_is :project
|
||||
end
|
||||
|
||||
determine_changes_by_this_update
|
||||
determine_remaining_in_container_count( (@context_changed || @project_changed) ? @original_item : @todo)
|
||||
|
|
@ -588,7 +589,7 @@ class TodosController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html do
|
||||
init_not_done_counts
|
||||
init_project_hidden_todo_counts
|
||||
init_hidden_todo_counts
|
||||
init_data_for_sidebar unless mobile?
|
||||
end
|
||||
format.m
|
||||
|
|
@ -1189,12 +1190,6 @@ end
|
|||
end
|
||||
end
|
||||
|
||||
def update_todo_state_if_project_changed
|
||||
if @project_changed
|
||||
@todo.update_state_from_project
|
||||
@remaining_undone_in_project = current_user.projects.find(@original_item_project_id).todos.active.count if source_view_is :project
|
||||
end
|
||||
end
|
||||
|
||||
def update_context
|
||||
@context_changed = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue