From d5617ab1e7d9f6ea532dcfc3bbb501bd1ee6af88 Mon Sep 17 00:00:00 2001 From: Silvio Hermann Date: Tue, 22 Oct 2024 09:37:52 +0200 Subject: [PATCH] MIR-1361 Added title attribute to ror inputs in xEditor --- .../META-INF/resources/js/mir/ror-search.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mir-module/src/main/resources/META-INF/resources/js/mir/ror-search.js b/mir-module/src/main/resources/META-INF/resources/js/mir/ror-search.js index 387dcc746f..d12fc38eb5 100644 --- a/mir-module/src/main/resources/META-INF/resources/js/mir/ror-search.js +++ b/mir-module/src/main/resources/META-INF/resources/js/mir/ror-search.js @@ -56,6 +56,7 @@ const RORSearch = { // User selects value from list if (option != null) { input.value = option.getAttribute("data-ror"); + input.title = option.getAttribute("value") event.preventDefault(); return; } @@ -85,6 +86,24 @@ const RORSearch = { }; }, + /** + * Resolve ror links in xEditor and update title attributes of ror inputs. + * */ + updateXEditorInputTitle: async function () { + let rorInputs = document.querySelectorAll("[id='mir-ror-input']"); + for (const rorInput of rorInputs) { + if (rorInput.value.length == 0) { + continue; + } + + RORSearch.search(rorInput.value).then(data => { + if (data.length > 0) { + rorInput.setAttribute("title", data[0].name + " (" + data[0].id + ")"); + } + }); + } + }, + /** * Resolve ror links on metadata page. * */ @@ -125,4 +144,5 @@ document.addEventListener('DOMContentLoaded', function () { } RORSearch.resolve(); + RORSearch.updateXEditorInputTitle(); });