Merge branch '11-apply-style-and-functions-from-course-catalogue-metadata-form' into 'master'

Apply style and functionality from course metadata form

See merge request oersi/metadata-form!19
This commit is contained in:
Mirjan Hoffmann 2024-09-05 11:54:34 +00:00
commit 7daa937c85
3 changed files with 363 additions and 247 deletions

View file

@ -47,5 +47,8 @@
"LABEL_NO_INSTITUTION_FOUND": "Keine passende Institution gefunden",
"LABEL_DATE_PUBLISHED": "Veröffentlichungsdatum",
"LABEL_SOFTWARE_LICENSE": "Software-Lizenz",
"LABEL_CC_LICENSE": "CC-Lizenz"
"LABEL_CC_LICENSE": "CC-Lizenz",
"LABEL_METADATA_OUTPUT": "Generierte Metadaten",
"LABEL_RESET": "Zurücksetzen",
"LABEL_CONFIRM_RESET": "Möchten Sie wirklich alle Einträge zurücksetzen?"
}

View file

@ -47,5 +47,8 @@
"LABEL_NO_INSTITUTION_FOUND": "No matching institution found",
"LABEL_DATE_PUBLISHED": "Date published",
"LABEL_SOFTWARE_LICENSE": "Software license",
"LABEL_CC_LICENSE": "CC license"
"LABEL_CC_LICENSE": "CC license",
"LABEL_METADATA_OUTPUT": "Metadata output",
"LABEL_RESET": "Reset",
"LABEL_CONFIRM_RESET": "Do you really want to reset all entries?"
}

View file

@ -34,54 +34,90 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.min.js"></script>
<style>
.btn-primary {
background-color: #0A1F40;
border: 0;
background-color: #0A1F40;
border: 0;
}
.btn-outline-primary {
color: #0A1F40;
border-color: #0A1F40;
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;
background-color: #0A1F40;
border-color: #0A1F40;
}
.btn-outline-primary:hover {
background-color: #0A1F40;
border-color: #0A1F40;
background-color: #0A1F40;
border-color: #0A1F40;
}
.main {
margin-top: 40px;
padding: 0 20px;
margin-bottom: 120px;
margin-top: 40px;
padding: 0 60px;
margin-bottom: 50px;
flex-grow: 1;
}
.input-dropdown {
background: #F1F6DF;
color: #0A1F40;
background: #F1F6DF;
color: #0A1F40;
}
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
background-color: white;
padding: 30px;
border-radius: 10px;
}
.shadow {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
@media only screen and (min-width: 1400px) {
.dualpane {
display: flex;
flex-direction: row;
column-gap: 40px;
}
}
@media only screen and (max-width: 1400px) {
.dualpane {
display: flex;
flex-direction: column;
row-gap: 40px;
}
.widescreen {
display: none;
}
}
</style>
</head>
<body>
<nav class="navbar navbar-light bg-light">
<nav class="navbar navbar-light bg-light shadow" style="display: flex; justify-content: space-between;">
<div class="navbar-brand">
<img src="logo.svg" height="50" width="116" alt="LOGO">
</div>
<form class="form-inline ml-auto mr-3">
<button class="btn" type="button" data-toggle="modal" data-target="#importModal">Import</button>
</form>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarLanguageDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span id="selectedLanguageLabel">DE</span>
</a>
<div class="dropdown-menu position-absolute dropdown-menu-right" aria-labelledby="navbarLanguageDropdown">
<a class="dropdown-item" onclick="changeLanguage('en')">English</a>
<a class="dropdown-item" onclick="changeLanguage('de')">Deutsch</a>
</div>
</li>
</ul>
<div>
<h2 data-i18n="FORM_HEADING">Kurskatalog Metadaten Formular</h2>
</div>
<div class="form-inline">
<form class=" ml-auto mr-3">
<button class="btn" type="button" data-toggle="modal" data-target="#importModal">Import</button>
</form>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarLanguageDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span id="selectedLanguageLabel">DE</span>
</a>
<div class="dropdown-menu position-absolute dropdown-menu-right" aria-labelledby="navbarLanguageDropdown">
<a class="dropdown-item" onclick="changeLanguage('en')">English</a>
<a class="dropdown-item" onclick="changeLanguage('de')">Deutsch</a>
</div>
</li>
</ul>
</div>
</nav>
<!-- Modal -->
<div class="modal fade" id="importModal" tabindex="-1" role="dialog" aria-labelledby="importModalLabel" aria-hidden="true">
@ -104,189 +140,208 @@
</div>
</div>
<div class="container main">
<h2 style="margin-bottom:40px;" data-i18n="FORM_HEADING">OER Metadaten Formular</h2>
<form class="was-validated">
<div class="form-group row">
<label for="inputTitle" class="col-sm-2 col-form-label" data-i18n="LABEL_TITLE">Titel</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputTitle" placeholder="Titel"
data-i18n-placeholder="LABEL_TITLE" value="" required>
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
</div>
</div>
<div class="form-group row">
<label for="inputDescription" class="col-sm-2 col-form-label"
data-i18n="LABEL_DESCRIPTION">Beschreibung</label>
<div class="col-sm-10">
<textarea class="form-control" id="inputDescription" placeholder="Beschreibung" data-i18n-placeholder="LABEL_DESCRIPTION"></textarea>
</div>
</div>
<div class="form-group row">
<label for="inputTags" class="col-sm-2 col-form-label" data-i18n="LABEL_KEYWORDS">Schlagworte</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputTags" placeholder="Komma getrennte Liste von Schlagworten"
data-i18n-placeholder="LABEL_KEYWORDS_PLACEHOLDER" value="">
</div>
</div>
<div class="form-group row">
<label for="inputEducationalLevel" class="col-sm-2 col-form-label" data-i18n="LABEL_EDUCATIONALLEVEL">Bildungsstufe</label>
<div class="col-sm-10">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputEducationalLevel" data-i18n-title="LABEL_EDUCATIONALLEVEL_CHOOSE" required multiple>
</select>
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
</div>
</div>
<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-live-search="true" 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>
</div>
</div>
<div class="form-group row">
<label for="creator-list" class="col-sm-2 col-form-label" data-i18n="LABEL_CREATOR">Autor</label>
<div class="col-sm-10 form-row">
<ul class="list-group col" id="creator-list">
<li class="list-group-item">
<button type="button" onclick="addCreator()" class="btn btn-primary"><i class="fa fa-plus"></i> <span
data-i18n="LABEL_CREATOR_ADD">Autor hinzufügen</span></button>
</li>
</ul>
</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">
<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>
</div>
</div>
<div class="form-group row">
<label for="choicesLicense" class="col-sm-2 col-form-label" data-i18n="LABEL_LICENSE">Lizenz</label>
<div class="col-sm-2">
<input type="radio" value="ccLicense" name="license" id="radioLicenseCC" onchange="ccOrSoftwareLicense()" checked>
<label data-i18n="LABEL_CC_LICENSE">CC-Lizenz</label>
</div>
<div class="col-sm-6" id="choicesLicense">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseBY" value="BY"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_BY">darf ohne Namensnennung verwendet werden</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseSA" value="SA"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_SA">darf unter anderer Lizenz veröffentlicht werden</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseND" value="ND"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_ND">darf verändert werden</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseNC" value="NC"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_NC">darf kommerziell genutzt werden</span>
<input type="hidden" id="licenseUrl"
value="https://creativecommons.org/share-your-work/public-domain/cc0/">
</label>
<div class="main">
<div class="dualpane">
<!-- left side -->
<div style="flex: 2;" class="card">
<form id="metadata-form" class="was-validated">
<div class="form-group">
<label for="inputTitle" class="form-row col-form-label" data-i18n="LABEL_TITLE">Titel</label>
<div class="form-row">
<input type="text" class="form-control" id="inputTitle" placeholder="Titel"
data-i18n-placeholder="LABEL_TITLE" value="" oninput="generate()" required>
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
</div>
</div>
<div class="col-sm-2">
<label for="choicesLicense" id="choosenLicense" class="col-form-label">CC-0</label>
<div class="form-group">
<label for="inputDescription" class="form-row col-form-label"
data-i18n="LABEL_DESCRIPTION">Beschreibung</label>
<div class="form-row">
<textarea class="form-control" id="inputDescription" oninput="generate()" placeholder="Beschreibung" data-i18n-placeholder="LABEL_DESCRIPTION"></textarea>
</div>
</div>
<label for="choicesLicense" class="col-sm-2 col-form-label"></label>
<div class="col-sm-2" id="softwareLicense">
<input type="radio" value="softwareLicenseInput" name="license" id="radioLicenseSoftware" onchange="ccOrSoftwareLicense()">
<label data-i18n="LABEL_SOFTWARE_LICENSE">Software-Lizenz</label>
<div class="form-group">
<label for="inputTags" class="form-row col-form-label" data-i18n="LABEL_KEYWORDS">Schlagworte</label>
<div class="form-row">
<input type="text" class="form-control" id="inputTags" placeholder="Komma getrennte Liste von Schlagworten"
data-i18n-placeholder="LABEL_KEYWORDS_PLACEHOLDER" value="" oninput="generate()">
</div>
</div>
<div class="col-sm-8" style="padding-top: 1ch">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputSoftwareLicense" data-live-search="true" data-i18n-title="LABEL_LICENSE" required disabled>
</select>
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
<div class="form-group">
<label for="inputEducationalLevel" class="form-row col-form-label" data-i18n="LABEL_EDUCATIONALLEVEL">Bildungsstufe</label>
<div class="form-row">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputEducationalLevel" data-i18n-title="LABEL_EDUCATIONALLEVEL_CHOOSE" required multiple>
</select>
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="inputSubjectOf" class="col-sm-2 col-form-label" data-i18n="LABEL_SUBJECT">Fach</label>
<div class="col-sm-10">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputSubjectOf" data-live-search="true" data-i18n-title="LABEL_CHOOSE" multiple>
</select>
</div>
</div>
<div class="form-group row">
<label for="inputUrl" class="col-sm-2 col-form-label" data-i18n="LABEL_URL">URL</label>
<div class="col-sm-10">
<input type="url" class="form-control" id="inputUrl" placeholder="URL" data-i18n-placeholder="LABEL_URL_PLACEHOLDER" value="">
<div class="valid-feedback"></div>
</div>
</div>
<div class="form-group row">
<label for="inputImage" class="col-sm-2 col-form-label" data-i18n="LABEL_IMAGE_URL">Vorschaubild URL</label>
<div class="col-sm-10">
<input type="url" class="form-control" id="inputImage" placeholder="Vorschaubild URL" data-i18n-placeholder="LABEL_IMAGE_URL" value="">
</div>
</div>
<div class="form-group row">
<label for="inputStatus" class="col-sm-2 col-form-label" data-i18n="LABEL_STATUS">Status</label>
<div class="col-sm-10">
<select class="custom-select" id="inputStatus" onchange="createOrUpdateDatePicker()" required>
<option value="Draft" data-i18n="LABEL_STATUS_DRAFT" selected>Entwurf</option>
<option value="Incomplete" data-i18n="LABEL_STATUS_INCOMPLETE">Unvollständig</option>
<option value="Published" data-i18n="LABEL_STATUS_PUBLISHED">Veröffentlicht</option>
</select>
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
</div>
</div>
<div class="form-group row" id="datePublishedFormGroup">
<label for="datePublished" class="col-sm-2 col-form-label" data-i18n="LABEL_DATE_PUBLISHED">Veröffentlichungsdatum</label>
<div class="col-sm-10 input-group date" id="datepicker1" data-target-input="nearest">
<input type="text" id="datepickerInput" class="form-control datepicker-input" data-target="#datepicker1"/>
<div class="input-group-append" data-target="#datepicker1" data-toggle="datepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
<div class="form-group">
<label for="inputResourceType" class="form-row col-form-label" data-i18n="LABEL_LEARNINGRESOURCETYPE">Materialart</label>
<div class="form-row">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputResourceType" data-live-search="true" 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>
</div>
</div>
</div>
<div class="form-group">
<label for="creator-list" class="form-row col-form-label" data-i18n="LABEL_CREATOR">Autor</label>
<div class="form-row">
<ul class="list-group col" id="creator-list">
<li class="list-group-item">
<button type="button" onclick="addCreator()" class="btn btn-primary"><i class="fa fa-plus"></i> <span
data-i18n="LABEL_CREATOR_ADD">Autor hinzufügen</span></button>
</li>
</ul>
</div>
</div>
<div class="form-group">
<label for="inputLanguage" class="form-row col-form-label" data-i18n="LABEL_LANGUAGE">Sprache</label>
<div class="form-row">
<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>
</div>
</div>
<div class="form-group">
<label for="choicesLicense" class="form-row col-form-label" data-i18n="LABEL_LICENSE">Lizenz</label>
<div class="list-group-item">
<div class="row">
<div class="col-sm-3">
<input type="radio" value="ccLicense" name="license" id="radioLicenseCC" onchange="ccOrSoftwareLicense()" checked>
<label data-i18n="LABEL_CC_LICENSE">CC-Lizenz</label>
</div>
<div class="col-sm-7" id="choicesLicense">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseBY" value="BY"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_BY">darf ohne Namensnennung verwendet werden</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseSA" value="SA"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_SA">darf unter anderer Lizenz veröffentlicht werden</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseND" value="ND"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_ND">darf verändert werden</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseNC" value="NC"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_NC">darf kommerziell genutzt werden</span>
<input type="hidden" id="licenseUrl"
value="https://creativecommons.org/share-your-work/public-domain/cc0/">
</label>
</div>
</div>
<div class="col-sm-2">
<label for="choicesLicense" id="choosenLicense" class="col-form-label">CC-0</label>
</div>
</div>
<div class="row">
<div class="col-sm-3" id="softwareLicense">
<input type="radio" value="softwareLicenseInput" name="license" id="radioLicenseSoftware" onchange="ccOrSoftwareLicense()">
<label data-i18n="LABEL_SOFTWARE_LICENSE">Software-Lizenz</label>
</div>
<div class="col-sm-9" style="padding-top: 1ch">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputSoftwareLicense" data-live-search="true" data-i18n-title="LABEL_LICENSE" required disabled>
</select>
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="inputSubjectOf" class="form-row col-form-label" data-i18n="LABEL_SUBJECT">Fach</label>
<div class="form-row">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputSubjectOf" data-live-search="true" data-i18n-title="LABEL_CHOOSE" multiple>
</select>
</div>
</div>
<div class="form-group">
<label for="inputUrl" class="form-row col-form-label" data-i18n="LABEL_URL">URL</label>
<div class="form-row">
<input type="url" class="form-control" id="inputUrl" placeholder="URL" data-i18n-placeholder="LABEL_URL_PLACEHOLDER" value="" oninput="generate()">
<div class="valid-feedback"></div>
</div>
</div>
<div class="form-group">
<label for="inputImage" class="form-row col-form-label" data-i18n="LABEL_IMAGE_URL">Vorschaubild URL</label>
<div class="form-row">
<input type="url" class="form-control" id="inputImage" placeholder="Vorschaubild URL" data-i18n-placeholder="LABEL_IMAGE_URL" value="" oninput="generate()">
</div>
</div>
<div class="form-group">
<label for="inputStatus" class="form-row col-form-label" data-i18n="LABEL_STATUS">Status</label>
<div class="form-row">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputStatus" onchange="createOrUpdateDatePicker()" required>
<option value="Draft" data-i18n="LABEL_STATUS_DRAFT" selected>Entwurf</option>
<option value="Incomplete" data-i18n="LABEL_STATUS_INCOMPLETE">Unvollständig</option>
<option value="Published" data-i18n="LABEL_STATUS_PUBLISHED">Veröffentlicht</option>
</select>
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
</div>
</div>
<div class="form-group" id="datePublishedFormGroup">
<label for="datePublished" class="form-row col-form-label" data-i18n="LABEL_DATE_PUBLISHED">Veröffentlichungsdatum</label>
<div class="form-row input-group date" id="datepicker1" data-target-input="nearest">
<input type="text" id="datepickerInput" class="form-control datepicker-input" data-target="#datepicker1"/>
<div class="input-group-append" data-target="#datepicker1" data-toggle="datepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
</div>
</form>
</div>
<div class="form-group">
<button type="button" onclick="generate()" class="btn btn-primary"><i class="fa fa-arrow-down"></i> <span data-i18n="LABEL_GENERATE">Generieren</span></button>
</div>
<div class="form-group">
<ul class="nav nav-tabs" id="outputTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="yaml-tab" data-toggle="tab" data-target="#yaml" type="button" role="tab" aria-controls="yaml" aria-selected="true">YAML</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="json-tab" data-toggle="tab" data-target="#json" type="button" role="tab" aria-controls="json" aria-selected="false">JSON</button>
</li>
</ul>
<div class="tab-content" id="outputTabContent">
<div class="tab-pane fade show active" id="yaml" role="tabpanel" aria-labelledby="yaml-tab">
<button type="button" disabled onclick="copy_generated_output('yaml_output')" class="btn btn-primary my-2" id="button_copy_generated_output_yaml"><i class="fa fa-copy"></i> YAML <span data-i18n="LABEL_COPY">Kopieren</span></button>
<textarea class="form-control" rows="15" id="yaml_output"></textarea>
</div>
<div class="tab-pane fade" id="json" role="tabpanel" aria-labelledby="json-tab">
<button type="button" disabled onclick="copy_generated_output('json_output')" class="btn btn-primary my-2" id="button_copy_generated_output_json"><i class="fa fa-copy"></i> JSON <span data-i18n="LABEL_COPY">Kopieren</span></button>
<textarea class="form-control" rows="15" id="json_output"></textarea>
<!-- right side -->
<div style="flex: 1;">
<div class="card">
<h3 style="text-align: center;" data-i18n="LABEL_METADATA_OUTPUT">Metadata output</h3>
<div class="form-group mt-4">
<ul class="nav nav-tabs" id="outputTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="yaml-tab" data-toggle="tab" data-target="#yaml" type="button" role="tab" aria-controls="yaml" aria-selected="true">YAML</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="json-tab" data-toggle="tab" data-target="#json" type="button" role="tab" aria-controls="json" aria-selected="false">JSON</button>
</li>
</ul>
<div class="tab-content mt-1" id="outputTabContent">
<div class="tab-pane fade show active" id="yaml" role="tabpanel" aria-labelledby="yaml-tab">
<div style="display: flex; justify-content: space-between;">
<button type="button" disabled onclick="copy_generated_output('yaml_output')" class="btn btn-primary my-2" id="button_copy_generated_output_yaml"><i class="fa fa-copy"></i> YAML <span data-i18n="LABEL_COPY">Kopieren</span></button>
<button type="button" onclick="resetForm()" class="btn btn-primary my-2"><i class="fa fa-rotate-left"></i> <span data-i18n="LABEL_RESET">Reset</span></button>
</div>
<textarea class="form-control" rows="15" id="yaml_output"></textarea>
</div>
<div class="tab-pane fade" id="json" role="tabpanel" aria-labelledby="json-tab">
<div style="display: flex; justify-content: space-between;">
<button type="button" disabled onclick="copy_generated_output('json_output')" class="btn btn-primary my-2" id="button_copy_generated_output_json"><i class="fa fa-copy"></i> JSON <span data-i18n="LABEL_COPY">Kopieren</span></button>
<button type="button" onclick="resetForm();" class="btn btn-primary my-2"><i class="fa fa-rotate-left"></i> <span data-i18n="LABEL_RESET">Reset</span></button>
</div>
<textarea class="form-control" rows="15" id="json_output"></textarea>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<div id="copied_to_clipboard_toast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true">
@ -312,6 +367,9 @@
addSoftwareLicenses();
addCreator();
$("#inputEducationalLevel option[value='https://w3id.org/kim/educationalLevel/level_A']").attr("selected", "true");
$('.selectpicker').on('change', function (e) {
generate();
});
$('.selectpicker').selectpicker('refresh');
var userLang = navigator.language || navigator.userLanguage;
@ -536,6 +594,8 @@
document.getElementById("licenseUrl").value = licenses[x].url
}
}
generate();
}
function addSoftwareLicenses() {
@ -557,6 +617,7 @@
document.getElementById("inputSoftwareLicense").removeAttribute("disabled");
}
$('.selectpicker').selectpicker('refresh');
generate();
}
function splitKeywords(keywordString) {
@ -565,14 +626,28 @@
}
function changeCreatorType(creatorListItem, type) {
const personElements = creatorListItem.getElementsByClassName("person-element")
if (type === "Person") {
creatorListItem.getElementsByClassName("person-label")[0].classList.add("active");
creatorListItem.getElementsByClassName("person-radio")[0].setAttribute("checked", "true");
creatorListItem.getElementsByClassName("organization-label")[0].classList.remove("active");
creatorListItem.getElementsByClassName("organization-radio")[0].removeAttribute("checked");
} else {
creatorListItem.getElementsByClassName("person-label")[0].classList.remove("active");
creatorListItem.getElementsByClassName("person-radio")[0].removeAttribute("checked");
creatorListItem.getElementsByClassName("organization-label")[0].classList.add("active");
creatorListItem.getElementsByClassName("organization-radio")[0].setAttribute("checked", "true");
}
const personElements = creatorListItem.getElementsByClassName("person-element");
for (let i = 0; i < personElements.length; i++) {
personElements[i].style.display = type === "Person" ? "flex" : "none"
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"
}
generate();
}
function changeAffiliationType(creatorListItem, type) {
@ -585,6 +660,7 @@
}
}
$('.selectpicker').selectpicker('refresh');
generate();
}
function changeOrganizationType(creatorListItem, type) {
@ -597,6 +673,7 @@
}
}
$('.selectpicker').selectpicker('refresh');
generate();
}
function addCreator(firstName = "", lastName = "", authorId = "", institution = "", organizationName = "", type = "Person", affiliationName = "") {
@ -625,29 +702,29 @@
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="${radioGroupName}" ${type === "Person" ? "checked" : ""} value="Person"><span data-i18n="LABEL_PERSON">Person</span>
<label class="btn btn-outline-primary person-label ${type === "Person" ? "active" : ""}" onclick="changeCreatorType(this.parentNode.parentNode.parentNode, 'Person')">
<input type="radio" class="person-radio" name="${radioGroupName}" ${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="${radioGroupName}" ${type === "Organization" ? "checked" : ""} value="Organization"><span data-i18n="LABEL_ORGANIZATION">Organisation</span>
<label class="btn btn-outline-primary organization-label ${type === "Organization" ? "active" : ""}" onclick="changeCreatorType(this.parentNode.parentNode.parentNode, 'Organization')">
<input type="radio" class="organization-radio" name="${radioGroupName}" ${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>
<input type="text" class="form-control inputGivenName" placeholder="Vorname" data-i18n-placeholder="LABEL_CREATOR_GIVEN_NAME" value="${firstName}" oninput="generate()" required >
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
</div>
<div class="col">
<input type="text" class="form-control inputFamilyName" placeholder="Nachname" data-i18n-placeholder="LABEL_CREATOR_LAST_NAME" value="${lastName}" required>
<input type="text" class="form-control inputFamilyName" placeholder="Nachname" data-i18n-placeholder="LABEL_CREATOR_LAST_NAME" value="${lastName}" oninput="generate()" 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 person-element" ${type !== "Person" ? 'style="display:none;"':''}>
<div class="col">
<input type="url" class="form-control inputAuthorId" placeholder="Persönliche ID (optional, wie ORCID, GND)" data-i18n-placeholder="LABEL_CREATOR_ID" value="${authorId}">
<input type="url" class="form-control inputAuthorId" placeholder="Persönliche ID (optional, wie ORCID, GND)" data-i18n-placeholder="LABEL_CREATOR_ID" value="${authorId}" oninput="generate()">
</div>
</div>
@ -669,7 +746,7 @@
<input class="affiliationType" type="radio" name="institution_${radioGroupName}" aria-label="radio button for custom institution" ${customInstitutionSelected ? "checked":""} value="custom" onclick="changeAffiliationType(this.parentNode.parentNode.parentNode, 'custom')">
</div>
<div class="col-11">
<input type="text" ${customInstitutionSelected ? "":"disabled"} class="form-control customAffiliation inputAffiliation" placeholder="Institution" data-i18n-placeholder="LABEL_CUSTOM_INSTITUTION" value="${customInstitutionSelected ? affiliationName:""}">
<input type="text" ${customInstitutionSelected ? "":"disabled"} class="form-control customAffiliation inputAffiliation" placeholder="Institution" data-i18n-placeholder="LABEL_CUSTOM_INSTITUTION" value="${customInstitutionSelected ? affiliationName:""}" oninput="generate()">
</div>
</div>
@ -689,7 +766,7 @@
<input class="organizationType" type="radio" name="organization_${radioGroupName}" aria-label="radio button for organization list" ${customOrganizationSelected ? "checked":""} value="custom" onclick="changeOrganizationType(this.parentNode.parentNode.parentNode, 'custom')">
</div>
<div class="col-11">
<input type="text" ${customOrganizationSelected ? "":"disabled"} class="form-control customOrganization inputOrganization" placeholder="Institution" data-i18n-placeholder="LABEL_CUSTOM_INSTITUTION" value="${customOrganizationSelected ? organizationName:""}">
<input type="text" ${customOrganizationSelected ? "":"disabled"} class="form-control customOrganization inputOrganization" placeholder="Institution" data-i18n-placeholder="LABEL_CUSTOM_INSTITUTION" value="${customOrganizationSelected ? organizationName:""}" oninput="generate()">
</div>
</div>
</div>
@ -710,6 +787,7 @@
function removeCreator(creatorListItem) {
creatorListItem.parentNode.removeChild(creatorListItem);
generate();
}
function getCreators() {
@ -728,16 +806,19 @@
} : undefined;
} else {
organizationInput = creatorsElement[i].querySelector("select.inputOrganization");
organization = organizationInput ? {
name: organizationInput.options[organizationInput.selectedIndex].innerHTML,
let organizationName = organizationInput.options[organizationInput.selectedIndex].innerHTML;
organization = organizationInput && organizationName != "Choose Institution ..." ? {
name: organizationName,
id: organizationInput.value
} : undefined;
}
creators.push({
name: organization.name,
id: organization.id ? organization.id : undefined,
type: "Organization"
})
if (organization) {
creators.push({
name: organization.name,
id: organization.id ? organization.id : undefined,
type: "Organization"
});
}
} else {
const creatorId = creatorsElement[i].getElementsByClassName("inputAuthorId")[0].value;
const affiliationTypeElement = creatorsElement[i].querySelector("input.affiliationType:checked");
@ -750,11 +831,13 @@
} : undefined
} else {
const affiliationInput = creatorsElement[i].querySelector("select.inputAffiliation");
affiliation = affiliationInput.value ? {
affiliation = affiliationInput.value;
if (affiliation && affiliation != "Choose Institution ...")
affiliation = {
name: affiliationInput.options[affiliationInput.selectedIndex].innerHTML,
id: affiliationInput.value,
type: "Organization"
} : undefined
};
}
creators.push({
givenName: creatorsElement[i].getElementsByClassName("inputGivenName")[0].value.trim(),
@ -779,6 +862,21 @@
});
}
function resetForm() {
if (window.confirm(i18next.t("LABEL_CONFIRM_RESET"))) {
document.getElementById("metadata-form").reset();
$('.selectpicker').on('change', function (e) {
generate();
});
$('.selectpicker').selectpicker('refresh');
setCreators();
chooseCCLicense();
ccOrSoftwareLicense();
createOrUpdateDatePicker(reset=true);
generate();
}
}
function generate() {
const creators = getCreators()
const selectedLanguages = $('#inputLanguage').val();
@ -786,7 +884,7 @@
const selectedResourceTypes = $('#inputResourceType').val();
const selectedEducationalLevel = $('#inputEducationalLevel').val();
const identifier = document.getElementById("inputUrl").value;
const datePublished = $("#datepicker1").datepicker("getDate");
const datePublished = $("#datepickerInput").datepicker("getDate");
let meta = {
"@context": "https://schema.org/",
creativeWorkStatus: document.getElementById("inputStatus").value,
@ -842,20 +940,23 @@
for (let i = 0; i < creatorsElement.length - 1; i++) {
removeCreator(creatorsElement[i]);
}
for (let i = 0; i < creators.length; i++) {
if (creators[i].type === "Organization") {
const name = creators[i].name ? creators[i].name : "";
const ror = creators[i].id ? creators[i].id : "";
console.log(creators[i], name, ror);
addCreator("", "", "", ror, 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 : "";
const affiliationName = creators[i].affiliation?.name ? creators[i].affiliation.name : "";
addCreator(firstName, lastName, authorId, ror, "", "Person", affiliationName);
if (creators) {
for (let i = 0; i < creators.length; i++) {
if (creators[i].type === "Organization") {
const name = creators[i].name ? creators[i].name : "";
const ror = creators[i].id ? creators[i].id : "";
addCreator("", "", "", ror, 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 : "";
const affiliationName = creators[i].affiliation?.name ? creators[i].affiliation.name : "";
addCreator(firstName, lastName, authorId, ror, "", "Person", affiliationName);
}
}
} else {
addCreator();
}
}
function importData() {
@ -868,7 +969,7 @@
const licenseUrl = data.license ? idMap(data.license) : ""
document.getElementById("inputStatus").value = data.creativeWorkStatus ? data.creativeWorkStatus : "Draft";
$("#datepicker1").datepicker("update", new Date(data.datePublished));
$("#datepickerInput").datepicker("update", new Date(data.datePublished));
document.getElementById("inputUrl").value = data.id ? data.id : "";
document.getElementById("inputTitle").value = data.name;
setCreators(data.creator ? data.creator : []);
@ -1034,6 +1135,9 @@
}
}
});
$('.select-organization').on('select2:select', function (e) {
generate();
});
}
function createOrUpdateSelectInputAffiliation() {
@ -1080,31 +1184,37 @@
}
}
});
$('.select-institution').on('select2:select', function (e) {
generate();
});
}
function createOrUpdateDatePicker() {
function createOrUpdateDatePicker(reset=false) {
// Keep previously set date when changing the language
let date = $('#datepicker1').datepicker("getDate");
let date = $("#datepickerInput").datepicker("getDate");
if (document.getElementById("inputStatus").value != "Published") {
document.getElementById("datepickerInput").required = false;
document.getElementById("datePublishedFormGroup").hidden = true;
} else {
// Make required if input status is set to published
document.getElementById("datepickerInput").required = true;
// When set to published, set datePublished to today
if (!date) {
$('#datepicker1').datepicker("update", new Date());
}
document.getElementById("datePublishedFormGroup").hidden = false;
}
$('#datepicker1').datepicker("destroy");
$('#datepickerInput').datepicker("destroy");
let language = document.getElementById("selectedLanguageLabel").textContent.toLowerCase();
if (language == "en") language += "-US";
$('#datepicker1').datepicker({
$('#datepickerInput').datepicker({
language: language
});
if (date) {
$('#datepicker1').datepicker("update", new Date(date));
if (date && !reset) {
$("#datepickerInput").datepicker("update", new Date(date));
} else {
$("#datepickerInput").val("").datepicker("update");;
}
$("#datepickerInput").datepicker().on("changeDate", function(e) {
generate();
});
}
function updateContent() {