From caa20985503462cb59b1fdb4d0c506fe94766aaa Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Mon, 12 Oct 2020 14:42:47 +0200 Subject: [PATCH] Improve handling of empty cells in inventory imports [SCI-5094] --- app/models/repository_checklist_value.rb | 2 ++ app/models/repository_list_value.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/models/repository_checklist_value.rb b/app/models/repository_checklist_value.rb index cd09c9f1a..d3ab9e1cf 100644 --- a/app/models/repository_checklist_value.rb +++ b/app/models/repository_checklist_value.rb @@ -75,6 +75,8 @@ class RepositoryChecklistValue < ApplicationRecord end def self.import_from_text(text, attributes, _options = {}) + return nil if text.blank? + value = new(attributes) column = attributes.dig(:repository_cell_attributes, :repository_column) RepositoryImportParser::Util.split_by_delimiter(text: text, delimiter: column.delimiter_char).each do |item_text| diff --git a/app/models/repository_list_value.rb b/app/models/repository_list_value.rb index b99b08345..44392bb32 100644 --- a/app/models/repository_list_value.rb +++ b/app/models/repository_list_value.rb @@ -66,6 +66,8 @@ class RepositoryListValue < ApplicationRecord end def self.import_from_text(text, attributes, _options = {}) + return nil if text.blank? + value = new(attributes) column = attributes.dig(:repository_cell_attributes, :repository_column) list_item = column.repository_list_items.find { |item| item.data == text }