Make DMS document available as Type of a custom field #1248
This commit is contained in:
parent
f2448c4990
commit
73193baa68
@ -21,6 +21,7 @@
|
||||
|
||||
cs:
|
||||
dmsf: DMS # Custom fields tab title
|
||||
label_dmsf_file: DMS Dokument
|
||||
label_dmsf_file_plural: DMS Dokumenty # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: Revize dokumentů
|
||||
label_dmsf_file_revision_access_plural: Přístupy k dokumentům
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
de:
|
||||
dmsf: DMS # Custom fields tab title
|
||||
label_dmsf_file: DMS Dokument
|
||||
label_dmsf_file_plural: DMS Dokumente # E-Mail subject & Search options
|
||||
label_dmsf_file_revision_plural: Dokumentenversion
|
||||
label_dmsf_file_revision_access_plural: Dokumentenzugriffe
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
en:
|
||||
dmsf: DMS # Custom fields tab title
|
||||
label_dmsf_file: DMS Document
|
||||
label_dmsf_file_plural: DMS Documents # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: Document revisions
|
||||
label_dmsf_file_revision_access_plural: Document accesses
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
es:
|
||||
dmsf: DMS # Custom fields tab title
|
||||
label_dmsf_file: DMS Archivo
|
||||
label_dmsf_file_plural: DMS Archivos # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: Document revisions
|
||||
label_dmsf_file_revision_access_plural: Document accesses
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
fa:
|
||||
dmsf: اسناد پیشرفته # Custom fields tab title
|
||||
label_dmsf_file: DMS Document
|
||||
label_dmsf_file_plural: اسناد پیشرفته # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: بازبینیهای اسناد
|
||||
label_dmsf_file_revision_access_plural: دسترسیهای اسناد پیشرفته
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
fr:
|
||||
dmsf: DMS # Custom fields tab title
|
||||
label_dmsf_file: DMS Fichier
|
||||
label_dmsf_file_plural: DMS Fichiers # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: Révisions du document
|
||||
label_dmsf_file_revision_access_plural: Accès au document
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
hu:
|
||||
dmsf: DMS # Custom fields tab title
|
||||
label_dmsf_file: DMS Dokumtum
|
||||
label_dmsf_file_plural: DMS Dokumentumok # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: Dokumtum felülvizsgálata
|
||||
label_dmsf_file_revision_access_plural: Dokumentum hozzáférései
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
it: # Italian strings thx 2 Matteo Arceci!
|
||||
dmsf: DMS # Custom fields tab title
|
||||
label_dmsf_file: DMS Documento
|
||||
label_dmsf_file_plural: DMS Documenti # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: Revisioni al documento
|
||||
label_dmsf_file_revision_access_plural: Accessi al documento
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
ja:
|
||||
dmsf: DMS # Custom fields tab title
|
||||
label_dmsf_file: DMS Document
|
||||
label_dmsf_file_plural: DMS 文書管理ファイル # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: 文書管理ファイルリビジョン
|
||||
label_dmsf_file_revision_access_plural: 文書管理ファイルアクセス
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
ko:
|
||||
dmsf: DMS
|
||||
label_dmsf_file: DMS Document
|
||||
label_dmsf_file_plural: DMS 문서
|
||||
label_dmsf_file_revision_plural: 문서 리비전
|
||||
label_dmsf_file_revision_access_plural: 문서 접근
|
||||
|
||||
@ -20,7 +20,8 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
nl:
|
||||
dmsf: Easy DMS
|
||||
dmsf: DMS
|
||||
label_dmsf_file: DMS Document
|
||||
label_dmsf_file_plural: Documenten
|
||||
label_dmsf_file_revision_plural: Document revisies
|
||||
label_dmsf_file_revision_access_plural: Document toegang
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
pt-BR:
|
||||
dmsf: DMS # Custom fields tab title
|
||||
label_dmsf_file: DMS Arquivo
|
||||
label_dmsf_file_plural: DMS Arquivos # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: Revisões dos Arquivos
|
||||
label_dmsf_file_revision_access_plural: Acessos aos Arquivos
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
sl:
|
||||
dmsf: Arhiv # Custom fields tab title
|
||||
label_dmsf_file: DMS Datoteka
|
||||
label_dmsf_file_plural: DMS Arhivske datoteke # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: Document revisions
|
||||
label_dmsf_file_revision_access_plural: Document accesses
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
uk:
|
||||
dmsf: ЕДО # Custom fields tab title - Заголовок таблиці спеціальних полів
|
||||
label_dmsf_file: ЕДО Документ
|
||||
label_dmsf_file_plural: ЕДО Документи # Email subject & Search options - Документи DMS # Тема електронного листа і опції пошуку
|
||||
label_dmsf_file_revision_plural: Перегляд / Редакція документа
|
||||
label_dmsf_file_revision_access_plural: Доступ до документів
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
zh-TW:
|
||||
dmsf: 文件總管 # Custom fields tab title
|
||||
label_dmsf_file: DMS Document
|
||||
label_dmsf_file_plural: DMS 文件檔案 # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: Document revisions
|
||||
label_dmsf_file_revision_access_plural: Document accesses
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
zh:
|
||||
dmsf: 文档管家 # Custom fields tab title
|
||||
label_dmsf_file: DMS Document
|
||||
label_dmsf_file_plural: DMS 文件檔案 # Email subject & Search options
|
||||
label_dmsf_file_revision_plural: Document revisions
|
||||
label_dmsf_file_revision_access_plural: Document accesses
|
||||
|
||||
@ -93,3 +93,6 @@ require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/helpers/project_helper_hoo
|
||||
|
||||
# Macros
|
||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/macros"
|
||||
|
||||
# Field formats
|
||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/field_formats/dmsf_file_format"
|
||||
|
||||
64
lib/redmine_dmsf/field_formats/dmsf_file_format.rb
Normal file
64
lib/redmine_dmsf/field_formats/dmsf_file_format.rb
Normal file
@ -0,0 +1,64 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright © 2011-23 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.
|
||||
|
||||
module RedmineDmsf
|
||||
module FieldFormats
|
||||
# Custom field type DmsfFile
|
||||
class DmsfFileFormat < Redmine::FieldFormat::RecordList
|
||||
add 'dmsf_file'
|
||||
|
||||
self.customized_class_names = nil
|
||||
self.multiple_supported = false
|
||||
self.bulk_edit_supported = false
|
||||
|
||||
def possible_values_options(_custom_field, object = nil)
|
||||
options = []
|
||||
if object&.project
|
||||
files = object.project.dmsf_files.visible.to_a
|
||||
object.project.dmsf_folders.visible.each do |f|
|
||||
files += f.dmsf_files.visible.to_a
|
||||
end
|
||||
files.sort! { |a, b| a.title.casecmp(b.title) }
|
||||
options = files.map { |f| [f.name, f.id.to_s] }
|
||||
end
|
||||
options
|
||||
end
|
||||
|
||||
def formatted_value(view, _custom_field, value, _customized: nil, _html: false)
|
||||
return '' if value.blank?
|
||||
|
||||
dmsf_file = DmsfFile.find_by(id: value)
|
||||
return '' unless dmsf_file
|
||||
|
||||
file_view_url = view.url_for({ controller: :dmsf_files, action: 'view', id: dmsf_file })
|
||||
view.link_to(
|
||||
h(dmsf_file.title),
|
||||
file_view_url,
|
||||
target: '_blank',
|
||||
rel: 'noopener',
|
||||
class: "icon icon-file #{DmsfHelper.filetype_css(dmsf_file.name)}",
|
||||
title: h(dmsf_file.last_revision.try(:tooltip)),
|
||||
'data-downloadurl' => "#{dmsf_file.last_revision.detect_content_type}:#{h(dmsf_file.name)}:#{file_view_url}"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
40
test/unit/custom_field_dmsf_file_format_test.rb
Normal file
40
test/unit/custom_field_dmsf_file_format_test.rb
Normal file
@ -0,0 +1,40 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-23 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.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
# File revision tests
|
||||
class CustomFieldDmsfFileFormatTest < RedmineDmsf::Test::UnitTest
|
||||
fixtures :custom_fields, :projects, :issues, :trackers
|
||||
def setup
|
||||
super
|
||||
User.current = nil
|
||||
@issue = Issue.find 1
|
||||
@field = IssueCustomField.create!(name: 'DMS Document', field_format: 'dmsf_file')
|
||||
end
|
||||
|
||||
def test_possible_values_options
|
||||
n = @issue.project.dmsf_files.visible.all.size
|
||||
@issue.project.dmsf_folders.visible.each do |f|
|
||||
n += f.dmsf_files.visible.all.size
|
||||
end
|
||||
assert_equal n, @field.possible_values_options(@issue).size
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user