OpenNIT

Quelltext des aktuellen Standes

Fassung 1.1.1

index.php

12 KB
<?php $this->layout('layouts/admin', [
    'page_title' => 'Seiten-Vorlagen',
    'current_admin_page' => 'page-templates',
]); ?>

<?php $templates = $templates ?? []; ?>

<div class="settings-page">

    <!-- Neue Vorlage erstellen -->
    <section class="settings-card">
        <div class="settings-card-header">
            <span class="settings-card-icon">&#10010;</span>
            <div>
                <h2><?= $this->te('Neue Vorlage erstellen') ?></h2>
                <p class="settings-card-desc"><?= $this->te('Erstellen Sie eine neue Seitenvorlage für die Dokumentation.') ?></p>
            </div>
        </div>
        <div class="settings-card-body">
            <form action="/admin/page-templates" method="POST" class="form">
                <input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
                <div class="form-row-2">
                    <div class="form-group">
                        <label for="new-name"><?= $this->te('Name') ?></label>
                        <input type="text" id="new-name" name="name" class="form-control" placeholder="<?= $this->te('z.B. Drucker-Dokumentation') ?>" required maxlength="255">
                    </div>
                    <div class="form-group">
                        <label for="new-category"><?= $this->te('Kategorie') ?></label>
                        <input type="text" id="new-category" name="category" class="form-control" placeholder="<?= $this->te('z.B. Infrastruktur') ?>" value="Allgemein">
                    </div>
                </div>
                <div class="form-row-2">
                    <div class="form-group">
                        <label for="new-icon"><?= $this->te('Icon') ?></label>
                        <select id="new-icon" name="icon" class="form-control icon-select">
                            <option value="&#128196;" selected><?= $this->te('&#128196; Dokument') ?></option>
                            <option value="&#128421;"><?= $this->te('&#128421; Server') ?></option>
                            <option value="&#128187;"><?= $this->te('&#128187; Laptop') ?></option>
                            <option value="&#128424;"><?= $this->te('&#128424; PC') ?></option>
                            <option value="&#127760;"><?= $this->te('&#127760; Netzwerk') ?></option>
                            <option value="&#128274;"><?= $this->te('&#128274; Sicherheit') ?></option>
                            <option value="&#128272;"><?= $this->te('&#128272; Schlüssel') ?></option>
                            <option value="&#128295;"><?= $this->te('&#128295; Werkzeug') ?></option>
                            <option value="&#9881;"><?= $this->te('&#9881; Zahnrad') ?></option>
                            <option value="&#128268;"><?= $this->te('&#128268; Stecker') ?></option>
                            <option value="&#128225;"><?= $this->te('&#128225; Fax/Drucker') ?></option>
                            <option value="&#9993;"><?= $this->te('&#9993; E-Mail') ?></option>
                            <option value="&#128222;"><?= $this->te('&#128222; Telefon') ?></option>
                            <option value="&#128241;"><?= $this->te('&#128241; Smartphone') ?></option>
                            <option value="&#9729;"><?= $this->te('&#9729; Cloud') ?></option>
                            <option value="&#128202;"><?= $this->te('&#128202; Diagramm') ?></option>
                            <option value="&#128200;"><?= $this->te('&#128200; Statistik') ?></option>
                            <option value="&#128203;"><?= $this->te('&#128203; Checkliste') ?></option>
                            <option value="&#128221;"><?= $this->te('&#128221; Notiz') ?></option>
                            <option value="&#128218;"><?= $this->te('&#128218; Buecher') ?></option>
                            <option value="&#128269;"><?= $this->te('&#128269; Suche') ?></option>
                            <option value="&#128279;"><?= $this->te('&#128279; Link') ?></option>
                            <option value="&#127918;"><?= $this->te('&#127918; Steuerung') ?></option>
                            <option value="&#128736;"><?= $this->te('&#128736; Wartung') ?></option>
                            <option value="&#128640;"><?= $this->te('&#128640; Rakete') ?></option>
                            <option value="&#9888;"><?= $this->te('&#9888; Warnung') ?></option>
                            <option value="&#128680;"><?= $this->te('&#128680; Alarm') ?></option>
                            <option value="&#9989;"><?= $this->te('&#9989; Erledigt') ?></option>
                            <option value="&#10060;"><?= $this->te('&#10060; Fehler') ?></option>
                            <option value="&#128100;"><?= $this->te('&#128100; Person') ?></option>
                            <option value="&#128101;"><?= $this->te('&#128101; Team') ?></option>
                            <option value="&#127970;"><?= $this->te('&#127970; Firma') ?></option>
                            <option value="&#128176;"><?= $this->te('&#128176; Finanzen') ?></option>
                            <option value="&#128197;"><?= $this->te('&#128197; Kalender') ?></option>
                            <option value="&#128337;"><?= $this->te('&#128337; Uhr') ?></option>
                            <option value="&#128190;"><?= $this->te('&#128190; Datenbank') ?></option>
                            <option value="&#128230;"><?= $this->te('&#128230; Paket') ?></option>
                            <option value="&#128209;"><?= $this->te('&#128209; Formular') ?></option>
                            <option value="&#128161;"><?= $this->te('&#128161; Idee') ?></option>
                            <option value="&#127919;"><?= $this->te('&#127919; Ziel') ?></option>
                        </select>
                    </div>
                    <div class="form-group" style="align-self:flex-end;">
                        <button type="submit" class="btn btn-primary"><?= $this->te('Vorlage erstellen') ?></button>
                    </div>
                </div>
            </form>
        </div>
    </section>

    <!-- Vorlagen-Liste -->
    <section class="settings-card">
        <div class="settings-card-header">
            <span class="settings-card-icon">&#128203;</span>
            <div>
                <h2><?= $this->t('Alle Vorlagen') ?> (<?= count($templates) ?>)</h2>
                <p class="settings-card-desc"><?= $this->te('Vorlagen für neue Dokumentationsseiten verwalten.') ?></p>
            </div>
        </div>
        <div class="settings-card-body" style="padding:0;">
            <?php if (empty($templates)): ?>
                <div style="padding:2rem;text-align:center;color:var(--color-text-muted,var(--gray-500));">
                    <p><?= $this->te('Noch keine Vorlagen vorhanden.') ?></p>
                    <p style="font-size:0.85rem;"><?= $this->te('Fuehren Sie die Datenbank-Migration aus oder erstellen Sie eine neue Vorlage.') ?></p>
                </div>
            <?php else: ?>
            <div class="admin-table-wrap">
                <table class="tpl-table">
                    <thead>
                        <tr>
                            <th scope="col" style="width:48px;"></th>
                            <th scope="col"><?= $this->te('Name') ?></th>
                            <th scope="col" class="tpl-col-hide-sm"><?= $this->te('Kategorie') ?></th>
                            <th scope="col" class="tpl-col-hide-md"><?= $this->te('Beschreibung') ?></th>
                            <th scope="col" class="tpl-col-hide-sm" style="width:70px;"><?= $this->te('Reihenf.') ?></th>
                            <th scope="col" style="width:70px;"><?= $this->te('Status') ?></th>
                            <th scope="col" style="width:130px;"><?= $this->te('Aktionen') ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($templates as $tpl): ?>
                        <tr>
                            <td style="font-size:1.25rem;text-align:center;"><?= $tpl['icon'] ?></td>
                            <td><strong><?= $this->e($tpl['name']) ?></strong></td>
                            <td class="tpl-col-hide-sm"><span class="tpl-cat-badge"><?= $this->e($tpl['category']) ?></span></td>
                            <td class="tpl-col-hide-md" style="color:var(--color-text-muted,var(--gray-500));font-size:0.85rem;"><?= $this->e($this->truncate($tpl['description'] ?? '', 60)) ?></td>
                            <td class="tpl-col-hide-sm" style="text-align:center;"><?= $tpl['sort_order'] ?></td>
                            <td>
                                <?php if ($tpl['is_active']): ?>
                                    <span class="tpl-status-active"><?= $this->te('Aktiv') ?></span>
                                <?php else: ?>
                                    <span class="tpl-status-inactive"><?= $this->te('Inaktiv') ?></span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <div style="display:flex;gap:0.375rem;">
                                    <a href="/admin/page-templates/<?= $tpl['id'] ?>/edit" class="btn btn-sm btn-secondary"><?= $this->te('Bearbeiten') ?></a>
                                    <form action="/admin/page-templates/<?= $tpl['id'] ?>" method="POST" style="margin:0;" onsubmit="return confirm('Vorlage wirklich löschen?')">
                                        <input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
                                        <input type="hidden" name="_method" value="DELETE">
                                        <button aria-label="<?= $this->te('Löschen') ?>" type="submit" class="btn btn-sm btn-danger-outline">&times;</button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
            <?php endif; ?>
        </div>
    </section>

</div>

<style>
.tpl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm, 0.875rem);
}

.tpl-table th,
.tpl-table td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border, var(--gray-200));
}

.tpl-table th {
    background: var(--color-bg-alt, var(--gray-50));
    font-weight: 600;
    font-size: var(--font-size-xs, 0.75rem);
    text-transform: uppercase;
    color: var(--color-text-muted, var(--gray-500));
    letter-spacing: 0.025em;
}

.tpl-table tbody tr:hover {
    background: var(--color-bg-hover, var(--gray-50));
}

.tpl-cat-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--color-bg-alt, var(--gray-200));
    color: var(--color-text, var(--gray-700));
}

.tpl-status-active {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--green-100);
    color: var(--green-800);
    text-transform: uppercase;
}

.tpl-status-inactive {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-400);
    text-transform: uppercase;
}

.btn-danger-outline {
    background: none;
    border: 1px solid var(--red-600);
    color: var(--red-600);
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius, 0.375rem);
    padding: 0.25rem 0.5rem;
    transition: all 0.15s;
}

.btn-danger-outline:hover {
    background: var(--red-600);
    color: var(--color-on-accent);
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {
    .form-row-2 {
        grid-template-columns: 1fr;
    }
}

.icon-select {
    font-size: 1.1rem;
    max-width: 220px;
    padding: 0.375rem 0.5rem;
}

@media (max-width: 640px) {
    .tpl-col-hide-sm { display: none; }
}
@media (max-width: 900px) {
    .tpl-col-hide-md { display: none; }
}
</style>