Custom fileds enabled again
This commit is contained in:
parent
b457d33ecc
commit
f82aa2d4b9
@ -86,7 +86,7 @@ class DmsfUploadController < ApplicationController
|
|||||||
files = []
|
files = []
|
||||||
failed_uploads = []
|
failed_uploads = []
|
||||||
commited_files.each_value do |commited_file|
|
commited_files.each_value do |commited_file|
|
||||||
name = commited_file["name"];
|
name = commited_file['name'];
|
||||||
|
|
||||||
new_revision = DmsfFileRevision.new
|
new_revision = DmsfFileRevision.new
|
||||||
file = DmsfFile.visible.find_file_by_name(@project, @folder, name)
|
file = DmsfFile.visible.find_file_by_name(@project, @folder, name)
|
||||||
@ -95,7 +95,7 @@ class DmsfUploadController < ApplicationController
|
|||||||
file.project = @project
|
file.project = @project
|
||||||
file.name = name
|
file.name = name
|
||||||
file.folder = @folder
|
file.folder = @folder
|
||||||
file.notification = !Setting.plugin_redmine_dmsf["dmsf_default_notifications"].blank?
|
file.notification = !Setting.plugin_redmine_dmsf['dmsf_default_notifications'].blank?
|
||||||
|
|
||||||
new_revision.minor_version = 0
|
new_revision.minor_version = 0
|
||||||
new_revision.major_version = 0
|
new_revision.major_version = 0
|
||||||
@ -108,25 +108,24 @@ class DmsfUploadController < ApplicationController
|
|||||||
new_revision.source_revision = last_revision
|
new_revision.source_revision = last_revision
|
||||||
new_revision.major_version = last_revision.major_version
|
new_revision.major_version = last_revision.major_version
|
||||||
new_revision.minor_version = last_revision.minor_version
|
new_revision.minor_version = last_revision.minor_version
|
||||||
#new_revision.workflow = last_revision.workflow
|
|
||||||
end
|
end
|
||||||
|
|
||||||
commited_disk_filepath = "#{DmsfHelper.temp_dir}/#{commited_file["disk_filename"].gsub(/[\/\\]/,'')}"
|
commited_disk_filepath = "#{DmsfHelper.temp_dir}/#{commited_file['disk_filename'].gsub(/[\/\\]/,'')}"
|
||||||
|
|
||||||
new_revision.project = @project
|
new_revision.project = @project
|
||||||
new_revision.folder = @folder
|
new_revision.folder = @folder
|
||||||
new_revision.file = file
|
new_revision.file = file
|
||||||
new_revision.user = User.current
|
new_revision.user = User.current
|
||||||
new_revision.name = name
|
new_revision.name = name
|
||||||
new_revision.title = commited_file["title"]
|
new_revision.title = commited_file['title']
|
||||||
new_revision.description = commited_file["description"]
|
new_revision.description = commited_file['description']
|
||||||
new_revision.comment = commited_file["comment"]
|
new_revision.comment = commited_file['comment']
|
||||||
new_revision.increase_version(commited_file["version"].to_i, true)
|
new_revision.increase_version(commited_file['version'].to_i, true)
|
||||||
new_revision.mime_type = Redmine::MimeType.of(new_revision.name)
|
new_revision.mime_type = Redmine::MimeType.of(new_revision.name)
|
||||||
new_revision.size = File.size(commited_disk_filepath)
|
new_revision.size = File.size(commited_disk_filepath)
|
||||||
|
|
||||||
file_upload = File.new(commited_disk_filepath, "rb")
|
file_upload = File.new(commited_disk_filepath, 'rb')
|
||||||
if file_upload.nil?
|
unless file_upload
|
||||||
failed_uploads.push(commited_file)
|
failed_uploads.push(commited_file)
|
||||||
flash[:error] = l(:error_file_commit_require_uploaded_file)
|
flash[:error] = l(:error_file_commit_require_uploaded_file)
|
||||||
next
|
next
|
||||||
@ -161,30 +160,32 @@ class DmsfUploadController < ApplicationController
|
|||||||
|
|
||||||
files.push(file)
|
files.push(file)
|
||||||
|
|
||||||
unless commited_file["dmsf_file_revision"].blank?
|
if commited_file['dmsf_file_revision'].present?
|
||||||
commited_file["dmsf_file_revision"]["custom_field_values"].each do |v|
|
commited_file['dmsf_file_revision']['custom_field_values'].each do |v|
|
||||||
cv = CustomValue.find(:first, :conditions => ["customized_id = " + new_revision.id.to_s + " AND custom_field_id = " + v[0]])
|
cv = CustomValue.where(:customized_id => new_revision.id, :custom_field_id => v[0]).first
|
||||||
|
if cv
|
||||||
cv.value = v[1]
|
cv.value = v[1]
|
||||||
cv.save
|
cv.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
failed_uploads.push(commited_file)
|
failed_uploads.push(commited_file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless files.empty?
|
unless files.empty?
|
||||||
files.each {|file| log_activity(file, "uploaded") unless file.nil?}
|
files.each { |file| log_activity(file, 'uploaded') if file }
|
||||||
begin
|
begin
|
||||||
DmsfMailer.files_updated(User.current, files).deliver
|
DmsfMailer.files_updated(User.current, files).deliver
|
||||||
rescue ActionView::MissingTemplate => e
|
rescue ActionView::MissingTemplate => e
|
||||||
Rails.logger.error "Could not send email notifications: " + e.to_s
|
Rails.logger.error "Could not send email notifications: #{e.message}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
unless failed_uploads.empty?
|
unless failed_uploads.empty?
|
||||||
flash[:warning] = l(:warning_some_files_were_not_commited, :files => failed_uploads.map{|u| u["name"]}.join(", "))
|
flash[:warning] = l(:warning_some_files_were_not_commited, :files => failed_uploads.map{|u| u['name']}.join(', '))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect_to :controller => "dmsf", :action => "show", :id => @project, :folder_id => @folder
|
redirect_to :controller => 'dmsf', :action => 'show', :id => @project, :folder_id => @folder
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -198,14 +199,14 @@ class DmsfUploadController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def find_folder
|
def find_folder
|
||||||
@folder = DmsfFolder.visible.find(params[:folder_id]) if params.keys.include?("folder_id")
|
@folder = DmsfFolder.visible.find(params[:folder_id]) if params.keys.include?('folder_id')
|
||||||
check_project(@folder)
|
check_project(@folder)
|
||||||
rescue DmsfAccessError
|
rescue DmsfAccessError
|
||||||
render_403
|
render_403
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_project(entry)
|
def check_project(entry)
|
||||||
if !entry.nil? && entry.project != @project
|
if entry && entry.project != @project
|
||||||
raise DmsfAccessError, l(:error_entry_project_does_not_match_current_project)
|
raise DmsfAccessError, l(:error_entry_project_does_not_match_current_project)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -20,7 +20,7 @@ begin
|
|||||||
require 'xapian'
|
require 'xapian'
|
||||||
$xapian_bindings_available = true
|
$xapian_bindings_available = true
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
Rails.logger.info "REDMAIN_XAPIAN ERROR: No Ruby bindings for Xapian installed !!. PLEASE install Xapian search engine interface for Ruby."
|
Rails.logger.info 'REDMAIN_XAPIAN ERROR: No Ruby bindings for Xapian installed !!. PLEASE install Xapian search engine interface for Ruby.'
|
||||||
$xapian_bindings_available = false
|
$xapian_bindings_available = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -30,15 +30,15 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
include RedmineDmsf::Lockable
|
include RedmineDmsf::Lockable
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :folder, :class_name => "DmsfFolder", :foreign_key => "dmsf_folder_id"
|
belongs_to :folder, :class_name => 'DmsfFolder', :foreign_key => 'dmsf_folder_id'
|
||||||
has_many :revisions, :class_name => "DmsfFileRevision", :foreign_key => "dmsf_file_id",
|
has_many :revisions, :class_name => 'DmsfFileRevision', :foreign_key => 'dmsf_file_id',
|
||||||
:order => "#{DmsfFileRevision.table_name}.major_version DESC, #{DmsfFileRevision.table_name}.minor_version DESC, #{DmsfFileRevision.table_name}.updated_at DESC",
|
:order => "#{DmsfFileRevision.table_name}.major_version DESC, #{DmsfFileRevision.table_name}.minor_version DESC, #{DmsfFileRevision.table_name}.updated_at DESC",
|
||||||
:dependent => :destroy
|
:dependent => :destroy
|
||||||
has_many :locks, :class_name => "DmsfLock", :foreign_key => "entity_id",
|
has_many :locks, :class_name => 'DmsfLock', :foreign_key => 'entity_id',
|
||||||
:order => "#{DmsfLock.table_name}.updated_at DESC",
|
:order => "#{DmsfLock.table_name}.updated_at DESC",
|
||||||
:conditions => {:entity_type => 0},
|
:conditions => {:entity_type => 0},
|
||||||
:dependent => :destroy
|
:dependent => :destroy
|
||||||
belongs_to :deleted_by_user, :class_name => "User", :foreign_key => "deleted_by_user_id"
|
belongs_to :deleted_by_user, :class_name => 'User', :foreign_key => 'deleted_by_user_id'
|
||||||
|
|
||||||
scope :visible, lambda {|*args| where(DmsfFile.visible_condition(args.shift || User.current, *args)).readonly(false)}
|
scope :visible, lambda {|*args| where(DmsfFile.visible_condition(args.shift || User.current, *args)).readonly(false)}
|
||||||
|
|
||||||
@ -55,18 +55,18 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
|
|
||||||
def validates_name_uniqueness
|
def validates_name_uniqueness
|
||||||
existing_file = DmsfFile.visible.find_file_by_name(self.project, self.folder, self.name)
|
existing_file = DmsfFile.visible.find_file_by_name(self.project, self.folder, self.name)
|
||||||
errors.add(:name, l("activerecord.errors.messages.taken")) unless
|
errors.add(:name, l('activerecord.errors.messages.taken')) unless
|
||||||
existing_file.nil? || existing_file.id == self.id
|
existing_file.nil? || existing_file.id == self.id
|
||||||
end
|
end
|
||||||
|
|
||||||
acts_as_event :title => Proc.new {|o| "#{o.title} - #{o.name}"},
|
acts_as_event :title => Proc.new {|o| "#{o.title} - #{o.name}"},
|
||||||
:description => Proc.new {|o| o.description },
|
:description => Proc.new {|o| o.description },
|
||||||
:url => Proc.new {|o| {:controller => "dmsf_files", :action => "show", :id => o, :download => ""}},
|
:url => Proc.new {|o| {:controller => 'dmsf_files', :action => 'show', :id => o, :download => ''}},
|
||||||
:datetime => Proc.new {|o| o.updated_at },
|
:datetime => Proc.new {|o| o.updated_at },
|
||||||
:author => Proc.new {|o| o.last_revision.user }
|
:author => Proc.new {|o| o.last_revision.user }
|
||||||
|
|
||||||
|
|
||||||
@@storage_path = Setting.plugin_redmine_dmsf["dmsf_storage_directory"].strip
|
@@storage_path = Setting.plugin_redmine_dmsf['dmsf_storage_directory'].strip
|
||||||
|
|
||||||
def self.storage_path
|
def self.storage_path
|
||||||
if !File.exists?(@@storage_path)
|
if !File.exists?(@@storage_path)
|
||||||
@ -82,20 +82,14 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.project_root_files(project)
|
def self.project_root_files(project)
|
||||||
visible.find(:all, :conditions =>
|
visible.where(:dmsf_folder_id => nil, :project_id => project.if).order('name ASC')
|
||||||
["dmsf_folder_id is NULL and project_id = :project_id",
|
|
||||||
{:project_id => project.id}], :order => "#{self.table_name}.name ASC")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_file_by_name(project, folder, name)
|
def self.find_file_by_name(project, folder, name)
|
||||||
if folder.nil?
|
if folder
|
||||||
visible.find(:first, :conditions =>
|
visible.where(:project_id => project, :dmsf_folder_id => folder.id, :name => name).first
|
||||||
["dmsf_folder_id is NULL and project_id = :project_id and name = :name",
|
|
||||||
{:project_id => project.id, :name => name}])
|
|
||||||
else
|
else
|
||||||
visible.find(:first, :conditions =>
|
visible.where(:project_id => project, :dmsf_folder_id => nil, :name => name).first
|
||||||
["dmsf_folder_id = :folder_id and project_id = :project_id and name = :name",
|
|
||||||
{:project_id => project.id, :folder_id => folder.id, :name => name}])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -109,8 +103,8 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
errors[:base] << l(:error_file_is_locked)
|
errors[:base] << l(:error_file_is_locked)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if Setting.plugin_redmine_dmsf["dmsf_really_delete_files"]
|
if Setting.plugin_redmine_dmsf['dmsf_really_delete_files']
|
||||||
CustomValue.find(:all, :conditions => "customized_id = " + self.id.to_s).each do |v|
|
CustomValue.where(:customized_id => self.id).all.each do |v|
|
||||||
v.destroy
|
v.destroy
|
||||||
end
|
end
|
||||||
self.revisions.visible.each {|r| r.delete(true)}
|
self.revisions.visible.each {|r| r.delete(true)}
|
||||||
@ -172,12 +166,7 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def display_name
|
def display_name
|
||||||
#if self.name.length > 33
|
|
||||||
# extension = File.extname(self.name)
|
|
||||||
# return self.name[0, self.name.length - extension.length][0, 25] + "..." + extension
|
|
||||||
#else
|
|
||||||
return self.name
|
return self.name
|
||||||
#end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of projects that current user can copy file to
|
# Returns an array of projects that current user can copy file to
|
||||||
@ -193,18 +182,8 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
|
|
||||||
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
||||||
def available_custom_fields
|
def available_custom_fields
|
||||||
search_project = nil
|
|
||||||
if self.project.present?
|
|
||||||
search_project = self.project
|
|
||||||
elsif self.project_id.present?
|
|
||||||
search_project = Project.find(self.project_id)
|
|
||||||
end
|
|
||||||
if search_project
|
|
||||||
search_project.all_dmsf_custom_fields
|
|
||||||
else
|
|
||||||
DmsfFileRevisionCustomField.all
|
DmsfFileRevisionCustomField.all
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def move_to(project, folder)
|
def move_to(project, folder)
|
||||||
if self.locked_for_user?
|
if self.locked_for_user?
|
||||||
@ -219,14 +198,14 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
new_revision.comment = l(:comment_moved_from, :source => "#{self.project.identifier}:#{self.dmsf_path_str}")
|
new_revision.comment = l(:comment_moved_from, :source => "#{self.project.identifier}:#{self.dmsf_path_str}")
|
||||||
|
|
||||||
new_revision.custom_values = []
|
new_revision.custom_values = []
|
||||||
temp_custom_values = self.last_revision.custom_values.select{|cv| new_revision.project.all_dmsf_custom_fields.include?(cv.custom_field)}.map(&:clone)
|
temp_custom_values = self.last_revision.custom_values.select{|cv| new_revision.available_custom_fields.include?(cv.custom_field)}.map(&:clone)
|
||||||
new_revision.custom_values = temp_custom_values
|
new_revision.custom_values = temp_custom_values
|
||||||
|
|
||||||
#add default value for CFs not existing
|
# Add default value for CFs not existing
|
||||||
present_custom_fields = new_revision.custom_values.collect(&:custom_field).uniq
|
present_custom_fields = new_revision.custom_values.collect(&:custom_field).uniq
|
||||||
Project.find(new_revision.project_id).all_dmsf_custom_fields.each do |cf|
|
new_revision.available_custom_fields.each do |cf|
|
||||||
unless present_custom_fields.include?(cf)
|
unless present_custom_fields.include?(cf)
|
||||||
new_revision.custom_values << CustomValue.new({:custom_field => cf, :value => cf.default_value})
|
new_revision.custom_values << CustomValue.new({:custom_field => cf, :value => cf.default_value}) if cf.default_value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -258,15 +237,13 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
new_revision.project = folder ? folder.project : project
|
new_revision.project = folder ? folder.project : project
|
||||||
new_revision.comment = l(:comment_copied_from, :source => "#{self.project.identifier}: #{self.dmsf_path_str}")
|
new_revision.comment = l(:comment_copied_from, :source => "#{self.project.identifier}: #{self.dmsf_path_str}")
|
||||||
|
|
||||||
new_revision.custom_values = []
|
new_revision.custom_values = Array.new(self.last_revision.custom_values)
|
||||||
temp_custom_values = self.last_revision.custom_values.select{|cv| new_revision.project.all_dmsf_custom_fields.include?(cv.custom_field)}.map(&:clone)
|
|
||||||
new_revision.custom_values = temp_custom_values
|
|
||||||
|
|
||||||
#add default value for CFs not existing
|
# Add default value for CFs not existing
|
||||||
present_custom_fields = new_revision.custom_values.collect(&:custom_field).uniq
|
present_custom_fields = new_revision.custom_values.collect(&:custom_field).uniq
|
||||||
new_revision.project.all_dmsf_custom_fields.each do |cf|
|
new_revision.available_custom_fields.each do |cf|
|
||||||
unless present_custom_fields.include?(cf)
|
unless present_custom_fields.include?(cf)
|
||||||
new_revision.custom_values << CustomValue.new({:custom_field => cf, :value => cf.default_value})
|
new_revision.custom_values << CustomValue.new({:custom_field => cf, :value => cf.default_value}) if cf.default_value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -324,9 +301,9 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
if !options[:titles_only] && $xapian_bindings_available
|
if !options[:titles_only] && $xapian_bindings_available
|
||||||
database = nil
|
database = nil
|
||||||
begin
|
begin
|
||||||
database = Xapian::Database.new(Setting.plugin_redmine_dmsf["dmsf_index_database"].strip)
|
database = Xapian::Database.new(Setting.plugin_redmine_dmsf['dmsf_index_database'].strip)
|
||||||
rescue
|
rescue
|
||||||
Rails.logger.warn "REDMAIN_XAPIAN ERROR: Xapian database is not properly set or initiated or is corrupted."
|
Rails.logger.warn 'REDMAIN_XAPIAN ERROR: Xapian database is not properly set or initiated or is corrupted.'
|
||||||
end
|
end
|
||||||
|
|
||||||
unless database.nil?
|
unless database.nil?
|
||||||
@ -339,9 +316,12 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
qp.database = database
|
qp.database = database
|
||||||
|
|
||||||
case Setting.plugin_redmine_dmsf['dmsf_stemming_strategy'].strip
|
case Setting.plugin_redmine_dmsf['dmsf_stemming_strategy'].strip
|
||||||
when "STEM_NONE" then qp.stemming_strategy = Xapian::QueryParser::STEM_NONE
|
when 'STEM_NONE'
|
||||||
when "STEM_SOME" then qp.stemming_strategy = Xapian::QueryParser::STEM_SOME
|
qp.stemming_strategy = Xapian::QueryParser::STEM_NONE
|
||||||
when "STEM_ALL" then qp.stemming_strategy = Xapian::QueryParser::STEM_ALL
|
when 'STEM_SOME'
|
||||||
|
qp.stemming_strategy = Xapian::QueryParser::STEM_SOME
|
||||||
|
when 'STEM_ALL'
|
||||||
|
qp.stemming_strategy = Xapian::QueryParser::STEM_ALL
|
||||||
end
|
end
|
||||||
|
|
||||||
if options[:all_words]
|
if options[:all_words]
|
||||||
@ -355,12 +335,12 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
enquire.query = query
|
enquire.query = query
|
||||||
matchset = enquire.mset(0, 1000)
|
matchset = enquire.mset(0, 1000)
|
||||||
|
|
||||||
unless matchset.nil?
|
if matchset
|
||||||
matchset.matches.each {|m|
|
matchset.matches.each {|m|
|
||||||
docdata = m.document.data{url}
|
docdata = m.document.data{url}
|
||||||
dochash = Hash[*docdata.scan(/(url|sample|modtime|type|size)=\/?([^\n\]]+)/).flatten]
|
dochash = Hash[*docdata.scan(/(url|sample|modtime|type|size)=\/?([^\n\]]+)/).flatten]
|
||||||
filename = dochash["url"]
|
filename = dochash['url']
|
||||||
if !filename.nil?
|
if filename
|
||||||
dmsf_attrs = filename.scan(/^([^\/]+\/[^_]+)_([\d]+)_(.*)$/)
|
dmsf_attrs = filename.scan(/^([^\/]+\/[^_]+)_([\d]+)_(.*)$/)
|
||||||
id_attribute = 0
|
id_attribute = 0
|
||||||
id_attribute = dmsf_attrs[0][1] if dmsf_attrs.length > 0
|
id_attribute = dmsf_attrs[0][1] if dmsf_attrs.length > 0
|
||||||
@ -369,7 +349,7 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
|
|
||||||
dmsf_file = DmsfFile.where(limit_options[:conditions]).where(:id => id_attribute, :deleted => false).first
|
dmsf_file = DmsfFile.where(limit_options[:conditions]).where(:id => id_attribute, :deleted => false).first
|
||||||
|
|
||||||
if !dmsf_file.nil?
|
if dmsf_file
|
||||||
if options[:offset]
|
if options[:offset]
|
||||||
if options[:before]
|
if options[:before]
|
||||||
next if dmsf_file.updated_at < options[:offset]
|
next if dmsf_file.updated_at < options[:offset]
|
||||||
@ -380,7 +360,7 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
|
|
||||||
allowed = User.current.allowed_to?(:view_dmsf_files, dmsf_file.project)
|
allowed = User.current.allowed_to?(:view_dmsf_files, dmsf_file.project)
|
||||||
project_included = false
|
project_included = false
|
||||||
project_included = true if projects.nil?
|
project_included = true unless projects
|
||||||
unless project_included
|
unless project_included
|
||||||
projects.each do |x|
|
projects.each do |x|
|
||||||
if x.is_a?(ActiveRecord::Relation)
|
if x.is_a?(ActiveRecord::Relation)
|
||||||
|
|||||||
@ -18,13 +18,13 @@
|
|||||||
|
|
||||||
class DmsfFileRevision < ActiveRecord::Base
|
class DmsfFileRevision < ActiveRecord::Base
|
||||||
unloadable
|
unloadable
|
||||||
belongs_to :file, :class_name => "DmsfFile", :foreign_key => "dmsf_file_id"
|
belongs_to :file, :class_name => 'DmsfFile', :foreign_key => 'dmsf_file_id'
|
||||||
belongs_to :source_revision, :class_name => "DmsfFileRevision", :foreign_key => "source_dmsf_file_revision_id"
|
belongs_to :source_revision, :class_name => 'DmsfFileRevision', :foreign_key => 'source_dmsf_file_revision_id'
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :folder, :class_name => "DmsfFolder", :foreign_key => "dmsf_folder_id"
|
belongs_to :folder, :class_name => 'DmsfFolder', :foreign_key => 'dmsf_folder_id'
|
||||||
belongs_to :deleted_by_user, :class_name => "User", :foreign_key => "deleted_by_user_id"
|
belongs_to :deleted_by_user, :class_name => 'User', :foreign_key => 'deleted_by_user_id'
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
has_many :access, :class_name => "DmsfFileRevisionAccess", :foreign_key => "dmsf_file_revision_id", :dependent => :destroy
|
has_many :access, :class_name => 'DmsfFileRevisionAccess', :foreign_key => 'dmsf_file_revision_id', :dependent => :destroy
|
||||||
has_many :dmsf_workflow_step_assignment, :dependent => :destroy
|
has_many :dmsf_workflow_step_assignment, :dependent => :destroy
|
||||||
|
|
||||||
# Returns a list of revisions that are not deleted here, or deleted at parent level either
|
# Returns a list of revisions that are not deleted here, or deleted at parent level either
|
||||||
@ -38,7 +38,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
:description => Proc.new {|o| o.comment },
|
:description => Proc.new {|o| o.comment },
|
||||||
:author => Proc.new {|o| o.user }
|
:author => Proc.new {|o| o.user }
|
||||||
|
|
||||||
acts_as_activity_provider :type => "dmsf_files",
|
acts_as_activity_provider :type => 'dmsf_files',
|
||||||
:timestamp => "#{DmsfFileRevision.table_name}.updated_at",
|
:timestamp => "#{DmsfFileRevision.table_name}.updated_at",
|
||||||
:author_key => "#{DmsfFileRevision.table_name}.user_id",
|
:author_key => "#{DmsfFileRevision.table_name}.user_id",
|
||||||
:permission => :view_dmsf_files,
|
:permission => :view_dmsf_files,
|
||||||
@ -59,7 +59,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
|
|
||||||
# TODO: check if better to move to dmsf_upload class
|
# TODO: check if better to move to dmsf_upload class
|
||||||
def self.filename_to_title(filename)
|
def self.filename_to_title(filename)
|
||||||
remove_extension(filename).gsub(/_+/, " ");
|
remove_extension(filename).gsub(/_+/, ' ');
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete(delete_all = false)
|
def delete(delete_all = false)
|
||||||
@ -71,19 +71,18 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
errors[:base] << l(:error_at_least_one_revision_must_be_present)
|
errors[:base] << l(:error_at_least_one_revision_must_be_present)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
dependent = DmsfFileRevision.find(:all, :conditions =>
|
dependent = DmsfFileRevision.find(:source_dmsf_file_revision_id => self.id, :deleted => false).all
|
||||||
["source_dmsf_file_revision_id = :id and deleted = :deleted",
|
|
||||||
{:id => self.id, :deleted => false}])
|
|
||||||
dependent.each do |d|
|
dependent.each do |d|
|
||||||
d.source_revision = self.source_revision
|
d.source_revision = self.source_revision
|
||||||
d.save!
|
d.save!
|
||||||
end
|
end
|
||||||
if Setting.plugin_redmine_dmsf["dmsf_really_delete_files"]
|
if Setting.plugin_redmine_dmsf['dmsf_really_delete_files']
|
||||||
dependent = DmsfFileRevision.find(:all, :conditions =>
|
dependent = DmsfFileRevision..where(:disk_filename => self.disk_filename).all
|
||||||
["disk_filename = :filename", {:filename => self.disk_filename}])
|
|
||||||
File.delete(self.disk_file) if dependent.length <= 1 && File.exist?(self.disk_file)
|
File.delete(self.disk_file) if dependent.length <= 1 && File.exist?(self.disk_file)
|
||||||
DmsfFileRevisionAccess.find(:all, :conditions => ["dmsf_file_revision_id = ?", self.id]).each {|a| a.destroy}
|
DmsfFileRevisionAccess.where(:dmsf_file_revision_id => self.id).all.each do |a|
|
||||||
CustomValue.find(:all, :conditions => "customized_id = " + self.id.to_s).each do |v|
|
a.destroy
|
||||||
|
end
|
||||||
|
CustomValue.find(:customized_id => self.id).all.each do |v|
|
||||||
v.destroy
|
v.destroy
|
||||||
end
|
end
|
||||||
self.destroy
|
self.destroy
|
||||||
@ -106,7 +105,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
# custom SQL into a temporary object
|
# custom SQL into a temporary object
|
||||||
#
|
#
|
||||||
def access_grouped
|
def access_grouped
|
||||||
access.select("user_id, count(*) as count, min(created_at) as first_at, max(created_at) as last_at").group("user_id")
|
access.select('user_id, COUNT(*) AS count, MIN(created_at) AS first_at, MAX(created_at) AS last_at').group('user_id')
|
||||||
end
|
end
|
||||||
|
|
||||||
def version
|
def version
|
||||||
@ -126,7 +125,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
def detect_content_type
|
def detect_content_type
|
||||||
content_type = self.mime_type
|
content_type = self.mime_type
|
||||||
content_type = Redmine::MimeType.of(self.disk_filename) if content_type.blank?
|
content_type = Redmine::MimeType.of(self.disk_filename) if content_type.blank?
|
||||||
content_type = "application/octet-stream" if content_type.blank?
|
content_type = 'application/octet-stream' if content_type.blank?
|
||||||
content_type.to_s
|
content_type.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -214,15 +213,11 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def display_title
|
def display_title
|
||||||
#if self.title.length > 35
|
|
||||||
# return self.title[0, 30] + "..."
|
|
||||||
#else
|
|
||||||
return self.title
|
return self.title
|
||||||
#end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_storage_filename
|
def new_storage_filename
|
||||||
raise DmsfAccessError, "File id is not set" unless self.file.id
|
raise DmsfAccessError, 'File id is not set' unless self.file.id
|
||||||
filename = DmsfHelper.sanitize_filename(self.name)
|
filename = DmsfHelper.sanitize_filename(self.name)
|
||||||
timestamp = DateTime.now.strftime("%y%m%d%H%M%S")
|
timestamp = DateTime.now.strftime("%y%m%d%H%M%S")
|
||||||
while File.exist?(File.join(DmsfFile.storage_path, "#{timestamp}_#{self.file.id}_#{filename}"))
|
while File.exist?(File.join(DmsfFile.storage_path, "#{timestamp}_#{self.file.id}_#{filename}"))
|
||||||
@ -232,7 +227,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def copy_file_content(open_file)
|
def copy_file_content(open_file)
|
||||||
File.open(self.disk_file, "wb") do |f|
|
File.open(self.disk_file, 'wb') do |f|
|
||||||
while (buffer = open_file.read(8192))
|
while (buffer = open_file.read(8192))
|
||||||
f.write(buffer)
|
f.write(buffer)
|
||||||
end
|
end
|
||||||
@ -241,17 +236,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
|
|
||||||
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
||||||
def available_custom_fields
|
def available_custom_fields
|
||||||
search_project = nil
|
|
||||||
if self.project.present?
|
|
||||||
search_project = self.project
|
|
||||||
elsif self.project_id.present?
|
|
||||||
search_project = Project.find(self.project_id)
|
|
||||||
end
|
|
||||||
if search_project
|
|
||||||
search_project.all_dmsf_custom_fields
|
|
||||||
else
|
|
||||||
DmsfFileRevisionCustomField.all
|
DmsfFileRevisionCustomField.all
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,13 +1,23 @@
|
|||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright (C) 2013 Karel Picman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class DmsfFileRevisionCustomField < CustomField
|
class DmsfFileRevisionCustomField < CustomField
|
||||||
unloadable
|
|
||||||
has_and_belongs_to_many :projects, :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :foreign_key => "custom_field_id"
|
|
||||||
|
|
||||||
def initialize(attributes = nil)
|
|
||||||
super
|
|
||||||
self.searchable = true
|
|
||||||
end
|
|
||||||
|
|
||||||
def type_name
|
def type_name
|
||||||
:DMSF_custom_field
|
:menu_dmsf
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -25,19 +25,19 @@ class DmsfFolder < ActiveRecord::Base
|
|||||||
@@invalid_characters = /\A[^\/\\\?":<>]*\z/
|
@@invalid_characters = /\A[^\/\\\?":<>]*\z/
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :folder, :class_name => "DmsfFolder", :foreign_key => "dmsf_folder_id"
|
belongs_to :folder, :class_name => 'DmsfFolder', :foreign_key => 'dmsf_folder_id'
|
||||||
has_many :subfolders, :class_name => "DmsfFolder", :foreign_key => "dmsf_folder_id", :order => "#{DmsfFolder.table_name}.title ASC",
|
has_many :subfolders, :class_name => 'DmsfFolder', :foreign_key => 'dmsf_folder_id', :order => "#{DmsfFolder.table_name}.title ASC",
|
||||||
:dependent => :destroy
|
:dependent => :destroy
|
||||||
has_many :files, :class_name => "DmsfFile", :foreign_key => "dmsf_folder_id",
|
has_many :files, :class_name => 'DmsfFile', :foreign_key => 'dmsf_folder_id',
|
||||||
:dependent => :destroy
|
:dependent => :destroy
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
has_many :locks, :class_name => "DmsfLock", :foreign_key => "entity_id",
|
has_many :locks, :class_name => 'DmsfLock', :foreign_key => 'entity_id',
|
||||||
:order => "#{DmsfLock.table_name}.updated_at DESC",
|
:order => "#{DmsfLock.table_name}.updated_at DESC",
|
||||||
:conditions => {:entity_type => 1},
|
:conditions => {:entity_type => 1},
|
||||||
:dependent => :destroy
|
:dependent => :destroy
|
||||||
|
|
||||||
scope :visible, lambda {|*args| {:conditions => "" }} #For future use, however best to be referenced now
|
scope :visible, lambda {|*args| {:conditions => '' }} #For future use, however best to be referenced now
|
||||||
|
|
||||||
acts_as_customizable
|
acts_as_customizable
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ class DmsfFolder < ActiveRecord::Base
|
|||||||
|
|
||||||
acts_as_event :title => Proc.new {|o| o.title},
|
acts_as_event :title => Proc.new {|o| o.title},
|
||||||
:description => Proc.new {|o| o.description },
|
:description => Proc.new {|o| o.description },
|
||||||
:url => Proc.new {|o| {:controller => "dmsf", :action => "show", :id => o.project, :folder_id => o}},
|
:url => Proc.new {|o| {:controller => 'dmsf', :action => 'show', :id => o.project, :folder_id => o}},
|
||||||
:datetime => Proc.new {|o| o.updated_at },
|
:datetime => Proc.new {|o| o.updated_at },
|
||||||
:author => Proc.new {|o| o.user }
|
:author => Proc.new {|o| o.user }
|
||||||
|
|
||||||
@ -69,19 +69,14 @@ class DmsfFolder < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.project_root_folders(project)
|
def self.project_root_folders(project)
|
||||||
find(:all, :conditions =>
|
visible.where(:project_id => project.id, :dmsf_folder_id => nil, ).order('title ASC').all
|
||||||
["#{DmsfFolder.table_name}.dmsf_folder_id is NULL and #{DmsfFolder.table_name}.project_id = :project_id", {:project_id => project.id}], :order => "#{DmsfFolder.table_name}.title ASC")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find_by_title(project, folder, title)
|
def self.find_by_title(project, folder, title)
|
||||||
if folder.nil?
|
if folder
|
||||||
visible.find(:first, :conditions =>
|
visible.where(:project_id => project.id, :dmsf_folder_id => nil, :title => title).first
|
||||||
["#{DmsfFolder.table_name}.dmsf_folder_id is NULL and #{DmsfFolder.table_name}.project_id = :project_id and #{DmsfFolder.table_name}.title = :title",
|
|
||||||
{:project_id => project.id, :title => title}])
|
|
||||||
else
|
else
|
||||||
visible.find(:first, :conditions =>
|
visible.where(:project_id => project.id, :dmsf_folder_id => folder.id, :title => title).first
|
||||||
["#{DmsfFolder.table_name}.dmsf_folder_id = :folder_id and #{DmsfFolder.table_name}.title = :title",
|
|
||||||
{:project_id => project.id, :folder_id => folder.id, :title => title}])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -99,7 +94,7 @@ class DmsfFolder < ActiveRecord::Base
|
|||||||
def dmsf_path
|
def dmsf_path
|
||||||
folder = self
|
folder = self
|
||||||
path = []
|
path = []
|
||||||
while !folder.nil?
|
while folder
|
||||||
path.unshift(folder)
|
path.unshift(folder)
|
||||||
folder = folder.folder
|
folder = folder.folder
|
||||||
end
|
end
|
||||||
@ -109,7 +104,7 @@ class DmsfFolder < ActiveRecord::Base
|
|||||||
def dmsf_path_str
|
def dmsf_path_str
|
||||||
path = self.dmsf_path
|
path = self.dmsf_path
|
||||||
string_path = path.map { |element| element.title }
|
string_path = path.map { |element| element.title }
|
||||||
string_path.join("/")
|
string_path.join('/')
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify?
|
def notify?
|
||||||
@ -197,16 +192,13 @@ class DmsfFolder < ActiveRecord::Base
|
|||||||
new_folder.description = self.description
|
new_folder.description = self.description
|
||||||
new_folder.user = User.current
|
new_folder.user = User.current
|
||||||
|
|
||||||
#copy only cfs present in destination project
|
new_folder.custom_values = Array.new(self.custom_values)
|
||||||
temp_custom_values = self.custom_values.select{|cv| new_folder.project.all_dmsf_custom_fields.include?(cv.custom_field)}.map(&:clone)
|
|
||||||
|
|
||||||
new_folder.custom_values = temp_custom_values
|
# Add default value for CFs not existing
|
||||||
|
|
||||||
#add default value for CFs not existing
|
|
||||||
present_custom_fields = new_folder.custom_values.collect(&:custom_field).uniq
|
present_custom_fields = new_folder.custom_values.collect(&:custom_field).uniq
|
||||||
new_folder.project.all_dmsf_custom_fields.each do |cf|
|
new_folder.available_custom_fields.each do |cf|
|
||||||
unless present_custom_fields.include?(cf)
|
unless present_custom_fields.include?(cf)
|
||||||
new_folder.custom_values << CustomValue.new({:custom_field => cf, :value => cf.default_value})
|
new_folder.custom_values << CustomValue.new({:custom_field => cf, :value => cf.default_value}) if cf.default_value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -225,18 +217,8 @@ class DmsfFolder < ActiveRecord::Base
|
|||||||
|
|
||||||
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
# Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields
|
||||||
def available_custom_fields
|
def available_custom_fields
|
||||||
search_project = nil
|
|
||||||
if self.project.present?
|
|
||||||
search_project = self.project
|
|
||||||
elsif self.project_id.present?
|
|
||||||
search_project = Project.find(self.project_id)
|
|
||||||
end
|
|
||||||
if search_project
|
|
||||||
search_project.all_dmsf_custom_fields
|
|
||||||
else
|
|
||||||
DmsfFileRevisionCustomField.all
|
DmsfFileRevisionCustomField.all
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# To fullfill searchable module expectations
|
# To fullfill searchable module expectations
|
||||||
def self.search(tokens, projects=nil, options={})
|
def self.search(tokens, projects=nil, options={})
|
||||||
@ -244,12 +226,12 @@ class DmsfFolder < ActiveRecord::Base
|
|||||||
projects = [] << projects unless projects.nil? || projects.is_a?(Array)
|
projects = [] << projects unless projects.nil? || projects.is_a?(Array)
|
||||||
|
|
||||||
find_options = {:include => [:project]}
|
find_options = {:include => [:project]}
|
||||||
find_options[:order] = "dmsf_folders.updated_at " + (options[:before] ? 'DESC' : 'ASC')
|
find_options[:order] = 'dmsf_folders.updated_at ' + (options[:before] ? 'DESC' : 'ASC')
|
||||||
|
|
||||||
limit_options = {}
|
limit_options = {}
|
||||||
limit_options[:limit] = options[:limit] if options[:limit]
|
limit_options[:limit] = options[:limit] if options[:limit]
|
||||||
if options[:offset]
|
if options[:offset]
|
||||||
limit_options[:conditions] = "(dmsf_folders.updated_at " + (options[:before] ? '<' : '>') + "'#{connection.quoted_date(options[:offset])}')"
|
limit_options[:conditions] = '(dmsf_folders.updated_at ' + (options[:before] ? '<' : '>') + "'#{connection.quoted_date(options[:offset])}')"
|
||||||
end
|
end
|
||||||
|
|
||||||
columns = options[:titles_only] ? ["dmsf_folders.title"] : ["dmsf_folders.title", "dmsf_folders.description"]
|
columns = options[:titles_only] ? ["dmsf_folders.title"] : ["dmsf_folders.title", "dmsf_folders.description"]
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
<% unless object.nil? %>
|
<% if object %>
|
||||||
<div class="dmsf-customfields">
|
<div class="dmsf-customfields">
|
||||||
<% object.show_custom_field_values.each do |custom_value| %>
|
<% object.show_custom_field_values.each do |custom_value| %>
|
||||||
<div class="dmsf-customfield-<%= custom_value.custom_field.id %> dmsf-customfield customfield">
|
<div class="dmsf-customfield-<%= custom_value.custom_field.id %> dmsf-customfield customfield">
|
||||||
<%= label_tag("", h(custom_value.custom_field.name) + ":") %> <%= show_value(custom_value) %>
|
<%= label_tag('', "#{h(custom_value.custom_field.name)}:") %> <%= show_value(custom_value) %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -55,9 +55,9 @@
|
|||||||
|
|
||||||
<div class="dmsf-header">
|
<div class="dmsf-header">
|
||||||
<div class="wiki">
|
<div class="wiki">
|
||||||
<%= textilizable(@folder.nil? ? @project.dmsf_description : @folder.description) %>
|
<%= textilizable(@folder ? @folder.description : @project.dmsf_description) %>
|
||||||
</div>
|
</div>
|
||||||
<%= render "custom_fields", :object => @folder %>
|
<%#= render 'custom_fields', :object => @folder %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= error_messages_for('dmsf_workflow') %>
|
<%= error_messages_for('dmsf_workflow') %>
|
||||||
@ -98,7 +98,7 @@
|
|||||||
{:action => "show", :id => @project, :folder_id => subfolder},
|
{:action => "show", :id => @project, :folder_id => subfolder},
|
||||||
:class => "icon icon-folder") %>
|
:class => "icon icon-folder") %>
|
||||||
<div class="filename" title="<%= l(:title_number_of_files_in_directory)%>">[<%= subfolder.deep_file_count %>]</div>
|
<div class="filename" title="<%= l(:title_number_of_files_in_directory)%>">[<%= subfolder.deep_file_count %>]</div>
|
||||||
<%= render 'custom_fields', :object => subfolder %>
|
<%#= render 'custom_fields', :object => subfolder %>
|
||||||
</td>
|
</td>
|
||||||
<td class="size" title="<%= l(:title_total_size_of_all_files)%>"><%= number_to_human_size(subfolder.deep_size) %></td>
|
<td class="size" title="<%= l(:title_total_size_of_all_files)%>"><%= number_to_human_size(subfolder.deep_size) %></td>
|
||||||
<td class="modified"><%= format_time(subfolder.updated_at) %>
|
<td class="modified"><%= format_time(subfolder.updated_at) %>
|
||||||
@ -178,7 +178,7 @@
|
|||||||
:title => l(:title_title_version_version_download, :title => h(file.title), :version => file.version),
|
:title => l(:title_title_version_version_download, :title => h(file.title), :version => file.version),
|
||||||
"data-downloadurl" => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_download_url}") %>
|
"data-downloadurl" => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_download_url}") %>
|
||||||
<div class="filename" title="<%= l(:title_filename_for_download)%>"><%= h(file.display_name) %></div>
|
<div class="filename" title="<%= l(:title_filename_for_download)%>"><%= h(file.display_name) %></div>
|
||||||
<%= render 'custom_fields', :object => file.last_revision %>
|
<%#= render 'custom_fields', :object => file.last_revision %>
|
||||||
</td>
|
</td>
|
||||||
<td class="size"><%= number_to_human_size(file.last_revision.size) %></td>
|
<td class="size"><%= number_to_human_size(file.last_revision.size) %></td>
|
||||||
<td class="modified">
|
<td class="modified">
|
||||||
|
|||||||
@ -1,54 +1,74 @@
|
|||||||
|
<%#
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright (C) 2013 Karel Picman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
%>
|
||||||
|
|
||||||
<div class="box dmsf_detail">
|
<div class="box dmsf_detail">
|
||||||
<strong><%= l(:heading_new_revision) %> <a href="#" id="newRevisionFormContentToggle">[-]</a></strong>
|
<strong><%= l(:heading_new_revision) %> <a href="#" id="newRevisionFormContentToggle">[-]</a></strong>
|
||||||
<div id="newRevisionFormContent">
|
<div id="newRevisionFormContent">
|
||||||
<% if @file.locked_for_user? %>
|
<% if @file.locked_for_user? %>
|
||||||
<p class="warning"><%= l(:info_file_locked) %></p>
|
<p class="warning"><%= l(:info_file_locked) %></p>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= form_for(@revision, :url => {:action => "create_revision", :id => @file},
|
<%= form_for(@revision, :url => {:action => 'create_revision', :id => @file},
|
||||||
:html => {:method=>:post, :multipart => true, :id => "new_revision_form"}) do |f| %>
|
:html => {:method=>:post, :multipart => true, :id => 'new_revision_form'}) do |f| %>
|
||||||
<div class="clear">
|
<div class="clear">
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag("dmsf_file_revision_title", l(:label_title) + ":") %>
|
<%= label_tag('dmsf_file_revision_title', "#{l(:label_title)}:") %>
|
||||||
<%= f.text_field(:title, :size => "32") %>
|
<%= f.text_field(:title, :size => '32') %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
<p style="white-space: nowrap;">
|
<p style="white-space: nowrap;">
|
||||||
<%= label_tag("", l(:label_file) + ":") %>
|
<%= label_tag('', "#{l(:label_file)}:") %>
|
||||||
<%= f.select(:dmsf_folder_id,
|
<%= f.select(:dmsf_folder_id,
|
||||||
options_for_select(DmsfFolder.directory_tree(@project),
|
options_for_select(DmsfFolder.directory_tree(@project),
|
||||||
:selected => (@revision.folder.id unless @revision.folder.nil?))) %> /
|
:selected => (@revision.folder.id if @revision.folder))) %> /
|
||||||
<%= f.text_field(:name, :size => "22") %>
|
<%= f.text_field(:name, :size => '22') %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="no-ident">
|
<p class="no-ident">
|
||||||
<%= label_tag("dmsf_file_revision_description", l(:label_description) + ":") %>
|
<%= label_tag('dmsf_file_revision_description', "#{l(:label_description)}:") %>
|
||||||
</p>
|
</p>
|
||||||
<div class="wiki data clear">
|
<div class="wiki data clear">
|
||||||
<%= f.text_area(:description, :rows=> "6", :class => "wiki-edit") %>
|
<%= f.text_area(:description, :rows=> '6', :class => 'wiki-edit') %>
|
||||||
</div>
|
</div>
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag("fileMinorVersionRadio", l(:label_version) + ":") %>
|
<%= label_tag('fileMinorVersionRadio', "#{l(:label_version)}:") %>
|
||||||
</p>
|
</p>
|
||||||
<div class="data clear">
|
<div class="data clear">
|
||||||
<%= radio_button_tag("version", 0, @revision.version == @file.last_revision.version, :id => "fileSameVersionRadio") %>
|
<%= radio_button_tag('version', 0, @revision.version == @file.last_revision.version, :id => 'fileSameVersionRadio') %>
|
||||||
<%= @file.last_revision.major_version %>.<%= @file.last_revision.minor_version %> <%= l(:option_version_same) %><br />
|
<%= @file.last_revision.major_version %>.<%= @file.last_revision.minor_version %> <%= l(:option_version_same) %><br />
|
||||||
<%= radio_button_tag("version", 1,
|
<%= radio_button_tag('version', 1,
|
||||||
@revision.major_version == @file.last_revision.major_version && @revision.minor_version != @file.last_revision.minor_version,
|
@revision.major_version == @file.last_revision.major_version && @revision.minor_version != @file.last_revision.minor_version,
|
||||||
:id => "fileMinorVersionRadio") %>
|
:id => 'fileMinorVersionRadio') %>
|
||||||
<%= @file.last_revision.major_version %>.<%= @file.last_revision.minor_version + 1 %> <%= l(:option_version_minor) %><br />
|
<%= @file.last_revision.major_version %>.<%= @file.last_revision.minor_version + 1 %> <%= l(:option_version_minor) %><br />
|
||||||
<%= radio_button_tag("version", 2, @revision.major_version != @file.last_revision.major_version) %>
|
<%= radio_button_tag('version', 2, @revision.major_version != @file.last_revision.major_version) %>
|
||||||
<%= @file.last_revision.major_version + 1 %>.0 <%= l(:option_version_major) %><br />
|
<%= @file.last_revision.major_version + 1 %>.0 <%= l(:option_version_major) %><br />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="splitcontentright clear">
|
<div class="splitcontentright clear">
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag("file_upload", l(:label_new_content) + ":") %>
|
<%= label_tag('file_upload', "#{l(:label_new_content)}:") %>
|
||||||
<div class="data">
|
<div class="data">
|
||||||
<%= file_field_tag("file_upload", :size => 30) %>
|
<%= file_field_tag('file_upload', :size => 30) %>
|
||||||
<br />
|
<br />
|
||||||
<small>
|
<small>
|
||||||
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
|
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
|
||||||
@ -64,18 +84,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="comment">
|
<div class="comment">
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag("dmsf_file_revision_comment", l(:label_comment) + ":") %>
|
<%= label_tag('dmsf_file_revision_comment', "#{l(:label_comment)}:") %>
|
||||||
<div class="data">
|
<div class="data">
|
||||||
<%= f.text_area(:comment, :rows=> "2", :style => "width: 99%;") %>
|
<%= f.text_area(:comment, :rows=> '2', :style => 'width: 99%;') %>
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<%= submit_tag(l(:submit_create)) %>
|
<%= submit_tag(l(:submit_create)) %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= wikitoolbar_for "dmsf_file_revision_description" %>
|
<%= wikitoolbar_for 'dmsf_file_revision_description' %>
|
||||||
|
|||||||
@ -1,3 +1,24 @@
|
|||||||
|
<%#=
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||||
|
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
|
||||||
|
# Copyright (C) 2013 Karel Pičman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
%>
|
||||||
<p>
|
<p>
|
||||||
<table class="display access-table list">
|
<table class="display access-table list">
|
||||||
<thead>
|
<thead>
|
||||||
@ -12,7 +33,7 @@
|
|||||||
<% revision.access_grouped.each do |access| %>
|
<% revision.access_grouped.each do |access| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to_user(access.user) %></td>
|
<td><%= link_to_user(access.user) %></td>
|
||||||
<td><%=access["count"]%></td>
|
<td><%= access['count'] %></td>
|
||||||
<td><%= format_time(DmsfHelper::to_time(access.first_at)) %></td>
|
<td><%= format_time(DmsfHelper::to_time(access.first_at)) %></td>
|
||||||
<td><%= format_time(DmsfHelper::to_time(access.last_at)) %></td>
|
<td><%= format_time(DmsfHelper::to_time(access.last_at)) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@ -5,39 +5,39 @@
|
|||||||
<% unless @file.locked_for_user? && !User.current.allowed_to?(:force_file_unlock, @project)%>
|
<% unless @file.locked_for_user? && !User.current.allowed_to?(:force_file_unlock, @project)%>
|
||||||
<% if @file.locked? %>
|
<% if @file.locked? %>
|
||||||
<% unless @file.unlockable? %>
|
<% unless @file.unlockable? %>
|
||||||
<%= image_tag("locked.png", :plugin => :redmine_dmsf, :title => l(:title_file_parent_locked, :name => @file.lock.reverse[0].folder.title)) %>
|
<%= image_tag('locked.png', :plugin => :redmine_dmsf, :title => l(:title_file_parent_locked, :name => @file.lock.reverse[0].folder.title)) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to_function(image_tag("unlock.png", :plugin => "redmine_dmsf"),
|
<%= link_to_function(image_tag('unlock.png', :plugin => 'redmine_dmsf'),
|
||||||
"manipulation_link('#{url_for(:action => 'unlock', :id => @file, :current => request.url)}')",
|
"manipulation_link('#{url_for(:action => 'unlock', :id => @file, :current => request.url)}')",
|
||||||
:title => l(:title_unlock_file)) %>
|
:title => l(:title_unlock_file)) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to_function(image_tag("lock.png", :plugin => "redmine_dmsf"),
|
<%= link_to_function(image_tag('lock.png', :plugin => 'redmine_dmsf'),
|
||||||
"manipulation_link('#{url_for(:action => 'lock', :id => @file, :current => request.url)}')",
|
"manipulation_link('#{url_for(:action => 'lock', :id => @file, :current => request.url)}')",
|
||||||
:title => l(:title_lock_file)) %>
|
:title => l(:title_lock_file)) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if User.current.allowed_to?(:file_manipulation, @project) && !@file.locked_for_user? %>
|
<% if User.current.allowed_to?(:file_manipulation, @project) && !@file.locked_for_user? %>
|
||||||
|
|
||||||
<%= link_to_function(image_tag("delete.png", :plugin => "redmine_dmsf"),
|
<%= link_to_function(image_tag('delete.png', :plugin => 'redmine_dmsf'),
|
||||||
"confirmation_link('#{url_for(:action => 'delete', :id => @file)}', '#{l(:question_do_you_really_want_to_delete_this_entry)}')",
|
"confirmation_link('#{url_for(:action => 'delete', :id => @file)}', '#{l(:question_do_you_really_want_to_delete_this_entry)}')",
|
||||||
:title => l(:title_delete)) %>
|
:title => l(:title_delete)) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if User.current.allowed_to?(:file_approval, @project) %>
|
<% if User.current.allowed_to?(:file_approval, @project) %>
|
||||||
|
|
||||||
<% if @file.notification %>
|
<% if @file.notification %>
|
||||||
<%= link_to_function(image_tag("notify.png", :plugin => "redmine_dmsf"),
|
<%= link_to_function(image_tag('notify.png', :plugin => 'redmine_dmsf'),
|
||||||
"manipulation_link('#{url_for(:action => 'notify_deactivate', :id => @file, :current => request.url)}')",
|
"manipulation_link('#{url_for(:action => 'notify_deactivate', :id => @file, :current => request.url)}')",
|
||||||
:title => l(:title_notifications_active_deactivate)) %>
|
:title => l(:title_notifications_active_deactivate)) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to_function(image_tag("notifynot.png", :plugin => "redmine_dmsf"),
|
<%= link_to_function(image_tag('notifynot.png', :plugin => 'redmine_dmsf'),
|
||||||
"manipulation_link('#{url_for(:action => 'notify_activate', :id => @file, :current => request.url)}')",
|
"manipulation_link('#{url_for(:action => 'notify_activate', :id => @file, :current => request.url)}')",
|
||||||
:title => l(:title_notifications_not_active_activate)) %>
|
:title => l(:title_notifications_not_active_activate)) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= link_to(image_tag("copy.png"), {:controller => :dmsf_files_copy, :action => "new", :id => @file }, :title => l(:title_copy_or_move)) %>
|
<%= link_to(image_tag('copy.png'), {:controller => :dmsf_files_copy, :action => "new", :id => @file }, :title => l(:title_copy_or_move)) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2>
|
<h2>
|
||||||
@ -52,12 +52,12 @@
|
|||||||
<%= image_tag('notify.png', :plugin => 'redmine_dmsf', :title => l(:title_notifications_active)) if @file.notification %>
|
<%= image_tag('notify.png', :plugin => 'redmine_dmsf', :title => l(:title_notifications_active)) if @file.notification %>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<%= error_messages_for("file") %>
|
<%= error_messages_for('file') %>
|
||||||
<%= error_messages_for("revision") %>
|
<%= error_messages_for('revision') %>
|
||||||
|
|
||||||
<%= render(:partial => "file_new_revision") if User.current.allowed_to?(:file_manipulation, @file.project) %>
|
<%= render(:partial => 'file_new_revision') if User.current.allowed_to?(:file_manipulation, @file.project) %>
|
||||||
|
|
||||||
<%= form_tag("", :id => "manipulation_form") %>
|
<%= form_tag('', :id => 'manipulation_form') %>
|
||||||
|
|
||||||
<h3><%= l(:heading_revisions) %></h3>
|
<h3><%= l(:heading_revisions) %></h3>
|
||||||
<% @file.revisions.visible[@revision_pages.current.offset,@revision_pages.items_per_page].each do |revision| %>
|
<% @file.revisions.visible[@revision_pages.current.offset,@revision_pages.items_per_page].each do |revision| %>
|
||||||
@ -84,44 +84,44 @@
|
|||||||
<div style="border: 1px solid #e4e4e4;">
|
<div style="border: 1px solid #e4e4e4;">
|
||||||
<div class="clear">
|
<div class="clear">
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<%= label_tag("", l(:label_title) + ":") %>
|
<%= label_tag('', "#{l(:label_title)}:") %>
|
||||||
<%= h(revision.title) %>
|
<%= h(revision.title) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
<%= label_tag("", l(:label_file) + ":") %>
|
<%= label_tag('', "#{l(:label_file)}:") %>
|
||||||
<%= (h(revision.folder.dmsf_path_str) + "/") unless revision.folder.nil? %><%= h(revision.name) %>
|
<%= ("#{h(revision.folder.dmsf_path_str)}/") if revision.folder %><%= h(revision.name) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="no-ident">
|
<p class="no-ident">
|
||||||
<%= label_tag("", l(:label_description) + ":") %>
|
<%= label_tag('', "#{l(:label_description)}:") %>
|
||||||
</p>
|
</p>
|
||||||
<div class="wiki clear" style="margin-left: 110px">
|
<div class="wiki clear" style="margin-left: 110px">
|
||||||
<%= textilizable(revision.description) %>
|
<%= textilizable(revision.description) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<%= label_tag("", l(:label_version) + ":") %>
|
<%= label_tag('', "#{l(:label_version)}:") %>
|
||||||
<%= revision.major_version %>.<%= revision.minor_version %>
|
<%= revision.major_version %>.<%= revision.minor_version %>
|
||||||
<br/>
|
<br/>
|
||||||
<%= label_tag('', l(:label_workflow) + ':') %>
|
<%= label_tag('', "#{l(:label_workflow)}:") %>
|
||||||
<%= revision.workflow_str true %>
|
<%= revision.workflow_str true %>
|
||||||
</div>
|
</div>
|
||||||
<div class="splitcontentright clear">
|
<div class="splitcontentright clear">
|
||||||
<%= label_tag("", l(:label_mime) + ":") %>
|
<%= label_tag('', "#{l(:label_mime)}:") %>
|
||||||
<%= h(revision.mime_type) %>
|
<%= h(revision.mime_type) %>
|
||||||
<br/>
|
<br/>
|
||||||
<%= label_tag("", l(:label_size) + ":") %>
|
<%= label_tag('', "#{l(:label_size)}:") %>
|
||||||
<%= number_to_human_size(revision.size) %>
|
<%= number_to_human_size(revision.size) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="no-ident clear">
|
<div class="no-ident clear">
|
||||||
<%= render "dmsf/custom_fields", :object => revision %>
|
<%= render 'dmsf/custom_fields', :object => revision %>
|
||||||
</div>
|
</div>
|
||||||
<div class="splitcontentleft clear">
|
<div class="splitcontentleft clear">
|
||||||
<%= label_tag("", l(:label_comment) + ":") %>
|
<%= label_tag('', "#{l(:label_comment)}:") %>
|
||||||
<%= h(revision.comment) %>
|
<%= h(revision.comment) %>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
<div id="<%= "revision_access-#{revision.id}" %>" style="display:none">
|
<div id="<%= "revision_access-#{revision.id}" %>" style="display:none">
|
||||||
<%= render(:partial => "revision_access", :locals => {:revision => revision}) if User.current.allowed_to?(:file_approval, @file.project) %>
|
<%= render(:partial => 'revision_access', :locals => {:revision => revision}) if User.current.allowed_to?(:file_approval, @file.project) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -132,67 +132,71 @@
|
|||||||
<p class="pagination"><%= pagination_links_full @revision_pages, @file.revisions.visible.count %></p>
|
<p class="pagination"><%= pagination_links_full @revision_pages, @file.revisions.visible.count %></p>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
sUrl = "jquery.dataTables/en.json"
|
sUrl = 'jquery.dataTables/en.json'
|
||||||
sUrl = "jquery.dataTables/#{I18n.locale.to_s.downcase}.json" if I18n.locale && !I18n.locale.to_s.match(/^en.*/)
|
sUrl = "jquery.dataTables/#{I18n.locale.to_s.downcase}.json" if I18n.locale && !I18n.locale.to_s.match(/^en.*/)
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery("a.delete-revision").click(function(event) {
|
jQuery('a.delete-revision').click(function(event) {
|
||||||
if(!window.confirm("<%= l(:question_do_you_really_want_to_delete_this_revision) %>")) event.preventDefault();
|
if(!window.confirm('<%= l(:question_do_you_really_want_to_delete_this_revision) %>')) {
|
||||||
})
|
event.preventDefault();
|
||||||
|
|
||||||
jQuery("a.delete-entry").click(function(event) {
|
|
||||||
if(!window.confirm("<%= l(:question_do_you_really_want_to_delete_this_entry) %>")) event.preventDefault();
|
|
||||||
})
|
|
||||||
|
|
||||||
jQuery("#file_upload").change(function() {
|
|
||||||
if(jQuery("input[name=\"version\"]:checked").val() == "0") {
|
|
||||||
jQuery("#fileMinorVersionRadio").prop("checked", true);
|
|
||||||
}
|
}
|
||||||
jQuery("#fileSameVersionRadio").prop("disabled", true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery("#newRevisionFormContentToggle").toggle(function() {
|
jQuery('a.delete-entry').click(function(event) {
|
||||||
jQuery("#newRevisionFormContentToggle").text("[-]");
|
if(!window.confirm('<%= l(:question_do_you_really_want_to_delete_this_entry) %>')) {
|
||||||
jQuery("#newRevisionFormContent").show();
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery('#file_upload').change(function() {
|
||||||
|
if(jQuery("input[name='version']:checked").val() === '0') {
|
||||||
|
jQuery('#fileMinorVersionRadio').prop('checked', true);
|
||||||
|
}
|
||||||
|
jQuery('#fileSameVersionRadio').prop('disabled', true);
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery('#newRevisionFormContentToggle').toggle(function() {
|
||||||
|
jQuery('#newRevisionFormContentToggle').text('[-]');
|
||||||
|
jQuery('#newRevisionFormContent').show();
|
||||||
}, function() {
|
}, function() {
|
||||||
jQuery("#newRevisionFormContentToggle").text("[+]");
|
jQuery('#newRevisionFormContentToggle').text('[+]');
|
||||||
jQuery("#newRevisionFormContent").hide();
|
jQuery('#newRevisionFormContent').hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery(".access-table").dataTable({
|
jQuery('.access-table').dataTable({
|
||||||
"bJQueryUI": true,
|
'bJQueryUI': true,
|
||||||
"oLanguage": {
|
'oLanguage': {
|
||||||
'sUrl': '/plugin_assets/<%= :redmine_dmsf %>/javascripts/<%= sUrl%>'
|
'sUrl': '/plugin_assets/<%= :redmine_dmsf %>/javascripts/<%= sUrl%>'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<% if @revision.valid? && @file.valid? %>
|
<% if @revision.valid? && @file.valid? %>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery("#newRevisionFormContentToggle").text("[+]");
|
jQuery('#newRevisionFormContentToggle').text('[+]');
|
||||||
jQuery("#newRevisionFormContent").hide();
|
jQuery('#newRevisionFormContent').hide();
|
||||||
</script>
|
</script>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% content_for :header_tags do %>
|
<% content_for :header_tags do %>
|
||||||
<%= stylesheet_link_tag "jquery-ui/jquery-ui-1.9.2.css", :plugin => "redmine_dmsf" %>
|
<%= stylesheet_link_tag 'jquery-ui/jquery-ui-1.9.2.css', :plugin => 'redmine_dmsf' %>
|
||||||
<%= stylesheet_link_tag "jquery.dataTables/jquery-ui.dataTables.css", :plugin => "redmine_dmsf" %>
|
<%= stylesheet_link_tag 'jquery.dataTables/jquery-ui.dataTables.css', :plugin => 'redmine_dmsf' %>
|
||||||
<%= stylesheet_link_tag "dmsf", :plugin => "redmine_dmsf" %>
|
<%= stylesheet_link_tag 'dmsf', :plugin => 'redmine_dmsf' %>
|
||||||
<%= javascript_include_tag "jquery-1.6.1.min.js", :plugin => "redmine_dmsf" %>
|
<%= javascript_include_tag 'jquery-1.6.1.min.js', :plugin => 'redmine_dmsf' %>
|
||||||
<%= javascript_include_tag "jquery-ui-1.8.13.min.js", :plugin => "redmine_dmsf" %>
|
<%= javascript_include_tag 'jquery-ui-1.8.13.min.js', :plugin => 'redmine_dmsf' %>
|
||||||
<%= javascript_include_tag "jquery.dataTables/jquery.dataTables.min.js", :plugin => "redmine_dmsf" %>
|
<%= javascript_include_tag 'jquery.dataTables/jquery.dataTables.min.js', :plugin => 'redmine_dmsf' %>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery.noConflict();
|
jQuery.noConflict();
|
||||||
|
|
||||||
function manipulation_link(action) {
|
function manipulation_link(action) {
|
||||||
jQuery("#manipulation_form").attr("action", action);
|
jQuery('#manipulation_form').attr('action', action);
|
||||||
jQuery("#manipulation_form").submit();
|
jQuery('#manipulation_form').submit();
|
||||||
};
|
};
|
||||||
|
|
||||||
function confirmation_link(action, question) {
|
function confirmation_link(action, question) {
|
||||||
if(!window.confirm(question)) return;
|
if(!window.confirm(question)) return;
|
||||||
jQuery("#manipulation_form").attr("action", action);
|
jQuery('#manipulation_form').attr('action', action);
|
||||||
jQuery("#manipulation_form").submit();
|
jQuery('#manipulation_form').submit();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -1,39 +1,40 @@
|
|||||||
|
<%#
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright (C) 2013 Karel Picman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
%>
|
||||||
|
|
||||||
<p><strong><%=l(:link_user_preferences)%></strong></p>
|
<p><strong><%=l(:link_user_preferences)%></strong></p>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<%= form_tag({:controller => "dmsf_state", :action => "user_pref_save", :id => @project},
|
<%= form_tag({:controller => 'dmsf_state', :action => 'user_pref_save', :id => @project}, :method => :post) do %>
|
||||||
:method=>:post) do %>
|
|
||||||
<div>
|
<div>
|
||||||
<%
|
<% member = @project.members.find(:first, :conditions => {:user_id => User.current.id}) %>
|
||||||
member = @project.members.find(:first, :conditions => {:user_id => User.current.id})
|
<% mail_notification = member ? member.dmsf_mail_notification : nil %>
|
||||||
mail_notification = member ? member.dmsf_mail_notification : nil
|
|
||||||
%>
|
|
||||||
<%= l(:label_notifications) %>:
|
<%= l(:label_notifications) %>:
|
||||||
<%= select_tag("email_notify",
|
<%= select_tag(
|
||||||
|
'email_notify',
|
||||||
options_for_select([[l(:select_option_default), nil],
|
options_for_select([[l(:select_option_default), nil],
|
||||||
[l(:select_option_activated), true], [l(:select_option_deactivated), false]],
|
[l(:select_option_activated), true], [l(:select_option_deactivated), false]],
|
||||||
:selected => mail_notification)) %>
|
:selected => mail_notification)) %>
|
||||||
<%= submit_tag(l(:submit_save), :title => l(:title_save_preferences)) %>
|
<%= submit_tag(l(:submit_save), :title => l(:title_save_preferences)) %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% custom_fields = DmsfFileRevisionCustomField.find(:all) %>
|
|
||||||
<% unless custom_fields.empty? %>
|
|
||||||
<%= form_for @project, :url => project_path(@project), :html => {:method=>:post} do %>
|
|
||||||
<fieldset id="project_issue_custom_fields"><legend><%=l(:label_custom_field_plural)%></legend>
|
|
||||||
<% custom_fields.each do |custom_field| %>
|
|
||||||
<label class="floating">
|
|
||||||
<%= check_box_tag 'project[dmsf_file_revision_custom_field_ids][]', custom_field.id, (@project.all_dmsf_custom_fields.include? custom_field), (custom_field.is_for_all? ? {:disabled => "disabled"} : {}) %>
|
|
||||||
<%= custom_field.name %>
|
|
||||||
</label>
|
|
||||||
<% end %>
|
|
||||||
<%= hidden_field_tag 'project[dmsf_file_revision_custom_field_ids][]', '' %>
|
|
||||||
<%= hidden_field_tag '_method', 'put' %>
|
|
||||||
</fieldset>
|
|
||||||
<%= submit_tag(l(:submit_save), :title => l(:title_save_preferences)) %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% content_for :header_tags do %>
|
<% content_for :header_tags do %>
|
||||||
<%= stylesheet_link_tag "dmsf", :plugin => "redmine_dmsf" %>
|
<%= stylesheet_link_tag 'dmsf', :plugin => 'redmine_dmsf' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -1,30 +1,48 @@
|
|||||||
|
<%#
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright (C) 2013 Karel Picman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
%>
|
||||||
<div class="box dmsf_detail">
|
<div class="box dmsf_detail">
|
||||||
<%= hidden_field_tag("commited_files[#{i}][disk_filename]", upload.disk_filename) %>
|
<%= hidden_field_tag("commited_files[#{i}][disk_filename]", upload.disk_filename) %>
|
||||||
<div class="clear">
|
<div class="clear">
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag("commited_files[#{i}][title]", l(:label_title) + ":") %>
|
<%= label_tag("commited_files[#{i}][title]", "#{l(:label_title)}:") %>
|
||||||
<%= text_field_tag("commited_files[#{i}][title]", upload.title, :size => "32") %>
|
<%= text_field_tag("commited_files[#{i}][title]", upload.title, :size => '32') %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag("", l(:label_filename) + ":") %>
|
<%= label_tag('', "#{l(:label_filename)}:") %>
|
||||||
<%= h(upload.name) %>
|
<%= h(upload.name) %>
|
||||||
<%= hidden_field_tag("commited_files[#{i}][name]", upload.name) %>
|
<%= hidden_field_tag("commited_files[#{i}][name]", upload.name) %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="no-ident">
|
<p class="no-ident">
|
||||||
<%= label_tag("commited_files[#{i}][description]", l(:label_description) + ":") %>
|
<%= label_tag("commited_files[#{i}][description]", "#{l(:label_description)}:") %>
|
||||||
</p>
|
</p>
|
||||||
<div class="wiki data clear">
|
<div class="wiki data clear">
|
||||||
<%= text_area_tag("commited_files[#{i}][description]", upload.description, :rows=> "6", :class => "wiki-edit") %>
|
<%= text_area_tag("commited_files[#{i}][description]", upload.description, :rows=> '6', :class => 'wiki-edit') %>
|
||||||
</div>
|
</div>
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag("commited_files[#{i}][version]_minor", l(:label_version) + ":") %>
|
<%= label_tag("commited_files[#{i}][version]_minor", "#{l(:label_version)}:") %>
|
||||||
</p>
|
</p>
|
||||||
<div class="data clear">
|
<div class="data clear">
|
||||||
<%= radio_button_tag("commited_files[#{i}][version]", 1, true) %>
|
<%= radio_button_tag("commited_files[#{i}][version]", 1, true) %>
|
||||||
@ -35,24 +53,23 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="splitcontentright clear">
|
<div class="splitcontentright clear">
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag("", l(:label_mime) + ":") %>
|
<%= label_tag('', "#{l(:label_mime)}:") %>
|
||||||
<%= h(upload.mime_type) %>
|
<%= h(upload.mime_type) %>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag("", l(:label_size) + ":") %>
|
<%= label_tag('', "#{l(:label_size)}:") %>
|
||||||
<%= number_to_human_size(upload.size) %>
|
<%= number_to_human_size(upload.size) %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<br style="clear: both"/>
|
<br style="clear: both"/>
|
||||||
<% @folder ? folder_exists = true : folder_exists = false %>
|
<% values = DmsfFileRevision.new(:file => DmsfFile.new(:project => @project)).custom_field_values %>
|
||||||
<% values = folder_exists ? @folder.custom_field_values : DmsfFileRevision.new(:file => DmsfFile.new(:project => @project)).custom_field_values %>
|
|
||||||
<% values.each do |value| %>
|
<% values.each do |value| %>
|
||||||
<p><%= custom_field_tag_with_label("commited_files[#{i}][dmsf_file_revision]", value) %></p>
|
<p><%= custom_field_tag_with_label("commited_files[#{i}][dmsf_file_revision]", value) %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag("commited_files[#{i}][comment]", l(:label_comment) + ":") %>
|
<%= label_tag("commited_files[#{i}][comment]", "#{l(:label_comment)}:") %>
|
||||||
<div class="data">
|
<div class="data">
|
||||||
<%= text_area_tag("commited_files[#{i}][comment]", upload.comment, :rows=> "2", :style => "width: 99%;") %>
|
<%= text_area_tag("commited_files[#{i}][comment]", upload.comment, :rows=> '2', :style => 'width: 99%;') %>
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -225,7 +225,7 @@ table.access-table tbody td, table.access-table tbody tr:hover td {
|
|||||||
|
|
||||||
/* Custom field */
|
/* Custom field */
|
||||||
.dmsf-customfields {
|
.dmsf-customfields {
|
||||||
margin: 5px 0 5px 25px;
|
margin: 5px 0px 5px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dmsf-customfields .customfield {
|
.dmsf-customfields .customfield {
|
||||||
|
|||||||
@ -1,7 +1,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>
|
||||||
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
|
# Copyright (C) 2012 Daniel Munn <dan.munn@munnster.co.uk>
|
||||||
|
# Copyright (C) 2013 Karel Pičman <karel.picman@kontron.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@ -21,13 +22,24 @@ module Redmine
|
|||||||
module Acts
|
module Acts
|
||||||
module Customizable
|
module Customizable
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
def available_custom_fields
|
# def available_custom_fields
|
||||||
cf_classname = self.class.name == 'DmsfFolder' ? 'DmsfFileRevision' : self.class.name
|
# cf_classname = self.class.name == 'DmsfFolder' ? 'DmsfFileRevision' : self.class.name
|
||||||
CustomField.find(:all, :conditions => "type = '#{cf_classname}CustomField'", :order => 'position')
|
# CustomField.find(:all, :conditions => "type = '#{cf_classname}CustomField'", :order => 'position')
|
||||||
end
|
# end
|
||||||
|
|
||||||
def show_custom_field_values
|
def show_custom_field_values
|
||||||
custom_field_values.delete_if { |x| (!x.id && x.id.blank?) || x.value.blank? }
|
# a = custom_field_values
|
||||||
|
# c = a.count
|
||||||
|
# custom_field_values.each do |v|
|
||||||
|
# if v.id.blank?
|
||||||
|
# if v.value.blank?
|
||||||
|
# d = true
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
#custom_field_values.delete_if { |x| (!x.id && x.id.blank?) || x.value.blank? } if d
|
||||||
|
custom_field_values.delete_if { |v| v.custom_field.blank? || v.value.blank? }
|
||||||
|
# b = a.count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -42,9 +42,9 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
|
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
def all_dmsf_custom_fields
|
#def all_dmsf_custom_fields
|
||||||
@all_dmsf_custom_fields ||= (DmsfFileRevisionCustomField.for_all).uniq.sort # + dmsf_file_revision_custom_fields).uniq.sort
|
# @all_dmsf_custom_fields ||= (DmsfFileRevisionCustomField.for_all).uniq.sort # + dmsf_file_revision_custom_fields).uniq.sort
|
||||||
end
|
#end
|
||||||
|
|
||||||
def dmsf_count
|
def dmsf_count
|
||||||
file_count = DmsfFile.visible.project_root_files(self).count
|
file_count = DmsfFile.visible.project_root_files(self).count
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user