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');
|
||||
120
app/views/notes/index.php
Normal file
120
app/views/notes/index.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../layout.php';
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
|
||||
<?php if (isset($success)): ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<i class="bi bi-check-circle-fill me-2"></i>
|
||||
<?= htmlspecialchars($success) ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?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; ?>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2 class="text-white mb-0">
|
||||
<i class="bi bi-journal-text me-2"></i>Moje notatki
|
||||
</h2>
|
||||
<a href="/notatnik/nowa" class="btn btn-light btn-lg">
|
||||
<i class="bi bi-plus-lg me-1"></i>Nowa notatka
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php if (empty($notes)): ?>
|
||||
<div class="card">
|
||||
<div class="card-body text-center py-5">
|
||||
<i class="bi bi-journal-x text-muted" style="font-size: 4rem;"></i>
|
||||
<h4 class="mt-3 text-muted">Brak notatek</h4>
|
||||
<p class="text-muted mb-4">Nie masz jeszcze żadnych notatek. Utwórz pierwszą!</p>
|
||||
<a href="/notatnik/nowa" class="btn btn-primary">
|
||||
<i class="bi bi-plus-lg me-1"></i>Utwórz notatkę
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="row g-4">
|
||||
<?php foreach ($notes as $note): ?>
|
||||
<div class="col-md-6 col-lg-4">
|
||||
<div class="card note-card border-top border-4 border-<?= htmlspecialchars($note['color']) ?>">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-start mb-2">
|
||||
<h5 class="card-title mb-0"><?= htmlspecialchars($note['title']) ?></h5>
|
||||
<div class="note-actions">
|
||||
<a href="/notatnik/edytuj/<?= $note['id'] ?>" class="btn btn-sm btn-outline-primary" title="Edytuj">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger"
|
||||
onclick="confirmDelete(<?= $note['id'] ?>, '<?= htmlspecialchars(addslashes($note['title'])) ?>')"
|
||||
title="Usuń">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="note-content text-muted small">
|
||||
<?= nl2br(htmlspecialchars($note['content'] ?: 'Brak treści')) ?>
|
||||
</p>
|
||||
<div class="mt-auto pt-2 border-top">
|
||||
<small class="text-muted">
|
||||
<i class="bi bi-clock me-1"></i>
|
||||
<?= date('d.m.Y H:i', strtotime($note['updated_at'])) ?>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Modal potwierdzenia usunięcia -->
|
||||
<div class="modal fade modal-confirm" id="deleteModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<div class="text-center w-100">
|
||||
<div class="bg-danger bg-opacity-10 rounded-circle d-inline-flex align-items-center justify-content-center mb-3" style="width: 80px; height: 80px;">
|
||||
<i class="bi bi-exclamation-triangle text-danger" style="font-size: 2.5rem;"></i>
|
||||
</div>
|
||||
<h5 class="modal-title">Potwierdzenie usunięcia</h5>
|
||||
</div>
|
||||
<button type="button" class="btn-close position-absolute top-0 end-0 m-3" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body text-center">
|
||||
<p class="mb-1">Czy na pewno chcesz usunąć notatkę:</p>
|
||||
<p class="fw-bold text-primary" id="deleteNoteTitle"></p>
|
||||
<p class="text-muted small mb-0">Ta operacja jest nieodwracalna.</p>
|
||||
</div>
|
||||
<div class="modal-footer justify-content-center">
|
||||
<button type="button" class="btn btn-secondary px-4" data-bs-dismiss="modal">
|
||||
<i class="bi bi-x-lg me-1"></i>Anuluj
|
||||
</button>
|
||||
<form id="deleteForm" method="POST" class="d-inline">
|
||||
<button type="submit" class="btn btn-danger px-4">
|
||||
<i class="bi bi-trash me-1"></i>Usuń
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function confirmDelete(id, title) {
|
||||
document.getElementById('deleteNoteTitle').textContent = '"' + title + '"';
|
||||
document.getElementById('deleteForm').action = '/notatnik/usun/' + id;
|
||||
new bootstrap.Modal(document.getElementById('deleteModal')).show();
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
$content = ob_get_clean();
|
||||
renderLayout('Notatnik', $content, true, 'notatnik', 'col-12');
|
||||
Reference in New Issue
Block a user