* friendy messages if no lists to show

This commit is contained in:
Max Pozdeev 2022-01-15 21:00:51 +03:00
parent 26567ee59b
commit d6ca663d4e
6 changed files with 70 additions and 24 deletions

View file

@ -23,12 +23,13 @@ if(isset($_GET['loadLists']))
{
check_token();
$t = array();
$t['total'] = 0;
if (!is_logged()) $sqlWhere = 'WHERE published=1';
else {
$sqlWhere = '';
$t['list'][] = prepareAllTasksList(); // show alltasks lists only for authorized user
$t['total'] = 1;
}
$t['total'] = 1;
$q = $db->dq("SELECT * FROM {$db->prefix}lists $sqlWhere ORDER BY ow ASC, id ASC");
while($r = $q->fetchAssoc())
{

View file

@ -161,6 +161,8 @@
"actionNoteCancel": "cancel",
"error": "Some error occurred (click for details)",
"denied": "Access denied",
"listNotFound": "Not found",
"noPublicLists": "No public tasks",
"invalidpass": "Wrong password",
"addList": "Create new list",
"addListDefault": "Todo",

View file

@ -116,6 +116,10 @@ $().ready(function(){
<span id="tagcloudbtn" class="mtt-menu-button"><?php _e('tagcloud');?> <span class="arrdown2"></span></span>
</h3>
<div id="tasks_info" style="display:none;">
<div class="v"></div>
</div>
<ol id="tasklist" class="sortable"></ol>
</div>
@ -258,7 +262,7 @@ $().ready(function(){
<div id="slmenucontainer" class="mtt-menu-container" style="display:none">
<ul>
<li id="slmenu_list:-1" class="list-id--1 mtt-need-list"><div class="menu-icon"></div><a href="#alltasks"><?php _e('alltasks'); ?></a></li>
<li id="slmenu_list:-1" class="list-id--1 mtt-need-authorized"><div class="menu-icon"></div><a href="#alltasks"><?php _e('alltasks'); ?></a></li>
<li class="mtt-menu-delimiter slmenu-lists-begin mtt-need-list"></li>
</ul>
</div>

View file

@ -66,6 +66,7 @@ a { color:#0000ff; cursor:pointer; text-decoration:underline; }
#msg.mtt-info .msg-details { border:1px solid #EFC300;}
#lists { font-size:0.95rem; display:flex; align-items:flex-start; justify-content:flex-end; }
#mtt_body.readonly.no-lists #lists > * { visibility: hidden; }
.tabs-n-button { flex-grow:1; display:flex; align-items:flex-start; }
.tab-height-wrapper { box-sizing:border-box; height:2.2rem; display:flex; align-items:center; }
.mtt-tabs { list-style:none; padding:0; margin:0; display:flex; justify-content:flex-start; flex-wrap:wrap; }
@ -103,7 +104,9 @@ a { color:#0000ff; cursor:pointer; text-decoration:underline; }
.mtt-img-button:hover, .mtt-img-button.mtt-menu-button-active { background-color:#efefef; cursor:pointer; }
.mtt-img-button span { display:block; width:16px; height:16px; }
#mtt_body.no-lists #toolbar > * { visibility:hidden; }
#mtt_body.no-lists #toolbar > * { visibility:hidden; }
#mtt_body.no-list-selected #toolbar > * { visibility:hidden; }
#mtt_body.readonly.no-lists #toolbar { visibility: hidden; }
#toolbar { padding:8px; border-bottom:1px solid #DEDEDE; background:#ededed; }
#toolbar .mtt-img-button:hover { background-color:#ddd; }
@ -145,7 +148,8 @@ a { color:#0000ff; cursor:pointer; text-decoration:underline; }
/* */
#page_tasks h3 { display:flex; align-items:baseline; }
#mtt_body.no-lists #page_tasks h3 > * { visibility:hidden; }
#mtt_body.no-lists #page_tasks h3 { visibility:hidden; }
#mtt_body.no-list-selected #page_tasks h3 { visibility:hidden; }
.mtt-notes-showhide { font-size:1rem; font-weight:normal; margin-left:5px; margin-right:5px; }
.mtt-notes-showhide a { text-decoration:none; border-bottom:1px dotted; }
@ -298,6 +302,22 @@ li.task-row.task-completed .task-note-block .task-note { text-decoration:line-th
.prio-zero { /*background-color:#dedede;*/ }
.task-prio.prio-zero { display:none; }
#tasks_info {
display: flex;
justify-content: center;
align-content: center;
flex-direction: column;
min-height: 100px;
border: 1px solid #ccc;
border-radius: 5px;
}
#tasks_info .v {
font-size: 1.1rem;
font-weight: bold;
text-align: center;
}
.form-row { margin-top:0.6rem; }
.form-row .h { font-weight:bold; color:#333333; }
.form-row div.h { margin-bottom:3px; }
@ -446,6 +466,7 @@ li.mtt-item-hidden { display:none; }
#slmenucontainer li.mtt-list-hidden a { font-style:italic; }
#cmenulistscontainer li.mtt-list-hidden { font-style:italic; }
#mtt_body.readonly .mtt-need-list { display:none; }
#mtt_body.readonly .mtt-need-authorized { display:none; }
#btnRssFeed .menu-icon { background:url(images/rss.svg) no-repeat; }
#btnRssFeed.mtt-item-disabled .menu-icon { background:url(images/rss-disabled.svg) no-repeat; }

View file

@ -112,6 +112,8 @@ class Lang
'actionNoteCancel',
'error',
'denied',
'listNotFound',
'noPublicLists',
'invalidpass',
'addList',
'addListDefault',

View file

@ -675,6 +675,7 @@ var mytinytodo = window.mytinytodo = _mtt = {
}
$('#page_tasks').hide();
$('#tasklist').html('');
$('#tasks_info').hide();
tabLists.clear();
@ -682,7 +683,7 @@ var mytinytodo = window.mytinytodo = _mtt = {
{
var ti = '';
var openListId = 0;
if(res && res.total)
if(res && res.total && res.list)
{
// open required or first non-hidden list
for(var i=0; i<res.list.length; i++) {
@ -701,9 +702,6 @@ var mytinytodo = window.mytinytodo = _mtt = {
// open all tasks tab
if(_mtt.options.openList == -1) openListId = -1;
// or open first if all list are hidden
if(!openListId) openListId = res.list[0].id;
$.each(res.list, function(i,item) {
if ( item.id == -1) {
tabLists._alltasks = item;
@ -720,32 +718,43 @@ var mytinytodo = window.mytinytodo = _mtt = {
});
}
if(openListId) {
$('#mtt_body').removeClass('no-lists');
$('.mtt-need-list').removeClass('mtt-item-disabled');
}
else {
if (openListId == 0) {
curList = 0;
$('#mtt_body').addClass('no-lists');
$('.mtt-need-list').addClass('mtt-item-disabled');
}
if (_mtt.options.openList && openListId != _mtt.options.openList) {
//TODO: handle unknown list
}
if (_mtt.options.markdown == true) {
$('#mtt_body').addClass('markdown-enabled');
}
if (tabLists.length() > 0) {
$('#mtt_body').removeClass('no-lists');
}
else {
$('#mtt_body').addClass('no-lists');
}
if (_mtt.options.openList != 0 && openListId == 0) {
// cant open list - not found
$('#tasks_info .v').text(_mtt.lang.get('listNotFound'))
$('#tasks_info').show();
}
else if (tabLists.length() == 0) {
if (flag.readOnly) $('#tasks_info .v').text(_mtt.lang.get('noPublicLists'));
else $('#tasks_info .v').text(_mtt.lang.get('listNotFound'))
$('#tasks_info').show();
}
_mtt.options.openList = 0;
$('#lists .mtt-tabs-selected').removeClass('mtt-tabs-selected');
$('#mtt_body').addClass('no-list-selected');
$('#lists ul').html(ti);
$('#lists').show();
_mtt.doAction('listsLoaded');
tabSelect(openListId);
if (tabLists.length() > 0 && openListId != 0) {
tabSelect(openListId);
}
$('#page_tasks').show();
});
},
@ -1378,11 +1387,18 @@ function tabSelect(elementOrId)
id = id.split('_', 2)[1];
if (id === 'all') id = -1;
}
if ( !tabLists.exists(id) ) {
// TODO: handle unknown list
flashError(_mtt.lang.get('denied'));
$('#tasks_info .v').text(_mtt.lang.get('listNotFound'))
$('#tasks_info').show();
$('.mtt-need-list').addClass('mtt-item-disabled');
return;
}
else {
$('#tasks_info').hide();
$('.mtt-need-list').removeClass('mtt-item-disabled');
$('#mtt_body').removeClass('no-list-selected');
}
var prevList = curList;
curList = tabLists.get(id);
@ -1409,7 +1425,7 @@ function tabSelect(elementOrId)
var isFirstLoad = flag.firstLoad;
updateHistoryState( { list:id }, _mtt.urlForList(curList), newTitle );
if(curList.hidden) {
if (curList.hidden && flag.readOnly != true) {
curList.hidden = false;
_mtt.db.request('setHideList', {list:curList.id, hide:0});
}