Eingabe von Verwandten Themen optimiert
This commit is contained in:
@@ -52,8 +52,8 @@ if (isset($_GET['subject']) && isset($_GET['topic'])) {
|
||||
$defaultValues['formulas'] = implode(";;;;", $tasks);
|
||||
$defaultValues['article'] = $editingTopic->getFinishedArticle();
|
||||
}
|
||||
} else if (isset($_GET['subject'])) {
|
||||
$defaultValues['subjectId'] = $_GET['subject'];
|
||||
} else if (isset($_GET['subjectId'])) {
|
||||
$defaultValues['subjectId'] = $_GET['subjectId'];
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
@@ -350,10 +350,33 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
id="relatedTopicSelect"
|
||||
class="w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-lg enabled:hover:border-gray-400"
|
||||
value="<?php echo $defaultValues['relatedTopics']; ?>">
|
||||
|
||||
|
||||
<?php
|
||||
if ($defaultValues['subjectId'] !== "") {
|
||||
?>
|
||||
<select id="addRelatedTopic"
|
||||
onchange="addSelectedRelatedTopic()"
|
||||
class="w-full px-4 py-3 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-lg enabled:hover:border-gray-400 appearance-none bg-white">
|
||||
<option selected value="">Thema hinzufügen</option>
|
||||
<?php
|
||||
|
||||
foreach ($allSubjects[$defaultValues['subjectId']]->getTopics() as $topic) {
|
||||
if(isset($editingTopic) && $topic->getId() === $editingTopic->getId()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo "<option value='" . $topic->getId() . "'>" . $topic->getDisplayName() . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="existing_files" class="block text-sm font-medium text-gray-700 mb-2">Existierende Übungsblätter</label>
|
||||
<label for="existing_files" class="block text-sm font-medium text-gray-700 mb-2">Existierende Übungsblätter - Entfernen zum Löschen</label>
|
||||
<input type="text"
|
||||
name="existing_files"
|
||||
id="existing_files"
|
||||
@@ -425,6 +448,12 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
foreach($errors as $error) {
|
||||
echo $error;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="flow-root gap-4">
|
||||
<?php if (isset($editingTopic)) { ?>
|
||||
<input type="submit" value="Thema löschen" name="submit"
|
||||
@@ -525,6 +554,26 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
iconInput.value = element.getAttribute('data-icon');
|
||||
}
|
||||
|
||||
function addSelectedRelatedTopic() {
|
||||
const input = document.querySelector('#relatedTopicSelect');
|
||||
const selector = document.querySelector('#addRelatedTopic');
|
||||
|
||||
if(selector.value === "") {
|
||||
return;
|
||||
}
|
||||
|
||||
if(input.value.includes(selector.value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(input.value.trim() === "") {
|
||||
input.value += selector.value;
|
||||
} else {
|
||||
input.value += ", " + selector.value;
|
||||
}
|
||||
selector.selectedIndex = 0;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user