From 7672112dd54ac3cc801e06db4fe4c5444f1a9145 Mon Sep 17 00:00:00 2001 From: lukemelia Date: Thu, 27 Sep 2007 03:08:50 +0000 Subject: [PATCH] Committed Reinier Balt's patch to hide contexts on the mobile view's home page that are marked hidden in Tracks. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@602 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/todos_controller.rb | 35 ++++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/tracks/app/controllers/todos_controller.rb b/tracks/app/controllers/todos_controller.rb index 9915c5e3..6368e227 100644 --- a/tracks/app/controllers/todos_controller.rb +++ b/tracks/app/controllers/todos_controller.rb @@ -13,8 +13,8 @@ class TodosController < ApplicationController @projects = current_user.projects.find(:all, :include => [ :todos ]) @contexts = current_user.contexts.find(:all, :include => [ :todos ]) - @contexts_to_show = @contexts.reject {|x| x.hide? } - + @contexts_to_show = @contexts.reject {|x| x.hide? } + respond_to do |format| format.html &render_todos_html format.m &render_todos_mobile @@ -409,19 +409,11 @@ class TodosController < ApplicationController def init_todos with_feed_query_scope do - with_parent_resource_scope do + with_parent_resource_scope do # @context or @project may get defined here with_limit_scope do if mobile? - - @todos, @page = current_user.todos.paginate(:all, - :conditions => ['state = ?', 'active' ], :include => [:context], - :order => 'due IS NULL, due ASC, todos.created_at ASC', - :page => params[:page], :per_page => prefs.mobile_todos_per_page) - @pagination_params = { :format => :m } - @pagination_params[:context_id] = @context.to_param if @context - @pagination_params[:project_id] = @project.to_param if @project - + init_todos_for_mobile_view else # Note: these next two finds were previously using current_users.todos.find but that broke with_scope for :limit @@ -439,6 +431,23 @@ class TodosController < ApplicationController end end + def init_todos_for_mobile_view + if @context or @project + conditions = ['state = ?', 'active'] + else + conditions = ['state = ? AND hide = ?', 'active', false] # hidden todos should not be visible in the homepage view + end + + @todos, @page = current_user.todos.paginate(:all, + :conditions => conditions, + :include => [:context], + :order => 'due IS NULL, due ASC, todos.created_at ASC', + :page => params[:page], :per_page => prefs.mobile_todos_per_page) + @pagination_params = { :format => :m } + @pagination_params[:context_id] = @context.to_param if @context + @pagination_params[:project_id] = @project.to_param if @project + end + def determine_down_count source_view do |from| from.todo do @@ -513,7 +522,7 @@ class TodosController < ApplicationController else determine_down_count end - + render :action => 'index_mobile' end end