Files
TimeTrack/templates/notes_list.html

2153 lines
59 KiB
HTML

{% extends "layout.html" %}
<!-- Folder tree rendering macro -->
{% macro render_folder_tree(tree, parent_path='') %}
{% for folder_path, children in tree.items() %}
{% set folder_name = folder_path.split('/')[-1] %}
{% set is_active = folder_filter == folder_path %}
<div class="folder-item {% if is_active %}active{% endif %}" style="padding-left: {{ (folder_path.count('/') + 1) * 20 }}px;">
<span class="folder-icon"><i class="ti ti-folder"></i></span>
<a href="{{ url_for('notes.notes_list', folder=folder_path) }}" class="folder-link">
{{ folder_name }}
</a>
<span class="folder-count">({{ folder_counts.get(folder_path, 0) }})</span>
</div>
{% if children %}
{{ render_folder_tree(children, folder_path) }}
{% endif %}
{% endfor %}
{% endmacro %}
{% block content %}
<div class="page-container">
<!-- Header Section -->
<div class="page-header">
<div class="header-content">
<div class="header-left">
<h1 class="page-title">
<span class="page-icon"><i class="ti ti-notes"></i></span>
Notes & Documentation
</h1>
<p class="page-subtitle">Organize your thoughts and documentation</p>
</div>
<div class="header-actions">
<a href="{{ url_for('notes.create_note') }}" class="btn btn-primary">
<span class="icon"><i class="ti ti-plus"></i></span>
Create New Note
</a>
<button type="button" class="btn btn-primary" id="upload-btn">
<span class="icon"><i class="ti ti-upload"></i></span>
Upload File
</button>
<button type="button" class="btn btn-secondary" id="toggle-sidebar">
<span class="icon"><i class="ti ti-folder"></i></span>
Toggle Folders
</button>
<a href="{{ url_for('notes.notes_folders') }}" class="btn btn-secondary">
<span class="icon"><i class="ti ti-settings"></i></span>
Manage Folders
</a>
</div>
</div>
</div>
<div class="notes-layout">
<!-- Sidebar -->
<div class="notes-sidebar" id="notes-sidebar">
<!-- Search -->
<div class="sidebar-section">
<form method="GET" action="{{ url_for('notes.notes_list') }}">
<div class="search-box">
<input type="text"
name="search"
class="form-control"
placeholder="Search notes..."
value="{{ search_query }}">
<button type="submit" class="search-btn"><i class="ti ti-search"></i></button>
</div>
</form>
</div>
<!-- Folders -->
<div class="sidebar-section">
<h4>Folders</h4>
<div class="folder-tree">
<div class="folder-item {% if not folder_filter %}active{% endif %}">
<span class="folder-icon"><i class="ti ti-home"></i></span>
<a href="{{ url_for('notes.notes_list') }}" class="folder-link">All Notes</a>
<span class="folder-count">({{ notes|length }})</span>
</div>
{{ render_folder_tree(folder_tree)|safe }}
</div>
</div>
<!-- Tags -->
<div class="sidebar-section">
<h4>Tags</h4>
{% if all_tags %}
<div class="tags-list">
{% for tag in all_tags %}
<a href="{{ url_for('notes.notes_list', tag=tag) }}"
class="tag-link {% if tag_filter == tag %}active{% endif %}">
<span class="tag-icon"><i class="ti ti-tag"></i></span>
{{ tag }}
<span class="tag-count">({{ tag_counts.get(tag, 0) }})</span>
</a>
{% endfor %}
</div>
{% else %}
<p class="text-muted">No tags yet</p>
{% endif %}
</div>
<!-- Visibility Filter -->
<div class="sidebar-section">
<h4>Visibility</h4>
<div class="visibility-filters">
<a href="{{ url_for('notes.notes_list') }}"
class="visibility-link {% if not visibility_filter %}active{% endif %}">
<span><i class="ti ti-eye"></i></span> All Notes
</a>
<a href="{{ url_for('notes.notes_list', visibility='private') }}"
class="visibility-link {% if visibility_filter == 'private' %}active{% endif %}">
<span><i class="ti ti-lock"></i></span> Private
</a>
<a href="{{ url_for('notes.notes_list', visibility='team') }}"
class="visibility-link {% if visibility_filter == 'team' %}active{% endif %}">
<span><i class="ti ti-users"></i></span> Team
</a>
<a href="{{ url_for('notes.notes_list', visibility='company') }}"
class="visibility-link {% if visibility_filter == 'company' %}active{% endif %}">
<span><i class="ti ti-building"></i></span> Company
</a>
</div>
</div>
</div>
<!-- Main Content -->
<div class="notes-content">
<!-- Active Filters -->
{% if folder_filter or tag_filter or visibility_filter or search_query %}
<div class="active-filters">
<span>Active filters:</span>
{% if folder_filter %}
<span class="filter-tag">
<i class="ti ti-folder"></i> {{ folder_filter }}
<a href="{{ url_for('notes.notes_list', tag=tag_filter, visibility=visibility_filter, search=search_query) }}" class="remove-filter"><i class="ti ti-x"></i></a>
</span>
{% endif %}
{% if tag_filter %}
<span class="filter-tag">
<i class="ti ti-tag"></i> {{ tag_filter }}
<a href="{{ url_for('notes.notes_list', folder=folder_filter, visibility=visibility_filter, search=search_query) }}" class="remove-filter"><i class="ti ti-x"></i></a>
</span>
{% endif %}
{% if visibility_filter %}
<span class="filter-tag">
<i class="ti ti-eye"></i> {{ visibility_filter|title }}
<a href="{{ url_for('notes.notes_list', folder=folder_filter, tag=tag_filter, search=search_query) }}" class="remove-filter"><i class="ti ti-x"></i></a>
</span>
{% endif %}
{% if search_query %}
<span class="filter-tag">
<i class="ti ti-search"></i> "{{ search_query }}"
<a href="{{ url_for('notes.notes_list', folder=folder_filter, tag=tag_filter, visibility=visibility_filter) }}" class="remove-filter"><i class="ti ti-x"></i></a>
</span>
{% endif %}
<a href="{{ url_for('notes.notes_list') }}" class="clear-all">Clear all</a>
</div>
{% endif %}
{% if notes %}
<!-- Bulk Actions Bar -->
<div class="bulk-actions-bar" id="bulk-actions-bar">
<div class="select-all-container">
<input type="checkbox" id="select-all" class="select-all-checkbox">
<label for="select-all">Select All</label>
</div>
<span class="selection-info">
<span id="selected-count">0</span> selected
</span>
<div class="bulk-actions">
<button class="bulk-action-btn" id="bulk-move-btn">
<i class="ti ti-folder-share"></i> Move
</button>
<button class="bulk-action-btn danger" id="bulk-delete-btn">
<i class="ti ti-trash"></i> Delete
</button>
</div>
</div>
<!-- View Toggle -->
<div class="view-controls">
<div class="view-toggle">
<button class="toggle-btn active" data-view="grid" onclick="switchView('grid')">
<span><i class="ti ti-layout-grid"></i></span> Grid
</button>
<button class="toggle-btn" data-view="list" onclick="switchView('list')">
<span><i class="ti ti-list"></i></span> List
</button>
</div>
</div>
<!-- Grid View -->
<div class="notes-view grid-view active" id="grid-view">
<div class="notes-grid" id="notes-grid">
{% for note in notes %}
<div class="note-card {% if note.is_pinned %}pinned{% endif %}"
data-note-id="{{ note.id }}"
draggable="true">
<input type="checkbox" class="note-checkbox" data-note-id="{{ note.id }}">
<div class="note-card-header">
{% if note.is_pinned %}
<span class="pin-indicator" title="Pinned"><i class="ti ti-pin"></i></span>
{% endif %}
<span class="visibility-badge visibility-{{ note.visibility.value.lower() }}">
{% if note.visibility.value == 'Private' %}<i class="ti ti-lock"></i>{% elif note.visibility.value == 'Team' %}<i class="ti ti-users"></i>{% else %}<i class="ti ti-building"></i>{% endif %}
{{ note.visibility.value }}
</span>
</div>
<h3 class="note-title">
<a href="{{ url_for('notes.view_note', slug=note.slug) }}" title="{{ note.title }}">{{ note.title }}</a>
</h3>
{% if note.is_image %}
<div class="note-image-preview">
<img src="{{ note.file_url }}" alt="{{ note.title }}" loading="lazy">
</div>
{% elif note.is_pdf %}
<div class="note-pdf-preview">
<i class="ti ti-file-type-pdf"></i>
<span>PDF Document</span>
</div>
{% else %}
<p class="note-preview">{{ note.get_preview(150) }}</p>
{% endif %}
{% if note.tags %}
<div class="note-tags">
{% for tag in note.get_tags_list() %}
<span class="tag-chip">{{ tag }}</span>
{% endfor %}
</div>
{% endif %}
<div class="note-footer">
<span class="note-meta">
<span><i class="ti ti-folder"></i></span> {{ note.folder or 'No folder' }}
</span>
<span class="note-meta">
<span><i class="ti ti-user"></i></span> {{ note.created_by.username }}
</span>
<span class="note-meta">
<span><i class="ti ti-clock"></i></span> {{ note.updated_at.strftime('%b %d, %Y') }}
</span>
</div>
<div class="note-actions">
<a href="{{ url_for('notes.view_note', slug=note.slug) }}" class="btn-sm btn-secondary">View</a>
{% if note.can_user_edit(g.user) %}
<a href="{{ url_for('notes.edit_note', slug=note.slug) }}" class="btn-sm btn-primary">Edit</a>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
<!-- List View -->
<div class="notes-view list-view" id="list-view">
<table class="notes-table">
<thead>
<tr>
<th class="checkbox-column">
<input type="checkbox" id="select-all-table" class="select-all-checkbox">
</th>
<th>Title</th>
<th>Folder</th>
<th>Tags</th>
<th>Visibility</th>
<th>Author</th>
<th>Updated</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for note in notes %}
<tr class="note-row {% if note.is_pinned %}pinned{% endif %}"
data-note-id="{{ note.id }}"
draggable="true">
<td class="checkbox-column">
<input type="checkbox" class="note-checkbox" data-note-id="{{ note.id }}">
</td>
<td>
{% if note.is_pinned %}<span class="pin-indicator" title="Pinned"><i class="ti ti-pin"></i></span>{% endif %}
{% if note.is_pdf %}<span class="file-type-indicator" title="PDF Document"><i class="ti ti-file-type-pdf"></i></span>{% endif %}
{% if note.is_image %}<span class="file-type-indicator" title="Image"><i class="ti ti-photo"></i></span>{% endif %}
<a href="{{ url_for('notes.view_note', slug=note.slug) }}">{{ note.title }}</a>
</td>
<td>{{ note.folder or '-' }}</td>
<td>
{% if note.tags %}
{% for tag in note.get_tags_list() %}
<span class="tag-chip">{{ tag }}</span>
{% endfor %}
{% else %}
-
{% endif %}
</td>
<td>
<span class="visibility-badge visibility-{{ note.visibility.value.lower() }}">
{% if note.visibility.value == 'Private' %}<i class="ti ti-lock"></i>{% elif note.visibility.value == 'Team' %}<i class="ti ti-users"></i>{% else %}<i class="ti ti-building"></i>{% endif %}
{{ note.visibility.value }}
</span>
</td>
<td>{{ note.created_by.username }}</td>
<td>{{ note.updated_at.strftime('%b %d, %Y') }}</td>
<td>
<a href="{{ url_for('notes.view_note', slug=note.slug) }}" class="btn-sm btn-secondary">View</a>
{% if note.can_user_edit(g.user) %}
<a href="{{ url_for('notes.edit_note', slug=note.slug) }}" class="btn-sm btn-primary">Edit</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty-state">
<div class="empty-icon"><i class="ti ti-notes"></i></div>
<h3>No notes found</h3>
<p>
{% if folder_filter or tag_filter or visibility_filter or search_query %}
No notes match your current filters. Try adjusting your search criteria.
{% else %}
Start documenting your knowledge by creating your first note.
{% endif %}
</p>
<a href="{{ url_for('notes.create_note') }}" class="btn btn-primary">Create Your First Note</a>
</div>
{% endif %}
</div>
</div>
</div>
<!-- Upload Modal -->
<div id="upload-modal" class="upload-modal">
<div class="upload-modal-content">
<div class="upload-modal-header">
<h2>Upload File</h2>
<button type="button" class="upload-modal-close" onclick="hideUploadModal()">&times;</button>
</div>
<form id="upload-form" enctype="multipart/form-data">
<div class="upload-modal-body">
<div class="upload-form-group">
<label for="file-input">Select Files or Folder</label>
<div class="file-input-wrapper">
<input type="file" id="file-input-folder" name="files" accept=".md,.markdown,.jpg,.jpeg,.png,.gif,.webp,.svg,.txt,.pdf,.doc,.docx" webkitdirectory style="display: none;">
<input type="file" id="file-input-multiple" name="files" accept=".md,.markdown,.jpg,.jpeg,.png,.gif,.webp,.svg,.txt,.pdf,.doc,.docx" multiple style="display: none;">
<label for="file-input" class="file-input-label" id="file-input-label">
<i class="ti ti-upload"></i>
<span>Choose files or drag & drop here</span>
<small>Supported: .md, images (.jpg, .png, .gif, .webp, .svg), documents (.txt, .pdf, .doc)</small>
<div class="upload-buttons">
<button type="button" class="btn btn-sm btn-secondary" onclick="selectMultipleFiles()">
<i class="ti ti-files"></i> Select Files
</button>
<button type="button" class="btn btn-sm btn-secondary" onclick="selectFolder()">
<i class="ti ti-folder"></i> Select Folder
</button>
</div>
</label>
</div>
<div id="upload-preview"></div>
<div id="upload-progress" style="display: none;">
<div class="progress-bar">
<div class="progress-fill" id="progress-fill"></div>
</div>
<div class="progress-text" id="progress-text">Uploading...</div>
</div>
</div>
<div class="upload-form-group">
<label for="upload-folder">Folder</label>
<input type="text" id="upload-folder" name="folder" class="form-control"
placeholder="e.g., Work/Projects (optional)"
list="upload-folder-suggestions">
<datalist id="upload-folder-suggestions">
{% for folder in all_folders %}
<option value="{{ folder.path }}">
{% endfor %}
</datalist>
</div>
<div class="upload-form-group">
<label for="upload-tags">Tags</label>
<input type="text" id="upload-tags" name="tags" class="form-control"
placeholder="documentation, images, reference (comma-separated, optional)">
</div>
</div>
<div class="upload-modal-footer">
<button type="button" class="btn btn-secondary" onclick="hideUploadModal()">Cancel</button>
<button type="submit" class="btn btn-primary">
<i class="ti ti-upload"></i> Upload
</button>
</div>
</form>
</div>
</div>
<style>
/* Container */
.notes-container {
max-width: 1400px;
margin: 0 auto;
padding: 2rem;
}
/* Page Header - Time Tracking style */
.page-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 16px;
padding: 2rem;
color: white;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
margin-bottom: 2rem;
}
.header-content {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 2rem;
}
.page-title {
font-size: 2rem;
font-weight: 700;
margin: 0;
display: flex;
align-items: center;
gap: 0.75rem;
}
.page-icon {
font-size: 2.5rem;
display: inline-block;
animation: float 3s ease-in-out infinite;
}
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}
.page-subtitle {
font-size: 1.1rem;
opacity: 0.9;
margin: 0.5rem 0 0 0;
}
.header-actions {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
/* Modern button styles to match Time Tracking */
.btn {
padding: 0.75rem 1.5rem;
border-radius: 8px;
font-weight: 600;
transition: all 0.3s ease;
border: 2px solid transparent;
display: inline-flex;
align-items: center;
gap: 0.5rem;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}
.btn-secondary {
background: white;
color: #667eea;
border-color: #e5e7eb;
}
.btn-secondary:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
border-color: #667eea;
}
.btn .icon {
font-size: 1.1em;
}
/* Small buttons */
.btn-sm {
padding: 0.5rem 1rem;
font-size: 0.875rem;
border-radius: 6px;
font-weight: 600;
transition: all 0.2s ease;
text-decoration: none;
display: inline-flex;
align-items: center;
gap: 0.375rem;
}
.btn-sm.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-sm.btn-primary:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.btn-sm.btn-secondary {
background: white;
color: #667eea;
border: 1px solid #e5e7eb;
}
.btn-sm.btn-secondary:hover {
transform: translateY(-1px);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
border-color: #667eea;
}
/* Notes layout */
.notes-layout {
display: flex;
gap: 20px;
margin-top: 20px;
}
/* Sidebar */
.notes-sidebar {
width: 280px;
background: white;
border-radius: 12px;
padding: 1.5rem;
height: fit-content;
position: sticky;
top: 20px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
border: 1px solid #e5e7eb;
}
.notes-sidebar.collapsed {
display: none;
}
.sidebar-section {
margin-bottom: 25px;
}
.sidebar-section h4 {
font-size: 1rem;
font-weight: 600;
margin-bottom: 12px;
color: #1f2937;
}
.search-box {
position: relative;
display: flex;
max-width: 100%;
}
.search-box input {
padding: 0.75rem;
padding-right: 35px;
width: 100%;
font-size: 0.9rem;
border: 1px solid #e5e7eb;
border-radius: 8px;
transition: all 0.2s;
}
.search-box input:focus {
border-color: #667eea;
outline: none;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.search-btn {
position: absolute;
right: 5px;
top: 50%;
transform: translateY(-50%);
background: none;
border: none;
cursor: pointer;
padding: 5px;
}
/* Folder Tree */
.folder-tree {
font-size: 0.85rem;
}
.folder-item {
padding: 5px 0;
display: flex;
align-items: center;
gap: 5px;
}
.folder-item.active .folder-link {
font-weight: 600;
color: #667eea;
}
.folder-item.drag-over {
background: #e3f2fd;
border-radius: 3px;
}
.folder-link {
color: #495057;
text-decoration: none;
flex: 1;
}
.folder-link:hover {
color: #667eea;
}
.folder-count {
font-size: 0.8rem;
color: #6c757d;
}
/* Tags */
.tags-list {
display: flex;
flex-direction: column;
gap: 5px;
}
.tag-link {
display: flex;
align-items: center;
gap: 5px;
padding: 8px 12px;
background: #f8f9fa;
border-radius: 8px;
text-decoration: none;
color: #495057;
font-size: 0.9rem;
transition: all 0.2s;
border: 1px solid transparent;
}
.tag-link:hover {
background: #e9ecef;
transform: translateX(2px);
}
.tag-link.active {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.tag-count {
margin-left: auto;
font-size: 0.8rem;
opacity: 0.7;
}
/* Visibility Filters */
.visibility-filters {
display: flex;
flex-direction: column;
gap: 5px;
}
.visibility-link {
display: flex;
align-items: center;
gap: 5px;
padding: 8px 12px;
background: #f8f9fa;
border-radius: 8px;
text-decoration: none;
color: #495057;
font-size: 0.9rem;
transition: all 0.2s;
border: 1px solid transparent;
}
.visibility-link:hover {
background: #e9ecef;
transform: translateX(2px);
}
.visibility-link.active {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
/* Main Content */
.notes-content {
flex: 1;
min-width: 0;
}
/* Active Filters */
.active-filters {
background: white;
padding: 12px 16px;
border-radius: 12px;
margin-bottom: 20px;
display: flex;
align-items: center;
gap: 10px;
font-size: 0.9rem;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
border: 1px solid #e5e7eb;
}
.filter-tag {
background: #f8f9fa;
padding: 6px 12px;
border-radius: 6px;
border: 1px solid #e5e7eb;
}
.remove-filter {
margin-left: 5px;
color: #dc3545;
text-decoration: none;
font-weight: bold;
}
.clear-all {
margin-left: auto;
color: #667eea;
text-decoration: none;
}
/* View Controls */
.view-controls {
display: flex;
justify-content: flex-end;
margin-bottom: 20px;
}
.view-toggle {
display: flex;
gap: 5px;
}
.toggle-btn {
padding: 5px 15px;
background: white;
border: 1px solid #dee2e6;
cursor: pointer;
transition: all 0.2s;
}
.toggle-btn:first-child {
border-radius: 3px 0 0 3px;
}
.toggle-btn:last-child {
border-radius: 0 3px 3px 0;
}
.toggle-btn.active {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-color: #667eea;
}
/* View Containers */
.notes-view {
display: none;
}
.notes-view.active {
display: block;
}
/* Notes Grid */
.notes-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 15px;
}
.note-card {
background: white;
border: 1px solid #e5e7eb;
border-radius: 12px;
padding: 1.5rem;
position: relative;
transition: all 0.2s;
cursor: move;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.note-card:hover {
box-shadow: 0 8px 24px rgba(0,0,0,0.12);
transform: translateY(-4px);
}
.note-card.pinned {
border-color: #ffc107;
}
.note-card.dragging {
opacity: 0.5;
cursor: grabbing;
}
.note-card.drag-over {
border: 2px dashed #667eea;
}
.note-card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.pin-indicator {
font-size: 0.875rem;
color: #f39c12;
margin-right: 0.25rem;
}
.file-type-indicator {
margin-right: 0.25rem;
}
.file-type-indicator i {
font-size: 1.1rem;
}
.file-type-indicator[title="PDF Document"] {
color: #dc3545;
}
.file-type-indicator[title="Image"] {
color: #28a745;
}
.visibility-badge {
font-size: 0.7rem;
padding: 2px 6px;
border-radius: 3px;
}
.visibility-private {
background: #f8d7da;
color: #721c24;
}
.visibility-team {
background: #d1ecf1;
color: #0c5460;
}
.visibility-company {
background: #d4edda;
color: #155724;
}
.note-title {
font-size: 1rem;
margin: 0 0 8px 0;
line-height: 1.3;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
max-height: 2.6em;
}
.note-title a {
color: #333;
text-decoration: none;
word-break: break-word;
}
.note-title a:hover {
color: #667eea;
}
.note-preview {
color: #6c757d;
font-size: 0.8rem;
line-height: 1.3;
margin-bottom: 8px;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
{% if g.user.preferences and g.user.preferences.note_preview_font %}
{% set font = g.user.preferences.note_preview_font %}
{% if font == 'sans-serif' %}
font-family: Arial, Helvetica, sans-serif;
{% elif font == 'serif' %}
font-family: "Times New Roman", Times, serif;
{% elif font == 'monospace' %}
font-family: "Courier New", Courier, monospace;
{% elif font == 'georgia' %}
font-family: Georgia, serif;
{% elif font == 'palatino' %}
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
{% elif font == 'garamond' %}
font-family: Garamond, serif;
{% elif font == 'bookman' %}
font-family: "Bookman Old Style", serif;
{% elif font == 'comic-sans' %}
font-family: "Comic Sans MS", cursive;
{% elif font == 'trebuchet' %}
font-family: "Trebuchet MS", sans-serif;
{% elif font == 'arial-black' %}
font-family: "Arial Black", sans-serif;
{% elif font == 'impact' %}
font-family: Impact, sans-serif;
{% endif %}
{% endif %}
}
.note-tags {
margin-bottom: 8px;
}
.tag-chip {
display: inline-block;
background: #e9ecef;
padding: 1px 6px;
border-radius: 3px;
font-size: 0.7rem;
margin-right: 4px;
}
.note-footer {
display: flex;
gap: 10px;
margin-bottom: 8px;
font-size: 0.7rem;
color: #6c757d;
}
.note-meta {
display: flex;
align-items: center;
gap: 2px;
}
.note-actions {
display: flex;
gap: 5px;
padding-top: 8px;
border-top: 1px solid #e9ecef;
}
/* Empty State */
.empty-state {
text-align: center;
padding: 60px 20px;
background: white;
border-radius: 16px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
border: 1px solid #e5e7eb;
}
.empty-icon {
font-size: 3rem;
margin-bottom: 20px;
}
.empty-icon i {
font-size: 3rem;
color: #667eea;
}
/* Icon styling */
.folder-icon i, .tag-icon i, .visibility-link i,
.filter-tag i, .note-meta i, .search-btn i,
.page-icon i {
font-size: 1em;
}
.btn .icon i {
font-size: 1.1em;
}
/* List View / Table */
.notes-table {
width: 100%;
background: white;
border: 1px solid #e5e7eb;
border-radius: 12px;
overflow: hidden;
border-collapse: collapse;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.notes-table th {
background: #f8f9fa;
padding: 10px;
text-align: left;
font-weight: 600;
color: #495057;
border-bottom: 2px solid #dee2e6;
font-size: 0.85rem;
}
.notes-table td {
padding: 10px;
border-bottom: 1px solid #e9ecef;
font-size: 0.85rem;
}
.notes-table tr:hover {
background: #f8f9fa;
}
.notes-table tr.pinned {
background: #fff8dc;
}
.notes-table tr.pinned:hover {
background: #fff3cd;
}
/* Draggable table rows */
.note-row {
cursor: move;
}
.note-row.dragging {
opacity: 0.5;
}
.note-row a {
pointer-events: auto;
cursor: pointer;
}
/* Responsive */
@media (max-width: 768px) {
.notes-layout {
flex-direction: column;
}
.notes-sidebar {
width: 100%;
position: static;
}
.notes-grid {
grid-template-columns: 1fr;
}
}
/* Image preview in note cards */
.note-image-preview {
margin: 0.75rem 0;
border-radius: 6px;
overflow: hidden;
background: #f8f9fa;
max-height: 200px;
display: flex;
align-items: center;
justify-content: center;
}
.note-image-preview img {
width: 100%;
height: auto;
max-height: 200px;
object-fit: contain;
}
/* PDF preview in note cards */
.note-pdf-preview {
margin: 0.75rem 0;
padding: 2rem;
border-radius: 6px;
background: #f8f9fa;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.5rem;
}
.note-pdf-preview i {
font-size: 3rem;
color: #dc3545;
}
.note-pdf-preview span {
color: #6c757d;
font-size: 0.875rem;
}
/* Upload modal */
.upload-modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
}
.upload-modal-content {
background-color: white;
margin: 5% auto;
padding: 0;
border-radius: 8px;
width: 90%;
max-width: 500px;
box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.upload-modal-header {
padding: 1.5rem;
border-bottom: 1px solid #e9ecef;
display: flex;
justify-content: space-between;
align-items: center;
}
.upload-modal-header h2 {
margin: 0;
font-size: 1.5rem;
}
.upload-modal-close {
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: #6c757d;
transition: color 0.2s;
}
.upload-modal-close:hover {
color: #333;
}
.upload-modal-body {
padding: 1.5rem;
}
.upload-form-group {
margin-bottom: 1rem;
}
.upload-form-group label {
display: block;
margin-bottom: 0.5rem;
font-weight: 600;
color: #495057;
}
.file-input-wrapper {
position: relative;
overflow: hidden;
display: inline-block;
width: 100%;
}
.file-input-wrapper input[type="file"] {
position: absolute;
left: -9999px;
}
.file-input-label {
display: block;
padding: 0.75rem;
border: 2px dashed #ced4da;
border-radius: 6px;
text-align: center;
cursor: pointer;
transition: all 0.2s;
background: #f8f9fa;
}
.file-input-label:hover {
border-color: var(--primary-color);
background: #fff;
}
.file-input-label i {
font-size: 2rem;
color: #6c757d;
display: block;
margin-bottom: 0.5rem;
}
#upload-preview {
margin-top: 1rem;
text-align: center;
}
#upload-preview img {
max-width: 100%;
max-height: 200px;
border-radius: 6px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.file-info {
padding: 1rem;
background: #f8f9fa;
border-radius: 6px;
display: flex;
align-items: center;
gap: 0.5rem;
}
.file-info i {
font-size: 2rem;
color: #6c757d;
}
.file-size {
color: #6c757d;
font-size: 0.875rem;
}
.upload-modal-footer {
padding: 1rem 1.5rem;
border-top: 1px solid #e9ecef;
display: flex;
justify-content: flex-end;
gap: 0.5rem;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.animate-spin {
animation: spin 1s linear infinite;
}
/* Upload buttons in label */
.upload-buttons {
margin-top: 1rem;
display: flex;
gap: 0.5rem;
justify-content: center;
}
.upload-buttons .btn {
padding: 0.375rem 0.75rem;
}
/* Progress bar */
#upload-progress {
margin-top: 1rem;
}
.progress-bar {
width: 100%;
height: 20px;
background: #e9ecef;
border-radius: 10px;
overflow: hidden;
}
.progress-fill {
height: 100%;
background: var(--primary-color);
transition: width 0.3s ease;
width: 0%;
}
.progress-text {
margin-top: 0.5rem;
font-size: 0.875rem;
color: #6c757d;
text-align: center;
}
/* File list preview */
.file-list-preview {
max-height: 200px;
overflow-y: auto;
margin-top: 1rem;
border: 1px solid #e9ecef;
border-radius: 6px;
padding: 0.5rem;
}
.file-list-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.375rem 0.5rem;
border-bottom: 1px solid #f0f0f0;
font-size: 0.875rem;
}
.file-list-item:last-child {
border-bottom: none;
}
.file-list-item-name {
display: flex;
align-items: center;
gap: 0.5rem;
flex: 1;
overflow: hidden;
}
.file-list-item-name i {
color: #6c757d;
flex-shrink: 0;
}
.file-list-item-name span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.file-list-item-size {
color: #6c757d;
font-size: 0.75rem;
flex-shrink: 0;
}
/* Drag and drop */
.file-input-label.drag-over {
border-color: var(--primary-color);
background: #e7f3ff;
}
/* Selection System Styles */
.bulk-actions-bar {
background: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 8px;
padding: 12px 16px;
margin-bottom: 1rem;
display: none;
align-items: center;
gap: 1rem;
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.bulk-actions-bar.active {
display: flex;
}
.selection-info {
font-weight: 500;
color: #495057;
}
.bulk-actions {
display: flex;
gap: 0.5rem;
margin-left: auto;
}
.bulk-action-btn {
padding: 6px 12px;
border: 1px solid #dee2e6;
background: white;
border-radius: 4px;
cursor: pointer;
font-size: 0.875rem;
display: flex;
align-items: center;
gap: 0.5rem;
transition: all 0.2s;
}
.bulk-action-btn:hover {
background: #f8f9fa;
border-color: #adb5bd;
}
.bulk-action-btn.danger {
color: #dc3545;
}
.bulk-action-btn.danger:hover {
background: #dc3545;
color: white;
border-color: #dc3545;
}
/* Checkbox Styles */
.note-checkbox {
position: absolute;
top: 12px;
left: 12px;
z-index: 10;
width: 20px;
height: 20px;
cursor: pointer;
opacity: 0;
transition: opacity 0.2s;
}
.note-card:hover .note-checkbox,
.note-checkbox:checked {
opacity: 1;
}
.note-card.selected {
border-color: #667eea;
background: #f7f8ff;
}
.note-row.selected {
background: #f7f8ff;
}
/* Select All Checkbox */
.select-all-container {
display: flex;
align-items: center;
gap: 0.5rem;
}
.select-all-checkbox {
width: 20px;
height: 20px;
cursor: pointer;
}
/* Table Header Checkbox */
th.checkbox-column {
width: 40px;
text-align: center;
}
td.checkbox-column {
text-align: center;
}
/* Table checkbox specific styles */
.notes-table .note-checkbox {
position: relative !important;
opacity: 1 !important;
top: auto !important;
left: auto !important;
margin: 0 auto;
}
/* Move Modal Styles */
.move-modal {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.5);
z-index: 1000;
align-items: center;
justify-content: center;
}
.move-modal.active {
display: flex;
}
.move-modal-content {
background: white;
border-radius: 8px;
width: 90%;
max-width: 400px;
box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.move-modal-header {
padding: 1.5rem;
border-bottom: 1px solid #e9ecef;
display: flex;
justify-content: space-between;
align-items: center;
}
.move-modal-body {
padding: 1.5rem;
}
.folder-select {
width: 100%;
padding: 8px 12px;
border: 1px solid #ced4da;
border-radius: 4px;
font-size: 1rem;
margin-bottom: 1rem;
}
.move-modal-footer {
padding: 1rem 1.5rem;
border-top: 1px solid #e9ecef;
display: flex;
justify-content: flex-end;
gap: 0.5rem;
}
@media (max-width: 768px) {
.bulk-actions-bar {
flex-wrap: wrap;
}
.bulk-actions {
width: 100%;
margin-left: 0;
margin-top: 0.5rem;
}
}
</style>
<!-- Move Modal -->
<div class="move-modal" id="move-modal">
<div class="move-modal-content">
<div class="move-modal-header">
<h3>Move Notes</h3>
<button class="btn-close" onclick="closeMoveModal()">
<i class="ti ti-x"></i>
</button>
</div>
<div class="move-modal-body">
<label for="move-folder-select">Select destination folder:</label>
<select id="move-folder-select" class="folder-select">
<option value="">No folder</option>
{% for folder in folders %}
<option value="{{ folder }}">{{ folder }}</option>
{% endfor %}
</select>
<p class="text-muted">Move <span id="move-count">0</span> selected note(s) to this folder.</p>
</div>
<div class="move-modal-footer">
<button class="btn btn-secondary" onclick="closeMoveModal()">Cancel</button>
<button class="btn btn-primary" onclick="confirmMove()">Move</button>
</div>
</div>
</div>
<script>
// Sidebar toggle
document.getElementById('toggle-sidebar').addEventListener('click', function() {
document.getElementById('notes-sidebar').classList.toggle('collapsed');
});
// View switching
function switchView(view) {
// Update button states
document.querySelectorAll('.toggle-btn').forEach(btn => {
btn.classList.remove('active');
if (btn.dataset.view === view) {
btn.classList.add('active');
}
});
// Update view visibility
document.querySelectorAll('.notes-view').forEach(v => {
v.classList.remove('active');
});
document.getElementById(view + '-view').classList.add('active');
}
// Drag and Drop functionality
let draggedNote = null;
let draggedNoteId = null;
document.addEventListener('DOMContentLoaded', function() {
initializeDragAndDrop();
});
function initializeDragAndDrop() {
// Note cards (grid view)
const noteCards = document.querySelectorAll('.note-card');
noteCards.forEach(card => {
card.addEventListener('dragstart', handleNoteDragStart);
card.addEventListener('dragend', handleNoteDragEnd);
card.addEventListener('dragover', handleNoteDragOver);
card.addEventListener('drop', handleNoteDrop);
card.addEventListener('dragleave', handleNoteDragLeave);
});
// Note rows (list view)
const noteRows = document.querySelectorAll('.note-row');
noteRows.forEach(row => {
row.addEventListener('dragstart', handleNoteDragStart);
row.addEventListener('dragend', handleNoteDragEnd);
});
// Folder items
const folderItems = document.querySelectorAll('.folder-item');
folderItems.forEach(folder => {
folder.addEventListener('dragover', handleFolderDragOver);
folder.addEventListener('drop', handleFolderDrop);
folder.addEventListener('dragleave', handleFolderDragLeave);
});
}
// Note drag handlers
function handleNoteDragStart(e) {
draggedNote = this;
draggedNoteId = this.dataset.noteId;
this.classList.add('dragging');
e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('text/plain', draggedNoteId);
}
function handleNoteDragEnd(e) {
this.classList.remove('dragging');
// Remove all drag-over classes
document.querySelectorAll('.note-card, .note-row, .folder-item').forEach(el => {
el.classList.remove('drag-over');
});
}
function handleNoteDragOver(e) {
if (e.preventDefault) {
e.preventDefault();
}
e.dataTransfer.dropEffect = 'move';
if (this !== draggedNote) {
this.classList.add('drag-over');
}
return false;
}
function handleNoteDragLeave(e) {
this.classList.remove('drag-over');
}
function handleNoteDrop(e) {
if (e.stopPropagation) {
e.stopPropagation();
}
if (draggedNote !== this) {
// Reorder notes
const notesGrid = document.getElementById('notes-grid');
const allCards = Array.from(notesGrid.querySelectorAll('.note-card'));
const draggedIndex = allCards.indexOf(draggedNote);
const targetIndex = allCards.indexOf(this);
if (draggedIndex < targetIndex) {
this.parentNode.insertBefore(draggedNote, this.nextSibling);
} else {
this.parentNode.insertBefore(draggedNote, this);
}
}
return false;
}
// Folder drag handlers
function handleFolderDragOver(e) {
if (e.preventDefault) {
e.preventDefault();
}
e.dataTransfer.dropEffect = 'move';
this.classList.add('drag-over');
return false;
}
function handleFolderDragLeave(e) {
this.classList.remove('drag-over');
}
function handleFolderDrop(e) {
if (e.stopPropagation) {
e.stopPropagation();
}
this.classList.remove('drag-over');
// Get folder path
const folderLink = this.querySelector('.folder-link');
let folderPath = '';
if (folderLink) {
// Extract folder path from the URL
const href = folderLink.getAttribute('href');
const url = new URL(href, window.location.origin);
folderPath = url.searchParams.get('folder') || '';
}
// Move note to folder
if (draggedNoteId && confirm(`Move this note to folder "${folderPath || 'All Notes'}"?`)) {
// Here you would make an API call to update the note's folder
fetch(`/api/notes/${draggedNoteId}/move`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ folder: folderPath })
})
.then(response => response.json())
.then(data => {
if (data.success) {
window.location.reload();
} else {
alert('Failed to move note: ' + (data.error || 'Unknown error'));
}
})
.catch(error => {
console.error('Error:', error);
alert('Failed to move note');
});
}
return false;
}
// Upload functionality
document.getElementById('upload-btn').addEventListener('click', function() {
showUploadModal();
});
function showUploadModal() {
const modal = document.getElementById('upload-modal');
modal.style.display = 'block';
}
function hideUploadModal() {
const modal = document.getElementById('upload-modal');
modal.style.display = 'none';
// Reset form
document.getElementById('upload-form').reset();
document.getElementById('upload-preview').innerHTML = '';
document.getElementById('upload-progress').style.display = 'none';
document.getElementById('progress-fill').style.width = '0%';
selectedFiles = [];
}
// Multiple file selection
function selectMultipleFiles() {
document.getElementById('file-input-multiple').click();
}
// Folder selection
function selectFolder() {
document.getElementById('file-input-folder').click();
}
// Handle file selection
let selectedFiles = [];
document.getElementById('file-input-folder').addEventListener('change', handleFileSelection);
document.getElementById('file-input-multiple').addEventListener('change', handleFileSelection);
function handleFileSelection(e) {
const files = Array.from(e.target.files);
if (files.length > 0) {
selectedFiles = files.filter(file => {
const ext = file.name.split('.').pop().toLowerCase();
return ['md', 'markdown', 'jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'txt', 'pdf', 'doc', 'docx'].includes(ext);
});
displayFilePreview();
}
}
function displayFilePreview() {
const preview = document.getElementById('upload-preview');
if (selectedFiles.length === 0) {
preview.innerHTML = '';
return;
}
const fileList = document.createElement('div');
fileList.className = 'file-list-preview';
const summary = document.createElement('div');
summary.style.marginBottom = '0.5rem';
summary.innerHTML = `<strong>${selectedFiles.length} files selected</strong>`;
fileList.appendChild(summary);
selectedFiles.forEach((file, index) => {
const item = document.createElement('div');
item.className = 'file-list-item';
const icon = getFileIcon(file.name);
const path = file.webkitRelativePath || file.name;
item.innerHTML = `
<div class="file-list-item-name">
<i class="ti ti-${icon}"></i>
<span title="${path}">${path}</span>
</div>
<span class="file-list-item-size">${formatFileSize(file.size)}</span>
`;
fileList.appendChild(item);
});
preview.innerHTML = '';
preview.appendChild(fileList);
}
function getFileIcon(filename) {
const ext = filename.split('.').pop().toLowerCase();
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg'].includes(ext)) return 'photo';
if (['md', 'markdown'].includes(ext)) return 'markdown';
if (['txt'].includes(ext)) return 'file-text';
if (['pdf'].includes(ext)) return 'file-type-pdf';
if (['doc', 'docx'].includes(ext)) return 'file-type-doc';
return 'file';
}
// Drag and drop
const fileLabel = document.getElementById('file-input-label');
fileLabel.addEventListener('dragover', function(e) {
e.preventDefault();
this.classList.add('drag-over');
});
fileLabel.addEventListener('dragleave', function(e) {
e.preventDefault();
this.classList.remove('drag-over');
});
fileLabel.addEventListener('drop', function(e) {
e.preventDefault();
this.classList.remove('drag-over');
const files = Array.from(e.dataTransfer.files);
selectedFiles = files.filter(file => {
const ext = file.name.split('.').pop().toLowerCase();
return ['md', 'markdown', 'jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'txt', 'pdf', 'doc', 'docx'].includes(ext);
});
displayFilePreview();
});
// Handle upload form submission
document.getElementById('upload-form').addEventListener('submit', async function(e) {
e.preventDefault();
if (selectedFiles.length === 0) {
alert('Please select files to upload');
return;
}
const submitBtn = this.querySelector('button[type="submit"]');
const progressDiv = document.getElementById('upload-progress');
const progressFill = document.getElementById('progress-fill');
const progressText = document.getElementById('progress-text');
// Disable submit button and show progress
submitBtn.disabled = true;
progressDiv.style.display = 'block';
let successCount = 0;
let errorCount = 0;
const errors = [];
// Upload files one by one
for (let i = 0; i < selectedFiles.length; i++) {
const file = selectedFiles[i];
const formData = new FormData();
// Add file
formData.append('file', file);
// Add folder path from webkitRelativePath if available
if (file.webkitRelativePath) {
const pathParts = file.webkitRelativePath.split('/');
if (pathParts.length > 1) {
// Remove filename, keep folder path
pathParts.pop();
const folderPath = pathParts.join('/');
// Combine with base folder if specified
const baseFolder = document.getElementById('upload-folder').value;
if (baseFolder) {
formData.append('folder', baseFolder + '/' + folderPath);
} else {
formData.append('folder', folderPath);
}
} else {
// Just use base folder
const folder = document.getElementById('upload-folder').value;
if (folder) formData.append('folder', folder);
}
} else {
// No webkitRelativePath, just use base folder
const folder = document.getElementById('upload-folder').value;
if (folder) formData.append('folder', folder);
}
// Add tags if specified
const tags = document.getElementById('upload-tags').value;
if (tags) formData.append('tags', tags);
// Update progress
const progress = ((i + 1) / selectedFiles.length) * 100;
progressFill.style.width = progress + '%';
progressText.textContent = `Uploading ${i + 1} of ${selectedFiles.length}: ${file.name}`;
try {
const response = await fetch('/api/notes/upload', {
method: 'POST',
body: formData
});
const data = await response.json();
if (data.success) {
successCount++;
} else {
errorCount++;
errors.push(`${file.name}: ${data.error || 'Unknown error'}`);
}
} catch (error) {
errorCount++;
errors.push(`${file.name}: Network error`);
}
}
// Show results
if (errorCount === 0) {
progressText.textContent = `Successfully uploaded ${successCount} files!`;
setTimeout(() => {
window.location.reload();
}, 1000);
} else {
progressText.textContent = `Uploaded ${successCount} files, ${errorCount} failed`;
if (errors.length > 0) {
alert('Failed uploads:\n' + errors.join('\n'));
}
submitBtn.disabled = false;
}
});
function formatFileSize(bytes) {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}
// Close modal when clicking outside
window.addEventListener('click', function(e) {
const modal = document.getElementById('upload-modal');
if (e.target === modal) {
hideUploadModal();
}
});
// Selection Management
let selectedNotes = new Set();
function updateSelectionUI() {
const count = selectedNotes.size;
document.getElementById('selected-count').textContent = count;
document.getElementById('move-count').textContent = count;
const bulkActionsBar = document.getElementById('bulk-actions-bar');
if (count > 0) {
bulkActionsBar.classList.add('active');
} else {
bulkActionsBar.classList.remove('active');
}
// Update visual state of cards/rows
document.querySelectorAll('.note-card, .note-row').forEach(el => {
const noteId = el.dataset.noteId;
if (selectedNotes.has(noteId)) {
el.classList.add('selected');
} else {
el.classList.remove('selected');
}
});
// Update select all checkbox state
const totalCheckboxes = document.querySelectorAll('.note-checkbox').length;
const selectAllCheckbox = document.getElementById('select-all');
const selectAllTableCheckbox = document.getElementById('select-all-table');
if (selectedNotes.size === totalCheckboxes && totalCheckboxes > 0) {
if (selectAllCheckbox) selectAllCheckbox.checked = true;
if (selectAllTableCheckbox) selectAllTableCheckbox.checked = true;
} else if (selectedNotes.size === 0) {
if (selectAllCheckbox) selectAllCheckbox.checked = false;
if (selectAllTableCheckbox) selectAllTableCheckbox.checked = false;
} else {
if (selectAllCheckbox) selectAllCheckbox.indeterminate = true;
if (selectAllTableCheckbox) selectAllTableCheckbox.indeterminate = true;
}
}
// Individual checkbox handling
document.addEventListener('change', function(e) {
if (e.target.classList.contains('note-checkbox')) {
const noteId = e.target.dataset.noteId;
if (e.target.checked) {
selectedNotes.add(noteId);
} else {
selectedNotes.delete(noteId);
}
updateSelectionUI();
}
});
// Select all handling
document.getElementById('select-all').addEventListener('change', function(e) {
if (e.target.checked) {
document.querySelectorAll('.note-checkbox').forEach(cb => {
cb.checked = true;
selectedNotes.add(cb.dataset.noteId);
});
} else {
document.querySelectorAll('.note-checkbox').forEach(cb => {
cb.checked = false;
});
selectedNotes.clear();
}
updateSelectionUI();
});
// Select all table handling
const selectAllTable = document.getElementById('select-all-table');
if (selectAllTable) {
selectAllTable.addEventListener('change', function(e) {
if (e.target.checked) {
document.querySelectorAll('.note-checkbox').forEach(cb => {
cb.checked = true;
selectedNotes.add(cb.dataset.noteId);
});
} else {
document.querySelectorAll('.note-checkbox').forEach(cb => {
cb.checked = false;
});
selectedNotes.clear();
}
updateSelectionUI();
});
}
// Bulk actions
document.getElementById('bulk-move-btn').addEventListener('click', function() {
if (selectedNotes.size === 0) {
alert('Please select at least one note.');
return;
}
document.getElementById('move-modal').classList.add('active');
});
document.getElementById('bulk-delete-btn').addEventListener('click', function() {
if (selectedNotes.size === 0) {
alert('Please select at least one note.');
return;
}
const count = selectedNotes.size;
if (confirm(`Are you sure you want to delete ${count} note(s)? This action cannot be undone.`)) {
bulkDelete();
}
});
// Move modal functions
function closeMoveModal() {
document.getElementById('move-modal').classList.remove('active');
}
function confirmMove() {
const folder = document.getElementById('move-folder-select').value;
bulkMove(folder);
}
// API calls
async function bulkMove(folder) {
try {
const response = await fetch('/api/notes/bulk-move', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
note_ids: Array.from(selectedNotes),
folder: folder
})
});
const data = await response.json();
if (data.success) {
window.location.reload();
} else {
alert('Error moving notes: ' + (data.error || 'Unknown error'));
}
} catch (error) {
alert('Error moving notes: ' + error.message);
}
}
async function bulkDelete() {
try {
const response = await fetch('/api/notes/bulk-delete', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
note_ids: Array.from(selectedNotes)
})
});
const data = await response.json();
if (data.success) {
window.location.reload();
} else {
alert('Error deleting notes: ' + (data.error || 'Unknown error'));
}
} catch (error) {
alert('Error deleting notes: ' + error.message);
}
}
// Close move modal when clicking outside
window.addEventListener('click', function(e) {
const moveModal = document.getElementById('move-modal');
if (e.target === moveModal) {
closeMoveModal();
}
});
</script>
{% endblock %}