mirror of
https://github.com/anteo/redmine_custom_workflows.git
synced 2026-01-26 00:04:20 +00:00
New observable objects added (Version)
This commit is contained in:
parent
7f343f9665
commit
84552f35e3
@ -118,7 +118,7 @@ This plug-in is compatible with Redmine 2.x.x, 3.x.x
|
||||
|
||||
== Changelog
|
||||
|
||||
[0.1.6] * New observable objects added (TimeEntry)
|
||||
[0.1.6] * New observable objects added (TimeEntry, Version)
|
||||
* Bug fixes
|
||||
[0.1.5] * New observable objects added (Project, Wiki Content, Attachment, Issue Attachments, Project Attachments, Wiki Page Attachments)
|
||||
* Ability to hook before_destroy and after_destroy events
|
||||
|
||||
@ -9,10 +9,10 @@ end
|
||||
|
||||
class CustomWorkflow < ActiveRecord::Base
|
||||
OBSERVABLES = [:issue, :issue_attachments, :user, :attachment, :group, :group_users, :project, :project_attachments,
|
||||
:wiki_content, :wiki_page_attachments, :time_entry, :shared]
|
||||
PROJECT_OBSERVABLES = [:issue, :issue_attachments, :project, :project_attachments, :wiki_content, :wiki_page_attachments, :time_entry]
|
||||
:wiki_content, :wiki_page_attachments, :time_entry, :version, :shared]
|
||||
PROJECT_OBSERVABLES = [:issue, :issue_attachments, :project, :project_attachments, :wiki_content, :wiki_page_attachments, :time_entry, :version]
|
||||
COLLECTION_OBSERVABLES = [:group_users, :issue_attachments, :project_attachments, :wiki_page_attachments]
|
||||
SINGLE_OBSERVABLES = [:issue, :user, :group, :attachment, :project, :wiki_content, :time_entry]
|
||||
SINGLE_OBSERVABLES = [:issue, :user, :group, :attachment, :project, :wiki_content, :time_entry, :version]
|
||||
|
||||
attr_protected :id
|
||||
has_and_belongs_to_many :projects
|
||||
|
||||
@ -63,6 +63,7 @@ en:
|
||||
text_custom_workflow_wiki_content_code_note: Scripts are executed in the context of Wiki Content object when project object changes (destroys). Use methods and properties of the project directly (or through "self")
|
||||
text_custom_workflow_wiki_page_attachments_code_note: These scripts are executed when a file being added to wiki page/removed from wiki page. Use variables @page and @attachment to access appropriate objects in your scripts.
|
||||
text_custom_workflow_time_entry_code_note: Scripts are executed in the context of TimeEntry object when time enty object changes (destroys). Use methods and properties of the time entry directly (or through "self")
|
||||
text_custom_workflow_version_code_note: Scripts are executed in the context of Version object when version object changes (destroys). Use methods and properties of the version directly (or through "self")
|
||||
|
||||
text_no_enabled_projects: No projects
|
||||
text_custom_workflow_author: Will be included in exported XML
|
||||
@ -81,3 +82,4 @@ en:
|
||||
custom_workflow_observable_wiki_page_attachments: "Wiki Page Attachments"
|
||||
custom_workflow_observable_group_users: "Group Users"
|
||||
custom_workflow_observable_time_entry: "Time Entry"
|
||||
custom_workflow_observable_version: "Version"
|
||||
|
||||
@ -63,6 +63,7 @@ ru:
|
||||
text_custom_workflow_wiki_content_code_note: Эти сценарии исполняются в контексте объекта Wiki содержания когда объект Wiki содержания изменяется (удаляется). Используйте методы и свойства объекта содержания Wiki (WikiContent) напрямую или через ключевое слово self.
|
||||
text_custom_workflow_wiki_page_attachments_code_note: Эти сценарии выполняются когда файл загружается на Wiki страницу/удаляется с Wiki страницы. Используйте переменные @page и @attachment для доступа к соответствующим объектам из Ваших сценариев.
|
||||
text_custom_workflow_time_entry_code_note: Эти сценарии исполняются в контексте объекта затраченного времени когда объект изменяется (удаляется). Используйте методы и свойства объекта затраченного времени (TimeEntry) напрямую или через ключевое слово self.
|
||||
text_custom_workflow_version_code_note: Эти сценарии исполняются в контексте объекта версии когда объект изменяется (удаляется). Используйте методы и свойства объекта версии (Version) напрямую или через ключевое слово self.
|
||||
|
||||
text_no_enabled_projects: Нет проектов
|
||||
text_custom_workflow_author: Будет использован в XML файле при экспорте
|
||||
@ -81,3 +82,4 @@ ru:
|
||||
custom_workflow_observable_wiki_page_attachments: "Вложения страниц Wiki"
|
||||
custom_workflow_observable_group_users: "Пользователи группы"
|
||||
custom_workflow_observable_time_entry: "Затраченное время"
|
||||
custom_workflow_observable_version: "Версия"
|
||||
|
||||
3
init.rb
3
init.rb
@ -23,6 +23,9 @@ Rails.application.config.to_prepare do
|
||||
unless TimeEntry.include?(RedmineCustomWorkflows::TimeEntryPatch)
|
||||
TimeEntry.send(:include, RedmineCustomWorkflows::TimeEntryPatch)
|
||||
end
|
||||
unless Version.include?(RedmineCustomWorkflows::VersionPatch)
|
||||
Version.send(:include, RedmineCustomWorkflows::VersionPatch)
|
||||
end
|
||||
unless WikiContent.include?(RedmineCustomWorkflows::WikiContentPatch)
|
||||
WikiContent.send(:include, RedmineCustomWorkflows::WikiContentPatch)
|
||||
end
|
||||
|
||||
38
lib/redmine_custom_workflows/version_patch.rb
Normal file
38
lib/redmine_custom_workflows/version_patch.rb
Normal file
@ -0,0 +1,38 @@
|
||||
module RedmineCustomWorkflows
|
||||
module VersionPatch
|
||||
|
||||
def self.included(base)
|
||||
base.send(:include, InstanceMethods)
|
||||
base.class_eval do
|
||||
before_save :before_save_custom_workflows
|
||||
after_save :after_save_custom_workflows
|
||||
before_destroy :before_destroy_custom_workflows
|
||||
after_destroy :after_destroy_custom_workflows
|
||||
end
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
def before_save_custom_workflows
|
||||
@version = self
|
||||
@saved_attributes = attributes.dup
|
||||
CustomWorkflow.run_shared_code(self)
|
||||
CustomWorkflow.run_custom_workflows(:version, self, :before_save)
|
||||
errors.empty? && (@saved_attributes == attributes || valid?)
|
||||
ensure
|
||||
@saved_attributes = nil
|
||||
end
|
||||
|
||||
def after_save_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows(:version, self, :after_save)
|
||||
end
|
||||
|
||||
def before_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows(:version, self, :before_destroy)
|
||||
end
|
||||
|
||||
def after_destroy_custom_workflows
|
||||
CustomWorkflow.run_custom_workflows(:version, self, :after_destroy)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user