New observable objects added (TimeEntry)

This commit is contained in:
Anton Argirov 2015-12-12 20:29:22 +06:00
parent eab90b312f
commit 3f0c80232a
4 changed files with 45 additions and 3 deletions

View File

@ -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, :shared]
PROJECT_OBSERVABLES = [:issue, :issue_attachments, :project, :project_attachments, :wiki_content, :wiki_page_attachments]
:wiki_content, :wiki_page_attachments, :time_entry, :shared]
PROJECT_OBSERVABLES = [:issue, :issue_attachments, :project, :project_attachments, :wiki_content, :wiki_page_attachments, :time_entry]
COLLECTION_OBSERVABLES = [:group_users, :issue_attachments, :project_attachments, :wiki_page_attachments]
SINGLE_OBSERVABLES = [:issue, :user, :group, :attachment, :project, :wiki_content]
SINGLE_OBSERVABLES = [:issue, :user, :group, :attachment, :project, :wiki_content, :time_entry]
attr_protected :id
has_and_belongs_to_many :projects

View File

@ -62,6 +62,7 @@ en:
text_custom_workflow_project_attachments_code_note: These scripts are executed when a file being added to project/removed from project. Use variables @project and @attachment to access appropriate objects in your scripts.
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 user object changes (destroys). Use methods and properties of the time entry directly (or through "self")
text_no_enabled_projects: No projects
text_custom_workflow_author: Will be included in exported XML
@ -79,3 +80,4 @@ en:
custom_workflow_observable_wiki_content: "Wiki Content"
custom_workflow_observable_wiki_page_attachments: "Wiki Page Attachments"
custom_workflow_observable_group_users: "Group Users"
custom_workflow_observable_time_entry: "Time Entry"

View File

@ -62,6 +62,7 @@ ru:
text_custom_workflow_project_attachments_code_note: Эти сценарии выполняются когда файл загружается в проект/удаляется из проекта. Используйте переменные @project и @attachment для доступа к соответствующим объектам из Ваших сценариев.
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_no_enabled_projects: Нет проектов
text_custom_workflow_author: Будет использован в XML файле при экспорте
@ -79,3 +80,4 @@ ru:
custom_workflow_observable_wiki_content: "Содержание Wiki"
custom_workflow_observable_wiki_page_attachments: "Вложения страниц Wiki"
custom_workflow_observable_group_users: "Пользователи группы"
custom_workflow_observable_time_entry: "Затраченное время"

View File

@ -0,0 +1,38 @@
module RedmineCustomWorkflows
module TimeEntryPatch
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
@time_entry = self
@saved_attributes = attributes.dup
CustomWorkflow.run_shared_code(self)
CustomWorkflow.run_custom_workflows(:time_entry, self, :before_save)
errors.empty? && (@saved_attributes == attributes || valid?)
ensure
@saved_attributes = nil
end
def after_save_custom_workflows
CustomWorkflow.run_custom_workflows(:time_entry, self, :after_save)
end
def before_destroy_custom_workflows
CustomWorkflow.run_custom_workflows(:time_entry, self, :before_destroy)
end
def after_destroy_custom_workflows
CustomWorkflow.run_custom_workflows(:time_entry, self, :after_destroy)
end
end
end
end