Spaces:
Running
Running
Download index.html from Wallahbibi/task-manager-board: direct link, hf CLI and curl.
- Browser
- Download file 34.3 kB
-
https://huggingface.co/spaces/Wallahbibi/task-manager-board/resolve/main/index.html
- Command line
-
hf download hf://spaces/Wallahbibi/task-manager-board/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Wallahbibi/task-manager-board/resolve/main/index.html
34.3 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>CRM - Tasks</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .task-card { | |
| transition: all 0.2s ease; | |
| } | |
| .task-card:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1); | |
| } | |
| .status-working { | |
| background-color: #fef3c7; | |
| color: #92400e; | |
| } | |
| .status-done { | |
| background-color: #d1fae5; | |
| color: #065f46; | |
| } | |
| .status-stuck { | |
| background-color: #fee2e2; | |
| color: #991b1b; | |
| } | |
| .priority-high { | |
| color: #dc2626; | |
| } | |
| .priority-medium { | |
| color: #ea580c; | |
| } | |
| .priority-low { | |
| color: #16a34a; | |
| } | |
| .slide-in { | |
| animation: slideIn 0.2s forwards; | |
| } | |
| @keyframes slideIn { | |
| from { transform: translateY(10px); opacity: 0; } | |
| to { transform: translateY(0); opacity: 1; } | |
| } | |
| .fade-in { | |
| animation: fadeIn 0.2s forwards; | |
| } | |
| @keyframes fadeIn { | |
| from { opacity: 0; } | |
| to { opacity: 1; } | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50"> | |
| <!-- Main Page Wrapper --> | |
| <div class="page-wrapper px-6 py-4 space-y-4 max-w-7xl mx-auto"> | |
| <!-- Page Header --> | |
| <div class="page-header flex items-center justify-between"> | |
| <h1 class="text-xl font-semibold text-gray-800">Tasks</h1> | |
| <div class="page-actions flex gap-2"> | |
| <div class="relative"> | |
| <div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none"> | |
| <i class="fas fa-search text-gray-400"></i> | |
| </div> | |
| <input | |
| type="text" | |
| id="search-tasks" | |
| class="bg-white border border-gray-200 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2" | |
| placeholder="Search tasks..." | |
| > | |
| </div> | |
| <select id="task-filter" class="bg-white border border-gray-200 text-gray-700 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2"> | |
| <option value="all">All</option> | |
| <option value="today">Today</option> | |
| <option value="upcoming">Upcoming</option> | |
| <option value="overdue">Overdue</option> | |
| <option value="completed">Completed</option> | |
| </select> | |
| <button id="new-task-btn" class="flex items-center justify-center gap-2 text-white bg-blue-600 hover:bg-blue-700 focus:ring-4 focus:ring-blue-200 font-medium rounded-lg text-sm px-4 py-2"> | |
| <i class="fas fa-plus"></i> New Task | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Page Content --> | |
| <div id="page-content" class="page-content space-y-6"> | |
| <!-- Task groups will be populated here --> | |
| <div class="text-center py-10 text-gray-500"> | |
| <i class="fas fa-spinner fa-spin text-2xl mb-2"></i> | |
| <p>Loading tasks from Monday.com...</p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- New Task Modal --> | |
| <div id="new-task-modal" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center p-4 z-50"> | |
| <div class="bg-white rounded-xl shadow-sm w-full max-w-md slide-in"> | |
| <div class="flex items-center justify-between p-4 border-b"> | |
| <h3 class="text-lg font-semibold text-gray-900">Create New Task</h3> | |
| <button id="close-modal" class="text-gray-400 hover:text-gray-500"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="p-4 space-y-4"> | |
| <div> | |
| <label for="task-title" class="block mb-2 text-sm font-medium text-gray-700">Title *</label> | |
| <input | |
| type="text" | |
| id="task-title" | |
| class="bg-gray-50 border border-gray-200 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2" | |
| placeholder="What needs to be done?" | |
| required | |
| > | |
| </div> | |
| <div> | |
| <label for="task-client" class="block mb-2 text-sm font-medium text-gray-700">Client</label> | |
| <input | |
| type="text" | |
| id="task-client" | |
| class="bg-gray-50 border border-gray-200 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2" | |
| placeholder="Search clients..." | |
| > | |
| </div> | |
| <div class="grid grid-cols-2 gap-4"> | |
| <div> | |
| <label for="task-due" class="block mb-2 text-sm font-medium text-gray-700">Due Date</label> | |
| <input | |
| type="date" | |
| id="task-due" | |
| class="bg-gray-50 border border-gray-200 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2" | |
| > | |
| </div> | |
| <div> | |
| <label for="task-priority" class="block mb-2 text-sm font-medium text-gray-700">Priority</label> | |
| <select | |
| id="task-priority" | |
| class="bg-gray-50 border border-gray-200 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2" | |
| > | |
| <option value="low">Low</option> | |
| <option value="medium" selected>Medium</option> | |
| <option value="high">High</option> | |
| </select> | |
| </div> | |
| </div> | |
| <div> | |
| <label for="task-notes" class="block mb-2 text-sm font-medium text-gray-700">Notes</label> | |
| <textarea | |
| id="task-notes" | |
| rows="3" | |
| class="bg-gray-50 border border-gray-200 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2" | |
| placeholder="Additional details..." | |
| ></textarea> | |
| </div> | |
| </div> | |
| <div class="flex items-center justify-end p-4 border-t gap-3"> | |
| <button id="cancel-task" class="text-gray-500 hover:text-gray-700 font-medium text-sm px-4 py-2">Cancel</button> | |
| <button id="create-task" class="text-white bg-blue-600 hover:bg-blue-700 focus:ring-4 focus:ring-blue-200 font-medium rounded-lg text-sm px-5 py-2"> | |
| Create Task | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Edit Task Modal --> | |
| <div id="edit-task-modal" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center p-4 z-50"> | |
| <div class="bg-white rounded-xl shadow-sm w-full max-w-md slide-in"> | |
| <div class="flex items-center justify-between p-4 border-b"> | |
| <h3 class="text-lg font-semibold text-gray-900">Edit Task</h3> | |
| <button id="close-edit-modal" class="text-gray-400 hover:text-gray-500"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="p-4 space-y-4"> | |
| <input type="hidden" id="edit-task-id"> | |
| <div> | |
| <label for="edit-task-title" class="block mb-2 text-sm font-medium text-gray-700">Title *</label> | |
| <input | |
| type="text" | |
| id="edit-task-title" | |
| class="bg-gray-50 border border-gray-200 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2" | |
| required | |
| > | |
| </div> | |
| <div> | |
| <label for="edit-task-client" class="block mb-2 text-sm font-medium text-gray-700">Client</label> | |
| <input | |
| type="text" | |
| id="edit-task-client" | |
| class="bg-gray-50 border border-gray-200 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2" | |
| > | |
| </div> | |
| <div class="grid grid-cols-2 gap-4"> | |
| <div> | |
| <label for="edit-task-due" class="block mb-2 text-sm font-medium text-gray-700">Due Date</label> | |
| <input | |
| type="date" | |
| id="edit-task-due" | |
| class="bg-gray-50 border border-gray-200 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2" | |
| > | |
| </div> | |
| <div> | |
| <label for="edit-task-status" class="block mb-2 text-sm font-medium text-gray-700">Status</label> | |
| <select | |
| id="edit-task-status" | |
| class="bg-gray-50 border border-gray-200 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2" | |
| > | |
| <option value="working">Working on it</option> | |
| <option value="stuck">Stuck</option> | |
| <option value="done">Done</option> | |
| </select> | |
| </div> | |
| </div> | |
| <div> | |
| <label for="edit-task-notes" class="block mb-2 text-sm font-medium text-gray-700">Notes</label> | |
| <textarea | |
| id="edit-task-notes" | |
| rows="3" | |
| class="bg-gray-50 border border-gray-200 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2" | |
| ></textarea> | |
| </div> | |
| </div> | |
| <div class="flex items-center justify-between p-4 border-t"> | |
| <button id="delete-task" class="text-red-600 hover:text-red-800 font-medium text-sm px-4 py-2">Delete Task</button> | |
| <div class="flex gap-3"> | |
| <button id="cancel-edit" class="text-gray-500 hover:text-gray-700 font-medium text-sm px-4 py-2">Cancel</button> | |
| <button id="save-task" class="text-white bg-blue-600 hover:bg-blue-700 focus:ring-4 focus:ring-blue-200 font-medium rounded-lg text-sm px-5 py-2"> | |
| Save Changes | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // Configuration - Replace with your Monday.com board ID | |
| const MONDAY_BOARD_ID = "123456789"; | |
| // DOM Elements | |
| const newTaskBtn = document.getElementById('new-task-btn'); | |
| const newTaskModal = document.getElementById('new-task-modal'); | |
| const closeModal = document.getElementById('close-modal'); | |
| const cancelTask = document.getElementById('cancel-task'); | |
| const createTask = document.getElementById('create-task'); | |
| const editTaskModal = document.getElementById('edit-task-modal'); | |
| const closeEditModal = document.getElementById('close-edit-modal'); | |
| const cancelEdit = document.getElementById('cancel-edit'); | |
| const saveTask = document.getElementById('save-task'); | |
| const deleteTask = document.getElementById('delete-task'); | |
| const taskFilter = document.getElementById('task-filter'); | |
| const searchInput = document.getElementById('search-tasks'); | |
| const pageContent = document.getElementById('page-content'); | |
| // Form elements | |
| const taskTitle = document.getElementById('task-title'); | |
| const taskClient = document.getElementById('task-client'); | |
| const taskDue = document.getElementById('task-due'); | |
| const taskPriority = document.getElementById('task-priority'); | |
| const taskNotes = document.getElementById('task-notes'); | |
| const editTaskId = document.getElementById('edit-task-id'); | |
| const editTaskTitle = document.getElementById('edit-task-title'); | |
| const editTaskClient = document.getElementById('edit-task-client'); | |
| const editTaskDue = document.getElementById('edit-task-due'); | |
| const editTaskStatus = document.getElementById('edit-task-status'); | |
| const editTaskNotes = document.getElementById('edit-task-notes'); | |
| // Current tasks and filter state | |
| let allTasks = []; | |
| let currentFilter = 'all'; | |
| let currentSearchTerm = ''; | |
| // Initialize the app | |
| document.addEventListener('DOMContentLoaded', () => { | |
| setDefaultDate(); | |
| setupEventListeners(); | |
| fetchTasksFromMonday(); | |
| }); | |
| function setDefaultDate() { | |
| const today = new Date().toISOString().split('T')[0]; | |
| taskDue.value = today; | |
| } | |
| function setupEventListeners() { | |
| // New Task Modal | |
| newTaskBtn.addEventListener('click', () => { | |
| newTaskModal.classList.remove('hidden'); | |
| newTaskModal.classList.add('flex'); | |
| }); | |
| closeModal.addEventListener('click', closeNewTaskModal); | |
| cancelTask.addEventListener('click', closeNewTaskModal); | |
| // Edit Task Modal | |
| closeEditModal.addEventListener('click', closeEditTaskModal); | |
| cancelEdit.addEventListener('click', closeEditTaskModal); | |
| // Create Task | |
| createTask.addEventListener('click', handleCreateTask); | |
| // Save Task | |
| saveTask.addEventListener('click', handleSaveTask); | |
| // Delete Task | |
| deleteTask.addEventListener('click', handleDeleteTask); | |
| // Filter tasks | |
| taskFilter.addEventListener('change', (e) => { | |
| currentFilter = e.target.value; | |
| renderTaskGroups(); | |
| }); | |
| // Search tasks | |
| searchInput.addEventListener('input', (e) => { | |
| currentSearchTerm = e.target.value.toLowerCase(); | |
| renderTaskGroups(); | |
| }); | |
| } | |
| function closeNewTaskModal() { | |
| newTaskModal.classList.add('hidden'); | |
| newTaskModal.classList.remove('flex'); | |
| resetTaskForm(); | |
| } | |
| function closeEditTaskModal() { | |
| editTaskModal.classList.add('hidden'); | |
| editTaskModal.classList.remove('flex'); | |
| } | |
| function resetTaskForm() { | |
| taskTitle.value = ''; | |
| taskClient.value = ''; | |
| setDefaultDate(); | |
| taskPriority.value = 'medium'; | |
| taskNotes.value = ''; | |
| } | |
| // Monday.com API Integration | |
| async function fetchTasksFromMonday() { | |
| // In a real implementation, this would call the Monday.com API | |
| // For demo purposes, we're using mock data that matches the expected structure | |
| // Simulate API delay | |
| await new Promise(resolve => setTimeout(resolve, 800)); | |
| // Mock data that matches what we'd get from Monday.com API | |
| const today = new Date().toISOString().split('T')[0]; | |
| const yesterday = new Date(Date.now() - 86400000).toISOString().split('T')[0]; | |
| const tomorrow = new Date(Date.now() + 86400000).toISOString().split('T')[0]; | |
| const nextWeek = new Date(Date.now() + 86400000 * 7).toISOString().split('T')[0]; | |
| allTasks = [ | |
| { | |
| id: "1", | |
| name: "Finalize client proposal", | |
| status: "working", | |
| due_date: today, | |
| priority: "high", | |
| client_name: "Acme Corp", | |
| notes: "Need to include pricing options", | |
| created_at: new Date().toISOString() | |
| }, | |
| { | |
| id: "2", | |
| name: "Send contract to new client", | |
| status: "working", | |
| due_date: tomorrow, | |
| priority: "medium", | |
| client_name: "Beta LLC", | |
| notes: "Waiting for legal review", | |
| created_at: new Date().toISOString() | |
| }, | |
| { | |
| id: "3", | |
| name: "Follow up on overdue invoice", | |
| status: "stuck", | |
| due_date: yesterday, | |
| priority: "high", | |
| client_name: "Gamma Inc", | |
| notes: "Client says payment will come next week", | |
| created_at: new Date().toISOString() | |
| }, | |
| { | |
| id: "4", | |
| name: "Prepare Q2 marketing plan", | |
| status: "done", | |
| due_date: yesterday, | |
| priority: "medium", | |
| client_name: "Delta Co", | |
| notes: "Approved by management", | |
| created_at: new Date().toISOString() | |
| }, | |
| { | |
| id: "5", | |
| name: "Schedule team meeting", | |
| status: "working", | |
| due_date: nextWeek, | |
| priority: "low", | |
| client_name: "", | |
| notes: "Discuss project timelines", | |
| created_at: new Date().toISOString() | |
| } | |
| ]; | |
| renderTaskGroups(); | |
| } | |
| function renderTaskGroups() { | |
| const today = new Date().toISOString().split('T')[0]; | |
| // Filter tasks based on search term | |
| let filteredTasks = allTasks.filter(task => | |
| task.name.toLowerCase().includes(currentSearchTerm) || | |
| (task.client_name && task.client_name.toLowerCase().includes(currentSearchTerm)) || | |
| (task.notes && task.notes.toLowerCase().includes(currentSearchTerm)) | |
| ); | |
| // Group tasks | |
| const todayTasks = filteredTasks.filter(task => | |
| task.due_date === today && task.status !== 'done' | |
| ); | |
| const upcomingTasks = filteredTasks.filter(task => | |
| task.due_date > today && task.status !== 'done' | |
| ); | |
| const overdueTasks = filteredTasks.filter(task => | |
| task.due_date < today && task.status !== 'done' | |
| ); | |
| const completedTasks = filteredTasks.filter(task => | |
| task.status === 'done' | |
| ); | |
| // Clear container | |
| pageContent.innerHTML = ''; | |
| // Render groups based on current filter | |
| if (currentFilter === 'all' || currentFilter === 'today') { | |
| renderTaskGroup('Today', todayTasks, 'text-blue-600'); | |
| } | |
| if (currentFilter === 'all' || currentFilter === 'upcoming') { | |
| renderTaskGroup('Upcoming', upcomingTasks, 'text-purple-600'); | |
| } | |
| if (currentFilter === 'all' || currentFilter === 'overdue') { | |
| renderTaskGroup('Overdue', overdueTasks, 'text-red-600'); | |
| } | |
| if (currentFilter === 'all' || currentFilter === 'completed') { | |
| renderTaskGroup('Completed', completedTasks, 'text-green-600', true); | |
| } | |
| // Show empty state if no tasks match | |
| if (pageContent.children.length === 0) { | |
| pageContent.innerHTML = ` | |
| <div class="text-center py-10 text-gray-500"> | |
| <i class="fas fa-tasks text-2xl mb-2"></i> | |
| <p>No tasks found matching your criteria</p> | |
| </div> | |
| `; | |
| } | |
| } | |
| function renderTaskGroup(title, tasks, iconColor, isCollapsible = false) { | |
| if (tasks.length === 0 && currentFilter !== 'all') return; | |
| const groupElement = document.createElement('div'); | |
| groupElement.className = 'section space-y-4 fade-in'; | |
| // Group header | |
| const header = document.createElement('div'); | |
| header.className = 'flex items-center gap-2'; | |
| header.innerHTML = ` | |
| <h2 class="text-lg font-semibold ${iconColor}">${title}</h2> | |
| <span class="text-xs bg-gray-100 text-gray-600 px-2 py-1 rounded-full">${tasks.length}</span> | |
| `; | |
| groupElement.appendChild(header); | |
| // Task cards | |
| if (tasks.length > 0) { | |
| const tasksContainer = document.createElement('div'); | |
| tasksContainer.className = 'space-y-3'; | |
| tasks.forEach(task => { | |
| tasksContainer.appendChild(createTaskCard(task)); | |
| }); | |
| groupElement.appendChild(tasksContainer); | |
| } else { | |
| const emptyState = document.createElement('div'); | |
| emptyState.className = 'text-center py-4 text-gray-500 text-sm'; | |
| emptyState.textContent = `No ${title.toLowerCase()} tasks`; | |
| groupElement.appendChild(emptyState); | |
| } | |
| pageContent.appendChild(groupElement); | |
| } | |
| function createTaskCard(task) { | |
| const taskElement = document.createElement('div'); | |
| taskElement.className = 'task-card bg-white border border-gray-200 rounded-xl p-4 shadow-sm'; | |
| taskElement.dataset.id = task.id; | |
| const today = new Date().toISOString().split('T')[0]; | |
| const isOverdue = task.due_date < today && task.status !== 'done'; | |
| let statusClass, statusIcon; | |
| switch(task.status) { | |
| case 'done': | |
| statusClass = 'status-done'; | |
| statusIcon = 'fa-check-circle'; | |
| break; | |
| case 'stuck': | |
| statusClass = 'status-stuck'; | |
| statusIcon = 'fa-exclamation-circle'; | |
| break; | |
| default: | |
| statusClass = 'status-working'; | |
| statusIcon = 'fa-spinner'; | |
| } | |
| let priorityClass; | |
| switch(task.priority) { | |
| case 'high': | |
| priorityClass = 'priority-high'; | |
| break; | |
| case 'medium': | |
| priorityClass = 'priority-medium'; | |
| break; | |
| default: | |
| priorityClass = 'priority-low'; | |
| } | |
| taskElement.innerHTML = ` | |
| <div class="flex justify-between items-start mb-2"> | |
| <div class="flex items-center gap-3"> | |
| <button class="task-checkbox w-5 h-5 rounded border border-gray-300 flex items-center justify-center ${task.status === 'done' ? 'bg-green-500 border-green-500 text-white' : 'bg-white'}" data-id="${task.id}"> | |
| ${task.status === 'done' ? '<i class="fas fa-check text-xs"></i>' : ''} | |
| </button> | |
| <h3 class="font-medium text-gray-800 ${task.status === 'done' ? 'line-through text-gray-500' : ''}">${task.name}</h3> | |
| </div> | |
| <span class="text-xs px-2 py-1 rounded-full ${statusClass}"> | |
| <i class="fas ${statusIcon} mr-1"></i> ${task.status === 'working' ? 'Working on it' : task.status === 'done' ? 'Done' : 'Stuck'} | |
| </span> | |
| </div> | |
| <div class="flex flex-wrap gap-4 text-sm text-gray-600 mt-3"> | |
| ${task.client_name ? `<div class="flex items-center gap-1"> | |
| <i class="fas fa-user-tie text-gray-400"></i> | |
| <span>${task.client_name}</span> | |
| </div>` : ''} | |
| ${task.due_date ? `<div class="flex items-center gap-1 ${isOverdue ? 'text-red-500' : ''}"> | |
| <i class="fas fa-calendar-day text-gray-400"></i> | |
| <span>${formatDueDate(task.due_date)}</span> | |
| </div>` : ''} | |
| ${task.priority ? `<div class="flex items-center gap-1 ${priorityClass}"> | |
| <i class="fas fa-bolt text-gray-400"></i> | |
| <span class="capitalize">${task.priority}</span> | |
| </div>` : ''} | |
| </div> | |
| ${task.notes ? `<div class="mt-3 text-sm text-gray-600"> | |
| <i class="fas fa-align-left text-gray-400 mr-1"></i> | |
| ${task.notes} | |
| </div>` : ''} | |
| <div class="flex justify-end mt-3 gap-2"> | |
| <button class="task-edit text-xs text-blue-600 hover:text-blue-800 px-2 py-1" data-id="${task.id}"> | |
| <i class="fas fa-pencil-alt mr-1"></i> Edit | |
| </button> | |
| </div> | |
| `; | |
| // Add event listeners to the buttons in this task | |
| const checkbox = taskElement.querySelector('.task-checkbox'); | |
| const editBtn = taskElement.querySelector('.task-edit'); | |
| checkbox.addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| toggleTaskStatus(task.id); | |
| }); | |
| editBtn.addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| openEditModal(task.id); | |
| }); | |
| taskElement.addEventListener('click', () => { | |
| openEditModal(task.id); | |
| }); | |
| return taskElement; | |
| } | |
| function formatDueDate(dateString) { | |
| const date = new Date(dateString); | |
| const today = new Date(); | |
| today.setHours(0, 0, 0, 0); | |
| const tomorrow = new Date(today); | |
| tomorrow.setDate(tomorrow.getDate() + 1); | |
| if (date.toDateString() === today.toDateString()) { | |
| return 'Today'; | |
| } else if (date.toDateString() === tomorrow.toDateString()) { | |
| return 'Tomorrow'; | |
| } else { | |
| return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }); | |
| } | |
| } | |
| function handleCreateTask() { | |
| const title = taskTitle.value.trim(); | |
| if (!title) { | |
| alert('Task title is required'); | |
| return; | |
| } | |
| const newTask = { | |
| name: title, | |
| client_name: taskClient.value.trim(), | |
| due_date: taskDue.value, | |
| priority: taskPriority.value, | |
| status: 'working', | |
| notes: taskNotes.value.trim() | |
| }; | |
| // In a real app, this would call Monday.com API to create the task | |
| createMondayTask(newTask).then(task => { | |
| allTasks.push(task); | |
| renderTaskGroups(); | |
| closeNewTaskModal(); | |
| }).catch(error => { | |
| console.error('Error creating task:', error); | |
| alert('Failed to create task. Please try again.'); | |
| }); | |
| } | |
| function openEditModal(taskId) { | |
| const task = allTasks.find(t => t.id === taskId); | |
| if (!task) return; | |
| editTaskId.value = task.id; | |
| editTaskTitle.value = task.name; | |
| editTaskClient.value = task.client_name || ''; | |
| editTaskDue.value = task.due_date; | |
| editTaskStatus.value = task.status; | |
| editTaskNotes.value = task.notes || ''; | |
| editTaskModal.classList.remove('hidden'); | |
| editTaskModal.classList.add('flex'); | |
| } | |
| function handleSaveTask() { | |
| const taskId = editTaskId.value; | |
| const taskIndex = allTasks.findIndex(t => t.id === taskId); | |
| if (taskIndex === -1) return; | |
| const updatedTask = { | |
| ...allTasks[taskIndex], | |
| name: editTaskTitle.value.trim(), | |
| client_name: editTaskClient.value.trim(), | |
| due_date: editTaskDue.value, | |
| status: editTaskStatus.value, | |
| notes: editTaskNotes.value.trim() | |
| }; | |
| // In a real app, this would call Monday.com API to update the task | |
| updateMondayTask(updatedTask).then(task => { | |
| allTasks[taskIndex] = task; | |
| renderTaskGroups(); | |
| closeEditTaskModal(); | |
| }).catch(error => { | |
| console.error('Error updating task:', error); | |
| alert('Failed to update task. Please try again.'); | |
| }); | |
| } | |
| function handleDeleteTask() { | |
| const taskId = editTaskId.value; | |
| if (confirm('Are you sure you want to delete this task?')) { | |
| // In a real app, this would call Monday.com API to delete the task | |
| deleteMondayTask(taskId).then(() => { | |
| allTasks = allTasks.filter(t => t.id !== taskId); | |
| renderTaskGroups(); | |
| closeEditTaskModal(); | |
| }).catch(error => { | |
| console.error('Error deleting task:', error); | |
| alert('Failed to delete task. Please try again.'); | |
| }); | |
| } | |
| } | |
| function toggleTaskStatus(taskId) { | |
| const taskIndex = allTasks.findIndex(t => t.id === taskId); | |
| if (taskIndex === -1) return; | |
| const currentTask = allTasks[taskIndex]; | |
| const newStatus = currentTask.status === 'done' ? 'working' : 'done'; | |
| // In a real app, this would call Monday.com API to update the status | |
| updateMondayTaskStatus(taskId, newStatus).then(updatedTask => { | |
| allTasks[taskIndex] = updatedTask; | |
| renderTaskGroups(); | |
| }).catch(error => { | |
| console.error('Error updating task status:', error); | |
| alert('Failed to update task status. Please try again.'); | |
| }); | |
| } | |
| // Mock Monday.com API functions | |
| // In a real implementation, these would make actual API calls | |
| function createMondayTask(taskData) { | |
| return new Promise((resolve) => { | |
| // Simulate API delay | |
| setTimeout(() => { | |
| const newTask = { | |
| id: Date.now().toString(), | |
| ...taskData, | |
| created_at: new Date().toISOString() | |
| }; | |
| resolve(newTask); | |
| }, 500); | |
| }); | |
| } | |
| function updateMondayTask(taskData) { | |
| return new Promise((resolve) => { | |
| // Simulate API delay | |
| setTimeout(() => { | |
| resolve(taskData); | |
| }, 500); | |
| }); | |
| } | |
| function deleteMondayTask(taskId) { | |
| return new Promise((resolve) => { | |
| // Simulate API delay | |
| setTimeout(() => { | |
| resolve(); | |
| }, 500); | |
| }); | |
| } | |
| function updateMondayTaskStatus(taskId, status) { | |
| return new Promise((resolve) => { | |
| // Simulate API delay | |
| setTimeout(() => { | |
| const taskIndex = allTasks.findIndex(t => t.id === taskId); | |
| if (taskIndex !== -1) { | |
| const updatedTask = { | |
| ...allTasks[taskIndex], | |
| status: status | |
| }; | |
| resolve(updatedTask); | |
| } | |
| }, 500); | |
| }); | |
| } | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Wallahbibi/task-manager-board" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |