Post review modifications

- Don't use class variables.
- Use memoized class instance variables.
- Fix class reloading in development environment.
pull/9381/head
Wieland Lindenthal 3 years ago
parent 4935d3a3d4
commit eff86a228c
  1. 18
      app/models/work_package/exporter/formatters.rb
  2. 6
      app/models/work_package/pdf_export/work_package_list_to_pdf.rb
  3. 2
      modules/bim/lib/open_project/bim/engine.rb

@ -1,19 +1,27 @@
module WorkPackage::Exporter
module Formatters
@@formatters = %i[default costs estimated_hours].map do |key|
Kernel.const_get("WorkPackage::Exporter::Formatters::#{key.to_s.camelize}")
def self.default_formatter_strings
@default_formatters_strings ||= %i[default costs estimated_hours].map do |key|
"WorkPackage::Exporter::Formatters::#{key.to_s.camelize}"
end
end
def self.all_formatter_strings
@all_formatter_strings ||= default_formatter_strings
end
def self.all
@@formatters
all_formatter_strings.each do |formatter_string|
Kernel.const_get(formatter_string)
end
end
def self.keys
all.map(&:key)
end
def self.register(clz)
@@formatters << clz
def self.register(class_string)
@all_formatter_strings = all_formatter_strings + [class_string]
end
##

@ -317,10 +317,4 @@ class WorkPackage::PDFExport::WorkPackageListToPdf < WorkPackage::Exporter::Base
false
end
end
def make_bcf_thumbnail_field_value(work_package)
# A BCF viewpoint must have a snapshot. So it's safe to check for
# viewpoint existence only.
work_package.bcf_issue.viewpoints.any? ? 'X' : ''
end
end

@ -213,7 +213,7 @@ module OpenProject::Bim
config.to_prepare do
::WorkPackage::Exporter
.register_for_list(:bcf, OpenProject::Bim::BcfXml::Exporter)
::WorkPackage::Exporter::Formatters.register(OpenProject::Bim::WorkPackage::Exporter::Formatters::BcfThumbnail)
::WorkPackage::Exporter::Formatters.register("OpenProject::Bim::WorkPackage::Exporter::Formatters::BcfThumbnail")
::Queries::Register.filter ::Query, ::Bim::Queries::WorkPackages::Filter::BcfIssueAssociatedFilter
::Queries::Register.column ::Query, ::Bim::Queries::WorkPackages::Columns::BcfThumbnailColumn

Loading…
Cancel
Save