Backup #1729

ID1729
Dateipfad/var/www/dev.campus.systemische-tools.de/src/View/semantic-explorer/ontologie/new.php
Version1
Typ modified
Größe2.7 KB
Hash026c7a03ae591fceaccefe590ad069cc467e02374174a20628b795ebf92f4c2e
Datum2025-12-27 12:36:20
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Write-Operation
Datei existiert Ja

Dateiinhalt

<?php ob_start(); ?>

<nav class="breadcrumb">
    <a href="/semantic-explorer">Semantic Explorer</a> &raquo;
    <a href="/semantic-explorer/ontologie">Ontologie</a> &raquo; Neu
</nav>

<h1>Neue Ontologie-Klasse</h1>

<form id="ontology-form" class="form" style="max-width: 600px;">
    <div class="form-group">
        <label for="name">Name *</label>
        <input type="text" id="name" name="name" class="form-input" required>
    </div>

    <div class="form-group">
        <label for="parent_class_id">Uebergeordnete Klasse</label>
        <select id="parent_class_id" name="parent_class_id" class="form-select">
            <option value="">-- Keine (Root-Klasse) --</option>
            <?php foreach ($classes as $c): ?>
            <option value="<?= $c['id'] ?>"><?= htmlspecialchars($c['name']) ?></option>
            <?php endforeach; ?>
        </select>
    </div>

    <div class="form-group">
        <label for="description">Beschreibung</label>
        <textarea id="description" name="description" class="form-textarea" rows="3"></textarea>
    </div>

    <div class="form-group">
        <label for="properties">Properties (JSON)</label>
        <textarea id="properties" name="properties" class="form-textarea" rows="4">{}</textarea>
        <small>z.B. {"color": "string", "count": "integer"}</small>
    </div>

    <div class="form-actions">
        <button type="submit" class="btn btn--primary">Klasse erstellen</button>
        <a href="/semantic-explorer/ontologie" class="btn">Abbrechen</a>
    </div>
</form>
<div id="form-message" class="form-message"></div>

<script>
document.getElementById('ontology-form').addEventListener('submit', async (e) => {
    e.preventDefault();
    const form = e.target;
    const formData = new FormData(form);
    const data = Object.fromEntries(formData.entries());
    if (data.parent_class_id === '') data.parent_class_id = null;

    try {
        data.properties = JSON.parse(data.properties || '{}');
    } catch (err) {
        document.getElementById('form-message').innerHTML =
            '<span class="form-message--error">Fehler: Ungültiges JSON in Properties</span>';
        return;
    }

    const response = await fetch('/semantic-explorer/ontologie', {
        method: 'POST',
        headers: {'Content-Type': 'application/json'},
        body: JSON.stringify(data)
    });
    const result = await response.json();

    if (result.success) {
        window.location.href = '/semantic-explorer/ontologie';
    } else {
        document.getElementById('form-message').innerHTML =
            '<span class="form-message--error">Fehler: ' + result.error + '</span>';
    }
});
</script>

<?php $content = ob_get_clean(); ?>
<?php require VIEW_PATH . '/layout.php'; ?>

Vollständig herunterladen

Aktionen

Herunterladen

← Zurück zur Übersicht