diff --git a/i18n/de.json b/i18n/de.json index 33db6a8..8584b10 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -10,6 +10,7 @@ "LABEL_CREATOR_ID": "Persönliche ID (wie ORCID, GND, ...)", "LABEL_CREATOR_LAST_NAME": "Nachname", "LABEL_CREATOR_REMOVE": "Autor entfernen", + "LABEL_CUSTOM_INSTITUTION": "benutzerdefinierte Institution", "LABEL_DESCRIPTION": "Zusammenfassung", "LABEL_EDUCATIONALLEVEL": "Bildungsstufe", "LABEL_EDUCATIONALLEVEL_CHOOSE": "Wähle eine Bildungsstufe ...", diff --git a/i18n/en.json b/i18n/en.json index 82a93dd..45ecd32 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -10,6 +10,7 @@ "LABEL_CREATOR_ID": "Personal ID (like ORCID, GND, ...)", "LABEL_CREATOR_LAST_NAME": "Lastname", "LABEL_CREATOR_REMOVE": "remove Author", + "LABEL_CUSTOM_INSTITUTION": "custom Institution", "LABEL_DESCRIPTION": "Abstract", "LABEL_EDUCATIONALLEVEL": "Level", "LABEL_EDUCATIONALLEVEL_CHOOSE": "Choose a level ...", diff --git a/metadata-generator.html b/metadata-generator.html index 1b0e6ea..1f5fbe7 100644 --- a/metadata-generator.html +++ b/metadata-generator.html @@ -461,7 +461,19 @@ } } - function addCreator(firstName = "", lastName = "", authorId = "", institution = "", organizationName = "", type = "Person") { + function changeAffiliationType(creatorListItem, type) { + const affiliationElements = creatorListItem.getElementsByClassName("inputAffiliation") + for (const element of affiliationElements) { + if (element.classList.contains("customAffiliation")) { + element.disabled = type !== "custom"; + } else { + element.disabled = type === "custom"; + } + } + $('.selectpicker').selectpicker('refresh'); + } + + function addCreator(firstName = "", lastName = "", authorId = "", institution = "", organizationName = "", type = "Person", affiliationName = "") { const creatorList = document.getElementById("creator-list"); const item = document.createElement("li"); item.setAttribute("class", "list-group-item"); @@ -469,6 +481,7 @@ $.each(vocabInstitutions, function (i, item) { institutionOptions += ''; }); + let customInstitutionSelected = institution === "" && affiliationName !== ""; let radioGroupName = creatorList.childElementCount > 1 ? $(creatorList.lastElementChild.previousElementSibling).find('.inputType').find('input').attr('name') : '' radioGroupName += 'x' @@ -501,13 +514,24 @@
-
- +
+
+
+
+
+ +
+
+ +
+
@@ -543,17 +567,28 @@ }); } else { const creatorId = creatorsElement[i].getElementsByClassName("inputAuthorId")[0].value; - const affiliationInput = creatorsElement[i].querySelector("select.inputAffiliation"); + const affiliationTypeElement = creatorsElement[i].querySelector("input.affiliationType:checked"); + let affiliation + if ("custom" === affiliationTypeElement.value) { + const affiliationInput = creatorsElement[i].getElementsByClassName("customAffiliation")[0].value.trim(); + affiliation = affiliationInput ? { + name: affiliationInput, + type: "Organization" + } : undefined + } else { + const affiliationInput = creatorsElement[i].querySelector("select.inputAffiliation"); + affiliation = affiliationInput.value ? { + name: affiliationInput.options[affiliationInput.selectedIndex].innerHTML, + id: affiliationInput.value, + type: "Organization" + } : undefined + } creators.push({ givenName: creatorsElement[i].getElementsByClassName("inputGivenName")[0].value.trim(), familyName: creatorsElement[i].getElementsByClassName("inputFamilyName")[0].value.trim(), id: creatorId ? creatorId : undefined, type: "Person", - affiliation: affiliationInput.value ? { - name: affiliationInput.options[affiliationInput.selectedIndex].innerHTML, - id: affiliationInput.value, - type: "Organization" - } : undefined + affiliation: affiliation }); } } @@ -624,7 +659,8 @@ const lastName = creators[i].familyName ? creators[i].familyName: creators[i].name.substring(creators[i].name.indexOf(" ") + 1); const authorId = creators[i].id ? creators[i].id : ""; const ror = creators[i].affiliation?.id ? creators[i].affiliation.id : ""; - addCreator(firstName, lastName, authorId, ror); + const affiliationName = creators[i].affiliation?.name ? creators[i].affiliation.name : ""; + addCreator(firstName, lastName, authorId, ror, "", "Person", affiliationName); } } }