mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
* show 'date edited' inline in tasklist instead of 'date created' if sorting is selected 'by date modified' (and in task edit form if not completed)
This commit is contained in:
parent
8fd6950d18
commit
8e90422ac8
6 changed files with 41 additions and 20 deletions
|
|
@ -1175,7 +1175,14 @@ _mtt.prepareDueDate = prepareDueDate;
|
|||
|
||||
function prepareInlineDate(item)
|
||||
{
|
||||
return '<span class="task-id">#' + item.id + '</span> ' + (item.compl ? item.dateCompletedInlineTitle : item.dateInlineTitle) ;
|
||||
var inlineDate = item.dateInlineTitle;
|
||||
if (item.compl) {
|
||||
inlineDate = item.dateCompletedInlineTitle;
|
||||
}
|
||||
else if ( item.isEdited && (curList.sort == 4 || curList.sort == 104) ) {
|
||||
inlineDate = item.dateEditedInlineTitle;
|
||||
}
|
||||
return '<span class="task-id">#' + item.id + '</span> ' + inlineDate;
|
||||
}
|
||||
_mtt.prepareInlineDate = prepareInlineDate;
|
||||
|
||||
|
|
@ -1617,11 +1624,20 @@ function editTask(id)
|
|||
form.prio.value = item.prio;
|
||||
$('#taskedit_id').text('#' + item.id);
|
||||
$('#taskedit_info .date-created-value').text(item.date);
|
||||
if(item.compl) {
|
||||
if (item.isEdited && !item.compl) {
|
||||
$('#taskedit_info .date-edited-value').text(item.dateEdited);
|
||||
$('#taskedit_info .date-edited').show()
|
||||
}
|
||||
else {
|
||||
$('#taskedit_info .date-edited').hide();
|
||||
}
|
||||
if (item.compl) {
|
||||
$('#taskedit_info .date-completed-value').text(item.dateCompleted);
|
||||
$('#taskedit_info .date-completed').show()
|
||||
}
|
||||
else $('#taskedit_info .date-completed').hide();
|
||||
else {
|
||||
$('#taskedit_info .date-completed').hide();
|
||||
}
|
||||
toggleEditAllTags(0);
|
||||
showEditForm();
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -233,9 +233,10 @@ class TasksController extends ApiController {
|
|||
$tags .= ',' . ($this->req->jsonBody['tag'] ?? '');
|
||||
}
|
||||
$ow = 1 + (int)$db->sq("SELECT MAX(ow) FROM {$db->prefix}todolist WHERE list_id=$listId AND compl=0");
|
||||
$date = time();
|
||||
$db->ex("BEGIN");
|
||||
$db->dq("INSERT INTO {$db->prefix}todolist (uuid,list_id,title,d_created,d_edited,ow,prio) VALUES (?,?,?,?,?,?,?)",
|
||||
array(generateUUID(), $listId, $title, time(), time(), $ow, $prio) );
|
||||
array(generateUUID(), $listId, $title, $date, $date, $ow, $prio) );
|
||||
$id = (int) $db->lastInsertId();
|
||||
if ($tags != '')
|
||||
{
|
||||
|
|
@ -270,9 +271,10 @@ class TasksController extends ApiController {
|
|||
if (Config::get('autotag'))
|
||||
$tags .= ',' . ($this->req->jsonBody['tag'] ?? '');
|
||||
$ow = 1 + (int)$db->sq("SELECT MAX(ow) FROM {$db->prefix}todolist WHERE list_id=$listId AND compl=0");
|
||||
$date = time();
|
||||
$db->ex("BEGIN");
|
||||
$db->dq("INSERT INTO {$db->prefix}todolist (uuid,list_id,title,d_created,d_edited,ow,prio,note,duedate) VALUES (?,?,?,?,?,?,?,?,?)",
|
||||
array(generateUUID(), $listId, $title, time(), time(), $ow, $prio, $note, $duedate) );
|
||||
array(generateUUID(), $listId, $title, $date, $date, $ow, $prio, $note, $duedate) );
|
||||
$id = (int) $db->lastInsertId();
|
||||
if ($tags != '')
|
||||
{
|
||||
|
|
@ -365,9 +367,10 @@ class TasksController extends ApiController {
|
|||
$listId = (int)$db->sq("SELECT list_id FROM {$db->prefix}todolist WHERE id=$id");
|
||||
if ($compl) $ow = 1 + (int)$db->sq("SELECT MAX(ow) FROM {$db->prefix}todolist WHERE list_id=$listId AND compl=1");
|
||||
else $ow = 1 + (int)$db->sq("SELECT MAX(ow) FROM {$db->prefix}todolist WHERE list_id=$listId AND compl=0");
|
||||
$dateCompleted = $compl ? time() : 0;
|
||||
$date = time();
|
||||
$dateCompleted = $compl ? $date : 0;
|
||||
$db->dq("UPDATE {$db->prefix}todolist SET compl=$compl,ow=$ow,d_completed=?,d_edited=? WHERE id=$id",
|
||||
array($dateCompleted, time()) );
|
||||
array($dateCompleted, $date) );
|
||||
$t = array();
|
||||
$t['total'] = 1;
|
||||
$r = $db->sqa("SELECT * FROM {$db->prefix}todolist WHERE id=$id");
|
||||
|
|
@ -442,13 +445,9 @@ class TasksController extends ApiController {
|
|||
{
|
||||
$lang = Lang::instance();
|
||||
$dueA = $this->prepareDuedate($r['duedate']);
|
||||
$formatCreatedInline = $formatCompletedInline = Config::get('dateformatshort');
|
||||
if (date('Y') != date('Y', (int)$r['d_created']))
|
||||
$formatCreatedInline = Config::get('dateformat2');
|
||||
if ($r['d_completed'] && date('Y') != date('Y', (int)$r['d_completed']))
|
||||
$formatCompletedInline = Config::get('dateformat2');
|
||||
|
||||
$dCreated = timestampToDatetime($r['d_created']);
|
||||
$isEdited = $r['d_edited'] != $r['d_created'];
|
||||
$dEdited = $isEdited ? timestampToDatetime($r['d_edited']) : '';
|
||||
$dCompleted = $r['d_completed'] ? timestampToDatetime($r['d_completed']) : '';
|
||||
|
||||
return array(
|
||||
|
|
@ -458,11 +457,12 @@ class TasksController extends ApiController {
|
|||
'listId' => $r['list_id'],
|
||||
'date' => htmlarray($dCreated),
|
||||
'dateInt' => (int)$r['d_created'],
|
||||
'dateInline' => htmlarray(formatTime($formatCreatedInline, $r['d_created'])),
|
||||
'dateInlineTitle' => htmlarray(sprintf($lang->get('taskdate_inline_created'), $dCreated)),
|
||||
'dateEdited' => htmlarray($dEdited),
|
||||
'dateEditedInt' => (int)$r['d_edited'],
|
||||
'dateEditedInlineTitle' => htmlarray(sprintf($lang->get('taskdate_inline_edited'), $dEdited)),
|
||||
'isEdited' => (bool)$isEdited,
|
||||
'dateCompleted' => htmlarray($dCompleted),
|
||||
'dateCompletedInline' => $r['d_completed'] ? htmlarray(formatTime($formatCompletedInline, $r['d_completed'])) : '',
|
||||
'dateCompletedInlineTitle' => htmlarray(sprintf($lang->get('taskdate_inline_completed'), $dCompleted)),
|
||||
'compl' => (int)$r['compl'],
|
||||
'prio' => $r['prio'],
|
||||
|
|
@ -473,7 +473,7 @@ class TasksController extends ApiController {
|
|||
'tags_ids' => htmlarray($r['tags_ids']),
|
||||
'duedate' => $dueA['formatted'],
|
||||
'dueClass' => $dueA['class'],
|
||||
'dueStr' => htmlarray($r['compl'] && $dueA['timestamp'] ? formatTime($formatCompletedInline, $dueA['timestamp']) : $dueA['str']),
|
||||
'dueStr' => htmlarray($dueA['str']),
|
||||
'dueInt' => $this->date2int($r['duedate']),
|
||||
'dueTitle' => htmlarray(sprintf($lang->get('taskdate_inline_duedate'), $dueA['formattedlong'])),
|
||||
);
|
||||
|
|
@ -560,7 +560,7 @@ class TasksController extends ApiController {
|
|||
return $a;
|
||||
}
|
||||
|
||||
private function date2int($d)
|
||||
private function date2int($d) : int
|
||||
{
|
||||
if (!$d) return 33330000;
|
||||
$ad = explode('-', $d);
|
||||
|
|
|
|||
|
|
@ -17,9 +17,11 @@
|
|||
"searching": "Searching for",
|
||||
"tasks": "Tasks",
|
||||
"taskdate_inline_created": "created at %s",
|
||||
"taskdate_inline_edited": "edited at %s",
|
||||
"taskdate_inline_completed": "completed at %s",
|
||||
"taskdate_inline_duedate": "Due %s",
|
||||
"taskdate_created": "Created",
|
||||
"taskdate_edited": "Last edited",
|
||||
"taskdate_completed": "Completed",
|
||||
"edit_task": "Edit Task",
|
||||
"add_task": "New Task",
|
||||
|
|
|
|||
|
|
@ -17,9 +17,11 @@
|
|||
"searching": "Поиск",
|
||||
"tasks": "Задачи",
|
||||
"taskdate_inline_created": "добавлена %s",
|
||||
"taskdate_inline_edited": "отредактирована %s",
|
||||
"taskdate_inline_completed": "завершена %s",
|
||||
"taskdate_inline_duedate": "В срок %s",
|
||||
"taskdate_created": "Дата создания",
|
||||
"taskdate_edited": "Последнее изменение",
|
||||
"taskdate_completed": "Дата завершения",
|
||||
"edit_task": "Редактирование задачи",
|
||||
"add_task": "Новая задача",
|
||||
|
|
|
|||
|
|
@ -134,7 +134,8 @@ $().ready(function(){
|
|||
<div id="taskedit_info" class="mtt-inedit">
|
||||
<div class="date-created"><?php _e('taskdate_created'); ?>: <span class="date-created-value"></span></div>
|
||||
<div class="date-completed"><?php _e('taskdate_completed'); ?>: <span class="date-completed-value"></span></div>
|
||||
</div>
|
||||
<div class="date-edited"><?php _e('taskdate_edited'); ?>: <span class="date-edited-value"></span></div>
|
||||
</div>
|
||||
|
||||
<form id="taskedit_form" name="edittask" method="post">
|
||||
<input type="hidden" name="isadd" value="0" />
|
||||
|
|
|
|||
|
|
@ -206,13 +206,13 @@ function setup_and_start_session()
|
|||
session_start();
|
||||
}
|
||||
|
||||
function timestampToDatetime($timestamp)
|
||||
function timestampToDatetime($timestamp) : string
|
||||
{
|
||||
$format = Config::get('dateformat') .' '. (Config::get('clock') == 12 ? 'g:i A' : 'H:i');
|
||||
return formatTime($format, $timestamp);
|
||||
}
|
||||
|
||||
function formatTime($format, $timestamp=0)
|
||||
function formatTime($format, $timestamp=0) : string
|
||||
{
|
||||
$lang = Lang::instance();
|
||||
if($timestamp == 0) $timestamp = time();
|
||||
|
|
|
|||
Loading…
Reference in a new issue