allow multiselection of languages and lrts

This commit is contained in:
Mirjan Hoffmann 2022-03-08 14:54:01 +01:00
parent a27a075637
commit 96654c03fb

View file

@ -107,7 +107,7 @@
<div class="form-group row">
<label for="inputResourceType" class="col-sm-2 col-form-label" data-i18n="LABEL_LEARNINGRESOURCETYPE">Materialart</label>
<div class="col-sm-10">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputResourceType" data-i18n-title="LABEL_LEARNINGRESOURCETYPE_CHOOSE" required>
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputResourceType" data-i18n-title="LABEL_LEARNINGRESOURCETYPE_CHOOSE" required multiple>
</select>
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
@ -127,7 +127,7 @@
<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">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputLanguage" required>
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputLanguage" data-i18n-title="LABEL_CHOOSE" required multiple>
</select>
<div class="valid-feedback"></div>
<div class="invalid-feedback">Pflichtfeld</div>
@ -456,7 +456,9 @@
function generate() {
const creators = getCreators()
const inputSourceOrganization = document.getElementById("inputSourceOrganization");
const selectedLanguages = $('#inputLanguage').val();
const selectedSubjects = $('#inputSubjectOf').val();
const selectedResourceTypes = $('#inputResourceType').val();
var meta = "---\n"
meta += "id: \"" + document.getElementById("inputUrl").value + "\"\n"
meta += "name: \"" + document.getElementById("inputTitle").value + "\"\n"
@ -469,7 +471,9 @@
meta += splitKeywords(document.getElementById("inputTags").value)
}
meta += "description: \"" + document.getElementById("inputDescription").value + "\"\n"
meta += "inLanguage:\n" + " - \"" + document.getElementById("inputLanguage").value + "\"\n"
if (selectedLanguages.length > 0) {
meta += "inLanguage:\n" + selectedLanguages.map((l) => " - \"" + l + "\"").join("\n") + "\n"
}
if (inputSourceOrganization.value) {
meta += "sourceOrganization:\n"
meta += " - name: \"" + inputSourceOrganization.options[inputSourceOrganization.selectedIndex].innerHTML + "\"\n"
@ -483,7 +487,9 @@
if (document.getElementById("inputImage").value) {
meta += "image: \"" + document.getElementById("inputImage").value + "\"\n"
}
meta += "learningResourceType:\n" + " - id: \"" + document.getElementById("inputResourceType").value + "\"\n"
if (selectedResourceTypes.length > 0) {
meta += "learningResourceType:\n" + selectedResourceTypes.map((t) => " - id: \"" + t + "\"").join("\n") + "\n"
}
document.getElementById("comment").value = meta;
}