WIP: redmine 3 support
This commit is contained in:
parent
b3b3db5a74
commit
6769cefeff
@ -22,13 +22,16 @@ require_dependency 'custom_fields_helper'
|
|||||||
|
|
||||||
module RedmineDmsf
|
module RedmineDmsf
|
||||||
module Patches
|
module Patches
|
||||||
module CustomFieldsHelperPatch
|
module CustomFieldsHelperPatch
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.extend(ClassMethods)
|
base.extend(ClassMethods)
|
||||||
base.send(:include, InstanceMethods)
|
base.send(:include, InstanceMethods)
|
||||||
base.class_eval do
|
base.class_eval do
|
||||||
unloadable
|
unloadable
|
||||||
if Redmine::VERSION::MAJOR >= 2 && Redmine::VERSION::MINOR >= 5
|
if (
|
||||||
|
(Redmine::VERSION::MAJOR >= 3) ||
|
||||||
|
(Redmine::VERSION::MAJOR >= 2 && Redmine::VERSION::MINOR >= 5)
|
||||||
|
)
|
||||||
alias_method_chain :render_custom_fields_tabs, :render_custom_tab
|
alias_method_chain :render_custom_fields_tabs, :render_custom_tab
|
||||||
alias_method_chain :custom_field_type_options, :custom_tab_options
|
alias_method_chain :custom_field_type_options, :custom_tab_options
|
||||||
else
|
else
|
||||||
@ -37,39 +40,42 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
end
|
end
|
||||||
|
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
|
|
||||||
def custom_fields_tabs_with_custom_tab
|
def custom_fields_tabs_with_custom_tab
|
||||||
add_cf
|
add_cf
|
||||||
custom_fields_tabs_without_custom_tab
|
custom_fields_tabs_without_custom_tab
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_custom_fields_tabs_with_render_custom_tab(types)
|
def render_custom_fields_tabs_with_render_custom_tab(types)
|
||||||
add_cf
|
add_cf
|
||||||
render_custom_fields_tabs_without_render_custom_tab(types)
|
render_custom_fields_tabs_without_render_custom_tab(types)
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_field_type_options_with_custom_tab_options
|
def custom_field_type_options_with_custom_tab_options
|
||||||
add_cf
|
add_cf
|
||||||
custom_field_type_options_without_custom_tab_options
|
custom_field_type_options_without_custom_tab_options
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def add_cf
|
def add_cf
|
||||||
cf = {:name => 'DmsfFileRevisionCustomField', :partial => 'custom_fields/index', :label => :dmsf}
|
cf = {:name => 'DmsfFileRevisionCustomField', :partial => 'custom_fields/index', :label => :dmsf}
|
||||||
if Redmine::VERSION::MAJOR <= 2 && Redmine::VERSION::MINOR < 4
|
if (
|
||||||
unless CustomField::CUSTOM_FIELDS_TABS.index { |f| f[:name] == cf[:name] }
|
(Redmine::VERSION::MAJOR >= 3) ||
|
||||||
CustomField::CUSTOM_FIELDS_TABS << cf
|
(Redmine::VERSION::MAJOR >= 2 && Redmine::VERSION::MINOR >= 5)
|
||||||
end
|
)
|
||||||
else
|
|
||||||
unless CustomFieldsHelper::CUSTOM_FIELDS_TABS.index { |f| f[:name] == cf[:name] }
|
unless CustomFieldsHelper::CUSTOM_FIELDS_TABS.index { |f| f[:name] == cf[:name] }
|
||||||
CustomFieldsHelper::CUSTOM_FIELDS_TABS << cf
|
CustomFieldsHelper::CUSTOM_FIELDS_TABS << cf
|
||||||
end
|
else
|
||||||
end
|
unless CustomField::CUSTOM_FIELDS_TABS.index { |f| f[:name] == cf[:name] }
|
||||||
|
CustomField::CUSTOM_FIELDS_TABS << cf
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
#
|
#
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
#
|
#
|
||||||
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||||
@ -27,30 +27,45 @@ module RedmineDmsf
|
|||||||
module ProjectPatch
|
module ProjectPatch
|
||||||
|
|
||||||
def self.included(base) # :nodoc:
|
def self.included(base) # :nodoc:
|
||||||
base.send(:include, InstanceMethods)
|
base.send(:include, InstanceMethods)
|
||||||
base.class_eval do
|
base.class_eval do
|
||||||
unloadable
|
unloadable
|
||||||
alias_method_chain :copy, :dmsf
|
alias_method_chain :copy, :dmsf
|
||||||
|
|
||||||
has_many :dmsf_files, :class_name => 'DmsfFile', :foreign_key => 'project_id',
|
if (Redmine::VERSION::MAJOR >= 3)
|
||||||
:conditions => { :dmsf_folder_id => nil }, :dependent => :destroy
|
has_many :dmsf_files, -> { where dmsf_folder_id: nil},
|
||||||
has_many :dmsf_folders, :class_name => 'DmsfFolder', :foreign_key => 'project_id',
|
:class_name => 'DmsfFile', :foreign_key => 'project_id', :dependent => :destroy
|
||||||
:conditions => {:dmsf_folder_id => nil}, :dependent => :destroy
|
has_many :dmsf_folders, -> {where dmsf_folder_id: nil},
|
||||||
has_many :dmsf_workflows, :dependent => :destroy
|
:class_name => 'DmsfFolder', :foreign_key => 'project_id',
|
||||||
has_many :folder_links, :class_name => 'DmsfLink', :foreign_key => 'project_id',
|
:dependent => :destroy
|
||||||
:conditions => { :dmsf_folder_id => nil, :target_type => 'DmsfFolder' },
|
has_many :dmsf_workflows, :dependent => :destroy
|
||||||
:dependent => :destroy
|
has_many :folder_links, -> { where dmsf_folder_id: nil, target_type: 'DmsfFolder' },
|
||||||
has_many :file_links, :class_name => 'DmsfLink', :foreign_key => 'project_id',
|
:class_name => 'DmsfLink', :foreign_key => 'project_id', :dependent => :destroy
|
||||||
:conditions => { :dmsf_folder_id => nil, :target_type => 'DmsfFile' },
|
has_many :file_links, -> { where dmsf_folder_id: nil, target_type: 'DmsfFile' },
|
||||||
:dependent => :destroy
|
:class_name => 'DmsfLink', :foreign_key => 'project_id', :dependent => :destroy
|
||||||
has_many :url_links, :class_name => 'DmsfLink', :foreign_key => 'project_id',
|
has_many :url_links, -> { where dmsf_folder_id: nil, target_type: 'DmsfUrl' },
|
||||||
:conditions => { :dmsf_folder_id => nil, :target_type => 'DmsfUrl' },
|
:class_name => 'DmsfLink', :foreign_key => 'project_id', :dependent => :destroy
|
||||||
:dependent => :destroy
|
else
|
||||||
|
has_many :dmsf_files, :class_name => 'DmsfFile', :foreign_key => 'project_id',
|
||||||
|
:conditions => { :dmsf_folder_id => nil }, :dependent => :destroy
|
||||||
|
has_many :dmsf_folders, :class_name => 'DmsfFolder', :foreign_key => 'project_id',
|
||||||
|
:conditions => {:dmsf_folder_id => nil}, :dependent => :destroy
|
||||||
|
has_many :dmsf_workflows, :dependent => :destroy
|
||||||
|
has_many :folder_links, :class_name => 'DmsfLink', :foreign_key => 'project_id',
|
||||||
|
:conditions => { :dmsf_folder_id => nil, :target_type => 'DmsfFolder' },
|
||||||
|
:dependent => :destroy
|
||||||
|
has_many :file_links, :class_name => 'DmsfLink', :foreign_key => 'project_id',
|
||||||
|
:conditions => { :dmsf_folder_id => nil, :target_type => 'DmsfFile' },
|
||||||
|
:dependent => :destroy
|
||||||
|
has_many :url_links, :class_name => 'DmsfLink', :foreign_key => 'project_id',
|
||||||
|
:conditions => { :dmsf_folder_id => nil, :target_type => 'DmsfUrl' },
|
||||||
|
:dependent => :destroy
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
|
|
||||||
def dmsf_count
|
def dmsf_count
|
||||||
file_count = self.dmsf_files.visible.count + self.file_links.count
|
file_count = self.dmsf_files.visible.count + self.file_links.count
|
||||||
folder_count = self.dmsf_folders.visible.count + self.folder_links.count
|
folder_count = self.dmsf_folders.visible.count + self.folder_links.count
|
||||||
@ -87,23 +102,23 @@ module RedmineDmsf
|
|||||||
f.copy_to(self, nil)
|
f.copy_to(self, nil)
|
||||||
end
|
end
|
||||||
project.folder_links.visible.each do |l|
|
project.folder_links.visible.each do |l|
|
||||||
l.copy_to(self, nil)
|
l.copy_to(self, nil)
|
||||||
end
|
end
|
||||||
project.file_links.visible.each do |l|
|
project.file_links.visible.each do |l|
|
||||||
l.copy_to(self, nil)
|
l.copy_to(self, nil)
|
||||||
end
|
end
|
||||||
project.url_links.visible.each do |l|
|
project.url_links.visible.each do |l|
|
||||||
l.copy_to(self, nil)
|
l.copy_to(self, nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_approval_workflows(project)
|
def copy_approval_workflows(project)
|
||||||
project.dmsf_workflows.each do |wf|
|
project.dmsf_workflows.each do |wf|
|
||||||
wf.copy_to self
|
wf.copy_to self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -113,4 +128,4 @@ Rails.configuration.to_prepare do
|
|||||||
unless Project.included_modules.include?(RedmineDmsf::Patches::ProjectPatch)
|
unless Project.included_modules.include?(RedmineDmsf::Patches::ProjectPatch)
|
||||||
Project.send(:include, RedmineDmsf::Patches::ProjectPatch)
|
Project.send(:include, RedmineDmsf::Patches::ProjectPatch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user