diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index 082a2e0d..02de0421 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -14,6 +14,7 @@ class TodoController < ApplicationController @page_title = "List tasks" @projects = Project.find_all @places = Context.find_all( "hide=0", "id ASC") + @hidden_places = Context.find_all( "hide=1") @done = Todo.find_all( "done=1", "completed DESC", 5 ) @count = Todo.count( "done=0" ) end @@ -32,33 +33,23 @@ class TodoController < ApplicationController # def add_item @item = Todo.new - @item.attributes = @params["new_item"] + @item.attributes = @params["item"] # Convert the date format entered (as set in config/settings.yml) # to the mysql format YYYY-MM-DD - if @params["new_item"]["due"] != "" + if @params["item"]["due"] != "" date_fmt = app_configurations["formats"]["date"] - formatted_date = DateTime.strptime(@params["new_item"]["due"], "#{date_fmt}") + formatted_date = DateTime.strptime(@params["item"]["due"], "#{date_fmt}") @item.due = formatted_date.strftime("%Y-%m-%d") else @item.due = "0000-00-00" end - # This doesn't seem to be working. No error, but the error - # message isn't printed either. - unless @item.errors.empty? - error_msg = '' - @item.errors.each_full do |message| - error_msg << message - end - return error_msg - end - - if @item.save + if @item.save flash["confirmation"] = "Next action was successfully added" redirect_to( :action => "list" ) else - flash["warning"] = "Couldn't add the action because of an error: #{error_msg}" + flash["warning"] = "Couldn't add the action because of an error" redirect_to( :action => "list" ) end end diff --git a/tracks/app/views/context/_not_done.rhtml b/tracks/app/views/context/_not_done.rhtml index 4d9d8ff7..2b45e48d 100644 --- a/tracks/app/views/context/_not_done.rhtml +++ b/tracks/app/views/context/_not_done.rhtml @@ -1,6 +1,7 @@ <% @item = not_done %> - <%= check_box( "item", "done", "onclick" => "document.location.href='/todo/toggle_check/#{@item.id}'" ) %> + + <%= check_box( "item", "done", "onclick" => "document.location.href='/todo/toggle_check/#{@item.id}'" ) %> <%= link_to( $edit_img, { :action => "edit", :id => @item.id }, :title => "Edit item" ) + " " + link_to($delete_img, { :controller => "todo", :action => "destroy", :id => @item.id }, :title => "Delete item", :confirm => "Are you sure you want to delete this entry: #{@item.description}" ) + " " %> <%= due_date( @item.due ) %> <%= @item.description %> diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml index 9f126640..ec21696e 100644 --- a/tracks/app/views/layouts/standard.rhtml +++ b/tracks/app/views/layouts/standard.rhtml @@ -6,6 +6,7 @@ + <%= @page_title %> diff --git a/tracks/app/views/todo/_done.rhtml b/tracks/app/views/todo/_done.rhtml index 9cf3cae9..a50832c0 100644 --- a/tracks/app/views/todo/_done.rhtml +++ b/tracks/app/views/todo/_done.rhtml @@ -1,24 +1,24 @@ -<% @item = done %> +<% @done_item = done %> -<% if @item.completed %> +<% if @done_item.completed %> <%= $done_img %> - <%= format_date( @item.completed ) %> - <%= " " + @item.description + " "%> + <%= format_date( @done_item.completed ) %> + <%= " " + @done_item.description + " "%> - <% if @item.project_id %> - <%= "(" + @item.context['name'].capitalize + ", " + @item.project['name'] + ")" %> + <% if @done_item.project_id %> + <%= "(" + @done_item.context['name'].capitalize + ", " + @done_item.project['name'] + ")" %> <% else %> - <%= "(" + @item.context['name'].capitalize + ")" %> + <%= "(" + @done_item.context['name'].capitalize + ")" %> <% end %> - <% if @item.due %> - <%= " - was due on " + format_date( @item.due ) %> + <% if @done_item.due %> + <%= " - was due on " + format_date( @done_item.due ) %> <% end %> - <% if @item.notes? %> - <%= "" + $notes_img + "" %> - <% m_notes = markdown( @item.notes ) %> - <%= "
" + m_notes + "
" %> + <% if @done_item.notes? %> + <%= "" + $notes_img + "" %> + <% m_notes = markdown( @done_item.notes ) %> + <%= "
" + m_notes + "
" %> <% end %> <% end %> diff --git a/tracks/app/views/todo/_item.rhtml b/tracks/app/views/todo/_item.rhtml new file mode 100644 index 00000000..2450abfa --- /dev/null +++ b/tracks/app/views/todo/_item.rhtml @@ -0,0 +1,40 @@ +<%= hidden_field( "item", "id" ) %> +
+<%= text_field( "item", "description" ) %> +
+
+<%= text_area( "item", "notes", "cols" => 35, "rows" => 15 ) %> +
+
+ +
+
+ +
+
+<%= text_field( "item", "due", {"size" => 10, "maxlength" => 10} ) %> +
diff --git a/tracks/app/views/todo/_not_done.rhtml b/tracks/app/views/todo/_not_done.rhtml index a0a88ed8..c2c35661 100644 --- a/tracks/app/views/todo/_not_done.rhtml +++ b/tracks/app/views/todo/_not_done.rhtml @@ -1,16 +1,18 @@ -<% @item = not_done %> +<% @notdone_item = not_done %> - <%= check_box( "item", "done", "onclick" => "document.location.href='/todo/toggle_check/#{@item.id}'" ) %> - <%= link_to( $edit_img, { :action => "edit", :id => @item.id }, :title => "Edit item" ) + " " + link_to($delete_img, { :action => "destroy", :id => @item.id }, :title => "Delete item", :confirm => "Are you sure you want to delete this entry: #{@item.description}" ) + " " %> - <%= due_date( @item.due ) %> - <%= @item.description %> - <% if @item.project_id %> - <%= link_to( "[P]", { :controller => "project", :action => "show", :id => @item.project_id }, :title => "View project: #{@item.project['name']}" ) %> + + + <%= check_box( "item", "done", "onclick" => "document.location.href='/todo/toggle_check/#{@notdone_item.id}'" ) %> + <%= link_to( $edit_img, { :action => "edit", :id => @notdone_item.id }, :title => "Edit item" ) + " " + link_to($delete_img, { :action => "destroy", :id => @notdone_item.id }, :title => "Delete item", :confirm => "Are you sure you want to delete this entry: #{@notdone_item.description}" ) + " " %> + <%= due_date( @notdone_item.due ) %> + <%= @notdone_item.description %> + <% if @notdone_item.project_id %> + <%= link_to( "[P]", { :controller => "project", :action => "show", :id => @notdone_item.project_id }, :title => "View project: #{@notdone_item.project['name']}" ) %> <% end %> - <% if @item.notes? %> - <%= "" + $notes_img + "" %> - <% m_notes = markdown( @item.notes ) %> - <%= "
" + m_notes + "
" %> + <% if @notdone_item.notes? %> + <%= "" + $notes_img + "" %> + <% m_notes = markdown( @notdone_item.notes ) %> + <%= "
" + m_notes + "
" %> <% end %> \ No newline at end of file diff --git a/tracks/app/views/todo/edit.rhtml b/tracks/app/views/todo/edit.rhtml index 3ecb129e..fefddad0 100644 --- a/tracks/app/views/todo/edit.rhtml +++ b/tracks/app/views/todo/edit.rhtml @@ -1,45 +1,9 @@

Update task

- <%= hidden_field( "item", "id" ) %> - -


- <%= text_field( "item", "description" ) %>

- -


- <%= text_area( "item", "notes" ) %>

- -


-

- -


-

- -


- <%= text_field( "item", "due" ) %>

- -

-
+ <%= render_partial "todo/item", "@item" %> + + <%= link_to 'Cancel', :action => 'list' %>
diff --git a/tracks/app/views/todo/list.rhtml b/tracks/app/views/todo/list.rhtml index c3c54ae8..1c639769 100644 --- a/tracks/app/views/todo/list.rhtml +++ b/tracks/app/views/todo/list.rhtml @@ -4,7 +4,7 @@ <% if !@not_done.empty? %>

<%= link_to( "#{@place.name.capitalize}", :controller => "context", :action => "show", :id => @place.id ) %>

- +
<%= render_collection_of_partials "not_done", @not_done %>
@@ -13,46 +13,25 @@

Last 5 completed actions

- +
<%= render_collection_of_partials "done", @done %>
+ +

Hidden contexts: +<% for @hidden_place in @hidden_places %> + "show", :id => "#{@hidden_place.id}" ) %>"><%= @hidden_place.name.capitalize %> | +<% end %> +

+ -
- - -

Add next action

-
-
- <%= text_field( "new_item", "description" ) %> -
-
- <%= text_area( "new_item", "notes", "cols" => 35, "rows" => 15 ) %> -
-
- -
-
- -
-
- <%= text_field( "new_item", "due", {"size" => 10, "maxlength" => 10} ) %> -
- -
- +
+

Add next action

+
+ <%= render_partial "todo/item", @item %> + +
<% if @flash["confirmation"] %>
<%= @flash["confirmation"] %>
<% end %> diff --git a/tracks/config/environment.rb b/tracks/config/environment.rb index d7918be9..3245cd1d 100644 --- a/tracks/config/environment.rb +++ b/tracks/config/environment.rb @@ -24,11 +24,11 @@ ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(di # Require Rails gems. -require 'rubygems' -require_gem 'activerecord' -require_gem 'actionpack' -require_gem 'actionmailer' -require_gem 'rails' + require 'rubygems' + require_gem 'activerecord' + require_gem 'actionpack' + require_gem 'actionmailer' + require_gem 'rails' # Environment-specific configuration. diff --git a/tracks/config/environments/development.rb b/tracks/config/environments/development.rb index aff146de..83f0c0de 100644 --- a/tracks/config/environments/development.rb +++ b/tracks/config/environments/development.rb @@ -2,4 +2,4 @@ Dependencies.mechanism = :load ActionController::Base.consider_all_requests_local = true BREAKPOINT_SERVER_PORT = 42531 -ActionController::Base.fragment_cache_store = ActionController::Caching::Fragments::MemoryStore.new +ActionController::Base.fragment_cache_store = ActionController::Caching::Fragments::FileStore.new("localhost") diff --git a/tracks/config/environments/production.rb b/tracks/config/environments/production.rb index e4065d91..36b14d79 100644 --- a/tracks/config/environments/production.rb +++ b/tracks/config/environments/production.rb @@ -1,5 +1,5 @@ Dependencies.mechanism = :require ActionController::Base.consider_all_requests_local = false -ActionController::Base.fragment_cache_store = ActionController::Caching::Fragments::MemoryStore.new +ActionController::Base.fragment_cache_store = ActionController::Caching::Fragments::FileStore.new("localhost") diff --git a/tracks/doc/CHANGENOTES.txt b/tracks/doc/CHANGENOTES.txt index 2af10d3c..a1eacb9f 100644 --- a/tracks/doc/CHANGENOTES.txt +++ b/tracks/doc/CHANGENOTES.txt @@ -12,6 +12,7 @@ Project wiki: 3. Added action caching. 4. Did a bit of refactoring to try to make page loading a bit more efficient. 5. Added a new row to the context table: 'hide'. This determines whether a particular context gets hidden on the main page. If the checkbox on the add new context form is checked, the context is hidden, and isn't listed on the front (todo/list) page. This is useful for contexts like 'wish list' or 'someday/maybe' that you don't want taking up your attention all the time. +6. Added a list of links to the hidden contexts at the bottom of the page. ## Version 1.01 diff --git a/tracks/public/stylesheets/standard.css b/tracks/public/stylesheets/standard.css index 88eb0f0d..2dfdbb92 100644 --- a/tracks/public/stylesheets/standard.css +++ b/tracks/public/stylesheets/standard.css @@ -17,6 +17,8 @@ p { a, a:link, a:active, a:visited { color: #cc3334; text-decoration: none; + padding-left: 1px; + padding-right: 1px; } a:hover {