Repository navigation
Expand file tree
/
Copy pathpatch_selected7.js
More file actions
49 lines (39 loc) · 2.02 KB
/
Copy pathpatch_selected7.js
File metadata and controls
49 lines (39 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const fs = require('fs');
// Fix 1: taskController.js
const tcPath = 'E:/Antigravity/TaskWhite/controllers/taskController.js';
let tcContent = fs.readFileSync(tcPath, 'utf8');
const tcSearch = ` // Auto-update status based on due date if it's not marked Completed
if (updates.status !== 'Completed' && currentData.status !== 'Completed') {
if (activeDueDate < todayStr) {
updates.status = 'Overdue';
} else if (updates.status === 'Overdue') {
// If it was overdue but date pushed forward, revert to Assigned/In Progress
updates.status = currentData.status === 'Overdue' ? 'Assigned' : currentData.status;
}
}`;
const tcReplace = ` // Auto-update status based on due date if it's not marked Completed
const targetStatus = updates.status !== undefined ? updates.status : currentData.status;
if (targetStatus !== 'Completed') {
if (activeDueDate < todayStr && targetStatus === 'Assigned') {
updates.status = 'Overdue';
} else if (activeDueDate >= todayStr && targetStatus === 'Overdue') {
// If it was overdue but date pushed forward, revert to Assigned
updates.status = 'Assigned';
}
}`;
tcContent = tcContent.replace(tcSearch, tcReplace);
fs.writeFileSync(tcPath, tcContent);
// Fix 2: dashboard.ejs
const ejsPath = 'E:/Antigravity/TaskWhite/views/pages/dashboard.ejs';
let ejsContent = fs.readFileSync(ejsPath, 'utf8');
const ejsSearch = ` const searchInput = document.getElementById('dashboardSearch');
if (searchInput && searchInput.value.trim() !== '') {
searchInput.dispatchEvent(new Event('input', { bubbles: true }));
}`;
const ejsReplace = ` const searchInput = document.getElementById('dashboardSearch');
if (searchInput && searchInput.value.trim() !== '') {
searchInput.dispatchEvent(new KeyboardEvent('keyup', { bubbles: true }));
}`;
ejsContent = ejsContent.replace(ejsSearch, ejsReplace);
fs.writeFileSync(ejsPath, ejsContent);
console.log("Patched successfully!");