updating kanban on

* task creation
* task update
* task deletion
This commit is contained in:
2025-12-20 13:51:06 +01:00
parent 78cae4644d
commit 711addd75c
4 changed files with 62 additions and 33 deletions

View File

@@ -103,20 +103,40 @@
}
}
function handleUpdateEvent(evt){
function handleCreateEvent(evt){
handleEvent(evt,'create');
}
function handleEvent(evt,method){
let json = JSON.parse(evt.data);
if (json.task && json.user){
// drop from kanban
for (let uid in tasks){
if (!uid) continue;
for (let state in tasks[uid]) delete tasks[uid][state][json.task.id];
}
processTask(json.task);
// (re) add to kanban
if (method != 'delete') processTask(json.task);
// show notification
if (json.user.id != user.id) {
info = t("user_updated_entity",{user:json.user.name,entity:json.task.name});
let term = "user_updated_entity";
if (method == 'create') term = "user_created_entity";
if (method == 'delete') term = "user_deleted_entity";
info = t(term,{user:json.user.name,entity:json.task.name});
setTimeout(() => { info = null; },2500);
}
}
}
function handleDeleteEvent(evt){
console.log('delete task');
handleEvent(evt,'delete');
}
function handleUpdateEvent(evt){
handleEvent(evt,'update');
}
function hover(ev,user_id,state){
@@ -135,7 +155,7 @@
async function load(){
try {
eventSource = eventStream(handleUpdateEvent);
eventSource = eventStream(handleCreateEvent,handleUpdateEvent,handleDeleteEvent);
await loadProject();
loadTasks({project_id:+id,parent_task_id:0});
} catch (ignored) {}