mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-11 17:36:13 +08:00
Fix index/position for export-all folder names [SCI-2817]
This commit is contained in:
parent
6ff117d662
commit
2a5b36b3c2
1 changed files with 15 additions and 10 deletions
|
@ -47,13 +47,15 @@ class TeamZipExport < ZipExport
|
||||||
FileUtils.mkdir_p(team_path)
|
FileUtils.mkdir_p(team_path)
|
||||||
|
|
||||||
# Iterate through every project
|
# Iterate through every project
|
||||||
data.each_with_index do |(_, p), ind|
|
p_idx = p_archive_idx = 0
|
||||||
|
data.each do |(_, p)|
|
||||||
|
idx = p.archived ? (p_archive_idx += 1) : (p_idx += 1)
|
||||||
|
project_path = make_model_dir(team_path, p, idx)
|
||||||
|
project_name = project_path.split('/')[-1]
|
||||||
|
|
||||||
obj_filenames = { my_module_repository: {}, step_asset: {},
|
obj_filenames = { my_module_repository: {}, step_asset: {},
|
||||||
step_table: {}, result_asset: {}, result_table: {} }
|
step_table: {}, result_asset: {}, result_table: {} }
|
||||||
|
|
||||||
project_path = make_model_dir(team_path, p, ind)
|
|
||||||
project_name = project_path.split('/')[-1]
|
|
||||||
|
|
||||||
# Change current dir for correct generation of relative links
|
# Change current dir for correct generation of relative links
|
||||||
Dir.chdir(project_path)
|
Dir.chdir(project_path)
|
||||||
project_path = '.'
|
project_path = '.'
|
||||||
|
@ -75,14 +77,16 @@ class TeamZipExport < ZipExport
|
||||||
end
|
end
|
||||||
|
|
||||||
# Include all experiments
|
# Include all experiments
|
||||||
p.experiments.each_with_index do |ex, ex_ind|
|
ex_idx = ex_archive_idx = 0
|
||||||
experiment_path = make_model_dir(project_path, ex, ex_ind)
|
p.experiments.each do |ex|
|
||||||
|
idx = ex.archived ? (ex_archive_idx += 1) : (ex_idx += 1)
|
||||||
|
experiment_path = make_model_dir(project_path, ex, idx)
|
||||||
|
|
||||||
# Include all modules
|
# Include all modules
|
||||||
ex.my_modules.order(:workflow_order)
|
mod_pos = mod_archive_pos = 0
|
||||||
.each_with_index do |my_module, mod_pos|
|
ex.my_modules.order(:workflow_order).each do |my_module|
|
||||||
|
pos = my_module.archived ? (mod_archive_pos += 1) : (mod_pos += 1)
|
||||||
my_module_path = make_model_dir(experiment_path, my_module, mod_pos)
|
my_module_path = make_model_dir(experiment_path, my_module, pos)
|
||||||
|
|
||||||
# Create upper directories for both elements
|
# Create upper directories for both elements
|
||||||
protocol_path = "#{my_module_path}/Protocol attachments"
|
protocol_path = "#{my_module_path}/Protocol attachments"
|
||||||
|
@ -139,6 +143,7 @@ class TeamZipExport < ZipExport
|
||||||
|
|
||||||
# Create directory for project, experiment, or module
|
# Create directory for project, experiment, or module
|
||||||
def make_model_dir(parent_path, model, index)
|
def make_model_dir(parent_path, model, index)
|
||||||
|
# For MyModule, the index indicates its position in project sidebar
|
||||||
model_name = format(
|
model_name = format(
|
||||||
model.class == MyModule ? '(%<idx>s) %<name>s' : '%<name>s (%<idx>s)',
|
model.class == MyModule ? '(%<idx>s) %<name>s' : '%<name>s (%<idx>s)',
|
||||||
idx: index, name: to_filesystem_name(model.name)
|
idx: index, name: to_filesystem_name(model.name)
|
||||||
|
|
Loading…
Reference in a new issue