* Fix actions of todo in API.

This commit is contained in:
zhujinyong
2021-08-23 11:34:04 +08:00
parent 15f32acefe
commit 49b8f26e32
3 changed files with 17 additions and 16 deletions
+4 -4
View File
@@ -14,28 +14,28 @@ class todoEntry extends entry
$control->view($todoID, $this->param('from', 'my'));
$data = $this->getData();
$todo = $data->data->todo;
$todo = $data->data->todo;
$this->send(200, $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time'));
}
public function put($todoID)
{
$oldTodo = $this->loadModel('todo')->getByID($todoID);
$oldTodo->date = date("Y-m-d", strtotime($oldTodo->date));
$oldTodo = $this->loadModel('todo')->getByID($todoID);
/* Set $_POST variables. */
$fields = 'date,type,name,pri,desc,status,begin,end,private';
$this->batchSetPost($fields, $oldTodo);
$this->setPost('idvalue', 0);
$this->setPost('date', date("Y-m-d", strtotime($oldTodo->date)));
$control = $this->loadController('todo', 'edit');
$control->edit($todoID);
$data = $this->getData();
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
$todo = $this->todo->getByID($todoID);
$this->send(200, $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time'));
+8 -11
View File
@@ -14,19 +14,16 @@ class todosEntry extends entry
$control->todo($this->param('date', 'all'), $this->param('user', ''), $this->param('status', 'all'), $this->param('order', 'date_desc'), 0, $this->param('total', 0), $this->param('limit', 20), $this->param('page', 1));
$data = $this->getData();
if(isset($data->status) and $data->status == 'success')
{
$pager = $data->data->pager;
$result = array();
foreach($data->data->todos as $todo)
{
$result[] = $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time');
}
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'todos' => $result));
}
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
return $this->sendError(400, 'error');
$pager = $data->data->pager;
$result = array();
foreach($data->data->todos as $todo)
{
$result[] = $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time');
}
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'todos' => $result));
}
public function post()
+5 -1
View File
@@ -149,6 +149,8 @@ class todo extends control
$actionID = $this->loadModel('action')->create('todo', $todoID, 'edited');
$this->action->logHistory($actionID, $changes);
}
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success'));
die(js::locate($this->session->todoList, 'parent.parent'));
}
@@ -434,7 +436,9 @@ class todo extends control
}
return $this->send($response);
}
if(isonlybody())die(js::reload('parent.parent'));
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success'));
if(isonlybody()) die(js::reload('parent.parent'));
$browseLink = $this->session->todoList ? $this->session->todoList : $this->createLink('my', 'todo');
die(js::locate($browseLink, 'parent'));