From 50992dc2b66772c77fa752ce0c9aa811e0d2ae7b Mon Sep 17 00:00:00 2001 From: Rodolfo Zitellini Date: Mon, 12 Dec 2022 16:14:29 +0100 Subject: [PATCH] #1304, make VIAF searches complete --- app/assets/javascripts/marc_editor_manipulation.js | 13 ++++++++----- app/assets/javascripts/viaf_interface.js | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/marc_editor_manipulation.js b/app/assets/javascripts/marc_editor_manipulation.js index cc0b9959c..b88e39f0c 100644 --- a/app/assets/javascripts/marc_editor_manipulation.js +++ b/app/assets/javascripts/marc_editor_manipulation.js @@ -4,7 +4,7 @@ * else: add other tags (new and append) * never update fields if not new */ - function _marc_editor_update_from_json(data, protected_fields) { + function _marc_editor_update_from_json(data, protected_fields, allow_multiple = false) { let tags = data["fields"]; let Last_tag = ""; let index = 0; @@ -28,12 +28,15 @@ _marc_editor_overwrite_tag(datafield.tag, current_json_tag) } // All the other fields. Is the tag collapsed (no instances of a tag)? - } else if (_marc_editor_count_tag(datafield.tag) == 0) { - // Create a new tag from the placeholders - _marc_editor_create_new_tag(datafield.tag, current_json_tag) - } else { + // If there is already a field overwrite it + } else if (_marc_editor_count_tag(datafield.tag) != 0 && allow_multiple == false) { _marc_editor_overwrite_tag(datafield.tag, current_json_tag) + } else { + // if we allow multiples, then we can append the fields + _marc_editor_create_new_tag(datafield.tag, current_json_tag) } + + } } diff --git a/app/assets/javascripts/viaf_interface.js b/app/assets/javascripts/viaf_interface.js index 5eee55a45..e58d40e25 100644 --- a/app/assets/javascripts/viaf_interface.js +++ b/app/assets/javascripts/viaf_interface.js @@ -7,7 +7,7 @@ var show_viaf_actions = function () { }); $viaf_table.on('click', '.data', function() { - _marc_editor_update_from_json($(this).data("viaf"),["100"]); + _marc_editor_update_from_json($(this).data("viaf"),["100"], true); marc_editor_show_panel("marc_editor_panel"); });