Add document revision.patch_version #1151
This commit is contained in:
parent
53582a46c4
commit
e9a8375911
@ -103,21 +103,16 @@ class DmsfFilesController < ApplicationController
|
|||||||
revision.name = params[:dmsf_file_revision][:name]
|
revision.name = params[:dmsf_file_revision][:name]
|
||||||
revision.description = params[:dmsf_file_revision][:description]
|
revision.description = params[:dmsf_file_revision][:description]
|
||||||
revision.comment = params[:dmsf_file_revision][:comment]
|
revision.comment = params[:dmsf_file_revision][:comment]
|
||||||
|
|
||||||
revision.dmsf_file = @file
|
revision.dmsf_file = @file
|
||||||
last_revision = @file.last_revision
|
last_revision = @file.last_revision
|
||||||
revision.source_revision = last_revision
|
revision.source_revision = last_revision
|
||||||
revision.user = User.current
|
revision.user = User.current
|
||||||
|
|
||||||
revision.major_version = last_revision.major_version
|
# Version
|
||||||
revision.minor_version = last_revision.minor_version
|
revision.major_version = DmsfUploadHelper::db_version(params[:version_major])
|
||||||
version = params[:version].to_i
|
revision.minor_version = DmsfUploadHelper::db_version(params[:version_minor])
|
||||||
if version == 3
|
revision.patch_version = DmsfUploadHelper::db_version(params[:version_patch])
|
||||||
revision.major_version = DmsfUploadHelper::db_version(params[:custom_version_major])
|
|
||||||
revision.minor_version = DmsfUploadHelper::db_version(params[:custom_version_minor])
|
|
||||||
else
|
|
||||||
revision.increase_version(version)
|
|
||||||
end
|
|
||||||
file_upload = params[:dmsf_attachments]['1'] if params[:dmsf_attachments].present?
|
file_upload = params[:dmsf_attachments]['1'] if params[:dmsf_attachments].present?
|
||||||
if file_upload
|
if file_upload
|
||||||
upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, file_upload)
|
upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, file_upload)
|
||||||
@ -144,7 +139,6 @@ class DmsfFilesController < ApplicationController
|
|||||||
|
|
||||||
@file.name = revision.name
|
@file.name = revision.name
|
||||||
ok = true
|
ok = true
|
||||||
|
|
||||||
if revision.save
|
if revision.save
|
||||||
revision.assign_workflow params[:dmsf_workflow_id]
|
revision.assign_workflow params[:dmsf_workflow_id]
|
||||||
if upload
|
if upload
|
||||||
|
|||||||
@ -30,7 +30,7 @@ module DmsfHelper
|
|||||||
unless Redmine::Plugin.installed?(:easy_extensions)
|
unless Redmine::Plugin.installed?(:easy_extensions)
|
||||||
|
|
||||||
def late_javascript_tag(content_or_options_with_block = nil, html_options = {}, &block)
|
def late_javascript_tag(content_or_options_with_block = nil, html_options = {}, &block)
|
||||||
javascript_tag content_or_options_with_block, html_options, &block
|
javascript_tag content_or_options_with_block, html_options, &block
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -35,16 +35,10 @@ module DmsfUploadHelper
|
|||||||
link = DmsfLink.find_link_by_file_name(project, folder, name)
|
link = DmsfLink.find_link_by_file_name(project, folder, name)
|
||||||
file = link.target_file if link
|
file = link.target_file if link
|
||||||
end
|
end
|
||||||
|
|
||||||
if file
|
if file
|
||||||
if file.last_revision
|
if file.last_revision
|
||||||
last_revision = file.last_revision
|
last_revision = file.last_revision
|
||||||
new_revision.source_revision = last_revision
|
new_revision.source_revision = last_revision
|
||||||
new_revision.major_version = last_revision.major_version
|
|
||||||
new_revision.minor_version = last_revision.minor_version
|
|
||||||
else
|
|
||||||
new_revision.minor_version = 0
|
|
||||||
new_revision.major_version = 0
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
file = DmsfFile.new
|
file = DmsfFile.new
|
||||||
@ -52,32 +46,20 @@ module DmsfUploadHelper
|
|||||||
file.name = name
|
file.name = name
|
||||||
file.dmsf_folder = folder
|
file.dmsf_folder = folder
|
||||||
file.notification = Setting.plugin_redmine_dmsf['dmsf_default_notifications'].present?
|
file.notification = Setting.plugin_redmine_dmsf['dmsf_default_notifications'].present?
|
||||||
new_revision.minor_version = 0
|
|
||||||
new_revision.major_version = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if file.locked_for_user?
|
if file.locked_for_user?
|
||||||
failed_uploads.push file
|
failed_uploads.push file
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
new_revision.dmsf_file = file
|
new_revision.dmsf_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]
|
||||||
if commited_file[:version].present?
|
new_revision.major_version = commited_file[:version_major].present? ? DmsfUploadHelper::db_version(commited_file[:version_major]) : 1
|
||||||
version = commited_file[:version].is_a?(Array) ? commited_file[:version][0].to_i : commited_file[:version].to_i
|
new_revision.minor_version = commited_file[:version_minor].present? ? DmsfUploadHelper::db_version(commited_file[:version_minor]) : 0
|
||||||
else
|
new_revision.patch_version = commited_file[:version_patch].present? ? DmsfUploadHelper::db_version(commited_file[:version_patch]) : nil
|
||||||
version = 1
|
|
||||||
end
|
|
||||||
if version == 3
|
|
||||||
new_revision.major_version = DmsfUploadHelper::db_version(commited_file[:custom_version_major])
|
|
||||||
new_revision.minor_version = DmsfUploadHelper::db_version(commited_file[:custom_version_minor])
|
|
||||||
else
|
|
||||||
new_revision.increase_version(version)
|
|
||||||
end
|
|
||||||
new_revision.mime_type = commited_file[:mime_type]
|
new_revision.mime_type = commited_file[:mime_type]
|
||||||
new_revision.size = commited_file[:size]
|
new_revision.size = commited_file[:size]
|
||||||
new_revision.digest = commited_file[:digest]
|
new_revision.digest = commited_file[:digest]
|
||||||
@ -177,27 +159,32 @@ module DmsfUploadHelper
|
|||||||
(0..999).to_a + [' ']
|
(0..999).to_a + [' ']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class <<self
|
||||||
|
alias_method :patch_version_select_options, :minor_version_select_options
|
||||||
|
end
|
||||||
|
|
||||||
# 1 -> 2, -1 -> -2, A -> B
|
# 1 -> 2, -1 -> -2, A -> B
|
||||||
def self.increase_version(version, number)
|
def self.increase_version(version)
|
||||||
return number if ((version == ' ') || ((-version) == ' '.ord))
|
version ||= 0
|
||||||
|
return 1 if ((version == ' ') || ((-version) == ' '.ord))
|
||||||
if Integer(version)
|
if Integer(version)
|
||||||
if version >= 0
|
if version >= 0
|
||||||
if (version + number) < 1000
|
if (version + 1) < 1000
|
||||||
version + number
|
version + 1
|
||||||
else
|
else
|
||||||
version
|
version
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if -(version - number) < 'Z'.ord
|
if -(version - 1) < 'Z'.ord
|
||||||
version - number
|
version - 1
|
||||||
else
|
else
|
||||||
version
|
version
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
if (version.ord + number) < 'Z'.ord
|
if (version.ord + 1) < 'Z'.ord
|
||||||
(version.ord + number).chr
|
(version.ord + 1).chr
|
||||||
else
|
else
|
||||||
version
|
version
|
||||||
end
|
end
|
||||||
@ -205,12 +192,14 @@ module DmsfUploadHelper
|
|||||||
|
|
||||||
# 1 -> 1, -65 -> A
|
# 1 -> 1, -65 -> A
|
||||||
def self.gui_version(version)
|
def self.gui_version(version)
|
||||||
|
return ' ' unless version
|
||||||
return version if version >= 0
|
return version if version >= 0
|
||||||
(-version).chr
|
(-version).chr
|
||||||
end
|
end
|
||||||
|
|
||||||
# 1 -> 1, A -> -65
|
# 1 -> 1, A -> -65
|
||||||
def self.db_version(version)
|
def self.db_version(version)
|
||||||
|
return nil if(version.nil? || version == ' ')
|
||||||
version.to_i if Integer(version)
|
version.to_i if Integer(version)
|
||||||
rescue
|
rescue
|
||||||
version = ' ' if version.blank?
|
version = ' ' if version.blank?
|
||||||
|
|||||||
@ -37,6 +37,10 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
STATUS_DELETED = 1
|
STATUS_DELETED = 1
|
||||||
STATUS_ACTIVE = 0
|
STATUS_ACTIVE = 0
|
||||||
|
|
||||||
|
PATCH_VERSION = 1
|
||||||
|
MINOR_VERSION = 2
|
||||||
|
MAJOR_VERSION = 3
|
||||||
|
|
||||||
PROTOCOLS = {
|
PROTOCOLS = {
|
||||||
'application/msword' => 'ms-word',
|
'application/msword' => 'ms-word',
|
||||||
'application/excel' => 'ms-excel',
|
'application/excel' => 'ms-excel',
|
||||||
@ -145,15 +149,18 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def version
|
def version
|
||||||
DmsfFileRevision.version major_version, minor_version
|
DmsfFileRevision.version major_version, minor_version, patch_version
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.version(major_version, minor_version)
|
def self.version(major_version, minor_version, patch_version)
|
||||||
if major_version && minor_version
|
if major_version && minor_version
|
||||||
ver = DmsfUploadHelper::gui_version(major_version).to_s
|
ver = DmsfUploadHelper::gui_version(major_version).to_s
|
||||||
if -minor_version != ' '.ord
|
if -minor_version != ' '.ord
|
||||||
ver << ".#{DmsfUploadHelper::gui_version(minor_version)}"
|
ver << ".#{DmsfUploadHelper::gui_version(minor_version)}"
|
||||||
end
|
end
|
||||||
|
if patch_version.present? && (-patch_version != ' '.ord)
|
||||||
|
ver << ".#{DmsfUploadHelper::gui_version(patch_version)}"
|
||||||
|
end
|
||||||
ver
|
ver
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -211,6 +218,7 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
new_revision.workflow = workflow
|
new_revision.workflow = workflow
|
||||||
new_revision.major_version = major_version
|
new_revision.major_version = major_version
|
||||||
new_revision.minor_version = minor_version
|
new_revision.minor_version = minor_version
|
||||||
|
new_revision.patch_version = patch_version
|
||||||
new_revision.source_revision = self
|
new_revision.source_revision = self
|
||||||
new_revision.user = User.current
|
new_revision.user = User.current
|
||||||
new_revision.name = name
|
new_revision.name = name
|
||||||
@ -259,17 +267,26 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def increase_version(version_to_increase)
|
def increase_version(version_to_increase)
|
||||||
|
# Patch version
|
||||||
|
self.patch_version = case version_to_increase
|
||||||
|
when PATCH_VERSION
|
||||||
|
DmsfUploadHelper.increase_version patch_version
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
# Minor version
|
||||||
self.minor_version = case version_to_increase
|
self.minor_version = case version_to_increase
|
||||||
when 1
|
when MINOR_VERSION
|
||||||
DmsfUploadHelper.increase_version(minor_version, 1)
|
DmsfUploadHelper.increase_version minor_version
|
||||||
when 2
|
when MAJOR_VERSION
|
||||||
(major_version < 0) ? -(' '.ord) : 0
|
(major_version < 0) ? -(' '.ord) : 0
|
||||||
else
|
else
|
||||||
minor_version
|
minor_version
|
||||||
end
|
end
|
||||||
|
# Major version
|
||||||
self.major_version = case version_to_increase
|
self.major_version = case version_to_increase
|
||||||
when 2
|
when MAJOR_VERSION
|
||||||
DmsfUploadHelper::increase_version(major_version, 1)
|
DmsfUploadHelper::increase_version major_version
|
||||||
else
|
else
|
||||||
major_version
|
major_version
|
||||||
end
|
end
|
||||||
|
|||||||
@ -172,7 +172,7 @@ class DmsfMailer < Mailer
|
|||||||
end
|
end
|
||||||
# Watchers
|
# Watchers
|
||||||
watchers = []
|
watchers = []
|
||||||
file.get_all_watchers(watchers)
|
file&.get_all_watchers(watchers)
|
||||||
users.concat watchers
|
users.concat watchers
|
||||||
if User.current&.pref.no_self_notified
|
if User.current&.pref.no_self_notified
|
||||||
users.delete User.current
|
users.delete User.current
|
||||||
|
|||||||
@ -33,9 +33,10 @@ class DmsfQuery < Query
|
|||||||
DmsfTitleQueryColumn.new(:title, sortable: 'title', frozen: true),
|
DmsfTitleQueryColumn.new(:title, sortable: 'title', frozen: true),
|
||||||
QueryColumn.new(:size, sortable: 'size'),
|
QueryColumn.new(:size, sortable: 'size'),
|
||||||
DmsfModifiedQueryColumn.new(:modified, sortable: 'updated'),
|
DmsfModifiedQueryColumn.new(:modified, sortable: 'updated'),
|
||||||
DmsfVersionQueryColumn.new(:version, sortable: 'major_version, minor_version', caption: :label_dmsf_version),
|
DmsfVersionQueryColumn.new(:version, sortable: %(major_version minor_version patch_version),
|
||||||
|
caption: :label_dmsf_version),
|
||||||
QueryColumn.new(:workflow, sortable: 'workflow'),
|
QueryColumn.new(:workflow, sortable: 'workflow'),
|
||||||
QueryColumn.new(:author, sortable: 'firstname, lastname')
|
QueryColumn.new(:author, sortable: %(firstname lastname))
|
||||||
]
|
]
|
||||||
|
|
||||||
def initialize(attributes=nil, *args)
|
def initialize(attributes=nil, *args)
|
||||||
@ -170,10 +171,10 @@ class DmsfQuery < Query
|
|||||||
order_option = ['sort', group_by_sort_order, (options[:order] || sort_clause[0])].flatten.reject(&:blank?)
|
order_option = ['sort', group_by_sort_order, (options[:order] || sort_clause[0])].flatten.reject(&:blank?)
|
||||||
if order_option.size > 1
|
if order_option.size > 1
|
||||||
DmsfFileRevisionCustomField.visible.pluck(:id, :name).each do |id, name|
|
DmsfFileRevisionCustomField.visible.pluck(:id, :name).each do |id, name|
|
||||||
order_option[1].gsub!("cf_#{id}.value", "cf_#{id}")
|
order_option[1].gsub! "cf_#{id}.value", "cf_#{id}"
|
||||||
end
|
end
|
||||||
if order_option[1] =~ /(firstname|major_version), (lastname|minor_version) (DESC|ASC)$/
|
if order_option[1] =~ /^(firstname|major_version),? (lastname|minor_version)( patch_version)? (DESC|ASC)$/
|
||||||
order_option[1].gsub!(',', " #{$3},")
|
order_option[1] = $3.present? ? "#{$1} #{$4}, #{$2} #{$4}, #{$3} #{$4}" : "#{$1} #{$4}, #{$2} #{$4}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -245,6 +246,7 @@ class DmsfQuery < Query
|
|||||||
projects.updated_on AS updated,
|
projects.updated_on AS updated,
|
||||||
CAST(NULL AS #{get_integer_type}) AS major_version,
|
CAST(NULL AS #{get_integer_type}) AS major_version,
|
||||||
CAST(NULL AS #{get_integer_type}) AS minor_version,
|
CAST(NULL AS #{get_integer_type}) AS minor_version,
|
||||||
|
CAST(NULL AS #{get_integer_type}) AS patch_version,
|
||||||
CAST(NULL AS #{get_integer_type}) AS workflow,
|
CAST(NULL AS #{get_integer_type}) AS workflow,
|
||||||
CAST(NULL AS #{get_integer_type}) AS workflow_id,
|
CAST(NULL AS #{get_integer_type}) AS workflow_id,
|
||||||
'' AS firstname,
|
'' AS firstname,
|
||||||
@ -278,6 +280,7 @@ class DmsfQuery < Query
|
|||||||
dmsf_folders.updated_at AS updated,
|
dmsf_folders.updated_at AS updated,
|
||||||
CAST(NULL AS #{get_integer_type}) AS major_version,
|
CAST(NULL AS #{get_integer_type}) AS major_version,
|
||||||
CAST(NULL AS #{get_integer_type}) AS minor_version,
|
CAST(NULL AS #{get_integer_type}) AS minor_version,
|
||||||
|
CAST(NULL AS #{get_integer_type}) AS patch_version,
|
||||||
CAST(NULL AS #{get_integer_type}) AS workflow,
|
CAST(NULL AS #{get_integer_type}) AS workflow,
|
||||||
CAST(NULL AS #{get_integer_type}) AS workflow_id,
|
CAST(NULL AS #{get_integer_type}) AS workflow_id,
|
||||||
users.firstname AS firstname,
|
users.firstname AS firstname,
|
||||||
@ -322,6 +325,7 @@ class DmsfQuery < Query
|
|||||||
COALESCE(dmsf_folders.updated_at, dmsf_links.updated_at) AS updated,
|
COALESCE(dmsf_folders.updated_at, dmsf_links.updated_at) AS updated,
|
||||||
CAST(NULL AS #{get_integer_type}) AS major_version,
|
CAST(NULL AS #{get_integer_type}) AS major_version,
|
||||||
CAST(NULL AS #{get_integer_type}) AS minor_version,
|
CAST(NULL AS #{get_integer_type}) AS minor_version,
|
||||||
|
CAST(NULL AS #{get_integer_type}) AS patch_version,
|
||||||
CAST(NULL AS #{get_integer_type}) AS workflow,
|
CAST(NULL AS #{get_integer_type}) AS workflow,
|
||||||
CAST(NULL AS #{get_integer_type}) AS workflow_id,
|
CAST(NULL AS #{get_integer_type}) AS workflow_id,
|
||||||
users.firstname AS firstname,
|
users.firstname AS firstname,
|
||||||
@ -361,6 +365,7 @@ class DmsfQuery < Query
|
|||||||
dmsf_file_revisions.updated_at AS updated,
|
dmsf_file_revisions.updated_at AS updated,
|
||||||
dmsf_file_revisions.major_version AS major_version,
|
dmsf_file_revisions.major_version AS major_version,
|
||||||
dmsf_file_revisions.minor_version AS minor_version,
|
dmsf_file_revisions.minor_version AS minor_version,
|
||||||
|
dmsf_file_revisions.patch_version AS patch_version,
|
||||||
dmsf_file_revisions.workflow AS workflow,
|
dmsf_file_revisions.workflow AS workflow,
|
||||||
dmsf_file_revisions.dmsf_workflow_id AS workflow_id,
|
dmsf_file_revisions.dmsf_workflow_id AS workflow_id,
|
||||||
users.firstname AS firstname,
|
users.firstname AS firstname,
|
||||||
@ -401,6 +406,7 @@ class DmsfQuery < Query
|
|||||||
dmsf_file_revisions.updated_at AS updated,
|
dmsf_file_revisions.updated_at AS updated,
|
||||||
dmsf_file_revisions.major_version AS major_version,
|
dmsf_file_revisions.major_version AS major_version,
|
||||||
dmsf_file_revisions.minor_version AS minor_version,
|
dmsf_file_revisions.minor_version AS minor_version,
|
||||||
|
dmsf_file_revisions.patch_version AS patch_version,
|
||||||
dmsf_file_revisions.workflow AS workflow,
|
dmsf_file_revisions.workflow AS workflow,
|
||||||
dmsf_file_revisions.dmsf_workflow_id AS workflow_id,
|
dmsf_file_revisions.dmsf_workflow_id AS workflow_id,
|
||||||
users.firstname AS firstname,
|
users.firstname AS firstname,
|
||||||
@ -443,6 +449,7 @@ class DmsfQuery < Query
|
|||||||
dmsf_links.updated_at AS updated,
|
dmsf_links.updated_at AS updated,
|
||||||
CAST(NULL AS #{get_integer_type}) AS major_version,
|
CAST(NULL AS #{get_integer_type}) AS major_version,
|
||||||
CAST(NULL AS #{get_integer_type}) AS minor_version,
|
CAST(NULL AS #{get_integer_type}) AS minor_version,
|
||||||
|
CAST(NULL AS #{get_integer_type}) AS patch_version,
|
||||||
CAST(NULL AS #{get_integer_type}) AS workflow,
|
CAST(NULL AS #{get_integer_type}) AS workflow,
|
||||||
CAST(NULL AS #{get_integer_type}) AS workflow_id,
|
CAST(NULL AS #{get_integer_type}) AS workflow_id,
|
||||||
users.firstname AS firstname,
|
users.firstname AS firstname,
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class DmsfUpload
|
|||||||
attr_accessor :comment
|
attr_accessor :comment
|
||||||
attr_accessor :major_version
|
attr_accessor :major_version
|
||||||
attr_accessor :minor_version
|
attr_accessor :minor_version
|
||||||
|
attr_accessor :patch_version
|
||||||
attr_accessor :locked
|
attr_accessor :locked
|
||||||
attr_accessor :workflow
|
attr_accessor :workflow
|
||||||
attr_accessor :custom_values
|
attr_accessor :custom_values
|
||||||
@ -83,6 +84,7 @@ class DmsfUpload
|
|||||||
@description = uploaded[:comment]
|
@description = uploaded[:comment]
|
||||||
@major_version = 0
|
@major_version = 0
|
||||||
@minor_version = 0
|
@minor_version = 0
|
||||||
|
@patch_version = nil
|
||||||
@workflow = nil
|
@workflow = nil
|
||||||
file = DmsfFile.new
|
file = DmsfFile.new
|
||||||
file.project_id = project.id
|
file.project_id = project.id
|
||||||
@ -100,6 +102,7 @@ class DmsfUpload
|
|||||||
end
|
end
|
||||||
@major_version = last_revision.major_version
|
@major_version = last_revision.major_version
|
||||||
@minor_version = last_revision.minor_version
|
@minor_version = last_revision.minor_version
|
||||||
|
@patch_version = last_revision.patch_version
|
||||||
@workflow = last_revision.workflow
|
@workflow = last_revision.workflow
|
||||||
@custom_values = Array.new(file.last_revision.custom_values)
|
@custom_values = Array.new(file.last_revision.custom_values)
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
class DmsfVersionQueryColumn < QueryColumn
|
class DmsfVersionQueryColumn < QueryColumn
|
||||||
|
|
||||||
def value_object(object)
|
def value_object(object)
|
||||||
DmsfFileRevision.version object.major_version, object.minor_version
|
DmsfFileRevision.version object.major_version, object.minor_version, object.patch_version
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
%>
|
%>
|
||||||
|
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<strong><%= l(:heading_new_revision) %> <a href="#" id="new_revision_form_content_toggle">[+]</a></strong>
|
<strong><%= l(:heading_new_revision) %> <a href="#" id="new_revision_form_content_toggle">[+]</a></strong>
|
||||||
<div id="new_revision_form_content">
|
<div id="new_revision_form_content">
|
||||||
<% 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>
|
||||||
@ -31,7 +31,7 @@
|
|||||||
<%= labelled_form_for(@revision, url: { action: 'create_revision', id: @file },
|
<%= labelled_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| %>
|
||||||
<%= hidden_field_tag 'back_url', params[:back_url] %>
|
<%= hidden_field_tag 'back_url', params[:back_url] %>
|
||||||
<div class="clear">
|
<div class="splitcontent">
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<p>
|
<p>
|
||||||
<%= f.text_field(:title) %>
|
<%= f.text_field(:title) %>
|
||||||
@ -46,37 +46,25 @@
|
|||||||
<p>
|
<p>
|
||||||
<%= f.text_area :description, rows: 6, class: 'wiki-edit dmsf-description' %>
|
<%= f.text_area :description, rows: 6, class: 'wiki-edit dmsf-description' %>
|
||||||
</p>
|
</p>
|
||||||
<div class="clear">
|
<div class="splitcontent">
|
||||||
|
<div class="splitcontentleft">
|
||||||
|
<p>
|
||||||
|
<%= render partial: 'dmsf_files/version_selector', locals: {
|
||||||
|
label_tag_name: 'version',
|
||||||
|
select_tag_name_patch: 'version_patch',
|
||||||
|
select_tag_name_minor: 'version_minor',
|
||||||
|
select_tag_name_major: 'version_major',
|
||||||
|
revision_or_upload: @file.last_revision } %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
<div class="custom_fields">
|
<div class="custom_fields">
|
||||||
<% @revision.custom_field_values.each do |value| %>
|
<% @revision.custom_field_values.each do |value| %>
|
||||||
<% value.value = nil if value.custom_field.dmsf_not_inheritable %>
|
<% value.value = nil if value.custom_field.dmsf_not_inheritable %>
|
||||||
<p><%= custom_field_tag_with_label(:dmsf_file_revision, value) %></p>
|
<p><%= custom_field_tag_with_label(:dmsf_file_revision, value) %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="splitcontentleft">
|
|
||||||
<p>
|
|
||||||
<%= label_tag('version_0', l(:label_dmsf_version)) %>
|
|
||||||
<%= radio_button_tag('version', 0, @revision.version == @file.last_revision.version) %>
|
|
||||||
<%= @file.last_revision.version %>
|
|
||||||
<%= l(:option_version_same) %><br/>
|
|
||||||
<%= radio_button_tag('version', 1, @revision.major_version == @file.last_revision.major_version && @revision.minor_version != @file.last_revision.minor_version) %>
|
|
||||||
<%= DmsfUploadHelper::gui_version(@file.last_revision.major_version) %>.<%= DmsfUploadHelper::gui_version(DmsfUploadHelper.increase_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) %>
|
|
||||||
<%= DmsfUploadHelper.gui_version(DmsfUploadHelper::increase_version(@file.last_revision.major_version, 1)) %>.0
|
|
||||||
<%= l(:option_version_major) %><br/>
|
|
||||||
<%= radio_button_tag('version', 3) %>
|
|
||||||
<%= select_tag 'custom_version_major', options_for_select(DmsfUploadHelper::major_version_select_options,
|
|
||||||
DmsfUploadHelper::gui_version(DmsfUploadHelper::increase_version(@file.last_revision.major_version, 2))),
|
|
||||||
onchange: '$("#version_3").prop("checked", true)', class: 'dmsf-select-version' %>.
|
|
||||||
<%= select_tag 'custom_version_minor', options_for_select(DmsfUploadHelper::minor_version_select_options,
|
|
||||||
DmsfUploadHelper::gui_version(DmsfUploadHelper.increase_version(@file.last_revision.minor_version, 1))),
|
|
||||||
onchange: '$("#version_3").prop("checked", true)', class: 'dmsf-select-version' %>
|
|
||||||
<%= l(:option_version_custom) %>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="box" id="file_upload_box">
|
<div class="box" id="file_upload_box">
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
45
app/views/dmsf_files/_version_selector.html.erb
Normal file
45
app/views/dmsf_files/_version_selector.html.erb
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<%
|
||||||
|
# encoding: utf-8
|
||||||
|
#
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||||
|
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
|
||||||
|
# Copyright © 2011-22 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.
|
||||||
|
%>
|
||||||
|
|
||||||
|
<%= label_tag(label_tag_name, l(:label_dmsf_version)) %>
|
||||||
|
<%= select_tag select_tag_name_major, options_for_select(DmsfUploadHelper::major_version_select_options,
|
||||||
|
DmsfUploadHelper::gui_version(revision_or_upload.major_version)),
|
||||||
|
class: 'dmsf-select-version' %>
|
||||||
|
<bold>.</bold>
|
||||||
|
<% if revision_or_upload.patch_version.present? && (DmsfUploadHelper::gui_version(revision_or_upload.patch_version) != ' ') %>
|
||||||
|
<%= select_tag select_tag_name_minor, options_for_select(DmsfUploadHelper::minor_version_select_options,
|
||||||
|
DmsfUploadHelper::gui_version(revision_or_upload.minor_version)),
|
||||||
|
class: 'dmsf-select-version' %>
|
||||||
|
<bold>.</bold>
|
||||||
|
<%= select_tag select_tag_name_patch, options_for_select(DmsfUploadHelper::patch_version_select_options,
|
||||||
|
DmsfUploadHelper::gui_version(DmsfUploadHelper.increase_version(revision_or_upload.patch_version))),
|
||||||
|
class: 'dmsf-select-version' %>
|
||||||
|
<% else %>
|
||||||
|
<%= select_tag select_tag_name_minor, options_for_select(DmsfUploadHelper::minor_version_select_options,
|
||||||
|
DmsfUploadHelper::gui_version(DmsfUploadHelper.increase_version(revision_or_upload.minor_version))),
|
||||||
|
class: 'dmsf-select-version' %>
|
||||||
|
<bold>.</bold>
|
||||||
|
<%= select_tag select_tag_name_patch, options_for_select(DmsfUploadHelper::patch_version_select_options,
|
||||||
|
[h(' '), '']), class: 'dmsf-select-version' %>
|
||||||
|
<% end %>
|
||||||
@ -18,7 +18,13 @@ api.dmsf_file do
|
|||||||
api.title r.title
|
api.title r.title
|
||||||
api.description r.description
|
api.description r.description
|
||||||
api.workflow r.workflow
|
api.workflow r.workflow
|
||||||
api.version "#{r.major_version}.#{r.minor_version}"
|
if r.patch_version.present?
|
||||||
|
api.version "#{r.major_version}.#{r.minor_version}.#{r.patch_version}"
|
||||||
|
elsif r.minor_version.present?
|
||||||
|
api.version "#{r.major_version}.#{r.minor_version}"
|
||||||
|
else
|
||||||
|
api.version r.major_version
|
||||||
|
end
|
||||||
api.comment r.comment
|
api.comment r.comment
|
||||||
api.user_id r.user_id
|
api.user_id r.user_id
|
||||||
api.created_at r.created_at
|
api.created_at r.created_at
|
||||||
|
|||||||
@ -190,12 +190,6 @@
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#file_upload_box').change(function() {
|
|
||||||
if($("input[name='version']:checked").val() == '0') {
|
|
||||||
$('#version_1').prop('checked', true);
|
|
||||||
}
|
|
||||||
$('#version_0').prop('disabled', true);
|
|
||||||
});
|
|
||||||
$('#new_revision_form_content_toggle').click(function() {
|
$('#new_revision_form_content_toggle').click(function() {
|
||||||
if($('#new_revision_form_content').is(':visible')) {
|
if($('#new_revision_form_content').is(':visible')) {
|
||||||
$(this).text('[+]');
|
$(this).text('[+]');
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
<%= hidden_field_tag "commited_files[#{i}][size]", upload.size %>
|
<%= hidden_field_tag "commited_files[#{i}][size]", upload.size %>
|
||||||
<%= hidden_field_tag "commited_files[#{i}][mime_type]", upload.mime_type %>
|
<%= hidden_field_tag "commited_files[#{i}][mime_type]", upload.mime_type %>
|
||||||
<%= hidden_field_tag "commited_files[#{i}][digest]", upload.digest %>
|
<%= hidden_field_tag "commited_files[#{i}][digest]", upload.digest %>
|
||||||
<div class="clear">
|
<div class="splitcontent">
|
||||||
<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) %>
|
||||||
@ -48,39 +48,16 @@
|
|||||||
<%= text_area_tag "commited_files[#{i}][description]", upload.description, rows: 6,
|
<%= text_area_tag "commited_files[#{i}][description]", upload.description, rows: 6,
|
||||||
class: 'wiki-edit dmsf-description' %>
|
class: 'wiki-edit dmsf-description' %>
|
||||||
</p>
|
</p>
|
||||||
<div class="clear">
|
<div class="splitcontent">
|
||||||
<div class="splitcontentright">
|
|
||||||
<div class="custom_fields">
|
|
||||||
<% upload.custom_values.each do |value| %>
|
|
||||||
<% value.value = nil if value.custom_field.dmsf_not_inheritable %>
|
|
||||||
<p><%= custom_field_tag_with_label "commited_files[#{i}]", value %></p>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag "commited_files[#{i}][version]_minor", l(:label_dmsf_version) %>
|
<%= render partial: 'dmsf_files/version_selector', locals: {
|
||||||
<%= radio_button_tag "commited_files[#{i}][version]", 1, true %>
|
label_tag_name: "commited_files[#{i}][version]",
|
||||||
<%= DmsfUploadHelper::gui_version(upload.major_version) %>.<%= DmsfUploadHelper::gui_version(DmsfUploadHelper.increase_version(upload.minor_version, 1)) %>
|
select_tag_name_patch: "commited_files[#{i}][version_patch]",
|
||||||
<%= l(:option_version_minor) %><br/>
|
select_tag_name_minor: "commited_files[#{i}][version_minor]",
|
||||||
<%= radio_button_tag "commited_files[#{i}][version]", 2 %>
|
select_tag_name_major: "commited_files[#{i}][version_major]",
|
||||||
<%= DmsfUploadHelper::gui_version(DmsfUploadHelper::increase_version(upload.major_version, 1)) %>.0
|
revision_or_upload: upload } %>
|
||||||
<%= l(:option_version_major) %><br/>
|
|
||||||
<%= radio_button_tag "commited_files[#{i}][version]", 3 %>
|
|
||||||
<%= select_tag "commited_files[#{i}][custom_version_major]",
|
|
||||||
options_for_select(DmsfUploadHelper::major_version_select_options,
|
|
||||||
DmsfUploadHelper::gui_version(DmsfUploadHelper::increase_version(upload.major_version, 2))),
|
|
||||||
onchange: "$('#commited_files_#{i}_version_3').prop('checked', true)",
|
|
||||||
class: 'dmsf-select-version'%>.
|
|
||||||
<%= select_tag "commited_files[#{i}][custom_version_minor]",
|
|
||||||
options_for_select(DmsfUploadHelper::minor_version_select_options,
|
|
||||||
DmsfUploadHelper::gui_version(DmsfUploadHelper.increase_version(upload.minor_version, 1))),
|
|
||||||
onchange: "$('#commited_files_#{i}_version_3').prop('checked', true)",
|
|
||||||
class: 'dmsf-select-version' %>
|
|
||||||
<%= l(:option_version_custom) %>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
<div class="splitcontentright">
|
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag '', l(:label_mime) %>
|
<%= label_tag '', l(:label_mime) %>
|
||||||
<%= text_field_tag :name, h(upload.mime_type), readonly: true %>
|
<%= text_field_tag :name, h(upload.mime_type), readonly: true %>
|
||||||
@ -90,6 +67,14 @@
|
|||||||
<%= text_field_tag :name, number_to_human_size(upload.size), readonly: true %>
|
<%= text_field_tag :name, number_to_human_size(upload.size), readonly: true %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="splitcontentright">
|
||||||
|
<div class="custom_fields">
|
||||||
|
<% upload.custom_values.each do |value| %>
|
||||||
|
<% value.value = nil if value.custom_field.dmsf_not_inheritable %>
|
||||||
|
<p><%= custom_field_tag_with_label "commited_files[#{i}]", value %></p>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag "commited_files[#{i}][comment]", l(:label_comment) %>
|
<%= label_tag "commited_files[#{i}][comment]", l(:label_comment) %>
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
<%= hidden_field_tag "commited_files[#{i}][name]", upload.name %>
|
<%= hidden_field_tag "commited_files[#{i}][name]", upload.name %>
|
||||||
<%= hidden_field_tag "commited_files[#{i}][digest]", upload.digest %>
|
<%= hidden_field_tag "commited_files[#{i}][digest]", upload.digest %>
|
||||||
<p class="warning"><%= l(:info_file_locked) %></p>
|
<p class="warning"><%= l(:info_file_locked) %></p>
|
||||||
<div class="clear">
|
<div class="splitcontent">
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag '', l(:label_title) %>
|
<%= label_tag '', l(:label_title) %>
|
||||||
@ -52,18 +52,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="clear">
|
<div class="splitcontent">
|
||||||
<div class="splitcontentright">
|
|
||||||
<div class="custom_fields">
|
|
||||||
<% upload.custom_values.each do |value| %>
|
|
||||||
<p>
|
|
||||||
<%= label_tag '', h(value.custom_field.name) %>
|
|
||||||
<% value.value = nil if value.custom_field.dmsf_not_inheritable %>
|
|
||||||
<%= text_field_tag :name, h(value.value), readonly: true %>
|
|
||||||
</p>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="splitcontentleft">
|
<div class="splitcontentleft">
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag '', l(:label_dmsf_version) %>
|
<%= label_tag '', l(:label_dmsf_version) %>
|
||||||
@ -71,8 +60,6 @@
|
|||||||
"#{DmsfUploadHelper::gui_version(upload.major_version)}.#{DmsfUploadHelper::gui_version(upload.minor_version)}",
|
"#{DmsfUploadHelper::gui_version(upload.major_version)}.#{DmsfUploadHelper::gui_version(upload.minor_version)}",
|
||||||
readonly: true %>
|
readonly: true %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
<div class="splitcontentright">
|
|
||||||
<p>
|
<p>
|
||||||
<%= label_tag '', l(:label_mime) %>
|
<%= label_tag '', l(:label_mime) %>
|
||||||
<%= text_field_tag :name, h(upload.mime_type), readonly: true %>
|
<%= text_field_tag :name, h(upload.mime_type), readonly: true %>
|
||||||
@ -82,6 +69,17 @@
|
|||||||
<%= text_field_tag :name, h(number_to_human_size(upload.size)), readonly: true %>
|
<%= text_field_tag :name, h(number_to_human_size(upload.size)), readonly: true %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="splitcontentright">
|
||||||
|
<div class="custom_fields">
|
||||||
|
<% upload.custom_values.each do |value| %>
|
||||||
|
<p>
|
||||||
|
<%= label_tag '', h(value.custom_field.name) %>
|
||||||
|
<% value.value = nil if value.custom_field.dmsf_not_inheritable %>
|
||||||
|
<%= text_field_tag :name, h(value.value), readonly: true %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% if upload.comment.present? %>
|
<% if upload.comment.present? %>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@ -296,5 +296,3 @@ else {
|
|||||||
$(document).on("erui_new_dom", dmsfSetupFileDrop);
|
$(document).on("erui_new_dom", dmsfSetupFileDrop);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -121,7 +121,8 @@ cs:
|
|||||||
label_size: Velikost
|
label_size: Velikost
|
||||||
heading_new_revision: Nová revize
|
heading_new_revision: Nová revize
|
||||||
option_version_same: Stejná
|
option_version_same: Stejná
|
||||||
option_version_minor: Podružná
|
option_version_patch: Revize
|
||||||
|
option_version_minor: Vedlejší
|
||||||
option_version_major: Hlavní
|
option_version_major: Hlavní
|
||||||
option_version_custom: Vlastní
|
option_version_custom: Vlastní
|
||||||
label_new_content: Nový obsah
|
label_new_content: Nový obsah
|
||||||
|
|||||||
@ -121,6 +121,7 @@ de:
|
|||||||
label_size: Größe
|
label_size: Größe
|
||||||
heading_new_revision: Neue Version
|
heading_new_revision: Neue Version
|
||||||
option_version_same: Gleiche Version
|
option_version_same: Gleiche Version
|
||||||
|
option_version_patch: Patchversion
|
||||||
option_version_minor: Unterversion
|
option_version_minor: Unterversion
|
||||||
option_version_major: Hauptversion
|
option_version_major: Hauptversion
|
||||||
label_new_content: Neuer Inhalt
|
label_new_content: Neuer Inhalt
|
||||||
|
|||||||
@ -121,6 +121,7 @@ en:
|
|||||||
label_size: Size
|
label_size: Size
|
||||||
heading_new_revision: New Revision
|
heading_new_revision: New Revision
|
||||||
option_version_same: Same
|
option_version_same: Same
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: Minor
|
option_version_minor: Minor
|
||||||
option_version_major: Major
|
option_version_major: Major
|
||||||
option_version_custom: Custom
|
option_version_custom: Custom
|
||||||
|
|||||||
@ -121,6 +121,7 @@ es:
|
|||||||
label_size: Tamaño
|
label_size: Tamaño
|
||||||
heading_new_revision: Nueva Revisión
|
heading_new_revision: Nueva Revisión
|
||||||
option_version_same: Misma
|
option_version_same: Misma
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: Menor
|
option_version_minor: Menor
|
||||||
option_version_major: Mayor
|
option_version_major: Mayor
|
||||||
option_version_custom: Custom
|
option_version_custom: Custom
|
||||||
|
|||||||
@ -121,6 +121,7 @@ fr:
|
|||||||
label_size: Taille
|
label_size: Taille
|
||||||
heading_new_revision: Nouvelle révision
|
heading_new_revision: Nouvelle révision
|
||||||
option_version_same: (identique)
|
option_version_same: (identique)
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: (modification mineure)
|
option_version_minor: (modification mineure)
|
||||||
option_version_major: (modification majeure)
|
option_version_major: (modification majeure)
|
||||||
option_version_custom: (personnalisée)
|
option_version_custom: (personnalisée)
|
||||||
|
|||||||
@ -121,6 +121,7 @@ hu:
|
|||||||
label_size: Méret
|
label_size: Méret
|
||||||
heading_new_revision: Új változat
|
heading_new_revision: Új változat
|
||||||
option_version_same: Ugyanaz
|
option_version_same: Ugyanaz
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: Kisebb
|
option_version_minor: Kisebb
|
||||||
option_version_major: Fő
|
option_version_major: Fő
|
||||||
option_version_custom: Egyedi
|
option_version_custom: Egyedi
|
||||||
|
|||||||
@ -121,6 +121,7 @@ it: # Italian strings thx 2 Matteo Arceci!
|
|||||||
label_size: Dimensioni
|
label_size: Dimensioni
|
||||||
heading_new_revision: Nuova revisione
|
heading_new_revision: Nuova revisione
|
||||||
option_version_same: Stessa
|
option_version_same: Stessa
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: Miniore
|
option_version_minor: Miniore
|
||||||
option_version_major: Maggiore
|
option_version_major: Maggiore
|
||||||
option_version_custom: Personalizzata
|
option_version_custom: Personalizzata
|
||||||
|
|||||||
@ -121,6 +121,7 @@ ja:
|
|||||||
label_size: サイズ
|
label_size: サイズ
|
||||||
heading_new_revision: 新しいリビジョン
|
heading_new_revision: 新しいリビジョン
|
||||||
option_version_same: 変更なし
|
option_version_same: 変更なし
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: マイナー
|
option_version_minor: マイナー
|
||||||
option_version_major: メジャー
|
option_version_major: メジャー
|
||||||
option_version_custom: カスタム
|
option_version_custom: カスタム
|
||||||
|
|||||||
@ -121,6 +121,7 @@ ko:
|
|||||||
label_size: 크기
|
label_size: 크기
|
||||||
heading_new_revision: 새로운 수정
|
heading_new_revision: 새로운 수정
|
||||||
option_version_same: 동일한
|
option_version_same: 동일한
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: 중요하지 않은
|
option_version_minor: 중요하지 않은
|
||||||
option_version_major: 중요한
|
option_version_major: 중요한
|
||||||
option_version_custom: 임의의
|
option_version_custom: 임의의
|
||||||
|
|||||||
@ -121,6 +121,7 @@ nl:
|
|||||||
label_size: Grootte
|
label_size: Grootte
|
||||||
heading_new_revision: Nieuwe Revisie
|
heading_new_revision: Nieuwe Revisie
|
||||||
option_version_same: Hetzelfde
|
option_version_same: Hetzelfde
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: Beperkt
|
option_version_minor: Beperkt
|
||||||
option_version_major: Belangrijk
|
option_version_major: Belangrijk
|
||||||
option_version_custom: Aangepast
|
option_version_custom: Aangepast
|
||||||
|
|||||||
@ -121,6 +121,7 @@ pl:
|
|||||||
label_size: Rozmiar
|
label_size: Rozmiar
|
||||||
heading_new_revision: Nowa wersja
|
heading_new_revision: Nowa wersja
|
||||||
option_version_same: Same
|
option_version_same: Same
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: Minor
|
option_version_minor: Minor
|
||||||
option_version_major: Major
|
option_version_major: Major
|
||||||
option_version_custom: Custom
|
option_version_custom: Custom
|
||||||
|
|||||||
@ -121,6 +121,7 @@ pt-BR:
|
|||||||
label_size: Tamanho
|
label_size: Tamanho
|
||||||
heading_new_revision: Nova revisão
|
heading_new_revision: Nova revisão
|
||||||
option_version_same: Mesma
|
option_version_same: Mesma
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: Minor
|
option_version_minor: Minor
|
||||||
option_version_major: Major
|
option_version_major: Major
|
||||||
option_version_custom: Personalizado
|
option_version_custom: Personalizado
|
||||||
|
|||||||
@ -121,6 +121,7 @@ ru:
|
|||||||
label_size: Размер
|
label_size: Размер
|
||||||
heading_new_revision: Новая редакция
|
heading_new_revision: Новая редакция
|
||||||
option_version_same: Та же версия
|
option_version_same: Та же версия
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: Незначительные изменения
|
option_version_minor: Незначительные изменения
|
||||||
option_version_major: Значительные изменения
|
option_version_major: Значительные изменения
|
||||||
option_version_custom: Пользовательская
|
option_version_custom: Пользовательская
|
||||||
|
|||||||
@ -121,6 +121,7 @@ sl:
|
|||||||
label_size: Velikost
|
label_size: Velikost
|
||||||
heading_new_revision: Nova verzija
|
heading_new_revision: Nova verzija
|
||||||
option_version_same: Enako
|
option_version_same: Enako
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: Minor
|
option_version_minor: Minor
|
||||||
option_version_major: Major
|
option_version_major: Major
|
||||||
option_version_custom: Custom
|
option_version_custom: Custom
|
||||||
|
|||||||
@ -121,6 +121,7 @@ zh-TW:
|
|||||||
label_size: 大小
|
label_size: 大小
|
||||||
heading_new_revision: 新增修訂版本
|
heading_new_revision: 新增修訂版本
|
||||||
option_version_same: Same
|
option_version_same: Same
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: Minor
|
option_version_minor: Minor
|
||||||
option_version_major: Major
|
option_version_major: Major
|
||||||
option_version_custom: Custom
|
option_version_custom: Custom
|
||||||
|
|||||||
@ -121,6 +121,7 @@ zh:
|
|||||||
label_size: 大小
|
label_size: 大小
|
||||||
heading_new_revision: 新修订
|
heading_new_revision: 新修订
|
||||||
option_version_same: Same
|
option_version_same: Same
|
||||||
|
option_version_patch: Patch
|
||||||
option_version_minor: Minor
|
option_version_minor: Minor
|
||||||
option_version_major: Major
|
option_version_major: Major
|
||||||
option_version_custom: Custom
|
option_version_custom: Custom
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
#
|
#
|
||||||
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
||||||
# Copyright © 2016-17 carlolars
|
|
||||||
#
|
#
|
||||||
# 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
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
#
|
#
|
||||||
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
# Copyright © 2011-22 Karel Pičman <karel.picman@kontron.com>
|
||||||
# Copyright © 2016-17 carlolars
|
|
||||||
#
|
#
|
||||||
# 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
|
||||||
@ -19,10 +18,11 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class AddOwnerToDmsfLock < ActiveRecord::Migration[5.2]
|
class AddPatchVersion < ActiveRecord::Migration[5.2]
|
||||||
|
|
||||||
def change
|
def change
|
||||||
add_column :dmsf_locks, :owner, :string, null: true
|
add_column :dmsf_file_revisions, :patch_version, :integer, null: true,
|
||||||
|
after: :minor_version
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -4,9 +4,13 @@
|
|||||||
<uploaded_file>
|
<uploaded_file>
|
||||||
<name>cat.gif</name>
|
<name>cat.gif</name>
|
||||||
<title>cat</title>
|
<title>cat</title>
|
||||||
|
<!-- Optional -->
|
||||||
<description>REST API</description>
|
<description>REST API</description>
|
||||||
<comment>From API</comment>
|
<comment>From API</comment>
|
||||||
<version/>
|
<version_major>A</version_major>
|
||||||
|
<version_minor>1</version_minor>
|
||||||
|
<version_patch>0</version_patch>
|
||||||
|
<!-- End of optional -->
|
||||||
<token>15838.c49f68ff81b552d315927df2e27df506</token>
|
<token>15838.c49f68ff81b552d315927df2e27df506</token>
|
||||||
</uploaded_file>
|
</uploaded_file>
|
||||||
</attachments>
|
</attachments>
|
||||||
|
|||||||
@ -47,22 +47,22 @@ module RedmineDmsf
|
|||||||
def lock!(scope = :scope_exclusive, type = :type_write, expire = nil, owner = nil)
|
def lock!(scope = :scope_exclusive, type = :type_write, expire = nil, owner = nil)
|
||||||
# Raise a lock error if entity is locked, but its not at resource level
|
# Raise a lock error if entity is locked, but its not at resource level
|
||||||
existing = lock(false)
|
existing = lock(false)
|
||||||
raise RedmineDmsf::Errors::RedmineDmsf::Errors::DmsfLockError.new(l(:error_resource_or_parent_locked)) if self.locked? && existing.empty?
|
raise RedmineDmsf::Errors::DmsfLockError.new(l(:error_resource_or_parent_locked)) if self.locked? && existing.empty?
|
||||||
unless existing.empty?
|
unless existing.empty?
|
||||||
if (existing[0].lock_scope == :scope_shared) && (scope == :scope_shared)
|
if (existing[0].lock_scope == :scope_shared) && (scope == :scope_shared)
|
||||||
# RFC states if an item is exclusively locked and another lock is attempted we reject
|
# RFC states if an item is exclusively locked and another lock is attempted we reject
|
||||||
# if the item is shared locked however, we can always add another lock to it
|
# if the item is shared locked however, we can always add another lock to it
|
||||||
if self.dmsf_folder.locked?
|
if self.dmsf_folder.locked?
|
||||||
raise RedmineDmsf::Errors::RedmineDmsf::Errors::DmsfLockError.new(l(:error_parent_locked))
|
raise RedmineDmsf::Errors::DmsfLockError.new(l(:error_parent_locked))
|
||||||
else
|
else
|
||||||
existing.each do |l|
|
existing.each do |l|
|
||||||
if (l.user.id == User.current.id) && (owner.nil? || (owner.downcase == l.owner&.downcase))
|
if (l.user.id == User.current.id) && (owner.nil? || (owner.downcase == l.owner&.downcase))
|
||||||
raise RedmineDmsf::Errors::RedmineDmsf::Errors::DmsfLockError.new(l(:error_resource_locked))
|
raise RedmineDmsf::Errors::DmsfLockError.new(l(:error_resource_locked))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise RedmineDmsf::Errors::RedmineDmsf::Errors::DmsfLockError.new(l(:error_lock_exclusively)) if scope == :scope_exclusive
|
raise RedmineDmsf::Errors::DmsfLockError.new(l(:error_lock_exclusively)) if scope == :scope_exclusive
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
l = DmsfLock.new
|
l = DmsfLock.new
|
||||||
@ -113,16 +113,16 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
|
|
||||||
def unlock!(force_file_unlock_allowed = false, owner = nil)
|
def unlock!(force_file_unlock_allowed = false, owner = nil)
|
||||||
raise RedmineDmsf::Errors::RedmineDmsf::Errors::DmsfLockError.new(l(:warning_file_not_locked)) unless self.locked?
|
raise RedmineDmsf::Errors::DmsfLockError.new(l(:warning_file_not_locked)) unless self.locked?
|
||||||
existing = self.lock(true)
|
existing = self.lock(true)
|
||||||
destroyed = false
|
destroyed = false
|
||||||
# If its empty its a folder that's locked (not root)
|
# If its empty its a folder that's locked (not root)
|
||||||
if existing.empty? || (!self.dmsf_folder.nil? && self.dmsf_folder.locked?)
|
if existing.empty? || (!self.dmsf_folder.nil? && self.dmsf_folder.locked?)
|
||||||
raise RedmineDmsf::Errors::RedmineDmsf::Errors::DmsfLockError.new(l(:error_unlock_parent_locked))
|
raise RedmineDmsf::Errors::DmsfLockError.new(l(:error_unlock_parent_locked))
|
||||||
else
|
else
|
||||||
# If entity is locked to you, you aren't the lock originator (or named in a shared lock) so deny action
|
# If entity is locked to you, you aren't the lock originator (or named in a shared lock) so deny action
|
||||||
# Unless of course you have the rights to force an unlock
|
# Unless of course you have the rights to force an unlock
|
||||||
raise RedmineDmsf::Errors::RedmineDmsf::Errors::DmsfLockError.new(l(:error_only_user_that_locked_file_can_unlock_it)) if (
|
raise RedmineDmsf::Errors::DmsfLockError.new(l(:error_only_user_that_locked_file_can_unlock_it)) if (
|
||||||
self.locked_for_user? && !User.current.allowed_to?(:force_file_unlock, self.project) && !force_file_unlock_allowed)
|
self.locked_for_user? && !User.current.allowed_to?(:force_file_unlock, self.project) && !force_file_unlock_allowed)
|
||||||
# Now we need to determine lock type and do the needful
|
# Now we need to determine lock type and do the needful
|
||||||
if (existing.count == 1) && (existing[0].lock_scope == :exclusive)
|
if (existing.count == 1) && (existing[0].lock_scope == :exclusive)
|
||||||
|
|||||||
@ -267,7 +267,7 @@ module RedmineDmsf
|
|||||||
else
|
else
|
||||||
# Create a new revison by cloning the last revision in the destination
|
# Create a new revison by cloning the last revision in the destination
|
||||||
new_revision = dest.resource.file.last_revision.clone
|
new_revision = dest.resource.file.last_revision.clone
|
||||||
new_revision.increase_version 1
|
new_revision.increase_version DmsfFileRevision::PATCH_VERSION
|
||||||
end
|
end
|
||||||
# The file on disk must be renamed from .tmp to the correct filetype or else Xapian won't know how to index.
|
# The file on disk must be renamed from .tmp to the correct filetype or else Xapian won't know how to index.
|
||||||
# Copy file.last_revision.disk_file to new_revision.disk_file
|
# Copy file.last_revision.disk_file to new_revision.disk_file
|
||||||
@ -569,7 +569,7 @@ module RedmineDmsf
|
|||||||
new_revision.dmsf_file = f
|
new_revision.dmsf_file = f
|
||||||
new_revision.user = User.current
|
new_revision.user = User.current
|
||||||
new_revision.name = basename
|
new_revision.name = basename
|
||||||
new_revision.increase_version(1) unless reuse_revision
|
new_revision.increase_version(DmsfFileRevision::PATCH_VERSION) unless reuse_revision
|
||||||
new_revision.mime_type = Redmine::MimeType.of(new_revision.name)
|
new_revision.mime_type = Redmine::MimeType.of(new_revision.name)
|
||||||
|
|
||||||
# Phusion passenger does not have a method "length" in its model
|
# Phusion passenger does not have a method "length" in its model
|
||||||
|
|||||||
@ -129,9 +129,13 @@ class DmsfFileApiTest < RedmineDmsf::Test::IntegrationTest
|
|||||||
<uploaded_file>
|
<uploaded_file>
|
||||||
<name>test.txt</name>
|
<name>test.txt</name>
|
||||||
<title>test.txt</title>
|
<title>test.txt</title>
|
||||||
|
<!-- Optional -->
|
||||||
<description>REST API</description>
|
<description>REST API</description>
|
||||||
<comment>From API</comment>
|
<comment>From API</comment>
|
||||||
<version/>
|
<version_major>A</version_major>
|
||||||
|
<version_minor>1</version_minor>
|
||||||
|
<version_patch>0</version_patch>
|
||||||
|
<!-- End of optional -->
|
||||||
<token>#{ftoken}</token>
|
<token>#{ftoken}</token>
|
||||||
</uploaded_file>
|
</uploaded_file>
|
||||||
</attachments>}
|
</attachments>}
|
||||||
|
|||||||
@ -129,40 +129,47 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_increase_version
|
def test_increase_version
|
||||||
|
# 1.0.0 -> 1.0.1
|
||||||
|
@revision1.major_version = 1
|
||||||
|
@revision1.minor_version = 0
|
||||||
|
@revision1.increase_version DmsfFileRevision::PATCH_VERSION
|
||||||
|
assert_equal 1, @revision1.major_version
|
||||||
|
assert_equal 0, @revision1.minor_version
|
||||||
|
assert_equal 1, @revision1.patch_version
|
||||||
# 1.0 -> 1.1
|
# 1.0 -> 1.1
|
||||||
@revision1.major_version = 1
|
@revision1.major_version = 1
|
||||||
@revision1.minor_version = 0
|
@revision1.minor_version = 0
|
||||||
@revision1.increase_version(1)
|
@revision1.increase_version DmsfFileRevision::MINOR_VERSION
|
||||||
assert_equal 1, @revision1.major_version
|
assert_equal 1, @revision1.major_version
|
||||||
assert_equal 1, @revision1.minor_version
|
assert_equal 1, @revision1.minor_version
|
||||||
# 1.0 -> 2.0
|
# 1.0 -> 2.0
|
||||||
@revision1.major_version = 1
|
@revision1.major_version = 1
|
||||||
@revision1.minor_version = 0
|
@revision1.minor_version = 0
|
||||||
@revision1.increase_version(2)
|
@revision1.increase_version DmsfFileRevision::MAJOR_VERSION
|
||||||
assert_equal 2, @revision1.major_version
|
assert_equal 2, @revision1.major_version
|
||||||
assert_equal 0, @revision1.minor_version
|
assert_equal 0, @revision1.minor_version
|
||||||
# 1.1 -> 2.0
|
# 1.1 -> 2.0
|
||||||
@revision1.major_version = 1
|
@revision1.major_version = 1
|
||||||
@revision1.minor_version = 1
|
@revision1.minor_version = 1
|
||||||
@revision1.increase_version(2)
|
@revision1.increase_version DmsfFileRevision::MAJOR_VERSION
|
||||||
assert_equal 2, @revision1.major_version
|
assert_equal 2, @revision1.major_version
|
||||||
assert_equal 0, @revision1.minor_version
|
assert_equal 0, @revision1.minor_version
|
||||||
# A -> A.1
|
# A -> A.1
|
||||||
@revision1.major_version = -('A'.ord)
|
@revision1.major_version = -('A'.ord)
|
||||||
@revision1.minor_version = -(' '.ord)
|
@revision1.minor_version = -(' '.ord)
|
||||||
@revision1.increase_version(1)
|
@revision1.increase_version DmsfFileRevision::MINOR_VERSION
|
||||||
assert_equal -('A'.ord), @revision1.major_version
|
assert_equal -('A'.ord), @revision1.major_version
|
||||||
assert_equal 1, @revision1.minor_version
|
assert_equal 1, @revision1.minor_version
|
||||||
# A -> B
|
# A -> B
|
||||||
@revision1.major_version = -('A'.ord)
|
@revision1.major_version = -('A'.ord)
|
||||||
@revision1.minor_version = -(' '.ord)
|
@revision1.minor_version = -(' '.ord)
|
||||||
@revision1.increase_version(2)
|
@revision1.increase_version DmsfFileRevision::MAJOR_VERSION
|
||||||
assert_equal -('B'.ord), @revision1.major_version
|
assert_equal -('B'.ord), @revision1.major_version
|
||||||
assert_equal -(' '.ord), @revision1.minor_version
|
assert_equal -(' '.ord), @revision1.minor_version
|
||||||
# A.1 -> B
|
# A.1 -> B
|
||||||
@revision1.major_version = -('A'.ord)
|
@revision1.major_version = -('A'.ord)
|
||||||
@revision1.minor_version = 1
|
@revision1.minor_version = 1
|
||||||
@revision1.increase_version(2)
|
@revision1.increase_version DmsfFileRevision::MAJOR_VERSION
|
||||||
assert_equal -('B'.ord), @revision1.major_version
|
assert_equal -('B'.ord), @revision1.major_version
|
||||||
assert_equal -(' '.ord), @revision1.minor_version
|
assert_equal -(' '.ord), @revision1.minor_version
|
||||||
end
|
end
|
||||||
|
|||||||
@ -69,13 +69,13 @@ class DmsfLockTest < RedmineDmsf::Test::UnitTest
|
|||||||
@folder7.lock!
|
@folder7.lock!
|
||||||
User.current = nil
|
User.current = nil
|
||||||
assert_no_difference('@folder7.lock.count') do
|
assert_no_difference('@folder7.lock.count') do
|
||||||
assert_raise RedmineDmsf::Errors::RedmineDmsf::Errors::DmsfLockError do
|
assert_raise RedmineDmsf::Errors::DmsfLockError do
|
||||||
@folder7.unlock!
|
@folder7.unlock!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
User.current = @jsmith
|
User.current = @jsmith
|
||||||
assert_no_difference('@folder7.lock.count') do
|
assert_no_difference('@folder7.lock.count') do
|
||||||
assert_raise RedmineDmsf::Errors::RedmineDmsf::Errors::DmsfLockError do
|
assert_raise RedmineDmsf::Errors::DmsfLockError do
|
||||||
@folder7.unlock!
|
@folder7.unlock!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user