diff -c -r -N --exclude-from=redmine_ignore redmine-1.0.1_original/app/controllers/watchers_controller.rb redmine-1.0.1/app/controllers/watchers_controller.rb
*** redmine-1.0.1_original/app/controllers/watchers_controller.rb	2010-06-20 19:08:15.000000000 +0300
--- redmine-1.0.1/app/controllers/watchers_controller.rb	2010-08-26 10:24:34.154602129 +0300
***************
*** 37,53 ****
    end
    
    def new
!     @watcher = Watcher.new(params[:watcher])
!     @watcher.watchable = @watched
!     @watcher.save if request.post?
!     respond_to do |format|
!       format.html { redirect_to :back }
!       format.js do
!         render :update do |page|
!           page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}
!         end
!       end
!     end
    rescue ::ActionController::RedirectBackError
      render :text => 'Watcher added.', :layout => true
    end
--- 37,71 ----
    end
    
    def new
! 		watchers = []
! 		if params[:watcher] && request.post?
! 		  attrs = params[:watcher].dup
! 		  if (user_ids = attrs.delete(:user_ids))
! 			user_ids.each do |user_id|
! 			  watchers << Watcher.new(attrs.merge(:user_id => user_id))
! 			end
! 		  else
! 				watchers << Watcher.new(attrs)
! 		  end
! 		end
! 		
! 		watchers.each do |w| 
! 			w.watchable = @watched
! 			w.save
! 		end
! 		
! 		@watcher = Watcher.new()	
! 		respond_to do |format|
! 			format.html { redirect_to :back }
! 			format.js do
! 				render :update do |page|
! 					page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}		
! 					if watchers.length > 0
! 							page.hide 'new-watcher-form'
! 					end
! 				end
! 			end
! 		end
    rescue ::ActionController::RedirectBackError
      render :text => 'Watcher added.', :layout => true
    end
***************
*** 64,69 ****
--- 82,92 ----
      end
    end
    
+   def autocomplete_for_watcher
+ 		@watchers = @watched.addable_watcher_users_like(params[:q])
+     render :layout => false
+   end  
+   
  private
    def find_project
      klass = Object.const_get(params[:object_type].camelcase)
***************
*** 74,80 ****
      render_404
    end
    
!   def set_watcher(user, watching)
      @watched.set_watcher(user, watching)
      if params[:replace].present?
        if params[:replace].is_a? Array
--- 97,103 ----
      render_404
    end
    
!   def set_watcher(user, watching)    
      @watched.set_watcher(user, watching)
      if params[:replace].present?
        if params[:replace].is_a? Array
diff -c -r -N --exclude-from=redmine_ignore redmine-1.0.1_original/app/helpers/application_helper.rb redmine-1.0.1/app/helpers/application_helper.rb
*** redmine-1.0.1_original/app/helpers/application_helper.rb	2010-08-22 22:49:31.000000000 +0300
--- redmine-1.0.1/app/helpers/application_helper.rb	2010-08-25 12:40:52.077153713 +0300
***************
*** 275,280 ****
--- 275,288 ----
      end
      s 
    end
+   
+   def watchers_check_box_tags(name, watchers)
+     s = ''
+     watchers.sort.each do |watcher|
+       s << "<label>#{ check_box_tag name, watcher.id, false } #{h watcher}</label>\n"
+     end
+     s 
+   end
  
    # Truncates and returns the string as a single line
    def truncate_single_line(string, *args)
diff -c -r -N --exclude-from=redmine_ignore redmine-1.0.1_original/app/views/watchers/autocomplete_for_watcher.rhtml redmine-1.0.1/app/views/watchers/autocomplete_for_watcher.rhtml
*** redmine-1.0.1_original/app/views/watchers/autocomplete_for_watcher.rhtml	1970-01-01 03:00:00.000000000 +0300
--- redmine-1.0.1/app/views/watchers/autocomplete_for_watcher.rhtml	2010-08-25 15:38:34.796831763 +0300
***************
*** 0 ****
--- 1 ----
+ <%= watchers_check_box_tags 'watcher[user_ids][]', @watchers %>
diff -c -r -N --exclude-from=redmine_ignore redmine-1.0.1_original/app/views/watchers/_watchers.rhtml redmine-1.0.1/app/views/watchers/_watchers.rhtml
*** redmine-1.0.1_original/app/views/watchers/_watchers.rhtml	2010-03-13 19:45:41.000000000 +0200
--- redmine-1.0.1/app/views/watchers/_watchers.rhtml	2010-08-26 11:18:34.509734467 +0300
***************
*** 1,4 ****
! <div class="contextual">
  <%= link_to_remote l(:button_add), 
                     :url => {:controller => 'watchers',
                              :action => 'new',
--- 1,6 ----
! <% watchers = watched.addable_watcher_users %>
! 
! <div class="contextual watchers">
  <%= link_to_remote l(:button_add), 
                     :url => {:controller => 'watchers',
                              :action => 'new',
***************
*** 16,26 ****
           	                    :object_id => watched},
         	             :method => :post,
        	             :html => {:id => 'new-watcher-form'}) do |f| %>
! 		<p><%= f.select :user_id, (watched.addable_watcher_users.collect {|m| [m.name, m.id]}), :prompt => "--- #{l(:actionview_instancetag_blank_option)} ---" %>
! 
! 		<%= submit_tag l(:button_add) %>
! 		<%= toggle_link l(:button_cancel), 'new-watcher-form'%></p>
! 	<% end %>
  <% end %>
  
  <%= watchers_list(watched) %>
--- 18,41 ----
           	                    :object_id => watched},
         	             :method => :post,
        	             :html => {:id => 'new-watcher-form'}) do |f| %>
! 	    
! 	    <fieldset>
! 		<p><%= text_field_tag 'watcher_search', nil %></p>
! 		<%= observe_field(:watcher_search,
!                  :frequency => 2,
!                  :update => :watcher_list,
!                  :url => { :controller => 'watchers', :action => 'autocomplete_for_watcher', :object_type => watched.class.name.underscore, :object_id => watched},
!                  :with => 'q')
!                   %>
! 		
! 				<div id="watcher_list">
! 					<%= watchers_check_box_tags 'watcher[user_ids][]', watchers %>
! 				</div>
! 	   	
! 				<%= submit_tag l(:button_add) %>
! 				<%= toggle_link l(:button_cancel), 'new-watcher-form'%></p>
! 		</fieldset>
! 	  <% end %>
  <% end %>
  
  <%= watchers_list(watched) %>
diff -c -r -N --exclude-from=redmine_ignore redmine-1.0.1_original/public/stylesheets/application.css redmine-1.0.1/public/stylesheets/application.css
*** redmine-1.0.1_original/public/stylesheets/application.css	2010-08-19 07:30:29.000000000 +0300
--- redmine-1.0.1/public/stylesheets/application.css	2010-08-25 12:17:30.828828219 +0300
***************
*** 443,448 ****
--- 443,450 ----
  div#tab-content-members fieldset label, div#tab-content-memberships fieldset label, div#tab-content-users fieldset label { display: block; }
  div#tab-content-members fieldset div, div#tab-content-users fieldset div { max-height: 400px; overflow:auto; }
  
+ div#watchers fieldset label { display: block; }
+ div#watchers fieldset { padding:1em; margin-bottom: 1em; }
  table.members td.group { padding-left: 20px; background: url(../images/group.png) no-repeat 0% 50%; }
  
  input#principal_search, input#user_search {width:100%}
diff -c -r -N --exclude-from=redmine_ignore redmine-1.0.1_original/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb redmine-1.0.1/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb
*** redmine-1.0.1_original/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb	2010-06-20 21:41:30.000000000 +0300
--- redmine-1.0.1/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb	2010-08-26 10:49:04.427228450 +0300
***************
*** 31,39 ****
          
          # Returns an array of users that are proposed as watchers
          def addable_watcher_users
!           self.project.users.sort - self.watcher_users
          end
          
          # Adds user as a watcher
          def add_watcher(user)
            self.watchers << Watcher.new(:user => user)
--- 31,48 ----
          
          # Returns an array of users that are proposed as watchers
          def addable_watcher_users
! 					self.project.users.sort - self.watcher_users
          end
          
+         # Returns an array of users that are proposed as watchers
+         def addable_watcher_users_like(query)
+ 					if query == ''
+ 						self.project.users.sort - self.watcher_users
+ 					else
+ 						User.active.like(query).sort - self.watcher_users
+           end
+         end        
+         
          # Adds user as a watcher
          def add_watcher(user)
            self.watchers << Watcher.new(:user => user)
