scinote-web/app/services/reports/docx/draw_my_module_activity.rb
aignatov-bio 2793777463
Features/docx report (#1873)
* Initial setup for docx report

* Add render for project, experiment, my_module

* Implement converter for RTE fields

* Add all report elements

* fix markup

* Change headers, remove empty blocks, refactored repository draw

* Add smart annotations support

* Fix justify fields

* Prepare for addons integration

* Fix markup

* Add comments to GemFile

* Fix TinyMCE error

* Change UI for new report download selector

* Fix file error in inventory cell for docx

* Fix i18n object for header
2019-07-01 10:14:16 +02:00

26 lines
920 B
Ruby

# frozen_string_literal: true
module DrawMyModuleActivity
def draw_my_module_activity(subject)
my_module = MyModule.find_by_id(subject['id']['my_module_id'])
return unless my_module
activities = ActivitiesService.my_module_activities(my_module).order(created_at: subject['sort_order'])
return false unless activities.any?
@docx.p
@docx.p I18n.t('projects.reports.elements.module_activity.name', my_module: my_module.name), bold: true
activities.each do |activity|
activity_ts = activity.created_at
activity_text = if activity.old_activity?
sanitize_input(activity.message)
else
sanitize_input(generate_activity_content(activity, true))
end
@docx.p I18n.l(activity_ts, format: :full), color: 'a0a0a0'
html_to_word_converter(activity_text)
@docx.p
end
end
end