mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
+ can delete task list with all contents
This commit is contained in:
parent
22e06039a9
commit
0ea71f7950
5 changed files with 51 additions and 8 deletions
35
src/ajax.js
35
src/ajax.js
|
|
@ -35,7 +35,6 @@ function loadTasks()
|
|||
nocache = '&rnd='+Math.random();
|
||||
$.getJSON('ajax.php?loadTasks&list='+curList.id+'&compl='+filter.compl+'&sort='+sortBy+search+tag+'&tz='+tz+nocache, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
$('#total').html(json.total);
|
||||
taskList = new Array();
|
||||
taskOrder = new Array();
|
||||
taskCnt.past = taskCnt.today = taskCnt.soon = 0;
|
||||
|
|
@ -48,6 +47,10 @@ function loadTasks()
|
|||
if(!item.compl) changeTaskCnt(item.dueClass);
|
||||
});
|
||||
refreshTaskCnt();
|
||||
if(filter.due == '') $('#total').html(taskCnt.total);
|
||||
else if(filter.due == 'past') $('#total').html(taskCnt.past);
|
||||
else if(filter.due == 'today') $('#total').html(taskCnt.today);
|
||||
else if(filter.due == 'soon') $('#total').html(taskCnt.soon);
|
||||
$('#tasklist').html(tasks);
|
||||
if(filter.compl) showhide($('#compl_hide'),$('#compl_show'));
|
||||
else showhide($('#compl_show'),$('#compl_hide'));
|
||||
|
|
@ -462,11 +465,6 @@ function doAuth(form)
|
|||
if(json.logged)
|
||||
{
|
||||
flag.isLogged = true;
|
||||
if(filter.search != '') {
|
||||
filter.search = '';
|
||||
$('#searchbarkeyword').text('');
|
||||
$('#searchbar').hide();
|
||||
}
|
||||
updateAccessStatus();
|
||||
loadLists();
|
||||
}
|
||||
|
|
@ -844,6 +842,11 @@ function mttTabSelected(el, indx)
|
|||
if(!tabLists[indx]) return;
|
||||
if(indx != curList.i) {
|
||||
$('#tasklist').html('');
|
||||
if(filter.search != '') {
|
||||
filter.search = '';
|
||||
$('#searchbarkeyword').text('');
|
||||
$('#searchbar').hide();
|
||||
}
|
||||
}
|
||||
curList = tabLists[indx];
|
||||
flag.tagsChanged = true;
|
||||
|
|
@ -922,6 +925,11 @@ function toggleAllNotes(showhide)
|
|||
function loadLists(onInit)
|
||||
{
|
||||
if(flag.needAuth && !flag.isLogged && !flag.canAllRead) return false;
|
||||
if(filter.search != '') {
|
||||
filter.search = '';
|
||||
$('#searchbarkeyword').text('');
|
||||
$('#searchbar').hide();
|
||||
}
|
||||
setAjaxErrorTrigger();
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.getJSON('ajax.php?loadLists'+nocache, function(json){
|
||||
|
|
@ -965,7 +973,7 @@ function renameCurList()
|
|||
{
|
||||
if(!curList) return;
|
||||
var r = prompt(lang.renameList, dehtml(curList.name));
|
||||
if(r == null) return;
|
||||
if(r == null || r == '') return;
|
||||
setAjaxErrorTrigger()
|
||||
nocache = '&rnd='+Math.random();
|
||||
$.post('ajax.php?'+nocache, { renameList:1, id:curList.id, name:r }, function(json){
|
||||
|
|
@ -979,6 +987,19 @@ function renameCurList()
|
|||
}, 'json');
|
||||
}
|
||||
|
||||
function deleteCurList()
|
||||
{
|
||||
var r = confirm(lang.deleteList);
|
||||
if(!r) return;
|
||||
setAjaxErrorTrigger()
|
||||
$.post('ajax.php?'+'&rnd='+Math.random(), { deleteList:1, id:curList.id }, function(json){
|
||||
resetAjaxErrorTrigger();
|
||||
if(!parseInt(json.total)) return;
|
||||
loadLists();
|
||||
}, 'json');
|
||||
|
||||
}
|
||||
|
||||
function addsearchToggle(toSearch)
|
||||
{
|
||||
if(toSearch)
|
||||
|
|
|
|||
20
src/ajax.php
20
src/ajax.php
|
|
@ -345,6 +345,26 @@ elseif(isset($_POST['renameList']))
|
|||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
elseif(isset($_POST['deleteList']))
|
||||
{
|
||||
check_write_access();
|
||||
stop_gpc($_POST);
|
||||
$t = array();
|
||||
$t['total'] = 0;
|
||||
$id = (int)_post('id');
|
||||
$db->ex("BEGIN");
|
||||
$db->ex("DELETE FROM lists WHERE id=$id");
|
||||
$t['total'] = $db->affected();
|
||||
if($t['total']) {
|
||||
$db->ex("DELETE FROM tags WHERE list_id=$id");
|
||||
# sqlite doesnt support DELETE FROM INNNER JOIN
|
||||
$db->ex("DELETE FROM tag2task WHERE task_id IN (SELECT id FROM todolist WHERE list_id=$id)");
|
||||
$db->ex("DELETE FROM todolist WHERE list_id=$id");
|
||||
}
|
||||
$db->ex("COMMIT");
|
||||
echo json_encode($t);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
###################################################################################################
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ $().ajaxStop( function(r,s) {$("#loading").fadeOut();} );
|
|||
<div id="mylistscontainer" class="mtt-btnmenu-container" style="display:none">
|
||||
<div class="li" onClick="addList()">New list</div>
|
||||
<div class="li" onClick="renameCurList()">Rename</div>
|
||||
<div class="li" onClick="confirm('This will delete current list with all tasks in it.\nAre you sure?')">Delete</div>
|
||||
<div class="li" onClick="deleteCurList()">Delete</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class DefaultLang
|
|||
'addList' => "Create new list",
|
||||
'addListDefault' => "Todo",
|
||||
'renameList' => "Rename list",
|
||||
'deleteList' => "This will delete current list with all tasks in it.\\nAre you sure?",
|
||||
);
|
||||
|
||||
private $default_inc = array
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class Lang extends DefaultLang
|
|||
'tagfilter' => "Tag:",
|
||||
'addList' => "Create new list",
|
||||
'renameList' => "Rename list",
|
||||
'deleteList' => "This will delete current list with all tasks in it.\\nAre you sure?",
|
||||
);
|
||||
|
||||
var $inc = array
|
||||
|
|
|
|||
Loading…
Reference in a new issue