From bcdf5e9eabdb13d789a0c97ec1299a48266cf870 Mon Sep 17 00:00:00 2001 From: Max Pozdeev Date: Wed, 15 Dec 2010 22:37:29 +0300 Subject: [PATCH] * fixed moving a task to other list in all tasks tab --- src/ajax.php | 10 +++++++--- src/mytinytodo.js | 25 ++++++++++++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/ajax.php b/src/ajax.php index c9e0e20..d5d9481 100644 --- a/src/ajax.php +++ b/src/ajax.php @@ -458,10 +458,14 @@ elseif(isset($_GET['moveTask'])) { check_write_access(); $id = (int)_post('id'); -// $fromId = (int)_post('from'); + $fromId = (int)_post('from'); $toId = (int)_post('to'); - $r = moveTask($id, $toId); - echo json_encode(array('total'=>$r?1:0)); + $result = moveTask($id, $toId); + $t = array('total' => $result ? 1 : 0); + if($fromId == -1 && $result && $r = $db->sqa("SELECT * FROM {$db->prefix}todolist WHERE id=$id")) { + $t['list'][] = prepareTaskRow($r); + } + echo json_encode($t); exit; } elseif(isset($_GET['changeListOrder'])) diff --git a/src/mytinytodo.js b/src/mytinytodo.js index 20c9078..0625d0f 100644 --- a/src/mytinytodo.js +++ b/src/mytinytodo.js @@ -1691,11 +1691,26 @@ function moveTaskToList(taskId, listId) if(curList.id == listId) return; _mtt.db.request('moveTask', {id:taskId, from:curList.id, to:listId}, function(json){ if(!parseInt(json.total)) return; - changeTaskCnt(taskList[taskId], -1) - delete taskList[taskId]; - taskOrder.splice($.inArray(taskId,taskOrder), 1); - $('#taskrow_'+taskId).fadeOut('normal', function(){ $(this).remove() }); - refreshTaskCnt(); + if(curList.id == -1) + { + // leave the task in current tab (all tasks tab) + var item = json.list[0]; + changeTaskCnt(item, 0, taskList[item.id]); + taskList[item.id] = item; + var noteExpanded = (item.note != '' && $('#taskrow_'+item.id).is('.task-expanded')) ? 1 : 0; + $('#taskrow_'+item.id).replaceWith(prepareTaskStr(item, noteExpanded)); + if(curList.sort != 0) changeTaskOrder(item.id); + refreshTaskCnt(); + $('#taskrow_'+item.id).effect("highlight", {color:_mtt.theme.editTaskFlashColor}, 'normal', function(){$(this).css('display','')}); + } + else { + // remove the task from currrent tab + changeTaskCnt(taskList[taskId], -1) + delete taskList[taskId]; + taskOrder.splice($.inArray(taskId,taskOrder), 1); + $('#taskrow_'+taskId).fadeOut('normal', function(){ $(this).remove() }); + refreshTaskCnt(); + } }); $("#edittags").flushCache();