2019-07-01 16:14:16 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# rubocop:disable Style/ClassAndModuleChildren
|
|
|
|
|
|
|
|
class Reports::Docx
|
|
|
|
include ActionView::Helpers::TextHelper
|
|
|
|
include ActionView::Helpers::UrlHelper
|
|
|
|
include ApplicationHelper
|
|
|
|
include InputSanitizeHelper
|
|
|
|
include TeamsHelper
|
2021-05-21 22:35:23 +08:00
|
|
|
include ReportsHelper
|
2019-07-01 16:14:16 +08:00
|
|
|
include GlobalActivitiesHelper
|
2020-07-21 20:11:42 +08:00
|
|
|
include Canaid::Helpers::PermissionsHelper
|
2019-07-01 16:14:16 +08:00
|
|
|
|
|
|
|
Dir[File.join(File.dirname(__FILE__), 'docx') + '**/*.rb'].each do |file|
|
|
|
|
include_module = File.basename(file).gsub('.rb', '').split('_').map(&:capitalize).join
|
2019-09-17 16:50:01 +08:00
|
|
|
include "Reports::Docx::#{include_module}".constantize
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
|
2021-04-14 21:45:51 +08:00
|
|
|
def initialize(report, docx, options)
|
|
|
|
@report = report
|
2021-05-21 22:35:23 +08:00
|
|
|
@settings = report.settings
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx = docx
|
|
|
|
@user = options[:user]
|
2021-05-21 22:35:23 +08:00
|
|
|
@report_team = report.project.team
|
2019-07-01 16:14:16 +08:00
|
|
|
@link_style = {}
|
|
|
|
@color = {}
|
|
|
|
@scinote_url = options[:scinote_url][0..-2]
|
|
|
|
end
|
|
|
|
|
|
|
|
def draw
|
|
|
|
initial_document_load
|
|
|
|
|
2021-04-14 21:45:51 +08:00
|
|
|
@report.root_elements.each do |subject|
|
|
|
|
public_send("draw_#{subject.type_of}", subject)
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
@docx
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# rubocop:enable Style/ClassAndModuleChildren
|