Files
Prism_old/notes.html
T
2025-12-15 12:28:00 -06:00

234 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Job Tracking - Notes</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/pocketbase@latest/dist/pocketbase.umd.js"></script>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
</head>
<body class="min-h-screen bg-gray-50">
<!-- Navigation Header -->
<nav class="bg-white shadow-sm border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex flex-col sm:flex-row justify-between items-center h-16 sm:h-auto py-4 sm:py-0 gap-4 sm:gap-0">
<div class="flex items-center gap-4 w-full sm:w-auto">
<a href="dashboard.html" class="text-indigo-600 hover:text-indigo-700 font-medium text-sm sm:text-base">← Dashboard</a>
<div class="text-lg sm:text-xl font-bold text-gray-800">Employee Reports</div>
</div>
<div class="flex flex-col sm:flex-row items-center gap-3 w-full sm:w-auto">
<div class="text-xs sm:text-sm text-gray-600" id="userEmail"></div>
<button
onclick="logout()"
class="w-full sm:w-auto bg-red-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 transition"
>
Logout
</button>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Page Header -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-6">
<div>
<h1 class="text-xl sm:text-2xl font-bold text-gray-800 mb-2">Job Notes</h1>
<p class="text-sm sm:text-base text-gray-600">Manage job notes and reports</p>
</div>
<button
onclick="openNoteModal()"
class="w-full sm:w-auto bg-indigo-600 text-white px-4 sm:px-6 py-2 sm:py-3 rounded-lg text-sm sm:text-base font-medium hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition"
>
+ Add Note
</button>
</div>
<!-- Message Container -->
<div id="messageContainer" class="mb-4"></div>
<!-- Loading Indicator -->
<div id="loadingIndicator" class="text-center py-8">
<div class="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600"></div>
<p class="mt-2 text-gray-600">Loading notes...</p>
</div>
<!-- Reports Table Container -->
<div id="reportsTableContainer" class="hidden bg-white rounded-lg shadow border border-gray-200 overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-3 sm:px-6 py-2 sm:py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Job</th>
<th class="px-3 sm:px-6 py-2 sm:py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Note</th>
<th class="px-3 sm:px-6 py-2 sm:py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Sentiment</th>
<th class="px-3 sm:px-6 py-2 sm:py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>
<th class="px-3 sm:px-6 py-2 sm:py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="notesTableBody" class="bg-white divide-y divide-gray-200">
</tbody>
</table>
</div>
</div>
<!-- Empty State -->
<div id="emptyState" class="hidden text-center py-12">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
<h3 class="mt-2 text-sm font-medium text-gray-900">No notes</h3>
<p class="mt-1 text-sm text-gray-500">Get started by creating a new note.</p>
<div class="mt-6">
<button
onclick="openNoteModal()"
class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
+ Add Note
</button>
</div>
</div>
</main>
<!-- Add/Edit Note Modal -->
<div id="noteModal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto z-50">
<div class="relative top-0 sm:top-10 mx-auto p-4 sm:p-5 border-0 sm:border w-full sm:max-w-2xl shadow-lg rounded-none sm:rounded-md bg-white mb-0 sm:mb-10 min-h-screen sm:min-h-0">
<!-- Modal Header -->
<div class="flex justify-between items-center mb-4">
<h2 class="text-lg font-medium text-gray-900" id="noteModalTitle">Add Note</h2>
<button
onclick="closeNoteModal()"
class="text-gray-400 hover:text-gray-500"
>
<svg class="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<!-- Note Form -->
<form id="noteForm" class="space-y-4 max-h-[calc(100vh-200px)] overflow-y-auto pr-2">
<input type="hidden" id="noteId" name="id">
<div>
<label for="noteJob" class="block text-sm font-medium text-gray-700 mb-1">Job *</label>
<select id="noteJob" name="job" required class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent outline-none text-base">
<option value="">Select a job...</option>
</select>
</div>
<div>
<label for="noteEditor" class="block text-sm font-medium text-gray-700 mb-1">Note</label>
<div id="noteEditor" style="height: 200px;"></div>
<textarea id="noteContent" name="content" class="hidden"></textarea>
</div>
<div>
<label for="noteSentiment" class="block text-sm font-medium text-gray-700 mb-1">Sentiment</label>
<select id="noteSentiment" name="sentiment" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent outline-none text-base">
<option value="">Select sentiment...</option>
<option value="Positive">Positive</option>
<option value="Negative">Negative</option>
<option value="Neutral">Neutral</option>
</select>
</div>
<div>
<label for="noteDate" class="block text-sm font-medium text-gray-700 mb-1">Date & Time</label>
<input type="datetime-local" id="noteDate" name="date" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent outline-none text-base">
</div>
<div class="flex flex-col sm:flex-row justify-end space-y-2 sm:space-y-0 sm:space-x-3 pt-4 border-t">
<button
type="button"
onclick="closeNoteModal()"
class="w-full sm:w-auto px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 text-base"
>
Cancel
</button>
<button
type="submit"
class="w-full sm:w-auto px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 text-base"
>
Save Note
</button>
</div>
</form>
</div>
</div>
<script src="js/pocketbase.js"></script>
<script src="js/config.js"></script>
<script src="js/auth.js"></script>
<script src="js/jobs.js"></script>
<script src="js/notes.js"></script>
<script>
let noteEditor = null;
// Check authentication
checkAuth();
// Set user email
const user = pb.authStore.model;
if (user) {
document.getElementById('userEmail').textContent = user.email || '';
}
// Initialize Quill editor
noteEditor = new Quill('#noteEditor', {
theme: 'snow',
modules: {
toolbar: [
[{ 'header': [1, 2, 3, false] }],
['bold', 'italic', 'underline'],
['link'],
[{ 'list': 'ordered'}, { 'list': 'bullet' }]
]
}
});
// Set global reference
window.noteEditorInstance = noteEditor;
// Modal functions
function openNoteModal(noteId = null) {
document.getElementById('noteModal').classList.remove('hidden');
if (noteId) {
document.getElementById('noteModalTitle').textContent = 'Edit Note';
document.getElementById('noteId').value = noteId;
loadNoteForEdit(noteId);
} else {
document.getElementById('noteModalTitle').textContent = 'Add Note';
document.getElementById('noteForm').reset();
document.getElementById('noteId').value = '';
noteEditor.setContents([]);
loadJobsForSelect();
}
}
function closeNoteModal() {
document.getElementById('noteModal').classList.add('hidden');
document.getElementById('noteForm').reset();
document.getElementById('noteId').value = '';
noteEditor.setContents([]);
}
// Form submission
document.getElementById('noteForm').addEventListener('submit', async (e) => {
e.preventDefault();
if (noteEditor) {
const content = noteEditor.root.innerHTML;
document.getElementById('noteContent').value = content;
}
await saveNote();
});
// Load notes on page load
loadAllNotes();
</script>
</body>
</html>