diff --git a/tracks/app/controllers/mobile_controller.rb b/tracks/app/controllers/mobile_controller.rb index 2d3ae245..6377a5ac 100644 --- a/tracks/app/controllers/mobile_controller.rb +++ b/tracks/app/controllers/mobile_controller.rb @@ -18,6 +18,7 @@ class MobileController < ApplicationController @todos_pages, @todos = paginate( :todos, :order => 'due IS NULL, due ASC, created_at ASC', :conditions => ['user_id = ? and type = ? and done = ?', @user.id, "Immediate", false], :per_page => 6 ) + @count = @all_todos.reject { |x| x.done? || x.context.hide? }.size end def detail @@ -30,16 +31,24 @@ class MobileController < ApplicationController if params[:id] @item = check_user_return_item else - @item = @user.todos.build + if params[:item][:"show_from(1i)"] == "" + @item = Immediate.create(params[:item]) if params[:item] + else + @item = Deferred.create(params[:item]) if params[:item] + end end - @item.attributes = params[:item] + @item.user_id = @user.id if @item.save redirect_to :action => 'list' else - flash["warning"] = "Action could not be saved" - redirect_to :action => 'list' + self.init + if params[:id] + render :partial => 'mobile_edit' + else + render :action => 'show_add_form' + end end end @@ -49,17 +58,20 @@ class MobileController < ApplicationController def filter self.init + @type = params[:type] case params[:type] when 'context' @context = Context.find( params[:context][:id] ) @page_title = @desc = "#{@context.name}" @todos_pages, @todos = paginate( :todos, :order => 'due IS NULL, due ASC, created_at ASC', :conditions => ['user_id = ? and type = ? and done = ? and context_id = ?', @user.id, "Immediate", false, @context.id], :per_page => 6 ) + @count = @all_todos.reject { |x| x.done? || x.context_id != @context.id }.size when 'project' @project = Project.find( params[:project][:id] ) @page_title = @desc = "#{@project.name}" @todos_pages, @todos = paginate( :todos, :order => 'due IS NULL, due ASC, created_at ASC', :conditions => ['user_id = ? and type = ? and done = ? and project_id = ?', @user.id, "Immediate", false, @project.id], :per_page => 6 ) + @count = @all_todos.reject { |x| x.done? || x.project_id != @project.id }.size end end @@ -80,6 +92,7 @@ class MobileController < ApplicationController :conditions => ['user_id = ?', @user.id] @projects = Project.find :all, :order => 'position ASC', :conditions => ['user_id = ? and done = ?', @user.id, false] + @all_todos = Todo.find(:all, :conditions => ['user_id = ? and type = ?', @user.id, "Immediate"]) end end diff --git a/tracks/app/views/mobile/_add_new_action_form.rhtml b/tracks/app/views/mobile/_add_new_action_form.rhtml deleted file mode 100644 index 2e705249..00000000 --- a/tracks/app/views/mobile/_add_new_action_form.rhtml +++ /dev/null @@ -1,14 +0,0 @@ -
-<%= text_field( "item", "description", "size" => 25, "tabindex" => 1) %>
- -<%= text_area( "item", "notes", "cols" => 25, "rows" => 10, "tabindex" => 2) %>
- -<%= collection_select( "item", "context_id", @contexts, "id", "name", - {}, {"tabindex" => 3}) %>
- -<%= collection_select( "item", "project_id", @projects, "id", "name", - { :include_blank => true }, {"tabindex" => 4}) %>
- -<%= text_field("item", "due", "size" => 10, "tabindex" => 5, "autocomplete" => "off") %>
-<%= hidden_field("type", "new") %> - \ No newline at end of file diff --git a/tracks/app/views/mobile/_mobile_actions.rhtml b/tracks/app/views/mobile/_mobile_actions.rhtml index f1403518..feaa71c4 100644 --- a/tracks/app/views/mobile/_mobile_actions.rhtml +++ b/tracks/app/views/mobile/_mobile_actions.rhtml @@ -1,3 +1,6 @@ +<% if @todos.length == 0 -%> +There are no uncompleted actions in this <%= @type %>
+<% else -%><%= check_box("item", "done", "tabindex" => 1) %>
@@ -10,5 +13,9 @@<%= collection_select( "item", "project_id", @projects, "id", "name", {:include_blank => true}, {"tabindex" => 5} ) %>
-<%= date_select("item", "due", :order => [:day, :month, :year], :include_blank => true) %>
+<%= date_select("item", "due", :order => [:day, :month, :year], + :start_year => this_year, :include_blank => true) %>
+ +<%= date_select("item", "show_from", :order => [:day, :month, :year], + :start_year => this_year, :include_blank => true) %>
\ No newline at end of file diff --git a/tracks/app/views/mobile/detail.rhtml b/tracks/app/views/mobile/detail.rhtml index d92ca79b..d8f09459 100644 --- a/tracks/app/views/mobile/detail.rhtml +++ b/tracks/app/views/mobile/detail.rhtml @@ -1,4 +1,4 @@ <%= form_tag :action => 'update_action', :id => @item.id %> - <%= render :partial => 'mobile_edit', :locals => {:type => "updated"} %> + <%= render :partial => 'mobile_edit' %> <%= end_form_tag %> <%= button_to "Back", :controller => 'mobile', :action => 'list' %> \ No newline at end of file diff --git a/tracks/app/views/mobile/filter.rhtml b/tracks/app/views/mobile/filter.rhtml index c2f50609..05c85777 100644 --- a/tracks/app/views/mobile/filter.rhtml +++ b/tracks/app/views/mobile/filter.rhtml @@ -1,5 +1,6 @@ -