mirror of
https://gitlab.com/comenius-institut/foerbico/metadata-form.git
synced 2025-12-07 23:34:31 +00:00
added possibility to choose between person/organization creator
This commit is contained in:
parent
af457b0e2d
commit
bb9f644c4c
3 changed files with 79 additions and 20 deletions
|
|
@ -26,7 +26,10 @@
|
|||
"LABEL_LICENSE_CHECKBOX_ND": "darf verändert werden",
|
||||
"LABEL_LICENSE_CHECKBOX_NC": "darf kommerziell genutzt werden",
|
||||
"LABEL_MANDATORY_FIELD": "Pflichtfeld",
|
||||
"LABEL_ORGANIZATION": "Organisation",
|
||||
"LABEL_ORGANIZATION_CHOOSE": "Wähle Institution ...",
|
||||
"LABEL_ORGANIZATION_NAME": "Name",
|
||||
"LABEL_PERSON": "Person",
|
||||
"LABEL_STATUS": "Status",
|
||||
"LABEL_STATUS_DRAFT": "Entwurf",
|
||||
"LABEL_STATUS_INCOMPLETE": "Unvollständig",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@
|
|||
"LABEL_LICENSE_CHECKBOX_ND": "may be changed",
|
||||
"LABEL_LICENSE_CHECKBOX_NC": "may be used commercially",
|
||||
"LABEL_MANDATORY_FIELD": "Mandatory field",
|
||||
"LABEL_ORGANIZATION": "Organization",
|
||||
"LABEL_ORGANIZATION_CHOOSE": "Choose Institution ...",
|
||||
"LABEL_ORGANIZATION_NAME": "Name",
|
||||
"LABEL_PERSON": "Person",
|
||||
"LABEL_STATUS": "Status",
|
||||
"LABEL_STATUS_DRAFT": "Draft",
|
||||
"LABEL_STATUS_INCOMPLETE": "Incomplete",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,18 @@
|
|||
background-color: #0A1F40;
|
||||
border: 0;
|
||||
}
|
||||
.btn-outline-primary {
|
||||
color: #0A1F40;
|
||||
border-color: #0A1F40;
|
||||
}
|
||||
.btn-outline-primary:not(:disabled):not(.disabled).active, .btn-outline-primary:not(:disabled):not(.disabled):active, .show > .btn-outline-primary.dropdown-toggle {
|
||||
background-color: #0A1F40;
|
||||
border-color: #0A1F40;
|
||||
}
|
||||
.btn-outline-primary:hover {
|
||||
background-color: #0A1F40;
|
||||
border-color: #0A1F40;
|
||||
}
|
||||
|
||||
.main {
|
||||
margin-top: 40px;
|
||||
|
|
@ -410,7 +422,18 @@
|
|||
return keywords.map((k) => k.trim());
|
||||
}
|
||||
|
||||
function addCreator(firstName = "", lastName = "", authorId = "", institution = "") {
|
||||
function changeCreatorType(creatorListItem, type) {
|
||||
const personElements = creatorListItem.getElementsByClassName("person-element")
|
||||
for (let i = 0; i < personElements.length; i++) {
|
||||
personElements[i].style.display = type === "Person" ? "flex" : "none"
|
||||
}
|
||||
const organizationElements = creatorListItem.getElementsByClassName("organization-element")
|
||||
for (let i = 0; i < organizationElements.length; i++) {
|
||||
organizationElements[i].style.display = type === "Organization" ? "flex" : "none"
|
||||
}
|
||||
}
|
||||
|
||||
function addCreator(firstName = "", lastName = "", authorId = "", institution = "", organizationName = "", type = "Person") {
|
||||
const creatorList = document.getElementById("creator-list");
|
||||
const item = document.createElement("li");
|
||||
item.setAttribute("class", "list-group-item");
|
||||
|
|
@ -421,6 +444,16 @@
|
|||
|
||||
item.innerHTML = `
|
||||
<div class="form-row">
|
||||
<div class="btn-group btn-group-toggle inputType" role="group" data-toggle="buttons">
|
||||
<label class="btn btn-outline-primary ${type === "Person" ? "active" : ""}" onclick="changeCreatorType(this.parentNode.parentNode.parentNode, 'Person')">
|
||||
<input type="radio" name="options" ${type === "Person" ? "checked" : ""} value="Person"><span data-i18n="LABEL_PERSON">Person</span>
|
||||
</label>
|
||||
<label class="btn btn-outline-primary ${type === "Organization" ? "active" : ""}" onclick="changeCreatorType(this.parentNode.parentNode.parentNode, 'Organization')">
|
||||
<input type="radio" name="options" ${type === "Organization" ? "checked" : ""} value="Organization"><span data-i18n="LABEL_ORGANIZATION">Organisation</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row mt-3 person-element" ${type !== "Person" ? 'style="display:none;"':''}>
|
||||
<div class="col">
|
||||
<input type="text" class="form-control inputGivenName" placeholder="Vorname" data-i18n-placeholder="LABEL_CREATOR_GIVEN_NAME" value="${firstName}" required>
|
||||
<div class="valid-feedback"></div>
|
||||
|
|
@ -432,12 +465,12 @@
|
|||
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row mt-2">
|
||||
<div class="form-row mt-2 person-element" ${type !== "Person" ? 'style="display:none;"':''}>
|
||||
<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="form-row mt-2 person-element" ${type !== "Person" ? 'style="display:none;"':''}>
|
||||
<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>
|
||||
|
|
@ -445,6 +478,13 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row mt-2 organization-element" ${type !== "Organization" ? 'style="display:none;"':''}>
|
||||
<div class="col">
|
||||
<input type="text" class="form-control inputOrganizationName" placeholder="Name" data-i18n-placeholder="LABEL_ORGANIZATION_NAME" value="${organizationName}" required>
|
||||
<div class="valid-feedback"></div>
|
||||
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
|
||||
</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>
|
||||
|
|
@ -464,19 +504,28 @@
|
|||
const creatorsElement = document.getElementById("creator-list").querySelectorAll(".list-group-item");
|
||||
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,
|
||||
affiliation: affiliationInput.value ? {
|
||||
name: affiliationInput.options[affiliationInput.selectedIndex].innerHTML,
|
||||
id: affiliationInput.value,
|
||||
const typeElement = creatorsElement[i].getElementsByClassName("inputType")[0];
|
||||
const type = $(typeElement).find('input:radio:checked').val()
|
||||
if (type === "Organization") {
|
||||
creators.push({
|
||||
name: creatorsElement[i].getElementsByClassName("inputOrganizationName")[0].value.trim(),
|
||||
type: "Organization"
|
||||
} : undefined
|
||||
});
|
||||
});
|
||||
} else {
|
||||
const creatorId = creatorsElement[i].getElementsByClassName("inputAuthorId")[0].value;
|
||||
const affiliationInput = creatorsElement[i].querySelector("select.inputAffiliation");
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
return creators;
|
||||
}
|
||||
|
|
@ -520,11 +569,15 @@
|
|||
removeCreator(creatorsElement[i]);
|
||||
}
|
||||
for (let i = 0; i < creators.length; i++) {
|
||||
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 : "";
|
||||
const ror = creators[i].affiliation?.id ? creators[i].affiliation.id : "";
|
||||
addCreator(firstName, lastName, authorId, ror);
|
||||
if (creators[i].type === "Organization") {
|
||||
addCreator("", "", "", "", creators[i].name, "Organization");
|
||||
} else {
|
||||
const firstName = creators[i].givenName ? creators[i].givenName : creators[i].name.split(" ")[0];
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
function importData() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue