mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-25 09:13:02 +08:00
Add archived and deleted repositories to reports [SCI-5781] (#3387)
* Add archived and deleted repositories to reports [SCI-5781] * Small markup fix [SCI-5781]
This commit is contained in:
parent
2763f5cf89
commit
7313b5fa16
9 changed files with 57 additions and 10 deletions
|
@ -975,7 +975,7 @@ function reportHandsonTableConverter() {
|
|||
reportData.report = {
|
||||
name: $('.report-name').val(),
|
||||
description: $('#projectDescription').val(),
|
||||
settings: { task: { protocol: {} } }
|
||||
settings: { task: { protocol: {} }, deleted_repositories: [] }
|
||||
};
|
||||
// Project
|
||||
reportData.project_id = dropdownSelector.getValues('#projectSelector');
|
||||
|
@ -1032,7 +1032,7 @@ function reportHandsonTableConverter() {
|
|||
reportData.project_content.tasks[experimentId].push(parseInt(myModule.value, 10));
|
||||
});
|
||||
});
|
||||
$.each($('.task-contents-container .repositories-contents .sci-checkbox:checked'), function(i, e) {
|
||||
$.each($('.task-contents-container .repositories-contents .repositories-setting:checked'), function(i, e) {
|
||||
reportData.project_content.repositories.push(parseInt(e.value, 10));
|
||||
});
|
||||
|
||||
|
@ -1046,6 +1046,9 @@ function reportHandsonTableConverter() {
|
|||
$.each($('.task-contents-container .content-element .task-setting'), function(i, e) {
|
||||
reportData.report.settings.task[e.value] = e.checked;
|
||||
});
|
||||
$.each($('.task-contents-container .repositories-contents .deleted-repositories-setting:checked'), function(i, e) {
|
||||
reportData.report.settings.deleted_repositories.push(parseInt(e.value, 10));
|
||||
});
|
||||
|
||||
reportData.report.settings.task.result_order = dropdownSelector.getValues('#taskResultsOrder');
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ class ReportsController < ApplicationController
|
|||
|
||||
before_action :check_manage_permissions, only: BEFORE_ACTION_METHODS
|
||||
before_action :switch_team_with_param, only: :index
|
||||
before_action :load_repositories, only: %i(new edit)
|
||||
|
||||
after_action :generate_pdf_report, only: %i(create update generate_pdf)
|
||||
|
||||
|
@ -51,7 +52,6 @@ class ReportsController < ApplicationController
|
|||
# Report grouped by modules
|
||||
def new
|
||||
@templates = Extends::REPORT_TEMPLATES
|
||||
@repositories = Repository.accessible_by_teams(current_team).active.select(:id, :name).order(:name)
|
||||
@report = current_team.reports.new
|
||||
end
|
||||
|
||||
|
@ -114,7 +114,6 @@ class ReportsController < ApplicationController
|
|||
@edit = true
|
||||
@templates = Extends::REPORT_TEMPLATES
|
||||
@active_template = @report.settings[:template]
|
||||
@repositories = Repository.accessible_by_teams(current_team).active.select(:id, :name).order(:name)
|
||||
@report.settings = Report::DEFAULT_SETTINGS if @report.settings.blank?
|
||||
|
||||
@project_contents = {
|
||||
|
@ -495,6 +494,16 @@ class ReportsController < ApplicationController
|
|||
include StringUtility
|
||||
AvailableRepository = Struct.new(:id, :name)
|
||||
|
||||
def load_repositories
|
||||
@repositories = Repository.accessible_by_teams(current_team).order(:name)
|
||||
@deleted_repositories = RepositorySnapshot.where(team: current_team)
|
||||
.group(:parent_id, :name)
|
||||
.where.not(
|
||||
original_repository: Repository.accessible_by_teams(current_team)
|
||||
)
|
||||
.select(:parent_id, :name)
|
||||
end
|
||||
|
||||
def load_vars
|
||||
@report = current_team.reports.find_by(id: params[:id])
|
||||
render_404 unless @report
|
||||
|
|
|
@ -14,7 +14,7 @@ module ReportActions
|
|||
@report = report
|
||||
@template_values = template_values
|
||||
@repositories = Repository.accessible_by_teams(report.project.team)
|
||||
.where(id: @content['repositories']).active
|
||||
.where(id: @content['repositories'])
|
||||
end
|
||||
|
||||
def save_with_content
|
||||
|
|
|
@ -88,6 +88,14 @@ module Reports::Docx::DrawMyModule
|
|||
end
|
||||
end
|
||||
|
||||
@settings['deleted_repositories']&.each do |repo|
|
||||
draw_my_module_repository(nil,
|
||||
my_module,
|
||||
my_module.repository_snapshots
|
||||
.where(parent_id: repo)
|
||||
.find_by(selected: true))
|
||||
end
|
||||
|
||||
@docx.p
|
||||
subject.children.active.each do |child|
|
||||
public_send("draw_#{child.type_of}", child)
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Reports::Docx::DrawMyModuleRepository
|
||||
def draw_my_module_repository(subject)
|
||||
my_module = subject.my_module
|
||||
repository = subject.repository
|
||||
return unless can_read_experiment?(@user, my_module.experiment) && can_read_repository?(@user, repository)
|
||||
def draw_my_module_repository(subject, my_module = nil, snapshot = nil)
|
||||
my_module ||= subject&.my_module
|
||||
repository = subject&.repository
|
||||
repository = assigned_repository_or_snapshot(my_module, repository&.id, nil, snapshot)
|
||||
return unless can_read_experiment?(@user, my_module.experiment) &&
|
||||
(can_read_repository?(@user, repository) || repository.is_a?(RepositorySnapshot))
|
||||
|
||||
repository_data = my_module.repository_docx_json(repository)
|
||||
|
||||
|
|
|
@ -98,6 +98,10 @@
|
|||
<%= render partial: 'reports/elements/my_module_result_text_element.html.erb', locals: { result: result, export_all: export_all } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% @settings['deleted_repositories']&.each do |repo| %>
|
||||
<%= render partial: 'reports/elements/my_module_repository_element.html.erb', locals: { repository_snapshot: my_module.repository_snapshots.where(parent_id: repo).find_by(selected: true), export_all: export_all, my_module: my_module } %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if defined?(children) %>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<% my_module ||= @my_module %>
|
||||
<% element_id ||= repository&.id %>
|
||||
<% repository ||= nil %>
|
||||
<% repository_snapshot ||= nil %>
|
||||
<% element_id ||= repository&.id %>
|
||||
<% 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) %>
|
||||
|
|
|
@ -73,6 +73,24 @@
|
|||
<span class="sci-checkbox-label"></span>
|
||||
</span>
|
||||
<%= repository.name %>
|
||||
<% unless repository.active? %>
|
||||
<span class="archived">
|
||||
<%= t("projects.reports.wizard.third_step.archived") %>
|
||||
</span>
|
||||
<% end %>
|
||||
<div class="divider"></div>
|
||||
</li>
|
||||
<% end %>
|
||||
<% @deleted_repositories.each do |repository| %>
|
||||
<li>
|
||||
<span class="sci-checkbox-container">
|
||||
<input type="checkbox" class="sci-checkbox deleted-repositories-setting" value="<%= repository.parent_id %>" <%= 'checked' if report.new_record? || report.settings.dig(:deleted_repositories).include?(repository.parent_id) %> />
|
||||
<span class="sci-checkbox-label"></span>
|
||||
</span>
|
||||
<%= repository.name %>
|
||||
<span class="deleted">
|
||||
<%= t("projects.reports.wizard.third_step.deleted") %>
|
||||
</span>
|
||||
<div class="divider"></div>
|
||||
</li>
|
||||
<% end %>
|
||||
|
|
|
@ -586,6 +586,8 @@ en:
|
|||
results_comments: "Include all result comments"
|
||||
additional_content: "Additional content"
|
||||
task_activity: "Include task activity"
|
||||
archived: "[archived]"
|
||||
deleted: "[deleted]"
|
||||
|
||||
new:
|
||||
report_name_placeholder: "Name your report"
|
||||
|
|
Loading…
Reference in a new issue