diff --git a/app/assets/javascripts/protocols/import_export/import.js b/app/assets/javascripts/protocols/import_export/import.js index 4cb415f01..685583b40 100644 --- a/app/assets/javascripts/protocols/import_export/import.js +++ b/app/assets/javascripts/protocols/import_export/import.js @@ -576,6 +576,7 @@ function importProtocolFromFile( var contents = tableNode.children('contents').text(); json.id = tableNode.attr('id'); json.name = tableNode.children('name').text(); + json.metadata = tableNode.children('metadata').text(); contents = hex2a(contents); contents = window.btoa(contents); json.contents = contents; diff --git a/app/models/table.rb b/app/models/table.rb index c6116a15e..b8395bb00 100644 --- a/app/models/table.rb +++ b/app/models/table.rb @@ -137,6 +137,7 @@ class Table < ApplicationRecord contents: contents.encode('UTF-8', 'UTF-8'), team: step.protocol.team, created_by: user, + metadata: metadata, last_modified_by: user ) diff --git a/app/utilities/protocols_exporter_v2.rb b/app/utilities/protocols_exporter_v2.rb index 0213f65a6..778189095 100644 --- a/app/utilities/protocols_exporter_v2.rb +++ b/app/utilities/protocols_exporter_v2.rb @@ -100,6 +100,7 @@ module ProtocolsExporterV2 "\n" \ "#{table.name}\n" \ "#{table.contents.unpack1('H*')}\n" \ + "#{table.metadata.to_json}\n" \ "\n" end diff --git a/app/utilities/protocols_importer_v2.rb b/app/utilities/protocols_importer_v2.rb index fefa99724..200a4feef 100644 --- a/app/utilities/protocols_importer_v2.rb +++ b/app/utilities/protocols_importer_v2.rb @@ -144,6 +144,7 @@ class ProtocolsImporterV2 table: Table.new( name: params['name'], contents: Base64.decode64(params['contents']), + metadata: JSON.parse(params['metadata'] || '{}'), created_by: @user, last_modified_by: @user, team: @team