Revision 756:18b0f6e6d7a8 vendor/plugins/redmine_tags/lib/redmine_tags/hooks

View differences:

vendor/plugins/redmine_tags/lib/redmine_tags/hooks/model_issue_hook.rb
1
# This file is a part of redmine_tags
2
# redMine plugin, that adds tagging support.
3
#
4
# Copyright (c) 2010 Eric Davis
5
# Copyright (c) 2010 Aleksey V Zapparov AKA ixti
6
#
7
# redmine_tags is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# redmine_tags is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with redmine_tags.  If not, see <http://www.gnu.org/licenses/>.
19

  
20
module RedmineTags
21
  module Hooks
22
    class ModelIssueHook < Redmine::Hook::ViewListener
23
      def controller_issues_edit_before_save(context={})
24
        save_tags_to_issue(context, true)
25
      end
26

  
27
      # Issue has an after_save method that calls reload (update_nested_set_attributes)
28
      # This makes it impossible for a new record to get a tag_list, it's
29
      # cleared on reload. So instead, hook in after the Issue#save to update
30
      # this issue's tag_list and call #save ourselves.
31
      def controller_issues_new_after_save(context={})
32
        save_tags_to_issue(context, false)
33
        context[:issue].save
34
      end
35

  
36
      def save_tags_to_issue(context, create_journal)
37
        params = context[:params]
38

  
39
        if params && params[:issue] && !params[:issue][:tag_list].nil?
40
          old_tags = context[:issue].tag_list.to_s
41
          context[:issue].tag_list = params[:issue][:tag_list]
42
          new_tags = context[:issue].tag_list.to_s
43

  
44
          if create_journal and not (old_tags == new_tags || context[:issue].current_journal.blank?)
45
            context[:issue].current_journal.details << JournalDetail.new(:property => 'attr',
46
                                                                         :prop_key => 'tag_list',
47
                                                                         :old_value => old_tags,
48
                                                                         :value => new_tags)
49
          end
50
        end
51
      end
52
    end
53
  end
54
end
vendor/plugins/redmine_tags/lib/redmine_tags/hooks/model_project_hook.rb
1
# This file is a part of redmine_tags
2
# redMine plugin, that adds tagging support.
3
#
4
# Copyright (c) 2010 Eric Davis
5
# Copyright (c) 2010 Aleksey V Zapparov AKA ixti
6
#
7
# redmine_tags is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# redmine_tags is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with redmine_tags.  If not, see <http://www.gnu.org/licenses/>.
19

  
20
module RedmineTags
21
  module Hooks
22
    class ModelProjectHook < Redmine::Hook::ViewListener
23
      def controller_project_before_save(context={})
24
        debugger
25
        save_tags_to_project(context, true)
26
      end
27

  
28
      # Issue has an after_save method that calls reload (update_nested_set_attributes)
29
      # This makes it impossible for a new record to get a tag_list, it's
30
      # cleared on reload. So instead, hook in after the Issue#save to update
31
      # this issue's tag_list and call #save ourselves.
32
      def controller_projects_before_save(context={})
33
        debugger
34
        save_tags_to_project(context, false)
35
        context[:project].save
36
      end
37

  
38
      def save_tags_to_project(context, create_journal)
39
        params = context[:params]
40
        debugger
41
        logger.error { "WORKING" }
42

  
43
   #     if params && params[:issue] && !params[:issue][:tag_list].nil?
44
   #       old_tags = context[:issue].tag_list.to_s
45
   #       context[:issue].tag_list = params[:issue][:tag_list]
46
   #       new_tags = context[:issue].tag_list.to_s
47
   #
48
   #       if create_journal and not (old_tags == new_tags || context[:issue].current_journal.blank?)
49
   #         context[:issue].current_journal.details << JournalDetail.new(:property => 'attr',
50
   #                                                                      :prop_key => 'tag_list',
51
   #                                                                      :old_value => old_tags,
52
   #                                                                      :value => new_tags)
53
   #       end
54
   #     end
55
      end
56
    end
57
  end
58
end
vendor/plugins/redmine_tags/lib/redmine_tags/hooks/views_issues_hook.rb
1
# This file is a part of redmine_tags
2
# redMine plugin, that adds tagging support.
3
#
4
# Copyright (c) 2010 Aleksey V Zapparov AKA ixti
5
#
6
# redmine_tags is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# redmine_tags is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with redmine_tags.  If not, see <http://www.gnu.org/licenses/>.
18

  
19
module RedmineTags
20
  module Hooks
21
    class ViewsIssuesHook < Redmine::Hook::ViewListener
22
      render_on :view_issues_show_details_bottom, :partial => 'issues/tags'
23
      render_on :view_issues_form_details_bottom, :partial => 'issues/tags_form'
24
      render_on :view_issues_sidebar_planning_bottom, :partial => 'issues/tags_sidebar'
25
    end
26
  end
27
end
28

  
vendor/plugins/redmine_tags/lib/redmine_tags/hooks/views_projects_hook.rb
1
module RedmineTags
2
  module Hooks
3
    class ViewsProjectsHook < Redmine::Hook::ViewListener
4
      render_on :view_projects_form, :partial => 'projects/tags_form'
5
      render_on :view_projects_show_left, :partial => 'projects/tags'
6
#      render_on :view_issues_sidebar_planning_bottom, :partial => 'issues/tags_sidebar'
7
    end
8
  end
9
end
10

  

Also available in: Unified diff