Changes First Version
This commit is contained in:
1 parent
42660a1f9c
commit
83a79dd346
4 files changed
+726
-288
No files matched your search
+353
-74
@@ -8,6 +8,7 @@ class Task {
|
|||||||
this.size = size;
|
this.size = size;
|
||||||
this.reward = reward;
|
this.reward = reward;
|
||||||
this.completed = false;
|
this.completed = false;
|
||||||
|
this.expandDescription = false;
|
||||||
this.subtasks = [];
|
this.subtasks = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +34,8 @@ class Task {
|
|||||||
class App {
|
class App {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.tasks = [];
|
this.tasks = [];
|
||||||
|
this.archivedTasks = [];
|
||||||
|
this.viewMode = 'active'; // 'active' or 'archive'
|
||||||
this.draggedTask = null;
|
this.draggedTask = null;
|
||||||
this.draggedSubtask = null;
|
this.draggedSubtask = null;
|
||||||
this.draggedParent = null;
|
this.draggedParent = null;
|
||||||
@@ -47,6 +50,7 @@ class App {
|
|||||||
async init() {
|
async init() {
|
||||||
this.setupEventListeners();
|
this.setupEventListeners();
|
||||||
await this.loadTasks();
|
await this.loadTasks();
|
||||||
|
await this.loadArchivedCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
setupEventListeners() {
|
setupEventListeners() {
|
||||||
@@ -64,20 +68,50 @@ class App {
|
|||||||
if (e.target === modal) this.toggleModal(false);
|
if (e.target === modal) this.toggleModal(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Context menu actions
|
||||||
document.getElementById('context-edit').addEventListener('click', () => this.handleContextEdit());
|
document.getElementById('context-edit').addEventListener('click', () => this.handleContextEdit());
|
||||||
document.getElementById('context-delete').addEventListener('click', () => this.handleContextDelete());
|
document.getElementById('context-delete').addEventListener('click', () => this.handleContextDelete());
|
||||||
document.getElementById('context-promote').addEventListener('click', () => this.handleContextPromote());
|
document.getElementById('context-promote').addEventListener('click', () => this.handleContextPromote());
|
||||||
|
document.getElementById('context-archive').addEventListener('click', () => this.handleContextArchive());
|
||||||
|
document.getElementById('context-restore').addEventListener('click', () => this.handleContextRestore());
|
||||||
|
|
||||||
document.addEventListener('click', () => this.hideContextMenu());
|
document.addEventListener('click', () => this.hideContextMenu());
|
||||||
contextMenu.addEventListener('click', (e) => e.stopPropagation());
|
contextMenu.addEventListener('click', (e) => e.stopPropagation());
|
||||||
|
|
||||||
|
// View toggle
|
||||||
|
document.getElementById('view-active').addEventListener('click', () => this.switchView('active'));
|
||||||
|
document.getElementById('view-archive').addEventListener('click', () => this.switchView('archive'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── View Switching ───
|
||||||
|
|
||||||
|
async switchView(mode) {
|
||||||
|
if (this.viewMode === mode) return;
|
||||||
|
this.viewMode = mode;
|
||||||
|
|
||||||
|
document.getElementById('view-active').classList.toggle('active', mode === 'active');
|
||||||
|
document.getElementById('view-archive').classList.toggle('active', mode === 'archive');
|
||||||
|
|
||||||
|
// Show/hide elements based on view
|
||||||
|
document.getElementById('overall-progress').classList.toggle('hidden', mode === 'archive');
|
||||||
|
document.getElementById('open-modal').style.display = mode === 'archive' ? 'none' : '';
|
||||||
|
|
||||||
|
if (mode === 'archive') {
|
||||||
|
await this.loadArchivedTasks();
|
||||||
|
} else {
|
||||||
|
await this.loadTasks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Modal ───
|
||||||
|
|
||||||
openCreateModal() {
|
openCreateModal() {
|
||||||
document.getElementById('modal-title').textContent = 'Create New Goal';
|
document.getElementById('modal-title').textContent = 'Create New Goal';
|
||||||
document.getElementById('submit-btn').textContent = 'Add Goal';
|
document.getElementById('submit-btn').textContent = 'Add Goal';
|
||||||
document.getElementById('task-form').reset();
|
document.getElementById('task-form').reset();
|
||||||
document.getElementById('edit-task-id').value = '';
|
document.getElementById('edit-task-id').value = '';
|
||||||
document.getElementById('edit-parent-id').value = '';
|
document.getElementById('edit-parent-id').value = '';
|
||||||
|
document.getElementById('task-expand-desc').checked = false;
|
||||||
this.toggleModal(true);
|
this.toggleModal(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,42 +124,42 @@ class App {
|
|||||||
document.getElementById('task-description').value = task.description || '';
|
document.getElementById('task-description').value = task.description || '';
|
||||||
document.getElementById('task-size').value = task.size;
|
document.getElementById('task-size').value = task.size;
|
||||||
document.getElementById('task-reward').value = task.reward || '';
|
document.getElementById('task-reward').value = task.reward || '';
|
||||||
|
document.getElementById('task-expand-desc').checked = !!task.expandDescription;
|
||||||
this.toggleModal(true);
|
this.toggleModal(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleModal(open) {
|
toggleModal(open) {
|
||||||
const modal = document.getElementById('modal');
|
const modal = document.getElementById('modal');
|
||||||
if (open) {
|
if (open) modal.classList.add('open');
|
||||||
modal.classList.add('open');
|
else modal.classList.remove('open');
|
||||||
} else {
|
|
||||||
modal.classList.remove('open');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Context Menu ───
|
||||||
|
|
||||||
showContextMenu(e, target, type, parentTask = null) {
|
showContextMenu(e, target, type, parentTask = null) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
const contextMenu = document.getElementById('context-menu');
|
const contextMenu = document.getElementById('context-menu');
|
||||||
const promoteOption = document.getElementById('context-promote');
|
const promoteOption = document.getElementById('context-promote');
|
||||||
|
const archiveOption = document.getElementById('context-archive');
|
||||||
|
const restoreOption = document.getElementById('context-restore');
|
||||||
|
|
||||||
this.contextMenuTarget = target;
|
this.contextMenuTarget = target;
|
||||||
this.contextMenuType = type;
|
this.contextMenuType = type;
|
||||||
this.contextMenuParent = parentTask;
|
this.contextMenuParent = parentTask;
|
||||||
|
|
||||||
// Show "Promote to Task" only for subtasks
|
// Show/hide context-specific options
|
||||||
if (type === 'subtask') {
|
promoteOption.style.display = (type === 'subtask' && this.viewMode === 'active') ? 'flex' : 'none';
|
||||||
promoteOption.style.display = 'block';
|
|
||||||
} else {
|
|
||||||
promoteOption.style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use clientX/clientY for fixed positioning (viewport-relative)
|
const isCompleted = target.completed || target.calculateProgress() === 100;
|
||||||
|
archiveOption.style.display = (type === 'task' && this.viewMode === 'active' && isCompleted) ? 'flex' : 'none';
|
||||||
|
restoreOption.style.display = (type === 'task' && this.viewMode === 'archive') ? 'flex' : 'none';
|
||||||
|
|
||||||
|
// Position using clientX/clientY for fixed menu, with viewport clamping
|
||||||
let x = e.clientX;
|
let x = e.clientX;
|
||||||
let y = e.clientY;
|
let y = e.clientY;
|
||||||
|
|
||||||
// Temporarily show offscreen to measure dimensions
|
|
||||||
contextMenu.style.left = '-9999px';
|
contextMenu.style.left = '-9999px';
|
||||||
contextMenu.style.top = '-9999px';
|
contextMenu.style.top = '-9999px';
|
||||||
contextMenu.classList.add('show');
|
contextMenu.classList.add('show');
|
||||||
@@ -133,13 +167,8 @@ class App {
|
|||||||
const menuWidth = contextMenu.offsetWidth;
|
const menuWidth = contextMenu.offsetWidth;
|
||||||
const menuHeight = contextMenu.offsetHeight;
|
const menuHeight = contextMenu.offsetHeight;
|
||||||
|
|
||||||
// Clamp to viewport boundaries
|
if (x + menuWidth > window.innerWidth) x = window.innerWidth - menuWidth - 5;
|
||||||
if (x + menuWidth > window.innerWidth) {
|
if (y + menuHeight > window.innerHeight) y = window.innerHeight - menuHeight - 5;
|
||||||
x = window.innerWidth - menuWidth - 5;
|
|
||||||
}
|
|
||||||
if (y + menuHeight > window.innerHeight) {
|
|
||||||
y = window.innerHeight - menuHeight - 5;
|
|
||||||
}
|
|
||||||
if (x < 0) x = 5;
|
if (x < 0) x = 5;
|
||||||
if (y < 0) y = 5;
|
if (y < 0) y = 5;
|
||||||
|
|
||||||
@@ -161,7 +190,8 @@ class App {
|
|||||||
async handleContextDelete() {
|
async handleContextDelete() {
|
||||||
if (!this.contextMenuTarget) return;
|
if (!this.contextMenuTarget) return;
|
||||||
|
|
||||||
if (!confirm('Delete this ' + (this.contextMenuType === 'task' ? 'task' : 'subtask') + '?')) {
|
const label = this.contextMenuType === 'task' ? 'task' : 'subtask';
|
||||||
|
if (!confirm(`Delete this ${label}?`)) {
|
||||||
this.hideContextMenu();
|
this.hideContextMenu();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -181,8 +211,7 @@ class App {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove from parent's subtasks
|
const parentTask = this.getCurrentTasks().find(t => t.id === this.contextMenuParent.id);
|
||||||
const parentTask = this.tasks.find(t => t.id === this.contextMenuParent.id);
|
|
||||||
if (!parentTask) {
|
if (!parentTask) {
|
||||||
this.hideContextMenu();
|
this.hideContextMenu();
|
||||||
return;
|
return;
|
||||||
@@ -192,14 +221,12 @@ class App {
|
|||||||
parentTask.subtasks = parentTask.subtasks.filter(st => st.id !== subtask.id);
|
parentTask.subtasks = parentTask.subtasks.filter(st => st.id !== subtask.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Update parent task
|
|
||||||
await fetch(`${API_URL}/tasks/${parentTask.id}`, {
|
await fetch(`${API_URL}/tasks/${parentTask.id}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(parentTask)
|
body: JSON.stringify(parentTask)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create new top-level task
|
|
||||||
await fetch(`${API_URL}/tasks`, {
|
await fetch(`${API_URL}/tasks`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
@@ -219,6 +246,26 @@ class App {
|
|||||||
this.hideContextMenu();
|
this.hideContextMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async handleContextArchive() {
|
||||||
|
if (!this.contextMenuTarget || this.contextMenuType !== 'task') {
|
||||||
|
this.hideContextMenu();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await this.archiveTask(this.contextMenuTarget.id);
|
||||||
|
this.hideContextMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
async handleContextRestore() {
|
||||||
|
if (!this.contextMenuTarget || this.contextMenuType !== 'task') {
|
||||||
|
this.hideContextMenu();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await this.unarchiveTask(this.contextMenuTarget.id);
|
||||||
|
this.hideContextMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Form Submit ───
|
||||||
|
|
||||||
async handleSubmit(e) {
|
async handleSubmit(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -226,13 +273,15 @@ class App {
|
|||||||
const description = document.getElementById('task-description').value.trim();
|
const description = document.getElementById('task-description').value.trim();
|
||||||
const size = document.getElementById('task-size').value;
|
const size = document.getElementById('task-size').value;
|
||||||
const reward = document.getElementById('task-reward').value.trim();
|
const reward = document.getElementById('task-reward').value.trim();
|
||||||
|
const expandDescription = document.getElementById('task-expand-desc').checked;
|
||||||
const editId = document.getElementById('edit-task-id').value;
|
const editId = document.getElementById('edit-task-id').value;
|
||||||
const parentId = document.getElementById('edit-parent-id').value;
|
const parentId = document.getElementById('edit-parent-id').value;
|
||||||
|
|
||||||
|
const taskList = this.getCurrentTasks();
|
||||||
|
|
||||||
if (editId) {
|
if (editId) {
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
// Editing a subtask
|
const parentTask = taskList.find(t => t.id === parentId);
|
||||||
const parentTask = this.tasks.find(t => t.id === parentId);
|
|
||||||
if (parentTask) {
|
if (parentTask) {
|
||||||
const subtask = parentTask.subtasks.find(st => st.id === editId);
|
const subtask = parentTask.subtasks.find(st => st.id === editId);
|
||||||
if (subtask) {
|
if (subtask) {
|
||||||
@@ -240,29 +289,28 @@ class App {
|
|||||||
subtask.description = description;
|
subtask.description = description;
|
||||||
subtask.size = size;
|
subtask.size = size;
|
||||||
subtask.reward = reward;
|
subtask.reward = reward;
|
||||||
|
subtask.expandDescription = expandDescription;
|
||||||
await this.updateTask(parentTask);
|
await this.updateTask(parentTask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Editing a main task
|
const task = taskList.find(t => t.id === editId);
|
||||||
const task = this.tasks.find(t => t.id === editId);
|
|
||||||
if (task) {
|
if (task) {
|
||||||
task.title = title;
|
task.title = title;
|
||||||
task.description = description;
|
task.description = description;
|
||||||
task.size = size;
|
task.size = size;
|
||||||
task.reward = reward;
|
task.reward = reward;
|
||||||
|
task.expandDescription = expandDescription;
|
||||||
await this.updateTask(task);
|
await this.updateTask(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Creating new task
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${API_URL}/tasks`, {
|
const response = await fetch(`${API_URL}/tasks`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ title, description, size, reward })
|
body: JSON.stringify({ title, description, size, reward, expandDescription })
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) await this.loadTasks();
|
if (response.ok) await this.loadTasks();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating task:', error);
|
console.error('Error creating task:', error);
|
||||||
@@ -273,6 +321,12 @@ class App {
|
|||||||
this.toggleModal(false);
|
this.toggleModal(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Data Loading ───
|
||||||
|
|
||||||
|
getCurrentTasks() {
|
||||||
|
return this.viewMode === 'archive' ? this.archivedTasks : this.tasks;
|
||||||
|
}
|
||||||
|
|
||||||
async loadTasks() {
|
async loadTasks() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${API_URL}/tasks`);
|
const response = await fetch(`${API_URL}/tasks`);
|
||||||
@@ -281,26 +335,77 @@ class App {
|
|||||||
this.tasks = data.map(taskData => {
|
this.tasks = data.map(taskData => {
|
||||||
const task = new Task(taskData.id, taskData.title, taskData.description, taskData.size, taskData.reward);
|
const task = new Task(taskData.id, taskData.title, taskData.description, taskData.size, taskData.reward);
|
||||||
task.completed = taskData.completed;
|
task.completed = taskData.completed;
|
||||||
|
task.expandDescription = !!taskData.expandDescription;
|
||||||
if (taskData.subtasks && Array.isArray(taskData.subtasks)) {
|
if (taskData.subtasks && Array.isArray(taskData.subtasks)) {
|
||||||
task.subtasks = taskData.subtasks.map(stData => {
|
task.subtasks = taskData.subtasks.map(stData => {
|
||||||
const subtask = new Task(stData.id, stData.title, stData.description, stData.size, stData.reward);
|
const subtask = new Task(stData.id, stData.title, stData.description, stData.size, stData.reward);
|
||||||
subtask.completed = stData.completed;
|
subtask.completed = stData.completed;
|
||||||
|
subtask.expandDescription = !!stData.expandDescription;
|
||||||
return subtask;
|
return subtask;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return task;
|
return task;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.updateOverallProgress();
|
this.updateOverallProgress();
|
||||||
this.render();
|
if (this.viewMode === 'active') this.render();
|
||||||
|
this.loadArchivedCount();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading tasks:', error);
|
console.error('Error loading tasks:', error);
|
||||||
this.showError();
|
this.showError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async loadArchivedTasks() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_URL}/tasks?archived=1`);
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
this.archivedTasks = data.map(taskData => {
|
||||||
|
const task = new Task(taskData.id, taskData.title, taskData.description, taskData.size, taskData.reward);
|
||||||
|
task.completed = taskData.completed;
|
||||||
|
task.expandDescription = !!taskData.expandDescription;
|
||||||
|
if (taskData.subtasks && Array.isArray(taskData.subtasks)) {
|
||||||
|
task.subtasks = taskData.subtasks.map(stData => {
|
||||||
|
const subtask = new Task(stData.id, stData.title, stData.description, stData.size, stData.reward);
|
||||||
|
subtask.completed = stData.completed;
|
||||||
|
subtask.expandDescription = !!stData.expandDescription;
|
||||||
|
return subtask;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return task;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.viewMode === 'archive') this.renderArchive();
|
||||||
|
this.updateArchiveCount();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error loading archived tasks:', error);
|
||||||
|
this.showError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async loadArchivedCount() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_URL}/tasks?archived=1`);
|
||||||
|
const data = await response.json();
|
||||||
|
this.archivedTasks = data.map(taskData => {
|
||||||
|
const task = new Task(taskData.id, taskData.title, taskData.description, taskData.size, taskData.reward);
|
||||||
|
task.completed = taskData.completed;
|
||||||
|
return task;
|
||||||
|
});
|
||||||
|
this.updateArchiveCount();
|
||||||
|
} catch (error) {
|
||||||
|
// Silently fail — count is non-critical
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateArchiveCount() {
|
||||||
|
const badge = document.getElementById('archive-count');
|
||||||
|
const count = this.archivedTasks.length;
|
||||||
|
badge.textContent = count;
|
||||||
|
badge.style.display = count > 0 ? 'inline-block' : 'none';
|
||||||
|
}
|
||||||
|
|
||||||
updateOverallProgress() {
|
updateOverallProgress() {
|
||||||
const totalTasks = this.tasks.length;
|
const totalTasks = this.tasks.length;
|
||||||
const completedTasks = this.tasks.filter(t => t.calculateProgress() === 100).length;
|
const completedTasks = this.tasks.filter(t => t.calculateProgress() === 100).length;
|
||||||
@@ -321,36 +426,37 @@ class App {
|
|||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
const overallProgress = totalWeight > 0 ? Math.round((completedWeight / totalWeight) * 100) : 0;
|
const overallProgress = totalWeight > 0 ? Math.round((completedWeight / totalWeight) * 100) : 0;
|
||||||
|
|
||||||
document.getElementById('overall-percentage').textContent = overallProgress + '%';
|
document.getElementById('overall-percentage').textContent = overallProgress + '%';
|
||||||
document.getElementById('overall-progress-fill').style.width = overallProgress + '%';
|
document.getElementById('overall-progress-fill').style.width = overallProgress + '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Task Actions ───
|
||||||
|
|
||||||
async deleteTask(taskId) {
|
async deleteTask(taskId) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${API_URL}/tasks/${taskId}`, { method: 'DELETE' });
|
const response = await fetch(`${API_URL}/tasks/${taskId}`, { method: 'DELETE' });
|
||||||
if (response.ok) await this.loadTasks();
|
if (response.ok) {
|
||||||
|
if (this.viewMode === 'archive') await this.loadArchivedTasks();
|
||||||
|
else await this.loadTasks();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting task:', error);
|
console.error('Error deleting task:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async toggleTaskComplete(taskId) {
|
async toggleTaskComplete(taskId) {
|
||||||
const task = this.tasks.find(t => t.id === taskId);
|
const task = this.getCurrentTasks().find(t => t.id === taskId);
|
||||||
if (!task) return;
|
if (!task) return;
|
||||||
|
|
||||||
task.completed = !task.completed;
|
task.completed = !task.completed;
|
||||||
|
|
||||||
// When completing or uncompleting a task, also update all subtasks
|
|
||||||
if (task.subtasks.length > 0) {
|
if (task.subtasks.length > 0) {
|
||||||
task.subtasks.forEach(st => st.completed = task.completed);
|
task.subtasks.forEach(st => st.completed = task.completed);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.updateTask(task);
|
await this.updateTask(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
async toggleSubtaskComplete(taskId, subtaskId) {
|
async toggleSubtaskComplete(taskId, subtaskId) {
|
||||||
const task = this.tasks.find(t => t.id === taskId);
|
const task = this.getCurrentTasks().find(t => t.id === taskId);
|
||||||
if (!task) return;
|
if (!task) return;
|
||||||
|
|
||||||
const subtask = task.subtasks.find(st => st.id === subtaskId);
|
const subtask = task.subtasks.find(st => st.id === subtaskId);
|
||||||
@@ -361,7 +467,7 @@ class App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async deleteSubtask(taskId, subtaskId) {
|
async deleteSubtask(taskId, subtaskId) {
|
||||||
const task = this.tasks.find(t => t.id === taskId);
|
const task = this.getCurrentTasks().find(t => t.id === taskId);
|
||||||
if (!task) return;
|
if (!task) return;
|
||||||
|
|
||||||
task.subtasks = task.subtasks.filter(st => st.id !== subtaskId);
|
task.subtasks = task.subtasks.filter(st => st.id !== subtaskId);
|
||||||
@@ -375,12 +481,41 @@ class App {
|
|||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(task)
|
body: JSON.stringify(task)
|
||||||
});
|
});
|
||||||
if (response.ok) await this.loadTasks();
|
if (response.ok) {
|
||||||
|
if (this.viewMode === 'archive') await this.loadArchivedTasks();
|
||||||
|
else await this.loadTasks();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating task:', error);
|
console.error('Error updating task:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async archiveTask(taskId) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_URL}/tasks/${taskId}/archive`, { method: 'PUT' });
|
||||||
|
if (response.ok) {
|
||||||
|
await this.loadTasks();
|
||||||
|
await this.loadArchivedCount();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error archiving task:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async unarchiveTask(taskId) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_URL}/tasks/${taskId}/unarchive`, { method: 'PUT' });
|
||||||
|
if (response.ok) {
|
||||||
|
await this.loadArchivedTasks();
|
||||||
|
await this.loadTasks();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error restoring task:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Drag & Drop ───
|
||||||
|
|
||||||
handleDragStart(e, item, isSubtask = false, parentTask = null, index = null) {
|
handleDragStart(e, item, isSubtask = false, parentTask = null, index = null) {
|
||||||
if (isSubtask) {
|
if (isSubtask) {
|
||||||
this.draggedSubtask = item;
|
this.draggedSubtask = item;
|
||||||
@@ -424,9 +559,7 @@ class App {
|
|||||||
|
|
||||||
handleDragEnter(e, taskId) {
|
handleDragEnter(e, taskId) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!this.draggedTask && !this.draggedSubtask) return;
|
if (!this.draggedTask && !this.draggedSubtask) return;
|
||||||
|
|
||||||
if (this.dropZoneTimer) clearTimeout(this.dropZoneTimer);
|
if (this.dropZoneTimer) clearTimeout(this.dropZoneTimer);
|
||||||
|
|
||||||
this.dropZoneTimer = setTimeout(() => {
|
this.dropZoneTimer = setTimeout(() => {
|
||||||
@@ -443,7 +576,6 @@ class App {
|
|||||||
e.currentTarget.classList.remove('drag-over');
|
e.currentTarget.classList.remove('drag-over');
|
||||||
|
|
||||||
if (this.draggedTask && this.draggedTask.id !== targetTask.id) {
|
if (this.draggedTask && this.draggedTask.id !== targetTask.id) {
|
||||||
// Move task as subtask
|
|
||||||
targetTask.subtasks.push(this.draggedTask);
|
targetTask.subtasks.push(this.draggedTask);
|
||||||
try {
|
try {
|
||||||
await fetch(`${API_URL}/tasks/${this.draggedTask.id}`, { method: 'DELETE' });
|
await fetch(`${API_URL}/tasks/${this.draggedTask.id}`, { method: 'DELETE' });
|
||||||
@@ -452,7 +584,6 @@ class App {
|
|||||||
console.error('Error moving task:', error);
|
console.error('Error moving task:', error);
|
||||||
}
|
}
|
||||||
} else if (this.draggedSubtask && this.draggedParent && targetTask.id !== this.draggedParent.id) {
|
} else if (this.draggedSubtask && this.draggedParent && targetTask.id !== this.draggedParent.id) {
|
||||||
// Move subtask between different parent tasks
|
|
||||||
this.draggedParent.subtasks = this.draggedParent.subtasks.filter(st => st.id !== this.draggedSubtask.id);
|
this.draggedParent.subtasks = this.draggedParent.subtasks.filter(st => st.id !== this.draggedSubtask.id);
|
||||||
targetTask.subtasks.push(this.draggedSubtask);
|
targetTask.subtasks.push(this.draggedSubtask);
|
||||||
try {
|
try {
|
||||||
@@ -499,7 +630,6 @@ class App {
|
|||||||
if (this.draggedParent.id !== parentTask.id) return;
|
if (this.draggedParent.id !== parentTask.id) return;
|
||||||
if (this.draggedSubtaskIndex === targetIndex) return;
|
if (this.draggedSubtaskIndex === targetIndex) return;
|
||||||
|
|
||||||
// Reorder within same parent
|
|
||||||
const currentIndex = this.draggedSubtaskIndex;
|
const currentIndex = this.draggedSubtaskIndex;
|
||||||
const subtask = parentTask.subtasks[currentIndex];
|
const subtask = parentTask.subtasks[currentIndex];
|
||||||
|
|
||||||
@@ -509,6 +639,8 @@ class App {
|
|||||||
await this.updateTask(parentTask);
|
await this.updateTask(parentTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Render: Active Tasks ───
|
||||||
|
|
||||||
renderTask(task, index) {
|
renderTask(task, index) {
|
||||||
const progress = task.calculateProgress();
|
const progress = task.calculateProgress();
|
||||||
const isCompleted = progress === 100 || task.completed;
|
const isCompleted = progress === 100 || task.completed;
|
||||||
@@ -518,6 +650,7 @@ class App {
|
|||||||
card.draggable = true;
|
card.draggable = true;
|
||||||
card.setAttribute('data-task-id', task.id);
|
card.setAttribute('data-task-id', task.id);
|
||||||
|
|
||||||
|
// Drag events
|
||||||
card.addEventListener('dragstart', (e) => this.handleDragStart(e, task, false));
|
card.addEventListener('dragstart', (e) => this.handleDragStart(e, task, false));
|
||||||
card.addEventListener('dragend', (e) => this.handleDragEnd(e));
|
card.addEventListener('dragend', (e) => this.handleDragEnd(e));
|
||||||
card.addEventListener('dragover', (e) => this.handleCardDragOver(e));
|
card.addEventListener('dragover', (e) => this.handleCardDragOver(e));
|
||||||
@@ -535,27 +668,31 @@ class App {
|
|||||||
this.showContextMenu(e, task, 'task');
|
this.showContextMenu(e, task, 'task');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
card.addEventListener('dblclick', (e) => {
|
||||||
|
if (!e.target.closest('.subtask') && !e.target.closest('button')) {
|
||||||
|
this.openEditModal(task);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const descClass = task.expandDescription ? 'task-description expanded' : 'task-description';
|
||||||
|
|
||||||
card.innerHTML = `
|
card.innerHTML = `
|
||||||
<div class="task-header">
|
<div class="task-header">
|
||||||
<div class="task-title">${this.escapeHtml(task.title)}</div>
|
<div class="task-title">${this.escapeHtml(task.title)}</div>
|
||||||
<div class="task-size-badge ${task.size}">${task.size}</div>
|
<div class="task-meta">
|
||||||
|
<div class="task-size-badge ${task.size}">${task.size}</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
${task.description ? `<div class="task-description">${this.escapeHtml(task.description)}</div>` : ''}
|
${task.description ? `<div class="${descClass}">${this.escapeHtml(task.description)}</div>` : ''}
|
||||||
<div class="progress-section">
|
<div class="progress-row">
|
||||||
<div class="progress-label">
|
|
||||||
<span>Progress</span>
|
|
||||||
<span>${progress}%</span>
|
|
||||||
</div>
|
|
||||||
<div class="progress-bar">
|
<div class="progress-bar">
|
||||||
<div class="progress-fill" style="width: ${progress}%">
|
<div class="progress-fill" style="width: ${progress}%"></div>
|
||||||
${progress > 15 ? progress + '%' : ''}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="progress-text">${progress}%</div>
|
||||||
</div>
|
</div>
|
||||||
${task.reward ? `
|
${task.reward ? `
|
||||||
<div class="reward-section">
|
<div class="reward-section">
|
||||||
<strong>🎁 Reward:</strong>
|
<span>🎁</span>
|
||||||
${isCompleted
|
${isCompleted
|
||||||
? `<span class="reward-revealed">${this.escapeHtml(task.reward)}</span>`
|
? `<span class="reward-revealed">${this.escapeHtml(task.reward)}</span>`
|
||||||
: `<span class="reward-hidden">Complete to reveal</span>`
|
: `<span class="reward-hidden">Complete to reveal</span>`
|
||||||
@@ -566,6 +703,7 @@ class App {
|
|||||||
<button class="btn-small btn-complete" onclick="app.toggleTaskComplete('${task.id}')">
|
<button class="btn-small btn-complete" onclick="app.toggleTaskComplete('${task.id}')">
|
||||||
${task.completed ? 'Undo' : 'Complete'}
|
${task.completed ? 'Undo' : 'Complete'}
|
||||||
</button>
|
</button>
|
||||||
|
${isCompleted ? `<button class="btn-small btn-archive" onclick="app.archiveTask('${task.id}')">Archive</button>` : ''}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -574,7 +712,7 @@ class App {
|
|||||||
card.appendChild(this.renderSubtasks(task));
|
card.appendChild(this.renderSubtasks(task));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add drop zone
|
// Drop zone
|
||||||
const dropZone = document.createElement('div');
|
const dropZone = document.createElement('div');
|
||||||
dropZone.className = 'drop-zone';
|
dropZone.className = 'drop-zone';
|
||||||
dropZone.textContent = 'Drop tasks here to add as subtasks';
|
dropZone.textContent = 'Drop tasks here to add as subtasks';
|
||||||
@@ -597,12 +735,10 @@ class App {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this.handleDragStart(e, subtask, true, task, index);
|
this.handleDragStart(e, subtask, true, task, index);
|
||||||
});
|
});
|
||||||
|
|
||||||
div.addEventListener('dragend', (e) => {
|
div.addEventListener('dragend', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this.handleDragEnd(e);
|
this.handleDragEnd(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
div.addEventListener('dragover', (e) => {
|
div.addEventListener('dragover', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -610,37 +746,47 @@ class App {
|
|||||||
e.currentTarget.classList.add('drag-over');
|
e.currentTarget.classList.add('drag-over');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
div.addEventListener('dragleave', (e) => {
|
div.addEventListener('dragleave', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.currentTarget.classList.remove('drag-over');
|
e.currentTarget.classList.remove('drag-over');
|
||||||
});
|
});
|
||||||
|
|
||||||
div.addEventListener('drop', (e) => {
|
div.addEventListener('drop', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this.handleSubtaskReorder(e, task, index);
|
this.handleSubtaskReorder(e, task, index);
|
||||||
});
|
});
|
||||||
|
|
||||||
div.addEventListener('contextmenu', (e) => {
|
div.addEventListener('contextmenu', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this.showContextMenu(e, subtask, 'subtask', task);
|
this.showContextMenu(e, subtask, 'subtask', task);
|
||||||
});
|
});
|
||||||
|
div.addEventListener('dblclick', (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (!e.target.closest('button')) {
|
||||||
|
this.openEditModal(subtask, task);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const progress = subtask.calculateProgress();
|
const progress = subtask.calculateProgress();
|
||||||
|
const stDescClass = subtask.expandDescription ? 'task-description expanded' : 'task-description';
|
||||||
|
|
||||||
div.innerHTML = `
|
div.innerHTML = `
|
||||||
<div class="subtask-header">
|
<div class="subtask-header">
|
||||||
<div class="subtask-title">${this.escapeHtml(subtask.title)}</div>
|
<div class="subtask-title">${this.escapeHtml(subtask.title)}</div>
|
||||||
<div class="task-size-badge ${subtask.size}">${subtask.size}</div>
|
<div class="task-size-badge ${subtask.size}">${subtask.size}</div>
|
||||||
</div>
|
</div>
|
||||||
${subtask.description ? `<div class="task-description">${this.escapeHtml(subtask.description)}</div>` : ''}
|
${subtask.description ? `<div class="${stDescClass}">${this.escapeHtml(subtask.description)}</div>` : ''}
|
||||||
<div class="subtask-progress">
|
<div class="subtask-progress-row">
|
||||||
<div class="subtask-progress-fill" style="width: ${progress}%"></div>
|
<div class="subtask-progress">
|
||||||
|
<div class="subtask-progress-fill" style="width: ${progress}%"></div>
|
||||||
|
</div>
|
||||||
|
<div class="progress-text" style="font-size:0.75em;">${progress}%</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size: 0.85em; color: #a0aec0; margin-bottom: 8px;">${progress}%</div>
|
${subtask.reward ? `
|
||||||
${subtask.reward && subtask.completed ? `
|
<div class="reward-section">
|
||||||
<div style="font-size: 0.9em; color: #68d391; margin-bottom: 8px;">
|
<span>🎁</span>
|
||||||
🎁 ${this.escapeHtml(subtask.reward)}
|
${subtask.completed
|
||||||
|
? `<span class="reward-revealed">${this.escapeHtml(subtask.reward)}</span>`
|
||||||
|
: `<span class="reward-hidden">Complete to reveal</span>`
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
` : ''}
|
` : ''}
|
||||||
<div class="subtask-actions">
|
<div class="subtask-actions">
|
||||||
@@ -675,6 +821,139 @@ class App {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── Render: Archive View ───
|
||||||
|
|
||||||
|
renderArchivedTask(task) {
|
||||||
|
const progress = task.calculateProgress();
|
||||||
|
const isCompleted = progress === 100 || task.completed;
|
||||||
|
|
||||||
|
const card = document.createElement('div');
|
||||||
|
card.className = `task-card archived-card ${isCompleted ? 'completed' : ''}`;
|
||||||
|
card.setAttribute('data-task-id', task.id);
|
||||||
|
|
||||||
|
card.addEventListener('contextmenu', (e) => {
|
||||||
|
if (!e.target.closest('.subtask')) {
|
||||||
|
this.showContextMenu(e, task, 'task');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
card.addEventListener('dblclick', (e) => {
|
||||||
|
if (!e.target.closest('.subtask') && !e.target.closest('button')) {
|
||||||
|
this.openEditModal(task);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const descClass = task.expandDescription ? 'task-description expanded' : 'task-description';
|
||||||
|
|
||||||
|
card.innerHTML = `
|
||||||
|
<div class="task-header">
|
||||||
|
<div class="task-title">${this.escapeHtml(task.title)}</div>
|
||||||
|
<div class="task-meta">
|
||||||
|
<div class="task-size-badge ${task.size}">${task.size}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
${task.description ? `<div class="${descClass}">${this.escapeHtml(task.description)}</div>` : ''}
|
||||||
|
<div class="progress-row">
|
||||||
|
<div class="progress-bar">
|
||||||
|
<div class="progress-fill" style="width: ${progress}%"></div>
|
||||||
|
</div>
|
||||||
|
<div class="progress-text">${progress}%</div>
|
||||||
|
</div>
|
||||||
|
${task.reward ? `
|
||||||
|
<div class="reward-section">
|
||||||
|
<span>🎁</span>
|
||||||
|
${isCompleted
|
||||||
|
? `<span class="reward-revealed">${this.escapeHtml(task.reward)}</span>`
|
||||||
|
: `<span class="reward-hidden">Complete to reveal</span>`
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
` : ''}
|
||||||
|
<div class="task-actions">
|
||||||
|
<button class="btn-small btn-restore" onclick="app.unarchiveTask('${task.id}')">Restore</button>
|
||||||
|
<button class="btn-small btn-delete" onclick="if(confirm('Delete permanently?')) app.deleteTask('${task.id}')">Delete</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Subtasks (read-only, no drag)
|
||||||
|
if (task.subtasks.length > 0) {
|
||||||
|
card.appendChild(this.renderArchivedSubtasks(task));
|
||||||
|
}
|
||||||
|
|
||||||
|
return card;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderArchivedSubtasks(task) {
|
||||||
|
const container = document.createElement('div');
|
||||||
|
container.className = 'subtasks-container';
|
||||||
|
|
||||||
|
task.subtasks.forEach((subtask) => {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.className = 'subtask';
|
||||||
|
div.style.cursor = 'default';
|
||||||
|
|
||||||
|
div.addEventListener('contextmenu', (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
this.showContextMenu(e, subtask, 'subtask', task);
|
||||||
|
});
|
||||||
|
div.addEventListener('dblclick', (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (!e.target.closest('button')) {
|
||||||
|
this.openEditModal(subtask, task);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const progress = subtask.calculateProgress();
|
||||||
|
const stDescClass = subtask.expandDescription ? 'task-description expanded' : 'task-description';
|
||||||
|
|
||||||
|
div.innerHTML = `
|
||||||
|
<div class="subtask-header">
|
||||||
|
<div class="subtask-title">${this.escapeHtml(subtask.title)}</div>
|
||||||
|
<div class="task-size-badge ${subtask.size}">${subtask.size}</div>
|
||||||
|
</div>
|
||||||
|
${subtask.description ? `<div class="${stDescClass}">${this.escapeHtml(subtask.description)}</div>` : ''}
|
||||||
|
<div class="subtask-progress-row">
|
||||||
|
<div class="subtask-progress">
|
||||||
|
<div class="subtask-progress-fill" style="width: ${progress}%"></div>
|
||||||
|
</div>
|
||||||
|
<div class="progress-text" style="font-size:0.75em;">${progress}%</div>
|
||||||
|
</div>
|
||||||
|
${subtask.reward ? `
|
||||||
|
<div class="reward-section">
|
||||||
|
<span>🎁</span>
|
||||||
|
${subtask.completed
|
||||||
|
? `<span class="reward-revealed">${this.escapeHtml(subtask.reward)}</span>`
|
||||||
|
: `<span class="reward-hidden">Complete to reveal</span>`
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
` : ''}
|
||||||
|
`;
|
||||||
|
|
||||||
|
container.appendChild(div);
|
||||||
|
});
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderArchive() {
|
||||||
|
const container = document.getElementById('tasks-container');
|
||||||
|
container.innerHTML = '';
|
||||||
|
|
||||||
|
if (this.archivedTasks.length === 0) {
|
||||||
|
container.innerHTML = `
|
||||||
|
<div class="empty-state">
|
||||||
|
<h2>Archive is empty</h2>
|
||||||
|
<p>Completed tasks you archive will appear here</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.archivedTasks.forEach(task => {
|
||||||
|
container.appendChild(this.renderArchivedTask(task));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Utility ───
|
||||||
|
|
||||||
showError() {
|
showError() {
|
||||||
const container = document.getElementById('tasks-container');
|
const container = document.getElementById('tasks-container');
|
||||||
container.innerHTML = `
|
container.innerHTML = `
|
||||||
|
|||||||
+21
-6
@@ -9,9 +9,11 @@
|
|||||||
<body>
|
<body>
|
||||||
<!-- Context Menu -->
|
<!-- Context Menu -->
|
||||||
<div class="context-menu" id="context-menu">
|
<div class="context-menu" id="context-menu">
|
||||||
<div class="context-menu-item" id="context-edit">✏️ Edit</div>
|
<div class="context-menu-item" id="context-edit">✎ Edit</div>
|
||||||
<div class="context-menu-item" id="context-promote" style="display: none;">⬆️ Promote to Task</div>
|
<div class="context-menu-item" id="context-promote" style="display: none;">⬆ Promote to Task</div>
|
||||||
<div class="context-menu-item danger" id="context-delete">🗑️ Delete</div>
|
<div class="context-menu-item" id="context-restore" style="display: none;">▶ Restore to Active</div>
|
||||||
|
<div class="context-menu-item" id="context-archive" style="display: none;">📦 Archive</div>
|
||||||
|
<div class="context-menu-item danger" id="context-delete">🗑 Delete</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Modal for creating/editing tasks -->
|
<!-- Modal for creating/editing tasks -->
|
||||||
@@ -33,7 +35,11 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="task-description">Description</label>
|
<label for="task-description">Description</label>
|
||||||
<textarea id="task-description" placeholder="What do you want to achieve?" rows="3"></textarea>
|
<textarea id="task-description" placeholder="What do you want to achieve?" rows="2"></textarea>
|
||||||
|
<label class="checkbox-label">
|
||||||
|
<input type="checkbox" id="task-expand-desc">
|
||||||
|
<span>Show full description on card</span>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@@ -61,10 +67,19 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<header>
|
<header>
|
||||||
<h1>Learning Progress Tracker</h1>
|
<h1>Learning Progress Tracker</h1>
|
||||||
<button class="btn-add" id="open-modal">+ New Goal</button>
|
<div class="header-actions">
|
||||||
|
<button class="btn-add" id="open-modal">+ New Goal</button>
|
||||||
|
<div class="view-toggle">
|
||||||
|
<button class="toggle-btn active" id="view-active">Active</button>
|
||||||
|
<button class="toggle-btn" id="view-archive">
|
||||||
|
Archive
|
||||||
|
<span class="archive-count" id="archive-count" style="display:none;">0</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<!-- Overall Progress - Always Visible -->
|
<!-- Overall Progress - Active view only -->
|
||||||
<div class="overall-progress" id="overall-progress">
|
<div class="overall-progress" id="overall-progress">
|
||||||
<div class="overall-header">
|
<div class="overall-header">
|
||||||
<span>Overall Progress</span>
|
<span>Overall Progress</span>
|
||||||
|
|||||||
+297
-165
@@ -8,7 +8,7 @@ body {
|
|||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
||||||
background: #0f1419;
|
background: #0f1419;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
padding: 20px;
|
padding: 16px;
|
||||||
color: #e4e6eb;
|
color: #e4e6eb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,20 +17,77 @@ body {
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ─── Header ─── */
|
||||||
header {
|
header {
|
||||||
margin-bottom: 30px;
|
margin-bottom: 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 1.8em;
|
font-size: 1.4em;
|
||||||
color: #e4e6eb;
|
color: #e4e6eb;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Context Menu */
|
.header-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ─── View Toggle ─── */
|
||||||
|
.view-toggle {
|
||||||
|
display: flex;
|
||||||
|
background: #1a2332;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid #2d3748;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-btn {
|
||||||
|
padding: 7px 16px;
|
||||||
|
font-size: 0.85em;
|
||||||
|
background: transparent;
|
||||||
|
color: #8b96a5;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
font-weight: 500;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-btn:hover {
|
||||||
|
color: #e4e6eb;
|
||||||
|
background: rgba(255,255,255,0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-btn.active {
|
||||||
|
background: #4299e1;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.archive-count {
|
||||||
|
background: rgba(255,255,255,0.2);
|
||||||
|
padding: 1px 7px;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 0.8em;
|
||||||
|
font-weight: 600;
|
||||||
|
min-width: 20px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-btn:not(.active) .archive-count {
|
||||||
|
background: #2d3748;
|
||||||
|
color: #a0aec0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ─── Context Menu ─── */
|
||||||
.context-menu {
|
.context-menu {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
background: #1e2936;
|
background: #1e2936;
|
||||||
@@ -38,8 +95,9 @@ h1 {
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
|
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
|
||||||
z-index: 2000;
|
z-index: 2000;
|
||||||
min-width: 150px;
|
min-width: 160px;
|
||||||
display: none;
|
display: none;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-menu.show {
|
.context-menu.show {
|
||||||
@@ -47,11 +105,11 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.context-menu-item {
|
.context-menu-item {
|
||||||
padding: 10px 16px;
|
padding: 9px 14px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background 0.2s;
|
transition: background 0.15s;
|
||||||
font-size: 0.9em;
|
font-size: 0.85em;
|
||||||
border-bottom: 1px solid #2d3748;
|
border-bottom: 1px solid #232e3c;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
@@ -71,7 +129,7 @@ h1 {
|
|||||||
color: #feb2b2;
|
color: #feb2b2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modal Styles */
|
/* ─── Modal ─── */
|
||||||
.modal {
|
.modal {
|
||||||
display: none;
|
display: none;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
@@ -93,7 +151,7 @@ h1 {
|
|||||||
background: #1a2332;
|
background: #1a2332;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
max-width: 500px;
|
max-width: 460px;
|
||||||
max-height: 90vh;
|
max-height: 90vh;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
|
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
|
||||||
@@ -104,12 +162,12 @@ h1 {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 20px;
|
padding: 16px 20px;
|
||||||
border-bottom: 1px solid #2d3748;
|
border-bottom: 1px solid #2d3748;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-header h2 {
|
.modal-header h2 {
|
||||||
font-size: 1.25em;
|
font-size: 1.1em;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #e4e6eb;
|
color: #e4e6eb;
|
||||||
}
|
}
|
||||||
@@ -117,11 +175,11 @@ h1 {
|
|||||||
.close-btn {
|
.close-btn {
|
||||||
background: none;
|
background: none;
|
||||||
border: none;
|
border: none;
|
||||||
font-size: 1.8em;
|
font-size: 1.6em;
|
||||||
color: #8b96a5;
|
color: #8b96a5;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: 32px;
|
width: 28px;
|
||||||
height: 32px;
|
height: 28px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -136,36 +194,36 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.modal-content form {
|
.modal-content form {
|
||||||
padding: 20px;
|
padding: 16px 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Form Styles */
|
/* ─── Form ─── */
|
||||||
.form-group {
|
.form-group {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-row {
|
.form-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
gap: 12px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 6px;
|
margin-bottom: 4px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #a0aec0;
|
color: #a0aec0;
|
||||||
font-size: 0.875em;
|
font-size: 0.82em;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="text"],
|
input[type="text"],
|
||||||
select,
|
select,
|
||||||
textarea {
|
textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 10px 12px;
|
padding: 8px 10px;
|
||||||
border: 1px solid #2d3748;
|
border: 1px solid #2d3748;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
font-size: 0.95em;
|
font-size: 0.9em;
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
background: #0f1419;
|
background: #0f1419;
|
||||||
@@ -184,12 +242,36 @@ textarea {
|
|||||||
resize: vertical;
|
resize: vertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.checkbox-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
margin-top: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.82em;
|
||||||
|
color: #a0aec0;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-label input[type="checkbox"] {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
accent-color: #4299e1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-description.expanded {
|
||||||
|
-webkit-line-clamp: unset;
|
||||||
|
display: block;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
select option {
|
select option {
|
||||||
background: #1a2332;
|
background: #1a2332;
|
||||||
color: #e4e6eb;
|
color: #e4e6eb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Button Styles */
|
/* ─── Buttons ─── */
|
||||||
button {
|
button {
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -201,8 +283,8 @@ button {
|
|||||||
|
|
||||||
.btn-primary {
|
.btn-primary {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 12px;
|
padding: 10px;
|
||||||
font-size: 1em;
|
font-size: 0.95em;
|
||||||
background: #4299e1;
|
background: #4299e1;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
@@ -212,8 +294,8 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn-add {
|
.btn-add {
|
||||||
padding: 10px 20px;
|
padding: 7px 16px;
|
||||||
font-size: 0.95em;
|
font-size: 0.85em;
|
||||||
background: #4299e1;
|
background: #4299e1;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
@@ -223,8 +305,8 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn-small {
|
.btn-small {
|
||||||
padding: 6px 12px;
|
padding: 4px 10px;
|
||||||
font-size: 0.85em;
|
font-size: 0.78em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-complete {
|
.btn-complete {
|
||||||
@@ -236,6 +318,24 @@ button {
|
|||||||
background: #38a169;
|
background: #38a169;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-archive {
|
||||||
|
background: #805ad5;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-archive:hover {
|
||||||
|
background: #6b46c1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-restore {
|
||||||
|
background: #4299e1;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-restore:hover {
|
||||||
|
background: #3182ce;
|
||||||
|
}
|
||||||
|
|
||||||
.btn-delete {
|
.btn-delete {
|
||||||
background: #f56565;
|
background: #f56565;
|
||||||
color: white;
|
color: white;
|
||||||
@@ -254,21 +354,26 @@ button {
|
|||||||
background: #3182ce;
|
background: #3182ce;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Overall Progress */
|
/* ─── Overall Progress ─── */
|
||||||
.overall-progress {
|
.overall-progress {
|
||||||
background: #1a2332;
|
background: #1a2332;
|
||||||
padding: 20px;
|
padding: 14px 18px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
margin-bottom: 24px;
|
margin-bottom: 16px;
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
||||||
border: 1px solid #2d3748;
|
border: 1px solid #2d3748;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.overall-progress.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.overall-header {
|
.overall-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 8px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
font-size: 0.9em;
|
||||||
color: #e4e6eb;
|
color: #e4e6eb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,22 +382,10 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.task-counter {
|
.task-counter {
|
||||||
margin-top: 12px;
|
margin-top: 8px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #a0aec0;
|
color: #a0aec0;
|
||||||
font-size: 0.9em;
|
font-size: 0.82em;
|
||||||
}
|
|
||||||
|
|
||||||
#completed-count {
|
|
||||||
color: #4299e1;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.task-counter {
|
|
||||||
margin-top: 12px;
|
|
||||||
text-align: center;
|
|
||||||
color: #a0aec0;
|
|
||||||
font-size: 0.9em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-counter span {
|
.task-counter span {
|
||||||
@@ -300,25 +393,26 @@ button {
|
|||||||
color: #e4e6eb;
|
color: #e4e6eb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tasks Container */
|
/* ─── Tasks Container ─── */
|
||||||
.tasks-container {
|
.tasks-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 16px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ─── Task Cards — Compact ─── */
|
||||||
.task-card {
|
.task-card {
|
||||||
background: #1a2332;
|
background: #1a2332;
|
||||||
border-radius: 10px;
|
border-radius: 8px;
|
||||||
padding: 16px;
|
padding: 12px 14px;
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
border: 2px solid transparent;
|
border: 1px solid transparent;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-card:hover {
|
.task-card:hover {
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
|
||||||
border-color: #2d3748;
|
border-color: #2d3748;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,27 +429,45 @@ button {
|
|||||||
background: #1e3a5f;
|
background: #1e3a5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.task-card.archived-card {
|
||||||
|
cursor: default;
|
||||||
|
border-left: 3px solid #805ad5;
|
||||||
|
}
|
||||||
|
|
||||||
.task-header {
|
.task-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: flex-start;
|
align-items: center;
|
||||||
margin-bottom: 12px;
|
margin-bottom: 6px;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-title {
|
.task-title {
|
||||||
font-size: 1.1em;
|
font-size: 0.95em;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #e4e6eb;
|
color: #e4e6eb;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-meta {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-size-badge {
|
.task-size-badge {
|
||||||
padding: 4px 10px;
|
padding: 2px 8px;
|
||||||
border-radius: 12px;
|
border-radius: 10px;
|
||||||
font-size: 0.75em;
|
font-size: 0.7em;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin-left: 10px;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-size-badge.small {
|
.task-size-badge.small {
|
||||||
@@ -364,42 +476,41 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.task-size-badge.medium {
|
.task-size-badge.medium {
|
||||||
background: #7c2d12;
|
background: #744210;
|
||||||
color: #fed7aa;
|
color: #fbd38d;
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-size-badge.large {
|
.task-size-badge.large {
|
||||||
background: #7c2d12;
|
background: #742a2a;
|
||||||
color: #fbb6ce;
|
color: #feb2b2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-description {
|
.task-description {
|
||||||
color: #a0aec0;
|
color: #8b96a5;
|
||||||
margin-bottom: 12px;
|
margin-bottom: 8px;
|
||||||
font-size: 0.9em;
|
font-size: 0.82em;
|
||||||
line-height: 1.5;
|
line-height: 1.4;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Progress Bar */
|
/* ─── Inline Progress ─── */
|
||||||
.progress-section {
|
.progress-row {
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-label {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
font-size: 0.85em;
|
|
||||||
color: #a0aec0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-bar {
|
.progress-bar {
|
||||||
width: 100%;
|
flex: 1;
|
||||||
height: 20px;
|
height: 6px;
|
||||||
background: #0f1419;
|
background: #0f1419;
|
||||||
border-radius: 10px;
|
border-radius: 3px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,22 +518,44 @@ button {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
background: #4299e1;
|
background: #4299e1;
|
||||||
transition: width 0.3s ease;
|
transition: width 0.3s ease;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-text {
|
||||||
|
font-size: 0.78em;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #a0aec0;
|
||||||
|
min-width: 32px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Overall progress bar is taller */
|
||||||
|
.overall-progress .progress-bar {
|
||||||
|
height: 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overall-progress .progress-fill {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
color: white;
|
color: white;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 0.75em;
|
font-size: 0.72em;
|
||||||
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reward Section */
|
/* ─── Reward ─── */
|
||||||
.reward-section {
|
.reward-section {
|
||||||
background: #2d3748;
|
background: #1e2936;
|
||||||
padding: 12px;
|
padding: 6px 10px;
|
||||||
border-radius: 8px;
|
border-radius: 6px;
|
||||||
margin-top: 12px;
|
margin-bottom: 6px;
|
||||||
font-size: 0.95em;
|
font-size: 0.82em;
|
||||||
border: 1px solid #4a5568;
|
border: 1px solid #2d3748;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.reward-hidden {
|
.reward-hidden {
|
||||||
@@ -433,36 +566,40 @@ button {
|
|||||||
.reward-revealed {
|
.reward-revealed {
|
||||||
color: #68d391;
|
color: #68d391;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 1em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Task Actions */
|
/* ─── Task Actions — Compact row ─── */
|
||||||
.task-actions {
|
.task-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 6px;
|
||||||
margin-top: 12px;
|
margin-top: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Subtasks */
|
/* ─── Subtasks ─── */
|
||||||
.subtasks-container {
|
.subtasks-container {
|
||||||
margin-top: 12px;
|
margin-top: 8px;
|
||||||
padding-left: 16px;
|
padding-left: 12px;
|
||||||
border-left: 2px solid #2d3748;
|
border-left: 2px solid #2d3748;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtask {
|
.subtask {
|
||||||
background: #0f1419;
|
background: #0f1419;
|
||||||
padding: 10px;
|
padding: 8px 10px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 4px;
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
font-size: 0.9em;
|
font-size: 0.85em;
|
||||||
border: 1px solid #2d3748;
|
border: 1px solid #1e2936;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
transition: border-color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtask:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtask:hover {
|
.subtask:hover {
|
||||||
border-color: #4a5568;
|
border-color: #3a4a5c;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtask:active {
|
.subtask:active {
|
||||||
@@ -477,56 +614,70 @@ button {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 6px;
|
margin-bottom: 4px;
|
||||||
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtask-title {
|
.subtask-title {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #e4e6eb;
|
color: #e4e6eb;
|
||||||
|
font-size: 0.92em;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtask-progress-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtask-progress {
|
.subtask-progress {
|
||||||
width: 100%;
|
flex: 1;
|
||||||
height: 16px;
|
height: 4px;
|
||||||
background: #1a2332;
|
background: #1a2332;
|
||||||
border-radius: 8px;
|
border-radius: 2px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtask-progress-fill {
|
.subtask-progress-fill {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: #48bb78;
|
background: #48bb78;
|
||||||
transition: width 0.3s ease;
|
transition: width 0.3s ease;
|
||||||
|
border-radius: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtask-actions {
|
.subtask-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 6px;
|
gap: 4px;
|
||||||
margin-top: 8px;
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Drop Zone */
|
/* ─── Drop Zone ─── */
|
||||||
.drop-zone {
|
.drop-zone {
|
||||||
border: 2px dashed #4a5568;
|
border: 2px dashed #4a5568;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
padding: 12px;
|
padding: 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #718096;
|
color: #718096;
|
||||||
margin-top: 12px;
|
font-size: 0.8em;
|
||||||
font-size: 0.85em;
|
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
max-height: 0;
|
max-height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drop-zone.visible {
|
.drop-zone.visible {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
max-height: 100px;
|
max-height: 60px;
|
||||||
padding: 12px;
|
padding: 10px;
|
||||||
margin-top: 12px;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drop-zone.drag-over {
|
.drop-zone.drag-over {
|
||||||
@@ -535,46 +686,37 @@ button {
|
|||||||
color: #4299e1;
|
color: #4299e1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Completed State */
|
/* ─── Completed ─── */
|
||||||
|
.completed .task-title,
|
||||||
|
.completed .subtask-title {
|
||||||
|
text-decoration: line-through;
|
||||||
|
color: #718096;
|
||||||
|
}
|
||||||
|
|
||||||
.completed {
|
.completed {
|
||||||
opacity: 0.85;
|
opacity: 0.85;
|
||||||
}
|
}
|
||||||
|
|
||||||
.completed .task-title {
|
/* ─── Empty / Loading State ─── */
|
||||||
text-decoration: line-through;
|
|
||||||
color: #a0aec0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Checkbox */
|
|
||||||
.checkbox-group {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox-group input[type="checkbox"] {
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Empty State */
|
|
||||||
.empty-state {
|
.empty-state {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 60px 20px;
|
padding: 50px 20px;
|
||||||
color: #a0aec0;
|
color: #a0aec0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-state h2 {
|
.empty-state h2 {
|
||||||
font-size: 1.5em;
|
font-size: 1.2em;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 6px;
|
||||||
color: #cbd5e0;
|
color: #cbd5e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loading State */
|
.empty-state p {
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
.loading {
|
.loading {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 60px 20px;
|
padding: 50px 20px;
|
||||||
color: #a0aec0;
|
color: #a0aec0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,10 +724,10 @@ button {
|
|||||||
border: 3px solid #2d3748;
|
border: 3px solid #2d3748;
|
||||||
border-top: 3px solid #4299e1;
|
border-top: 3px solid #4299e1;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
width: 40px;
|
width: 32px;
|
||||||
height: 40px;
|
height: 32px;
|
||||||
animation: spin 1s linear infinite;
|
animation: spin 1s linear infinite;
|
||||||
margin: 0 auto 16px;
|
margin: 0 auto 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes spin {
|
@keyframes spin {
|
||||||
@@ -593,36 +735,26 @@ button {
|
|||||||
100% { transform: rotate(360deg); }
|
100% { transform: rotate(360deg); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive */
|
/* ─── Responsive ─── */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 640px) {
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 1.5em;
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
header {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: stretch;
|
||||||
gap: 12px;
|
}
|
||||||
|
|
||||||
|
.header-actions {
|
||||||
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-row {
|
.form-row {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.task-header {
|
.task-card {
|
||||||
flex-direction: column;
|
padding: 10px 12px;
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.task-size-badge {
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.task-actions {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.task-actions button {
|
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+55
-43
@@ -37,19 +37,27 @@ function initDatabase() {
|
|||||||
size TEXT NOT NULL,
|
size TEXT NOT NULL,
|
||||||
reward TEXT,
|
reward TEXT,
|
||||||
completed INTEGER DEFAULT 0,
|
completed INTEGER DEFAULT 0,
|
||||||
|
archived INTEGER DEFAULT 0,
|
||||||
|
expand_description INTEGER DEFAULT 0,
|
||||||
position INTEGER,
|
position INTEGER,
|
||||||
subtasks TEXT,
|
subtasks TEXT,
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
)
|
)
|
||||||
`);
|
`, (err) => {
|
||||||
|
if (err) return;
|
||||||
|
// Migrate: add columns if missing on existing databases
|
||||||
|
db.run(`ALTER TABLE tasks ADD COLUMN archived INTEGER DEFAULT 0`, () => {});
|
||||||
|
db.run(`ALTER TABLE tasks ADD COLUMN expand_description INTEGER DEFAULT 0`, () => {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// API Routes
|
// API Routes
|
||||||
|
|
||||||
// Get all tasks
|
// Get tasks — ?archived=1 returns archived, default returns active
|
||||||
app.get('/api/tasks', (req, res) => {
|
app.get('/api/tasks', (req, res) => {
|
||||||
db.all('SELECT * FROM tasks ORDER BY position ASC, created_at ASC', [], (err, rows) => {
|
const archived = req.query.archived === '1' ? 1 : 0;
|
||||||
|
db.all('SELECT * FROM tasks WHERE archived = ? ORDER BY position ASC, created_at ASC', [archived], (err, rows) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('Error fetching tasks:', err);
|
console.error('Error fetching tasks:', err);
|
||||||
return res.status(500).json({ error: 'Failed to fetch tasks' });
|
return res.status(500).json({ error: 'Failed to fetch tasks' });
|
||||||
@@ -62,6 +70,8 @@ app.get('/api/tasks', (req, res) => {
|
|||||||
size: row.size,
|
size: row.size,
|
||||||
reward: row.reward,
|
reward: row.reward,
|
||||||
completed: row.completed === 1,
|
completed: row.completed === 1,
|
||||||
|
archived: row.archived === 1,
|
||||||
|
expandDescription: row.expand_description === 1,
|
||||||
subtasks: row.subtasks ? JSON.parse(row.subtasks) : []
|
subtasks: row.subtasks ? JSON.parse(row.subtasks) : []
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -71,13 +81,13 @@ app.get('/api/tasks', (req, res) => {
|
|||||||
|
|
||||||
// Create a new task
|
// Create a new task
|
||||||
app.post('/api/tasks', (req, res) => {
|
app.post('/api/tasks', (req, res) => {
|
||||||
const { title, description, size, reward } = req.body;
|
const { title, description, size, reward, expandDescription } = req.body;
|
||||||
const id = Date.now().toString();
|
const id = Date.now().toString();
|
||||||
|
|
||||||
db.run(
|
db.run(
|
||||||
`INSERT INTO tasks (id, title, description, size, reward, position)
|
`INSERT INTO tasks (id, title, description, size, reward, expand_description, archived, position)
|
||||||
VALUES (?, ?, ?, ?, ?, (SELECT COALESCE(MAX(position), 0) + 1 FROM tasks))`,
|
VALUES (?, ?, ?, ?, ?, ?, 0, (SELECT COALESCE(MAX(position), 0) + 1 FROM tasks WHERE archived = 0))`,
|
||||||
[id, title, description || '', size, reward || ''],
|
[id, title, description || '', size, reward || '', expandDescription ? 1 : 0],
|
||||||
function(err) {
|
function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('Error creating task:', err);
|
console.error('Error creating task:', err);
|
||||||
@@ -91,6 +101,8 @@ app.post('/api/tasks', (req, res) => {
|
|||||||
size,
|
size,
|
||||||
reward: reward || '',
|
reward: reward || '',
|
||||||
completed: false,
|
completed: false,
|
||||||
|
archived: false,
|
||||||
|
expandDescription: !!expandDescription,
|
||||||
subtasks: []
|
subtasks: []
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -100,31 +112,47 @@ app.post('/api/tasks', (req, res) => {
|
|||||||
// Update a task
|
// Update a task
|
||||||
app.put('/api/tasks/:id', (req, res) => {
|
app.put('/api/tasks/:id', (req, res) => {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
const { title, description, size, reward, completed, subtasks } = req.body;
|
const { title, description, size, reward, completed, expandDescription, subtasks } = req.body;
|
||||||
|
|
||||||
db.run(
|
db.run(
|
||||||
`UPDATE tasks
|
`UPDATE tasks
|
||||||
SET title = ?, description = ?, size = ?, reward = ?, completed = ?, subtasks = ?, updated_at = CURRENT_TIMESTAMP
|
SET title = ?, description = ?, size = ?, reward = ?, completed = ?, expand_description = ?, subtasks = ?, updated_at = CURRENT_TIMESTAMP
|
||||||
WHERE id = ?`,
|
WHERE id = ?`,
|
||||||
[
|
[title, description || '', size, reward || '', completed ? 1 : 0, expandDescription ? 1 : 0, JSON.stringify(subtasks || []), id],
|
||||||
title,
|
|
||||||
description || '',
|
|
||||||
size,
|
|
||||||
reward || '',
|
|
||||||
completed ? 1 : 0,
|
|
||||||
JSON.stringify(subtasks || []),
|
|
||||||
id
|
|
||||||
],
|
|
||||||
function(err) {
|
function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('Error updating task:', err);
|
console.error('Error updating task:', err);
|
||||||
return res.status(500).json({ error: 'Failed to update task' });
|
return res.status(500).json({ error: 'Failed to update task' });
|
||||||
}
|
}
|
||||||
|
if (this.changes === 0) return res.status(404).json({ error: 'Task not found' });
|
||||||
|
res.json({ success: true });
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
if (this.changes === 0) {
|
// Archive a task
|
||||||
return res.status(404).json({ error: 'Task not found' });
|
app.put('/api/tasks/:id/archive', (req, res) => {
|
||||||
}
|
const { id } = req.params;
|
||||||
|
db.run(
|
||||||
|
`UPDATE tasks SET archived = 1, updated_at = CURRENT_TIMESTAMP WHERE id = ?`,
|
||||||
|
[id],
|
||||||
|
function(err) {
|
||||||
|
if (err) return res.status(500).json({ error: 'Failed to archive task' });
|
||||||
|
if (this.changes === 0) return res.status(404).json({ error: 'Task not found' });
|
||||||
|
res.json({ success: true });
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Unarchive (restore) a task
|
||||||
|
app.put('/api/tasks/:id/unarchive', (req, res) => {
|
||||||
|
const { id } = req.params;
|
||||||
|
db.run(
|
||||||
|
`UPDATE tasks SET archived = 0, position = (SELECT COALESCE(MAX(position), 0) + 1 FROM tasks WHERE archived = 0), updated_at = CURRENT_TIMESTAMP WHERE id = ?`,
|
||||||
|
[id],
|
||||||
|
function(err) {
|
||||||
|
if (err) return res.status(500).json({ error: 'Failed to unarchive task' });
|
||||||
|
if (this.changes === 0) return res.status(404).json({ error: 'Task not found' });
|
||||||
res.json({ success: true });
|
res.json({ success: true });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -133,17 +161,9 @@ app.put('/api/tasks/:id', (req, res) => {
|
|||||||
// Delete a task
|
// Delete a task
|
||||||
app.delete('/api/tasks/:id', (req, res) => {
|
app.delete('/api/tasks/:id', (req, res) => {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
|
|
||||||
db.run('DELETE FROM tasks WHERE id = ?', [id], function(err) {
|
db.run('DELETE FROM tasks WHERE id = ?', [id], function(err) {
|
||||||
if (err) {
|
if (err) return res.status(500).json({ error: 'Failed to delete task' });
|
||||||
console.error('Error deleting task:', err);
|
if (this.changes === 0) return res.status(404).json({ error: 'Task not found' });
|
||||||
return res.status(500).json({ error: 'Failed to delete task' });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.changes === 0) {
|
|
||||||
return res.status(404).json({ error: 'Task not found' });
|
|
||||||
}
|
|
||||||
|
|
||||||
res.json({ success: true });
|
res.json({ success: true });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -151,10 +171,7 @@ app.delete('/api/tasks/:id', (req, res) => {
|
|||||||
// Reorder tasks
|
// Reorder tasks
|
||||||
app.post('/api/tasks/reorder', (req, res) => {
|
app.post('/api/tasks/reorder', (req, res) => {
|
||||||
const taskIds = req.body;
|
const taskIds = req.body;
|
||||||
|
if (!Array.isArray(taskIds)) return res.status(400).json({ error: 'Invalid task order data' });
|
||||||
if (!Array.isArray(taskIds)) {
|
|
||||||
return res.status(400).json({ error: 'Invalid task order data' });
|
|
||||||
}
|
|
||||||
|
|
||||||
const promises = taskIds.map((id, index) => {
|
const promises = taskIds.map((id, index) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -178,19 +195,14 @@ app.get('/', (req, res) => {
|
|||||||
res.sendFile(path.join(__dirname, '../public/index.html'));
|
res.sendFile(path.join(__dirname, '../public/index.html'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Start server
|
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
console.log(`🚀 Learning Progress Tracker running on http://localhost:${PORT}`);
|
console.log(`Learning Progress Tracker running on http://localhost:${PORT}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Graceful shutdown
|
|
||||||
process.on('SIGINT', () => {
|
process.on('SIGINT', () => {
|
||||||
db.close((err) => {
|
db.close((err) => {
|
||||||
if (err) {
|
if (err) console.error('Error closing database:', err);
|
||||||
console.error('Error closing database:', err);
|
else console.log('Database connection closed');
|
||||||
} else {
|
|
||||||
console.log('Database connection closed');
|
|
||||||
}
|
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user