mirror of
https://gitlab.com/comenius-institut/foerbico/metadata-form.git
synced 2025-12-09 16:24:30 +00:00
use affiliation instead of sourceOrganization
This commit is contained in:
parent
0f0acc4dee
commit
cf0700c21f
3 changed files with 31 additions and 32 deletions
|
|
@ -127,14 +127,6 @@
|
|||
</ul>
|
||||
</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">
|
||||
<label for="inputLanguage" class="col-sm-2 col-form-label" data-i18n="LABEL_LANGUAGE">Sprache</label>
|
||||
<div class="col-sm-10">
|
||||
|
|
@ -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('<option value="' + item["ror"] + '">' + item["label"] + '</option>');
|
||||
});
|
||||
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 += '<option value="' + item["ror"] + '"' + (item["ror"] === institution ? ' selected' : '') + '>' + item["label"] + '</option>';
|
||||
});
|
||||
|
||||
item.innerHTML = `
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
|
|
@ -436,11 +432,19 @@
|
|||
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-row mt-2">
|
||||
<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}">
|
||||
</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="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>
|
||||
|
|
@ -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 : "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue