mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-06 20:56:42 +08:00
Merge pull request #7404 from lasniscinote/gl_SCI_10490
(dev) Create a new column during import into inventory [SCI-10490]
This commit is contained in:
commit
71d286bf26
2 changed files with 9 additions and 1 deletions
|
@ -39,10 +39,18 @@ module RepositoryImportParser
|
|||
|
||||
def fetch_columns
|
||||
@mappings.each_with_index do |(_, value), index|
|
||||
value = JSON.parse(value) rescue value
|
||||
value = value.to_s unless value.is_a?(Hash)
|
||||
|
||||
if value == '-1'
|
||||
# Fill blank space, so our indices stay the same
|
||||
@columns << nil
|
||||
@name_index = index
|
||||
|
||||
# creating a custom option column
|
||||
elsif value.is_a?(Hash)
|
||||
new_repository_column = @repository.repository_columns.create!(created_by: @user, name: value['name']+rand(10000).to_s, data_type: "Repository#{value['type']}Value")
|
||||
@columns << new_repository_column
|
||||
else
|
||||
@columns << @repository_columns.where(data_type: Extends::REPOSITORY_IMPORTABLE_TYPES)
|
||||
.preload(Extends::REPOSITORY_IMPORT_COLUMN_PRELOADS)
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<% @import_data.header.each.with_index do |th, index| %>
|
||||
<th style="min-width: 150px" title="<%= th %>">
|
||||
<%= f.select("mappings[#{index.to_s}]",
|
||||
options_from_collection_for_select(@import_data.available_fields,
|
||||
options_from_collection_for_select(@import_data.available_fields.merge({{name: 'new text option', type: 'Text'}.to_json => "new_text_option"}, {{name: 'new list option', type: 'List'}.to_json => "new_list_option"}),
|
||||
:first,
|
||||
:last),
|
||||
{ include_blank: t('repositories.parse_sheet.do_not_include_column'), hide_label: true },
|
||||
|
|
Loading…
Reference in a new issue