Add step table metadata during import/export and copy [SCI-7948]

This commit is contained in:
Anton 2023-02-17 14:50:45 +01:00
parent ed76fac640
commit df8579d52f
4 changed files with 4 additions and 0 deletions

View file

@ -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;

View file

@ -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
)

View file

@ -100,6 +100,7 @@ module ProtocolsExporterV2
"<elnTable id=\"#{table.id}\" guid=\"#{get_guid(table.id)}\">\n" \
"<name>#{table.name}</name>\n" \
"<contents>#{table.contents.unpack1('H*')}</contents>\n" \
"<metadata>#{table.metadata.to_json}</metadata>\n" \
"</elnTable>\n"
end

View file

@ -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