project view updates
This commit is contained in:
@@ -30,6 +30,9 @@ function getDB() {
|
||||
db.exec(`ALTER TABLE projects ADD COLUMN isolated INTEGER NOT NULL DEFAULT 0`);
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
db.exec(`ALTER TABLE projects ADD COLUMN notes TEXT`); // ← add this
|
||||
} catch {}
|
||||
|
||||
// Sync FTS index with any existing episodes data
|
||||
db.exec(`INSERT OR REPLACE INTO episodes_fts(rowid, user_message, ai_response)
|
||||
|
||||
@@ -20,12 +20,23 @@ function getProject(id) {
|
||||
return parseRow(db.prepare(`SELECT * FROM projects WHERE id = ?`).get(id));
|
||||
}
|
||||
|
||||
function updateProject(id, { name, description, colour, icon, isolated }) {
|
||||
function updateProject(id, fields = {}) {
|
||||
const db = getDB();
|
||||
db.prepare(`
|
||||
UPDATE projects SET name = ?, description = ?, colour = ?, icon = ?, isolated = ?
|
||||
WHERE id = ?
|
||||
`).run(name, description ?? null, colour ?? null, icon ?? null, isolated ?? 0, id);
|
||||
const allowed = ['name', 'description', 'colour', 'icon', 'isolated', 'notes'];
|
||||
const updates = [];
|
||||
const values = [];
|
||||
|
||||
for (const key of allowed) {
|
||||
if (fields[key] !== undefined) {
|
||||
updates.push(`${key} = ?`);
|
||||
values.push(fields[key] ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
if (updates.length === 0) return getProject(id);
|
||||
|
||||
values.push(id);
|
||||
db.prepare(`UPDATE projects SET ${updates.join(', ')} WHERE id = ?`).run(...values);
|
||||
return getProject(id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user