mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-02 09:54:37 +08:00
Fix forms items NA [SCI-11844]
This commit is contained in:
parent
19e6b0740e
commit
0610fb347b
1 changed files with 7 additions and 5 deletions
|
@ -21,13 +21,15 @@ class FormRepositoryRowsFieldValue < FormFieldValue
|
|||
before_save :attach_snapshot_files
|
||||
|
||||
def attach_snapshot_files
|
||||
# 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')
|
||||
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')
|
||||
|
||||
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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue