国内貌似没什么人用 Redmine,很少有帖子交流 Redmine 自定义工作流方面的问题。
我丢个 custom workflow 插件的配置代码出来,权作备忘吧。
这段代码的功能,是在 issues 的类别(category)有改动之后,将 category 的内容填充到标题(subject)中。
if [5, 7].include?(@issue.tracker_id) && (@issue.new_record? || @issue.category_id_changed? ) && !@issue.category_id.nil? # find the underline in subject, so that remove the unless content which contains category en_underline=@issue.subject.to_s.rindex("-") zh_underline=@issue.subject.to_s.rindex("-") if !en_underline.nil? && !zh_underline.nil? if en_underline > zh_underline rm_index = en_underline else rm_index = zh_underline end elsif en_underline.nil? && !zh_underline.nil? rm_index = zh_underline elsif !en_underline.nil? && zh_underline.nil? rm_index = en_underline end if !rm_index.nil? subject = @issue.subject[rm_index+1, @issue.subject.length] else subject = @issue.subject end # the category looks like '01 - xx - xxx' in our project, and no need show the number in the subject category_name = IssueCategory.find(@issue.category_id).name underline_index = category_name.index("-") if !underline_index.nil? category_name = category_name[underline_index+2, category_name.length] end # set the value of subject new_subject = category_name + ' - ' + subject @issue.subject = new_subject end