use affiliation instead of sourceOrganization

This commit is contained in:
Mirjan Hoffmann 2022-03-10 07:14:09 +01:00
parent 0f0acc4dee
commit cf0700c21f
3 changed files with 31 additions and 32 deletions

View file

@ -5,7 +5,7 @@
"LABEL_CREATOR": "Autor", "LABEL_CREATOR": "Autor",
"LABEL_CREATOR_ADD": "weiteren Autor hinzufügen", "LABEL_CREATOR_ADD": "weiteren Autor hinzufügen",
"LABEL_CREATOR_GIVEN_NAME": "Vorname", "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_LAST_NAME": "Nachname",
"LABEL_CREATOR_REMOVE": "Autor entfernen", "LABEL_CREATOR_REMOVE": "Autor entfernen",
"LABEL_DESCRIPTION": "Zusammenfassung", "LABEL_DESCRIPTION": "Zusammenfassung",
@ -26,7 +26,7 @@
"LABEL_LICENSE_CHECKBOX_ND": "darf verändert werden", "LABEL_LICENSE_CHECKBOX_ND": "darf verändert werden",
"LABEL_LICENSE_CHECKBOX_NC": "darf kommerziell genutzt werden", "LABEL_LICENSE_CHECKBOX_NC": "darf kommerziell genutzt werden",
"LABEL_MANDATORY_FIELD": "Pflichtfeld", "LABEL_MANDATORY_FIELD": "Pflichtfeld",
"LABEL_ORGANIZATION": "Institution", "LABEL_ORGANIZATION_CHOOSE": "Wähle Institution ...",
"LABEL_STATUS": "Status", "LABEL_STATUS": "Status",
"LABEL_STATUS_DRAFT": "Entwurf", "LABEL_STATUS_DRAFT": "Entwurf",
"LABEL_STATUS_INCOMPLETE": "Unvollständig", "LABEL_STATUS_INCOMPLETE": "Unvollständig",

View file

@ -5,7 +5,7 @@
"LABEL_CREATOR": "Author", "LABEL_CREATOR": "Author",
"LABEL_CREATOR_ADD": "add Author", "LABEL_CREATOR_ADD": "add Author",
"LABEL_CREATOR_GIVEN_NAME": "Firstname", "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_LAST_NAME": "Lastname",
"LABEL_CREATOR_REMOVE": "remove Author", "LABEL_CREATOR_REMOVE": "remove Author",
"LABEL_DESCRIPTION": "Abstract", "LABEL_DESCRIPTION": "Abstract",
@ -19,14 +19,14 @@
"LABEL_KEYWORDS_PLACEHOLDER": "Comma separated list of keywords", "LABEL_KEYWORDS_PLACEHOLDER": "Comma separated list of keywords",
"LABEL_LANGUAGE": "Language", "LABEL_LANGUAGE": "Language",
"LABEL_LEARNINGRESOURCETYPE": "Type", "LABEL_LEARNINGRESOURCETYPE": "Type",
"LABEL_LEARNINGRESOURCETYPE_CHOOSE": "Choose a type ...", "LABEL_LEARNINGRESOURCETYPE_CHOOSE": "Choose a type ...",
"LABEL_LICENSE": "License", "LABEL_LICENSE": "License",
"LABEL_LICENSE_CHECKBOX_BY": "may be used without attribution", "LABEL_LICENSE_CHECKBOX_BY": "may be used without attribution",
"LABEL_LICENSE_CHECKBOX_SA": "may be published under another license", "LABEL_LICENSE_CHECKBOX_SA": "may be published under another license",
"LABEL_LICENSE_CHECKBOX_ND": "may be changed", "LABEL_LICENSE_CHECKBOX_ND": "may be changed",
"LABEL_LICENSE_CHECKBOX_NC": "may be used commercially", "LABEL_LICENSE_CHECKBOX_NC": "may be used commercially",
"LABEL_MANDATORY_FIELD": "Mandatory field", "LABEL_MANDATORY_FIELD": "Mandatory field",
"LABEL_ORGANIZATION": "Institution", "LABEL_ORGANIZATION_CHOOSE": "Choose Institution ...",
"LABEL_STATUS": "Status", "LABEL_STATUS": "Status",
"LABEL_STATUS_DRAFT": "Draft", "LABEL_STATUS_DRAFT": "Draft",
"LABEL_STATUS_INCOMPLETE": "Incomplete", "LABEL_STATUS_INCOMPLETE": "Incomplete",

View file

@ -127,14 +127,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<div class="form-group row">
<label for="inputSourceOrganization" class="col-sm-2 col-form-label" data-i18n="LABEL_ORGANIZATION">Institution</label>
<div class="col-sm-10">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputSourceOrganization" data-live-search="true">
<option value="" data-i18n="LABEL_CHOOSE" selected>Wähle ...</option>
</select>
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<label for="inputLanguage" class="col-sm-2 col-form-label" data-i18n="LABEL_LANGUAGE">Sprache</label> <label for="inputLanguage" class="col-sm-2 col-form-label" data-i18n="LABEL_LANGUAGE">Sprache</label>
<div class="col-sm-10"> <div class="col-sm-10">
@ -243,6 +235,7 @@
chooseLicense(); chooseLicense();
addCreator(); addCreator();
} }
let vocabInstitutions = []
function loadVocabs() { function loadVocabs() {
$(document).ready(function () { $(document).ready(function () {
@ -257,9 +250,7 @@
}); });
}); });
$.getJSON("vocabs/organizations.json", function (result) { $.getJSON("vocabs/organizations.json", function (result) {
$.each(result, function (i, item) { vocabInstitutions = result;
$("#inputSourceOrganization").append('<option value="' + item["ror"] + '">' + item["label"] + '</option>');
});
}); });
$.getJSON("vocabs/subject.json", function (result) { $.getJSON("vocabs/subject.json", function (result) {
$.each(result, function (i, item) { $.each(result, function (i, item) {
@ -419,10 +410,15 @@
return keywords.map((k) => k.trim()); return keywords.map((k) => k.trim());
} }
function addCreator(firstName = "", lastName = "", authorId = "") { function addCreator(firstName = "", lastName = "", authorId = "", institution = "") {
const creatorList = document.getElementById("creator-list"); const creatorList = document.getElementById("creator-list");
const item = document.createElement("li"); const item = document.createElement("li");
item.setAttribute("class", "list-group-item"); item.setAttribute("class", "list-group-item");
let institutionOptions = ""
$.each(vocabInstitutions, function (i, item) {
institutionOptions += '<option value="' + item["ror"] + '"' + (item["ror"] === institution ? ' selected' : '') + '>' + item["label"] + '</option>';
});
item.innerHTML = ` item.innerHTML = `
<div class="form-row"> <div class="form-row">
<div class="col"> <div class="col">
@ -436,11 +432,19 @@
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div> <div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row mt-2">
<div class="col"> <div class="col">
<input type="text" class="form-control inputAuthorId" placeholder="Persönliche ID (optional, wie ORCID, GND)" data-i18n-placeholder="LABEL_CREATOR_ID" value="${authorId}"> <input type="text" class="form-control inputAuthorId" placeholder="Persönliche ID (optional, wie ORCID, GND)" data-i18n-placeholder="LABEL_CREATOR_ID" value="${authorId}">
</div> </div>
</div> </div>
<div class="form-row mt-2">
<div class="col">
<select data-style="input-dropdown" data-width="100%" class="selectpicker inputAffiliation" data-live-search="true">
<option value="" data-i18n="LABEL_ORGANIZATION_CHOOSE" ${institution === "" ? "selected":""}>Wähle Institution ...</option>
${institutionOptions}
</select>
</div>
</div>
<div class="form-row mt-2"> <div class="form-row mt-2">
<div class="col"> <div class="col">
<button type="button" onclick="removeCreator(this.parentNode.parentNode.parentNode)" class="btn btn-primary"><i class="fa fa-minus"></i> <span data-i18n="LABEL_CREATOR_REMOVE"> Autor entfernen</span></button> <button type="button" onclick="removeCreator(this.parentNode.parentNode.parentNode)" class="btn btn-primary"><i class="fa fa-minus"></i> <span data-i18n="LABEL_CREATOR_REMOVE"> Autor entfernen</span></button>
@ -461,11 +465,17 @@
const creators = []; const creators = [];
for (let i = 0; i < creatorsElement.length - 1; i++) { for (let i = 0; i < creatorsElement.length - 1; i++) {
const creatorId = creatorsElement[i].getElementsByClassName("inputAuthorId")[0].value; const creatorId = creatorsElement[i].getElementsByClassName("inputAuthorId")[0].value;
const affiliationInput = creatorsElement[i].querySelector("select.inputAffiliation");
creators.push({ creators.push({
name: (creatorsElement[i].getElementsByClassName("inputGivenName")[0].value name: (creatorsElement[i].getElementsByClassName("inputGivenName")[0].value
+ " " + " "
+ creatorsElement[i].getElementsByClassName("inputFamilyName")[0].value).trim(), + 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; return creators;
@ -473,7 +483,6 @@
function generate() { function generate() {
const creators = getCreators() const creators = getCreators()
const inputSourceOrganization = document.getElementById("inputSourceOrganization");
const selectedLanguages = $('#inputLanguage').val(); const selectedLanguages = $('#inputLanguage').val();
const selectedSubjects = $('#inputSubjectOf').val(); const selectedSubjects = $('#inputSubjectOf').val();
const selectedResourceTypes = $('#inputResourceType').val(); const selectedResourceTypes = $('#inputResourceType').val();
@ -493,15 +502,6 @@
if (selectedLanguages.length > 0) { if (selectedLanguages.length > 0) {
meta.inLanguage = selectedLanguages; meta.inLanguage = selectedLanguages;
} }
if (inputSourceOrganization.value) {
meta.sourceOrganization = [
{
name: inputSourceOrganization.options[inputSourceOrganization.selectedIndex].innerHTML,
id: inputSourceOrganization.value,
type: "Organization"
}
]
}
if (selectedSubjects.length > 0) { if (selectedSubjects.length > 0) {
meta.about = selectedSubjects.map((s) => ({id: s})) meta.about = selectedSubjects.map((s) => ({id: s}))
} }
@ -523,13 +523,13 @@
const firstName = creators[i].name.split(" ")[0]; const firstName = creators[i].name.split(" ")[0];
const lastName = creators[i].name.substring(creators[i].name.indexOf(" ") + 1); const lastName = creators[i].name.substring(creators[i].name.indexOf(" ") + 1);
const authorId = creators[i].id ? creators[i].id : ""; 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() { function importData() {
try { try {
const data = jsyaml.load(document.getElementById("importData").value); 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 aboutIds = data.about ? data.about.map((o) => o.id) : [];
const learningResourceTypeIds = data.learningResourceType ? data.learningResourceType.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("inputTags").value = data.keywords ? data.keywords.join(", ") : "";
document.getElementById("inputDescription").value = data.description ? data.description : ""; document.getElementById("inputDescription").value = data.description ? data.description : "";
$('#inputLanguage').val(data.inLanguage ? data.inLanguage : []).selectpicker('refresh'); $('#inputLanguage').val(data.inLanguage ? data.inLanguage : []).selectpicker('refresh');
$('#inputSourceOrganization').val(sourceOrganizationIds).selectpicker('refresh');
$('#inputSubjectOf').val(aboutIds).selectpicker('refresh'); $('#inputSubjectOf').val(aboutIds).selectpicker('refresh');
setLicense((data.license && data.license.id) ? data.license.id : "") setLicense((data.license && data.license.id) ? data.license.id : "")
document.getElementById("inputImage").value = data.image ? data.image : ""; document.getElementById("inputImage").value = data.image ? data.image : "";