Project

General

Profile

Defect #40448 » lib_script.rb

Example in plugins/redmine_plugin_name/lib/lib_script.rb - Ctrl Sup, 2024-03-25 13:14

 
1
module RedminePluginName
2
  module LibScript
3
    module IssuePatch
4
      def self.included(base)
5
        base.send(:include, InstanceMethods)
6
        base.class_eval do
7
          include Tools
8
          before_destroy :get_linked_issues
9
          after_destroy :update_linked_issues
10

    
11
          attr_accessor :linked_issues
12

    
13
          def get_linked_issues
14
            relations = IssueRelation.all
15
            Rails.logger.info("---------------------------------------------")
16
            # Parcourir chaque relation
17
            relations.each do |relation|
18
              Rails.logger.info("Issue from: #{relation.issue_from_id}, Issue to: #{relation.issue_to_id}, Relation type: #{relation.relation_type}")
19
            end
20
          end
21

    
22
          def update_linked_issues
23
            if self.linked_issues.length > 0
24
              self.linked_issues.each do |relation|
25
                issue = Issue.find(relation)
26
                relation.save
27
              end
28
            end
29
          end
30
        end
31
      end
32
    end
33
    module InstanceMethods
34
        # Ajoutez ici des méthodes d'instance personnalisées si nécessaire.
35
    end
36
  end
37
end
38

    
39
Issue.send(:include, RedminePluginName::LibScript::IssuePatch)
    (1-1/1)