Fix forms items NA [SCI-11844]

This commit is contained in:
Anton 2025-04-18 11:05:57 +02:00
parent 19e6b0740e
commit 0610fb347b

View file

@ -21,13 +21,15 @@ class FormRepositoryRowsFieldValue < FormFieldValue
before_save :attach_snapshot_files before_save :attach_snapshot_files
def attach_snapshot_files def attach_snapshot_files
# find asset values and attach file blobs if data.present?
data.map { |r| r['repository_cells'] }.flatten.filter { |c| c['value_type'] == 'RepositoryAssetValue' }.each do |c| # find asset values and attach file blobs
blob_id = c.dig('repository_asset_value', 'asset', 'file', 'blob', 'id') data.map { |r| r['repository_cells'] }.flatten.filter { |c| c['value_type'] == 'RepositoryAssetValue' }.each do |c|
blob_id = c.dig('repository_asset_value', 'asset', 'file', 'blob', 'id')
next if snapshot_files.find { |f| f.blob.id == blob_id } next if snapshot_files.find { |f| f.blob.id == blob_id }
snapshot_files.attach(ActiveStorage::Blob.find(blob_id)) snapshot_files.attach(ActiveStorage::Blob.find(blob_id))
end
end end
end end