first commit
This commit is contained in:
91
app/views/notes/form.php
Normal file
91
app/views/notes/form.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../layout.php';
|
||||
|
||||
$error = $_SESSION['error'] ?? null;
|
||||
unset($_SESSION['error']);
|
||||
|
||||
$colors = [
|
||||
'primary' => '#667eea',
|
||||
'success' => '#28a745',
|
||||
'danger' => '#dc3545',
|
||||
'warning' => '#ffc107',
|
||||
'info' => '#17a2b8',
|
||||
'secondary' => '#6c757d'
|
||||
];
|
||||
|
||||
$currentColor = $note['color'] ?? 'primary';
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header text-center text-white">
|
||||
<i class="bi bi-<?= $isEdit ? 'pencil-square' : 'plus-circle' ?> icon-large"></i>
|
||||
<h4 class="mt-2 mb-0"><?= $isEdit ? 'Edytuj notatkę' : 'Nowa notatka' ?></h4>
|
||||
</div>
|
||||
<div class="card-body p-4">
|
||||
<?php if (isset($error)): ?>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<i class="bi bi-exclamation-triangle-fill me-2"></i>
|
||||
<?= htmlspecialchars($error) ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST" action="<?= $isEdit ? '/notatnik/zapisz/' . $note['id'] : '/notatnik/dodaj' ?>">
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">
|
||||
<i class="bi bi-type me-1"></i>Tytuł
|
||||
</label>
|
||||
<input type="text" class="form-control" id="title" name="title"
|
||||
value="<?= htmlspecialchars($note['title'] ?? '') ?>"
|
||||
placeholder="Wprowadź tytuł notatki" required autofocus>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="content" class="form-label">
|
||||
<i class="bi bi-text-paragraph me-1"></i>Treść
|
||||
</label>
|
||||
<textarea class="form-control" id="content" name="content" rows="6"
|
||||
placeholder="Wprowadź treść notatki..."><?= htmlspecialchars($note['content'] ?? '') ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="form-label">
|
||||
<i class="bi bi-palette me-1"></i>Kolor
|
||||
</label>
|
||||
<div class="d-flex gap-2 flex-wrap">
|
||||
<?php foreach ($colors as $name => $hex): ?>
|
||||
<div class="color-option <?= $currentColor === $name ? 'selected' : '' ?>"
|
||||
style="background-color: <?= $hex ?>;"
|
||||
onclick="selectColor('<?= $name ?>', this)"
|
||||
title="<?= ucfirst($name) ?>">
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<input type="hidden" name="color" id="colorInput" value="<?= htmlspecialchars($currentColor) ?>">
|
||||
</div>
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<button type="submit" class="btn btn-primary btn-lg">
|
||||
<i class="bi bi-check-lg me-2"></i><?= $isEdit ? 'Zapisz zmiany' : 'Dodaj notatkę' ?>
|
||||
</button>
|
||||
<a href="/notatnik" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left me-2"></i>Powrót do listy
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function selectColor(color, element) {
|
||||
document.querySelectorAll('.color-option').forEach(el => el.classList.remove('selected'));
|
||||
element.classList.add('selected');
|
||||
document.getElementById('colorInput').value = color;
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
$content = ob_get_clean();
|
||||
renderLayout($isEdit ? 'Edytuj notatkę' : 'Nowa notatka', $content, true, 'notatnik', 'col-md-6');
|
||||
Reference in New Issue
Block a user