mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-08 14:15:35 +08:00
Fix export all functionality [SCI-5776]
This commit is contained in:
parent
44b4e13fa8
commit
16bad9eb9c
22 changed files with 95 additions and 272 deletions
|
@ -75,15 +75,6 @@ module ReportsHelper
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
if obj_id
|
||||
file = provided_locals[:obj_filenames][element['type_of'].to_sym][obj_id]
|
||||
locals[:path] = {
|
||||
file: file[:file].sub(%r{/usr/src/app/tmp/temp-zip-\d+/}, ''),
|
||||
preview: file[:preview]&.sub(%r{/usr/src/app/tmp/temp-zip-\d+/}, '')
|
||||
}
|
||||
locals[:filename] = locals[:path][:file].split('/').last
|
||||
end
|
||||
end
|
||||
|
||||
# ReportExtends is located in config/initializers/extends/report_extends.rb
|
||||
|
@ -130,7 +121,10 @@ module ReportsHelper
|
|||
repository = Repository.accessible_by_teams(my_module.experiment.project.team).find_by(id: element_id)
|
||||
# Check for default set snapshots when repository still exists
|
||||
if repository
|
||||
selected_snapshot = repository.repository_snapshots.where(my_module: my_module).find_by(selected: true)
|
||||
selected_snapshot = repository.repository_snapshots
|
||||
.joins(repository_rows: { my_module_repository_rows: :my_module })
|
||||
.where(repository_rows: { my_module_repository_rows: { my_module: my_module } })
|
||||
.find_by(selected: true)
|
||||
repository = selected_snapshot if selected_snapshot
|
||||
end
|
||||
repository ||= RepositorySnapshot.joins(my_module: { experiment: :project })
|
||||
|
|
|
@ -216,7 +216,7 @@ class Project < ApplicationRecord
|
|||
|
||||
def assigned_repositories_and_snapshots
|
||||
live_repositories = Repository.assigned_to_project(self)
|
||||
snapshots = RepositorySnapshot.of_unassigned_from_project(self)
|
||||
snapshots = RepositorySnapshot.assigned_to_project(self)
|
||||
(live_repositories + snapshots).sort_by { |r| r.name.downcase }
|
||||
end
|
||||
|
||||
|
@ -267,15 +267,15 @@ class Project < ApplicationRecord
|
|||
ActionController::Renderer::RACK_KEY_TRANSLATION['warden'] ||= 'warden'
|
||||
proxy = Warden::Proxy.new({}, Warden::Manager.new({}))
|
||||
proxy.set_user(user, scope: :user, store: false)
|
||||
ApplicationController.renderer.defaults[:http_host] = Rails.application.routes.default_url_options[:host]
|
||||
renderer = ApplicationController.renderer.new(warden: proxy)
|
||||
|
||||
report = Report.generate_whole_project_report(self, user, team)
|
||||
|
||||
page_html_string =
|
||||
renderer.render 'reports/new_old.html.erb',
|
||||
locals: { export_all: true,
|
||||
obj_filenames: obj_filenames },
|
||||
assigns: { project: self, report: report }
|
||||
renderer.render 'reports/export.html.erb',
|
||||
locals: { report: report, export_all: true },
|
||||
assigns: { settings: report.settings, obj_filenames: obj_filenames }
|
||||
parsed_page_html = Nokogiri::HTML(page_html_string)
|
||||
parsed_html = parsed_page_html.at_css('#report-content')
|
||||
|
||||
|
|
|
@ -100,7 +100,6 @@ class Report < ApplicationRecord
|
|||
end
|
||||
|
||||
def self.generate_whole_project_report(project, current_user, current_team)
|
||||
# report_contents = gen_element_content(project, Extends::EXPORT_ALL_PROJECT_ELEMENTS)
|
||||
content = {
|
||||
'experiments' => [],
|
||||
'tasks' => {},
|
||||
|
@ -114,40 +113,13 @@ class Report < ApplicationRecord
|
|||
report = Report.new
|
||||
report.name = loop do
|
||||
dummy_name = SecureRandom.hex(10)
|
||||
break dummy_name unless Report.where(name: dummy_name).exists?
|
||||
break dummy_name unless Report.exists?(name: dummy_name)
|
||||
end
|
||||
report.project = project
|
||||
report.user = current_user
|
||||
report.team = current_team
|
||||
report.last_modified_by = current_user
|
||||
ReportActions::ReportContent.new(report, content, {}, current_user).save_with_content
|
||||
# report.save_with_contents(report_contents)
|
||||
report
|
||||
end
|
||||
|
||||
def self.gen_element_content(parent, children)
|
||||
elements = []
|
||||
|
||||
children.each do |element|
|
||||
element_hash = lambda { |object|
|
||||
hash_object = {
|
||||
'type_of' => element[:type_of] || element[:type_of_lambda].call(object),
|
||||
'id' => { element[:id_key] => object.id },
|
||||
'sort_order' => element[:sort_order],
|
||||
'children' => gen_element_content(object, element[:children] || [])
|
||||
}
|
||||
hash_object['id'][element[:parent_id_key]] = parent.id if element[:parent_id_key]
|
||||
hash_object
|
||||
}
|
||||
|
||||
if element[:relation]
|
||||
(element[:relation].inject(parent) { |p, method| p.public_send(method) }).each do |child|
|
||||
elements.push(element_hash.call(child))
|
||||
end
|
||||
else
|
||||
elements.push(element_hash.call(parent))
|
||||
end
|
||||
end
|
||||
elements
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,12 @@ class RepositorySnapshot < RepositoryBase
|
|||
.order(:parent_id, updated_at: :desc)
|
||||
}
|
||||
|
||||
scope :assigned_to_project, lambda { |project|
|
||||
where(team: project.team)
|
||||
.joins(repository_rows: { my_module_repository_rows: { my_module: { experiment: :project } } })
|
||||
.where(repository_rows: { my_module_repository_rows: { my_module: { experiments: { project: project } } } })
|
||||
}
|
||||
|
||||
def self.create_preliminary(repository, my_module, created_by = nil)
|
||||
created_by ||= repository.created_by
|
||||
repository_snapshot = repository.dup.becomes(RepositorySnapshot)
|
||||
|
|
|
@ -49,8 +49,7 @@ class TeamZipExport < ZipExport
|
|||
project_path = make_model_dir(team_path, p, idx)
|
||||
project_name = project_path.split('/')[-1]
|
||||
|
||||
obj_filenames = { my_module_repository: {}, step_asset: {},
|
||||
step_table: {}, result_asset: {}, result_table: {} }
|
||||
obj_filenames = { repositories: {}, assets: {}, tables: {} }
|
||||
|
||||
# Change current dir for correct generation of relative links
|
||||
Dir.chdir(project_path)
|
||||
|
@ -63,7 +62,9 @@ class TeamZipExport < ZipExport
|
|||
|
||||
# Iterate through every inventory repo and save it to CSV
|
||||
repositories.each_with_index do |repo, repo_idx|
|
||||
obj_filenames[:my_module_repository][repo.id] = {
|
||||
next if obj_filenames[:repositories][repo.id].present?
|
||||
|
||||
obj_filenames[:repositories][repo.id] = {
|
||||
file: save_inventories_to_csv(inventories, repo, repo_idx)
|
||||
}
|
||||
end
|
||||
|
@ -88,16 +89,16 @@ class TeamZipExport < ZipExport
|
|||
|
||||
# Export protocols
|
||||
steps = my_module.protocols.map(&:steps).flatten
|
||||
obj_filenames[:step_asset].merge!(
|
||||
obj_filenames[:assets].merge!(
|
||||
export_assets(StepAsset.where(step: steps), :step, protocol_path)
|
||||
)
|
||||
obj_filenames[:step_table].merge!(
|
||||
obj_filenames[:tables].merge!(
|
||||
export_tables(StepTable.where(step: steps), :step, protocol_path)
|
||||
)
|
||||
|
||||
# Export results
|
||||
[false, true].each do |archived|
|
||||
obj_filenames[:result_asset].merge!(
|
||||
obj_filenames[:assets].merge!(
|
||||
export_assets(
|
||||
ResultAsset.where(result: my_module.results.where(archived: archived)),
|
||||
:result,
|
||||
|
@ -108,7 +109,7 @@ class TeamZipExport < ZipExport
|
|||
end
|
||||
|
||||
[false, true].each do |archived|
|
||||
obj_filenames[:result_table].merge!(
|
||||
obj_filenames[:tables].merge!(
|
||||
export_tables(
|
||||
ResultTable.where(result: my_module.results.where(archived: archived)),
|
||||
:result,
|
||||
|
|
|
@ -84,10 +84,6 @@ module ReportActions
|
|||
my_module_element
|
||||
)
|
||||
end
|
||||
|
||||
MY_MODULE_ADDONS_ELEMENTS.each do |e|
|
||||
public_send("generate_#{e}_content", my_module, my_module_element)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% timestamp = experiment.created_at %>
|
||||
<% name = experiment.name %>
|
||||
<% for_export_all = defined?(export_all) && export_all %>
|
||||
<% export_all = defined?(export_all) && export_all %>
|
||||
<div class="report-element report-experiment-element"
|
||||
data-ts="<%= timestamp.to_i %>"
|
||||
data-type="experiment"
|
||||
|
@ -34,7 +34,7 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<% if experiment.description.present? %>
|
||||
<%= custom_auto_link(experiment.description, team: current_team, base64_encoded_imgs: for_export_all) %>
|
||||
<%= custom_auto_link(experiment.description, team: current_team, base64_encoded_imgs: export_all) %>
|
||||
<% else %>
|
||||
<em><%=t "projects.reports.elements.experiment.no_description" %></em>
|
||||
<% end %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% if my_module.blank? and @my_module.present? then my_module = @my_module end %>
|
||||
<% timestamp = my_module.created_at %>
|
||||
<% name = my_module.name %>
|
||||
<% for_export_all = defined?(export_all) && export_all %>
|
||||
<% export_all = defined?(export_all) && export_all %>
|
||||
<div class="report-element report-module-element" data-ts="<%= timestamp.to_i %>" data-type="my_module" data-id='{ "my_module_id": <%= my_module.id %> }' data-scroll-id="<%= my_module.id %>" data-modal-title="<%=t "projects.reports.elements.modals.module_contents.head_title", module: my_module.name %>" data-name="<%= name %>" data-icon-class="fas fa-credit-card">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
|
@ -70,10 +70,10 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<% if my_module.description.present? %>
|
||||
<%= custom_auto_link(my_module.prepare_for_report(:description, for_export_all),
|
||||
<%= custom_auto_link(my_module.prepare_for_report(:description, export_all),
|
||||
team: current_team,
|
||||
simple_format: false,
|
||||
base64_encoded_imgs: for_export_all) %>
|
||||
base64_encoded_imgs: export_all) %>
|
||||
<% else %>
|
||||
<em><%= t("projects.reports.elements.module.no_description") %></em>
|
||||
<% end %>
|
||||
|
@ -86,16 +86,16 @@
|
|||
<% end %>
|
||||
|
||||
<% filter_steps_for_report(my_module.protocol.steps, @settings).order(:position).each do |step| %>
|
||||
<%= render partial: 'reports/elements/my_module_step_element.html.erb', locals: { step: step } %>
|
||||
<%= render partial: 'reports/elements/my_module_step_element.html.erb', locals: { step: step, export_all: export_all } %>
|
||||
<% end %>
|
||||
|
||||
<% order_results_for_report(my_module.results, @settings.dig('task', 'result_order')).each do |result| %>
|
||||
<% if result.is_asset && @settings.dig('task', 'file_results') %>
|
||||
<%= render partial: 'reports/elements/my_module_result_asset_element.html.erb', locals: { result: result, report: report } %>
|
||||
<%= render partial: 'reports/elements/my_module_result_asset_element.html.erb', locals: { result: result, report: report, export_all: export_all } %>
|
||||
<% elsif result.is_table && @settings.dig('task', 'table_results') %>
|
||||
<%= render partial: 'reports/elements/my_module_result_table_element.html.erb', locals: { result: result } %>
|
||||
<%= render partial: 'reports/elements/my_module_result_table_element.html.erb', locals: { result: result, export_all: export_all } %>
|
||||
<% elsif result.is_text && @settings.dig('task', 'text_results') %>
|
||||
<%= render partial: 'reports/elements/my_module_result_text_element.html.erb', locals: { result: result } %>
|
||||
<%= render partial: 'reports/elements/my_module_result_text_element.html.erb', locals: { result: result, export_all: export_all } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -108,7 +108,7 @@
|
|||
|
||||
<% if @settings.dig('task', 'activities') %>
|
||||
<div class="report-element-children">
|
||||
<%= render partial: 'reports/elements/my_module_activity_element.html.erb', locals: { my_module: my_module } %>
|
||||
<%= render partial: 'reports/elements/my_module_activity_element.html.erb', locals: { my_module: my_module, export_all: export_all } %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% protocol ||= my_module.protocol %>
|
||||
<% my_module = protocol.my_module %>
|
||||
<% for_export_all = defined?(export_all) && export_all %>
|
||||
<% export_all = defined?(export_all) && export_all %>
|
||||
<div class="report-element report-module-protocol-element" data-ts="<%= protocol.created_at %>" data-type="my_module_protocol" data-id='{ "my_module_id": <%= my_module.id %> }' data-scroll-id="<%= protocol.id %>">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
|
@ -15,10 +15,10 @@
|
|||
<div class="report-element-body">
|
||||
<div class="row module-protocol-description">
|
||||
<% if protocol.description.present? %>
|
||||
<%= custom_auto_link(protocol.prepare_for_report(:description, for_export_all),
|
||||
<%= custom_auto_link(protocol.prepare_for_report(:description, export_all),
|
||||
team: current_team,
|
||||
simple_format: false,
|
||||
base64_encoded_imgs: for_export_all) %>
|
||||
base64_encoded_imgs: export_all) %>
|
||||
<% else %>
|
||||
<em><%= t('my_modules.protocols.protocol_status_bar.no_description') %></em>
|
||||
<% end %>
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<% my_module ||= @my_module %>
|
||||
<% repository ||= nil %>
|
||||
<% element_id ||= repository&.id %>
|
||||
<% repository_snapshot ||= nil %>
|
||||
<% repository = assigned_repository_or_snapshot(my_module, element_id, repository, repository_snapshot) %>
|
||||
<% repository ||= assigned_repository_or_snapshot(my_module, element_id, repository, repository_snapshot) %>
|
||||
<% timestamp = Time.current + 1.year - 1.days %>
|
||||
<% rows_json = my_module.repository_json_hot(repository, :desc) %>
|
||||
<div class="report-element report-module-repository-element"
|
||||
|
@ -24,8 +23,10 @@
|
|||
</div>
|
||||
<% if defined?(export_all) && export_all %>
|
||||
<div class="pull-left table-name">
|
||||
<a href="<%= path[:file] %>">
|
||||
<em><%= t('projects.reports.elements.module_repository.table_name', name: filename) %></em>
|
||||
<% file_link = @obj_filenames.dig(:repositories, repository.id, :file) %>
|
||||
<% byebug if file_link.nil? %>
|
||||
<a href="<%= file_link %>">
|
||||
<em><%= t('projects.reports.elements.module_repository.table_name', name: file_link&.split('/').last) %></em>
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -24,8 +24,9 @@
|
|||
</div>
|
||||
<div class="pull-left file-name">
|
||||
<% if defined? export_all and export_all %>
|
||||
<a href="<%= path[:file] %>">
|
||||
<em><%= t("projects.reports.elements.result_asset.file_name", file: filename) %></em>
|
||||
<% file_link = @obj_filenames.dig(:assets, asset.id, :file) %>
|
||||
<a href="<%= file_link %>">
|
||||
<em><%= t("projects.reports.elements.result_asset.file_name", file: file_link&.split('/').last) %></em>
|
||||
</a>
|
||||
<% else %>
|
||||
<em>
|
||||
|
@ -52,7 +53,7 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12 file-image">
|
||||
<% if defined?(export_all) && export_all %>
|
||||
<img class="report-export-img" src="<%= path[:preview] %>">
|
||||
<img class="report-export-img" src="<%= @obj_filenames.dig(:assets, asset.id, :preview) %>">
|
||||
<% else %>
|
||||
<%= report_image_asset_url(asset) %>
|
||||
<% end %>
|
||||
|
|
|
@ -17,11 +17,10 @@
|
|||
</div>
|
||||
<% if defined? export_all and export_all %>
|
||||
<div class="pull-left table-name">
|
||||
<a href="<%= path[:file] %>">
|
||||
<em><%=t "projects.reports.elements.result_table.table_name",
|
||||
name: filename %></em>
|
||||
|
||||
</a>
|
||||
<% file_link = @obj_filenames.dig(:tables, table.id, :file) %>
|
||||
<a href="<%= file_link %>">
|
||||
<em><%=t "projects.reports.elements.result_table.table_name", name: file_link&.split('/').last %></em>
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="pull-left user-time">
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<% comments = result.result_comments %>
|
||||
<% timestamp = result.created_at %>
|
||||
<% name = result.name %>
|
||||
<% for_export_all = defined?(export_all) && export_all %>
|
||||
<% export_all = defined?(export_all) && export_all %>
|
||||
<div class="report-element report-result-element report-result-text-element" data-ts="<%= timestamp.to_i %>" data-type="result_text" data-id='{ "result_id": <%= result.id %> }' data-scroll-id="<%= result.id %>" data-modal-title="<%=t "projects.reports.elements.modals.result_contents.head_title", result: result.name %>" data-name="<%= name %>" data-icon-class="fas fa-asterisk">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
|
@ -27,11 +27,11 @@
|
|||
<div class="report-element-body">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 text-container ql-editor">
|
||||
<%= custom_auto_link(result_text.prepare_for_report(:text, for_export_all),
|
||||
<%= custom_auto_link(result_text.prepare_for_report(:text, export_all),
|
||||
team: current_team,
|
||||
simple_format: false,
|
||||
tags: %w(img),
|
||||
base64_encoded_imgs: for_export_all) %>
|
||||
base64_encoded_imgs: export_all) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<% tables = step.tables %>
|
||||
<% assets = step.assets %>
|
||||
<% checklists = step.checklists %>
|
||||
<% for_export_all = defined?(export_all) && export_all %>
|
||||
<% export_all = defined?(export_all) && export_all %>
|
||||
<div class="report-element report-step-element"
|
||||
data-ts="<%= timestamp.to_i %>"
|
||||
data-type="step"
|
||||
|
@ -37,11 +37,11 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12 ql-editor">
|
||||
<% if step.description.present? %>
|
||||
<%= custom_auto_link(step.prepare_for_report(:description, for_export_all),
|
||||
<%= custom_auto_link(step.prepare_for_report(:description, export_all),
|
||||
team: current_team,
|
||||
simple_format: false,
|
||||
tags: %w(img),
|
||||
base64_encoded_imgs: for_export_all) %>
|
||||
base64_encoded_imgs: export_all) %>
|
||||
<% else %>
|
||||
<em><%=t "projects.reports.elements.step.no_description" %></em>
|
||||
<% end %>
|
||||
|
@ -51,21 +51,21 @@
|
|||
<div class="report-element-children">
|
||||
<% if @settings.dig('task', 'protocol', 'step_tables') %>
|
||||
<% tables.each do |table| %>
|
||||
<%= render partial: 'reports/elements/step_table_element.html.erb', locals: { table: table } %>
|
||||
<%= render partial: 'reports/elements/step_table_element.html.erb', locals: { table: table, export_all: export_all } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if @settings.dig('task', 'protocol', 'step_files') %>
|
||||
<% assets.each do |asset| %>
|
||||
<%= render partial: 'reports/elements/step_asset_element.html.erb', locals: { asset: asset } %>
|
||||
<%= render partial: 'reports/elements/step_asset_element.html.erb', locals: { asset: asset, export_all: export_all } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if @settings.dig('task', 'protocol', 'step_checklists') %>
|
||||
<% checklists.each do |checklist| %>
|
||||
<%= render partial: 'reports/elements/step_checklist_element.html.erb', locals: { checklist: checklist } %>
|
||||
<%= render partial: 'reports/elements/step_checklist_element.html.erb', locals: { checklist: checklist, export_all: export_all } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if @settings.dig('task', 'protocol', 'step_comments') %>
|
||||
<%= render partial: 'reports/elements/step_comments_element.html.erb', locals: { step: step } %>
|
||||
<%= render partial: 'reports/elements/step_comments_element.html.erb', locals: { step: step, export_all: export_all } %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if defined?(children) %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% result ||= @result %>
|
||||
<% comments = result.result_comments.order(created_at: :desc) %>
|
||||
<% timestamp = Time.current + 1.year %>
|
||||
<% for_export_all = defined?(export_all) && export_all %>
|
||||
<% export_all = defined?(export_all) && export_all %>
|
||||
<div class="report-element report-comments-element report-result-comments-element" data-ts="<%= timestamp.to_i %>" data-type="result_comments" data-id='{ "result_id": <%= result.id %> }' data-scroll-id="<%= result.id %>" data-name="<%=t "projects.reports.elements.result_comments.sidebar_name" %>" data-icon-class="fas fa-comment">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
|
@ -23,7 +23,7 @@
|
|||
<ul class="no-style content-comments">
|
||||
<% comments.each do |comment| %>
|
||||
<%= render partial: 'shared/comments/item.html.erb',
|
||||
locals: { comment: comment, readonly: true, report: true, export_all: for_export_all } %>
|
||||
locals: { comment: comment, readonly: true, report: true, export_all: export_all } %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
</div>
|
||||
<div class="pull-left file-name">
|
||||
<% if defined? export_all and export_all %>
|
||||
<a href="<%= path[:file] %>">
|
||||
<em><%= t('projects.reports.elements.step_asset.file_name', file: filename) %></em>
|
||||
<% file_link = @obj_filenames.dig(:assets, asset.id, :file) %>
|
||||
<a href="<%= file_link %>">
|
||||
<em><%= t('projects.reports.elements.step_asset.file_name', file: file_link&.split('/').last) %></em>
|
||||
</a>
|
||||
<% else %>
|
||||
<em>
|
||||
|
@ -18,7 +19,6 @@
|
|||
file: truncate(asset.file_name, length: Constants::FILENAME_TRUNCATION_LENGTH)) %>
|
||||
<%= link_to t('projects.reports.elements.download'), asset_download_url(asset, disposition: 'attachment'), class: 'download-link', target: :_blank %>
|
||||
</em>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="pull-left user-time">
|
||||
|
@ -34,7 +34,7 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12 file-image">
|
||||
<% if defined?(export_all) && export_all %>
|
||||
<img class="report-export-img" src="<%= path[:preview] %>">
|
||||
<img class="report-export-img" src="<%= @obj_filenames.dig(:assets, asset.id, :preview) %>">
|
||||
<% else %>
|
||||
<%= report_image_asset_url(asset) %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% if checklist.blank? and @checklist.present? then checklist = @checklist end %>
|
||||
<% items = checklist.checklist_items %>
|
||||
<% timestamp = checklist.created_at %>
|
||||
<% for_export_all = defined?(export_all) && export_all %>
|
||||
<% export_all = defined?(export_all) && export_all %>
|
||||
<div class="report-element report-step-attachment-element report-step-checklist-element" data-ts="<%= timestamp.to_i %>" data-type="step_checklist" data-id='{ "checklist_id": <%= checklist.id %> }' data-scroll-id="<%= checklist.id %>" data-name="<%= checklist.name %>" data-icon-class="fas fa-tasks">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
|
@ -12,7 +12,7 @@
|
|||
<%= custom_auto_link(t('projects.reports.elements.step_checklist.checklist_name',
|
||||
name: checklist.name),
|
||||
team: current_team,
|
||||
base64_encoded_imgs: for_export_all) %>
|
||||
base64_encoded_imgs: export_all) %>
|
||||
</div>
|
||||
<div class="pull-left user-time">
|
||||
<%=t 'projects.reports.elements.step_checklist.user_time', timestamp: l(timestamp, format: :full) %>
|
||||
|
@ -32,7 +32,7 @@
|
|||
team: current_team,
|
||||
simple_format: true,
|
||||
wrapper_tag: { wrapper_tag: 'span'},
|
||||
base64_encoded_imgs: for_export_all) %>
|
||||
base64_encoded_imgs: export_all) %>
|
||||
</span>
|
||||
</li>
|
||||
<% end %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% if step.blank? and @step.present? then step = @step end %>
|
||||
<% comments = step.step_comments.order(created_at: :desc) %>
|
||||
<% timestamp = Time.current + 1.year %>
|
||||
<% for_export_all = defined?(export_all) && export_all %>
|
||||
<% export_all = defined?(export_all) && export_all %>
|
||||
<div class="report-element report-comments-element report-step-comments-element" data-ts="<%= timestamp.to_i %>" data-order="asc" data-type="step_comments" data-id='{ "step_id": <%= step.id %> }' data-scroll-id="<%= step.id %>" data-name="<%=t "projects.reports.elements.step_comments.sidebar_name" %>" data-icon-class="fas fa-comment">
|
||||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
|
@ -23,7 +23,7 @@
|
|||
<ul class="no-style content-comments">
|
||||
<% comments.each do |comment| %>
|
||||
<%= render partial: 'shared/comments/item.html.erb',
|
||||
locals: { comment: comment, readonly: true, report: true, export_all: for_export_all } %>
|
||||
locals: { comment: comment, readonly: true, report: true, export_all: export_all } %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
</div>
|
||||
<div class="pull-left table-name">
|
||||
<% if defined? export_all and export_all %>
|
||||
<a href="<%= path[:file] %>">
|
||||
<em><%=t 'projects.reports.elements.step_table.table_name',
|
||||
name: filename %></em>
|
||||
<% file_link = @obj_filenames.dig(:tables, table.id, :file) %>
|
||||
<a href="<%= file_link %>">
|
||||
<em><%=t 'projects.reports.elements.step_table.table_name', name: file_link&.split('/').last %></em>
|
||||
</a>
|
||||
<% else %>
|
||||
<% if table.try(:name) %>
|
||||
|
|
21
app/views/reports/export.html.erb
Normal file
21
app/views/reports/export.html.erb
Normal file
|
@ -0,0 +1,21 @@
|
|||
<div class="content-pane" id="report-new">
|
||||
<div class="report-container">
|
||||
<!-- Report "preview" -->
|
||||
<div id="report-content">
|
||||
|
||||
<% report.root_elements.each do |el| %>
|
||||
<%= render_report_element(el, local_assigns) %>
|
||||
<%= render_new_element(false) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<%= javascript_include_tag "handsontable.full" %>
|
||||
|
||||
<!-- Libraries for formulas -->
|
||||
<%= render partial: "shared/formulas_libraries.html.erb" %>
|
||||
|
||||
<%= javascript_include_tag("reports/new") %>
|
||||
<%= javascript_include_tag 'reports/save_pdf_to_inventory' %>
|
|
@ -1,90 +0,0 @@
|
|||
<% content_for :head do %>
|
||||
<meta name="turbolinks-cache-control" content="no-cache">
|
||||
<meta name="turbolinks-visit-control" content="reload">
|
||||
<% end %>
|
||||
|
||||
<% @settings = @report.settings %>
|
||||
|
||||
|
||||
<% provide(:head_title, t("projects.reports.new.head_title", project: h(@project.name)).html_safe) %>
|
||||
|
||||
<%= render partial: "reports/new/report_navigation" %>
|
||||
|
||||
<div class="content-pane" id="report-new">
|
||||
<div class="report-container">
|
||||
<div
|
||||
id="data-holder"
|
||||
class="hidden"
|
||||
data-project-modal-title="<%=t "projects.reports.elements.modals.project_contents.head_title" %>"
|
||||
data-add-project-contents-url="<%= project_contents_modal_project_reports_url(@project) %>"
|
||||
data-add-experiment-contents-url="<%= experiment_contents_modal_project_reports_url(@project) %>"
|
||||
data-add-module-contents-url="<%= module_contents_modal_project_reports_url(@project) %>"
|
||||
data-add-step-contents-url="<%= step_contents_modal_project_reports_url(@project) %>"
|
||||
data-add-result-contents-url="<%= result_contents_modal_project_reports_url(@project) %>"
|
||||
data-stylesheet-url="<%= stylesheet_path "application" %>"
|
||||
data-print-title="<%=t "projects.reports.print_title", project: @project.name %>"
|
||||
data-project-id="<%= @project.id %>"
|
||||
data-save-report-url="<%= save_modal_project_reports_url(@project) %>"
|
||||
data-report-id="<%= @report.present? ? @report.id : "" %>"
|
||||
data-unsaved-work-text="<%=t "projects.reports.new.unsaved_work" %>"
|
||||
data-global-sort-text="<%=t "projects.reports.new.global_sort" %>"></div>
|
||||
|
||||
<!-- Report "preview" -->
|
||||
<div id="report-content">
|
||||
|
||||
<% if @report.present? %>
|
||||
<% @report.root_elements.each do |el| %>
|
||||
<%= render_report_element(el, local_assigns) %>
|
||||
<%= render_new_element(false) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render partial: "reports/elements/project_header_element", locals: { project: @project } %>
|
||||
<%= render partial: "reports/elements/new_element", locals: { initial: true } %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Add elements modal -->
|
||||
<div class="modal" id="add-contents-modal" tabindex="-1" role="dialog" aria-labelledby="add-contents-modal-label">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="add-contents-modal-label"></h4>
|
||||
</div>
|
||||
<div class="modal-body"></div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal"><%=t "general.cancel" %></button>
|
||||
<button type="button" data-action="add" class="btn btn-primary"><%=t "projects.reports.elements.modals.add" %></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Save report modal -->
|
||||
<div class="modal" id="save-report-modal" tabindex="-1" role="dialog" aria-labelledby="save-report-modal-label">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="save-report-modal-label"><%=t "projects.reports.elements.modals.save_report.head_title" %></h4>
|
||||
</div>
|
||||
<div class="modal-body"></div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal"><%=t "general.cancel" %></button>
|
||||
<button type="button" data-action="save" class="btn btn-primary"><%=t "projects.reports.elements.modals.save_report.save" %></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<%= javascript_include_tag "handsontable.full" %>
|
||||
|
||||
<!-- Libraries for formulas -->
|
||||
<%= render partial: "shared/formulas_libraries.html.erb" %>
|
||||
|
||||
<%= javascript_include_tag("reports/new") %>
|
||||
<%= javascript_include_tag 'reports/save_pdf_to_inventory' %>
|
|
@ -42,84 +42,6 @@ class Extends
|
|||
my_module_repository: 17,
|
||||
my_module_protocol: 18 }
|
||||
|
||||
EXPORT_ALL_PROJECT_ELEMENTS = [
|
||||
{
|
||||
type_of: 'project_header',
|
||||
id_key: 'project_id'
|
||||
},
|
||||
{
|
||||
type_of: 'experiment',
|
||||
id_key: 'experiment_id',
|
||||
relation: %w(experiments),
|
||||
children: [
|
||||
{
|
||||
type_of: 'my_module',
|
||||
id_key: 'my_module_id',
|
||||
relation: %w(my_modules),
|
||||
children: [
|
||||
{
|
||||
type_of: 'my_module_protocol',
|
||||
id_key: 'my_module_id'
|
||||
},
|
||||
{
|
||||
type_of: 'step',
|
||||
relation: %w(protocol steps),
|
||||
id_key: 'step_id',
|
||||
children: [
|
||||
{
|
||||
type_of: 'step_asset',
|
||||
relation: %w(assets),
|
||||
id_key: 'asset_id'
|
||||
},
|
||||
{
|
||||
type_of: 'step_table',
|
||||
relation: %w(tables),
|
||||
id_key: 'table_id'
|
||||
},
|
||||
{
|
||||
type_of: 'step_checklist',
|
||||
relation: %w(checklists),
|
||||
id_key: 'checklist_id'
|
||||
},
|
||||
{
|
||||
type_of: 'step_comments',
|
||||
id_key: 'step_id',
|
||||
sort_order: 'asc'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type_of_lambda: lambda { |result|
|
||||
(result.result_asset ||
|
||||
result.result_table ||
|
||||
result.result_text).class.to_s.underscore
|
||||
},
|
||||
relation: %w(results),
|
||||
id_key: 'result_id',
|
||||
children: [{
|
||||
type_of: 'result_comments',
|
||||
id_key: 'result_id',
|
||||
sort_order: 'asc'
|
||||
}]
|
||||
},
|
||||
{
|
||||
type_of: 'my_module_activity',
|
||||
id_key: 'my_module_id',
|
||||
sort_order: 'asc'
|
||||
},
|
||||
{
|
||||
type_of: 'my_module_repository',
|
||||
relation: %w(experiment project assigned_repositories_and_snapshots),
|
||||
id_key: 'repository_id',
|
||||
parent_id_key: 'my_module_id',
|
||||
sort_order: 'asc'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
# Data type name should match corresponding model's name
|
||||
REPOSITORY_DATA_TYPES = { RepositoryTextValue: 0,
|
||||
RepositoryDateValue: 1,
|
||||
|
|
Loading…
Add table
Reference in a new issue