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,6 +21,7 @@ class FormRepositoryRowsFieldValue < FormFieldValue
before_save :attach_snapshot_files
def attach_snapshot_files
if data.present?
# find asset values and attach file blobs
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')
@ -30,6 +31,7 @@ class FormRepositoryRowsFieldValue < FormFieldValue
snapshot_files.attach(ActiveStorage::Blob.find(blob_id))
end
end
end
def value=(repository_row_ids)
# removes repository row snapshots if they are not present in the new id array,