Skip to content

Commit

Permalink
MIR-1361 Added title attribute to ror inputs in xEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
Possommi committed Oct 22, 2024
1 parent 56c7f13 commit d5617ab
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
* */
Expand Down Expand Up @@ -125,4 +144,5 @@ document.addEventListener('DOMContentLoaded', function () {
}

RORSearch.resolve();
RORSearch.updateXEditorInputTitle();
});

0 comments on commit d5617ab

Please sign in to comment.