diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index af6eecd1..d87db7d6 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -33,6 +33,7 @@ class TodoController < ApplicationController def create @item = @user.todos.build p = params['request'] || params + # @item.tag_with(params[:tag_list]) @item.attributes = p['todo'] if p['todo']['project_id'].blank? && !p['project_name'].blank? && p['project_name'] != 'None' @@ -69,6 +70,7 @@ class TodoController < ApplicationController @item.show_from = parse_date_per_user_prefs(p['todo']['show_from']) end + @item.tag_with(params[:tag_list], @user) @saved = @item.save respond_to do |wants| @@ -124,6 +126,7 @@ class TodoController < ApplicationController def update @item = check_user_return_item + @item.tag_with(params[:tag_list], @user) @original_item_context_id = @item.context_id @original_item_project_id = @item.project_id @original_item_was_deferred = @item.deferred? @@ -159,6 +162,8 @@ class TodoController < ApplicationController params['item']['show_from'] = parse_date_per_user_prefs(params['item']['show_from']) end + + @saved = @item.update_attributes params["item"] @context_changed = @original_item_context_id != @item.context_id @item_was_activated_from_deferred_state = @original_item_was_deferred && @item.active? @@ -234,6 +239,19 @@ class TodoController < ApplicationController end end + # /todo/tag/[tag_name] shows all the actions tagged with tag_name + # + def tag + @tag = tag_name = params[:id] + if Tag.find_by_name(tag_name) + @todos = Todo.find_tagged_with(tag_name, @user) + else + @todos = [] + end + + @count = @todos.size unless @todos.empty? + end + private def check_user_return_item diff --git a/tracks/app/models/todo.rb b/tracks/app/models/todo.rb index e11c3807..9e525edb 100644 --- a/tracks/app/models/todo.rb +++ b/tracks/app/models/todo.rb @@ -5,6 +5,7 @@ class Todo < ActiveRecord::Base belongs_to :project belongs_to :user + acts_as_taggable acts_as_state_machine :initial => :active, :column => 'state' state :active, :enter => Proc.new { |t| t[:show_from] = nil } diff --git a/tracks/app/models/user.rb b/tracks/app/models/user.rb index 98717aa4..8a0f5d93 100644 --- a/tracks/app/models/user.rb +++ b/tracks/app/models/user.rb @@ -33,6 +33,8 @@ class User < ActiveRecord::Base end has_many :notes, :order => "created_at DESC", :dependent => :delete_all has_one :preference, :dependent => :destroy + has_many :taggings + has_many :tags, :through => :taggings, :select => "DISTINCT tags.*" attr_protected :is_admin diff --git a/tracks/app/views/shared/_add_new_item_form.rhtml b/tracks/app/views/shared/_add_new_item_form.rhtml index a1da6b83..30c58da4 100644 --- a/tracks/app/views/shared/_add_new_item_form.rhtml +++ b/tracks/app/views/shared/_add_new_item_form.rhtml @@ -43,14 +43,17 @@ Event.observe($('todo_project_name'), "focus", projectAutoCompleter.activate.bin Event.observe($('todo_project_name'), "click", projectAutoCompleter.activate.bind(projectAutoCompleter)); + +<%= text_field_tag "tag_list", nil, :size => 40, :tabindex => 5 %> + -<%= text_field("todo", "due", "size" => 10, "class" => "Date", "onfocus" => "Calendar.setup", "tabindex" => 5, "autocomplete" => "off") %> +<%= text_field("todo", "due", "size" => 10, "class" => "Date", "onfocus" => "Calendar.setup", "tabindex" => 6, "autocomplete" => "off") %> - <%= text_field("todo", "show_from", "size" => 10, "class" => "Date", "onfocus" => "Calendar.setup", "tabindex" => 6, "autocomplete" => "off") %> + <%= text_field("todo", "show_from", "size" => 10, "class" => "Date", "onfocus" => "Calendar.setup", "tabindex" => 7, "autocomplete" => "off") %> <%= source_view_tag( @source_view ) %> -
+
<% end -%> diff --git a/tracks/app/views/todo/_edit_form.rhtml b/tracks/app/views/todo/_edit_form.rhtml index 632ab413..90bb49e6 100644 --- a/tracks/app/views/todo/_edit_form.rhtml +++ b/tracks/app/views/todo/_edit_form.rhtml @@ -34,6 +34,10 @@ Event.observe($('<%= dom_id(@item, 'project_name') %>'), "click", editFormProjectAutoCompleter.activate.bind(editFormProjectAutoCompleter)); + + + <%= text_field_tag "tag_list", @item.tags.collect{|t| t.name}.join(" "), :size => 40 %> +