Index: app/models/issue_category.rb =================================================================== --- app/models/issue_category.rb (revision 8748) +++ app/models/issue_category.rb (working copy) @@ -20,6 +20,8 @@ belongs_to :assigned_to, :class_name => 'Principal', :foreign_key => 'assigned_to_id' has_many :issues, :foreign_key => 'category_id', :dependent => :nullify + acts_as_watchable + validates_presence_of :name validates_uniqueness_of :name, :scope => [:project_id] validates_length_of :name, :maximum => 30 Index: app/controllers/issue_categories_controller.rb =================================================================== --- app/controllers/issue_categories_controller.rb (revision 8748) +++ app/controllers/issue_categories_controller.rb (working copy) @@ -40,11 +40,13 @@ def new @category = @project.issue_categories.build(params[:issue_category]) + assign_watchers_from_params end verify :method => :post, :only => :create def create @category = @project.issue_categories.build(params[:issue_category]) + assign_watchers_from_params if @category.save respond_to do |format| format.html do @@ -75,6 +77,7 @@ verify :method => :put, :only => :update def update + assign_watchers_from_params if @category.update_attributes(params[:issue_category]) respond_to do |format| format.html { @@ -122,4 +125,10 @@ rescue ActiveRecord::RecordNotFound render_404 end + + def assign_watchers_from_params + if params[:issue_category].is_a?(Hash) + @category.watcher_user_ids = params[:issue_category]['watcher_user_ids'] + end + end end Index: app/controllers/watchers_controller.rb =================================================================== --- app/controllers/watchers_controller.rb (revision 8748) +++ app/controllers/watchers_controller.rb (working copy) @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class WatchersController < ApplicationController - before_filter :find_project + before_filter :find_project, :except => [:show] before_filter :require_login, :check_project_privacy, :only => [:watch, :unwatch] before_filter :authorize, :only => [:new, :destroy] @@ -36,6 +36,16 @@ set_watcher(User.current, false) end + def show + p params + respond_to do |format| + format.api { + result = Watcher.find(:all, :conditions => [ "watchable_type = ? and watchable_id = ?", params['watchable_type'].classify, params['watchable_id'].to_i]) + render :json => result + } + end + end + def new @watcher = Watcher.new(params[:watcher]) @watcher.watchable = @watched Index: app/views/issues/_form.html.erb =================================================================== --- app/views/issues/_form.html.erb (revision 8748) +++ app/views/issues/_form.html.erb (working copy) @@ -30,9 +30,10 @@ <% if @issue.new_record? && User.current.allowed_to?(:add_issue_watchers, @project) -%>
<% @issue.project.users.sort.each do |user| -%> - + <% end -%>
+<%= javascript_tag "setupNewIssueWatchersByCategory('#{j(url_for :controller => 'watchers', :action => 'show', :watchable_type => 'issue_category', :watchable_id => 'watchable_id', :format => 'json')}')" %> <% end %> <%= call_hook(:view_issues_form_details_bottom, { :issue => @issue, :form => f }) %> Index: app/views/issue_categories/_form.html.erb =================================================================== --- app/views/issue_categories/_form.html.erb (revision 8748) +++ app/views/issue_categories/_form.html.erb (working copy) @@ -3,4 +3,8 @@<%= f.text_field :name, :size => 30, :required => true %>
<%= f.select :assigned_to_id, principals_options_for_select(@project.assignable_users, @category.assigned_to), :include_blank => true %>
++<% @project.users.sort.each do |user| -%> + +<% end -%>