diff --git a/i18n/de.json b/i18n/de.json index 3555eb1..6c35c8a 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -5,7 +5,7 @@ "LABEL_CREATOR": "Autor", "LABEL_CREATOR_ADD": "weiteren Autor hinzufügen", "LABEL_CREATOR_GIVEN_NAME": "Vorname", - "LABEL_CREATOR_ID": "(Optional) Persönliche ID (wie ORCID, GND, ...)", + "LABEL_CREATOR_ID": "Persönliche ID (wie ORCID, GND, ...)", "LABEL_CREATOR_LAST_NAME": "Nachname", "LABEL_CREATOR_REMOVE": "Autor entfernen", "LABEL_DESCRIPTION": "Zusammenfassung", @@ -26,7 +26,7 @@ "LABEL_LICENSE_CHECKBOX_ND": "darf verändert werden", "LABEL_LICENSE_CHECKBOX_NC": "darf kommerziell genutzt werden", "LABEL_MANDATORY_FIELD": "Pflichtfeld", - "LABEL_ORGANIZATION": "Institution", + "LABEL_ORGANIZATION_CHOOSE": "Wähle Institution ...", "LABEL_STATUS": "Status", "LABEL_STATUS_DRAFT": "Entwurf", "LABEL_STATUS_INCOMPLETE": "Unvollständig", diff --git a/i18n/en.json b/i18n/en.json index a6d86c2..edfb314 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -5,7 +5,7 @@ "LABEL_CREATOR": "Author", "LABEL_CREATOR_ADD": "add Author", "LABEL_CREATOR_GIVEN_NAME": "Firstname", - "LABEL_CREATOR_ID": "(Optional) Personal ID (like ORCID, GND, ...)", + "LABEL_CREATOR_ID": "Personal ID (like ORCID, GND, ...)", "LABEL_CREATOR_LAST_NAME": "Lastname", "LABEL_CREATOR_REMOVE": "remove Author", "LABEL_DESCRIPTION": "Abstract", @@ -19,14 +19,14 @@ "LABEL_KEYWORDS_PLACEHOLDER": "Comma separated list of keywords", "LABEL_LANGUAGE": "Language", "LABEL_LEARNINGRESOURCETYPE": "Type", - "LABEL_LEARNINGRESOURCETYPE_CHOOSE": "Choose a type ...", + "LABEL_LEARNINGRESOURCETYPE_CHOOSE": "Choose a type ...", "LABEL_LICENSE": "License", "LABEL_LICENSE_CHECKBOX_BY": "may be used without attribution", "LABEL_LICENSE_CHECKBOX_SA": "may be published under another license", "LABEL_LICENSE_CHECKBOX_ND": "may be changed", "LABEL_LICENSE_CHECKBOX_NC": "may be used commercially", "LABEL_MANDATORY_FIELD": "Mandatory field", - "LABEL_ORGANIZATION": "Institution", + "LABEL_ORGANIZATION_CHOOSE": "Choose Institution ...", "LABEL_STATUS": "Status", "LABEL_STATUS_DRAFT": "Draft", "LABEL_STATUS_INCOMPLETE": "Incomplete", diff --git a/metadata-generator.html b/metadata-generator.html index ad86d72..eaffc98 100644 --- a/metadata-generator.html +++ b/metadata-generator.html @@ -127,14 +127,6 @@ -
- -
- -
-
@@ -243,6 +235,7 @@ chooseLicense(); addCreator(); } + let vocabInstitutions = [] function loadVocabs() { $(document).ready(function () { @@ -257,9 +250,7 @@ }); }); $.getJSON("vocabs/organizations.json", function (result) { - $.each(result, function (i, item) { - $("#inputSourceOrganization").append(''); - }); + vocabInstitutions = result; }); $.getJSON("vocabs/subject.json", function (result) { $.each(result, function (i, item) { @@ -419,10 +410,15 @@ return keywords.map((k) => k.trim()); } - function addCreator(firstName = "", lastName = "", authorId = "") { + function addCreator(firstName = "", lastName = "", authorId = "", institution = "") { const creatorList = document.getElementById("creator-list"); const item = document.createElement("li"); item.setAttribute("class", "list-group-item"); + let institutionOptions = "" + $.each(vocabInstitutions, function (i, item) { + institutionOptions += ''; + }); + item.innerHTML = `
@@ -436,11 +432,19 @@
Pflichtfeld
-
+
+
+
+ +
+
@@ -461,11 +465,17 @@ const creators = []; for (let i = 0; i < creatorsElement.length - 1; i++) { const creatorId = creatorsElement[i].getElementsByClassName("inputAuthorId")[0].value; + const affiliationInput = creatorsElement[i].querySelector("select.inputAffiliation"); creators.push({ name: (creatorsElement[i].getElementsByClassName("inputGivenName")[0].value + " " + creatorsElement[i].getElementsByClassName("inputFamilyName")[0].value).trim(), - id: creatorId ? creatorId : undefined + id: creatorId ? creatorId : undefined, + affiliation: affiliationInput.value ? { + name: affiliationInput.options[affiliationInput.selectedIndex].innerHTML, + id: affiliationInput.value, + type: "Organization" + } : undefined }); } return creators; @@ -473,7 +483,6 @@ function generate() { const creators = getCreators() - const inputSourceOrganization = document.getElementById("inputSourceOrganization"); const selectedLanguages = $('#inputLanguage').val(); const selectedSubjects = $('#inputSubjectOf').val(); const selectedResourceTypes = $('#inputResourceType').val(); @@ -493,15 +502,6 @@ if (selectedLanguages.length > 0) { meta.inLanguage = selectedLanguages; } - if (inputSourceOrganization.value) { - meta.sourceOrganization = [ - { - name: inputSourceOrganization.options[inputSourceOrganization.selectedIndex].innerHTML, - id: inputSourceOrganization.value, - type: "Organization" - } - ] - } if (selectedSubjects.length > 0) { meta.about = selectedSubjects.map((s) => ({id: s})) } @@ -523,13 +523,13 @@ const firstName = creators[i].name.split(" ")[0]; const lastName = creators[i].name.substring(creators[i].name.indexOf(" ") + 1); const authorId = creators[i].id ? creators[i].id : ""; - addCreator(firstName, lastName, authorId); + const ror = creators[i].affiliation?.id ? creators[i].affiliation.id : ""; + addCreator(firstName, lastName, authorId, ror); } } function importData() { try { const data = jsyaml.load(document.getElementById("importData").value); - const sourceOrganizationIds = data.sourceOrganization ? data.sourceOrganization.map((o) => o.id) : []; const aboutIds = data.about ? data.about.map((o) => o.id) : []; const learningResourceTypeIds = data.learningResourceType ? data.learningResourceType.map((o) => o.id) : []; @@ -540,7 +540,6 @@ document.getElementById("inputTags").value = data.keywords ? data.keywords.join(", ") : ""; document.getElementById("inputDescription").value = data.description ? data.description : ""; $('#inputLanguage').val(data.inLanguage ? data.inLanguage : []).selectpicker('refresh'); - $('#inputSourceOrganization').val(sourceOrganizationIds).selectpicker('refresh'); $('#inputSubjectOf').val(aboutIds).selectpicker('refresh'); setLicense((data.license && data.license.id) ? data.license.id : "") document.getElementById("inputImage").value = data.image ? data.image : "";