From 2d7743a6fb6fe1daae8b616dbf86e22f2bb245f8 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Fri, 16 Jun 2023 16:05:25 +0800 Subject: [PATCH] * Fix error of todo::edit. --- module/todo/control.php | 14 +++----------- module/todo/ui/create.html.php | 4 +--- module/todo/ui/edit.html.php | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/module/todo/control.php b/module/todo/control.php index 4d78daa26b..e3fc26341e 100755 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -126,25 +126,17 @@ class todo extends control /* Processing edit request data. */ $todo = $this->todoZen->beforeEdit($todoID, $form); - if(dao::isError()) - { - if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => dao::getError())); - return print(js::error(dao::getError())); - } + if(dao::isError()) return $this->send(array('status' => 'fail', 'message' => dao::getError())); /* update a todo. */ $changes = $this->todo->update($todoID, $todo); - if(dao::isError()) - { - if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => dao::getError())); - return print(js::error(dao::getError())); - } + if(dao::isError()) return $this->send(array('status' => 'fail', 'message' => dao::getError())); /* Handle data after edit todo. */ $this->todoZen->afterEdit($todoID, $changes); if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success')); - return print(js::locate($this->session->todoList, 'parent.parent')); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'load' => $this->session->todoList ? $this->session->todoList : $this->createLink('my', 'todo'))); } /* Judge a private todo or not, If private, die. */ diff --git a/module/todo/ui/create.html.php b/module/todo/ui/create.html.php index f5320b52e8..a21024add4 100644 --- a/module/todo/ui/create.html.php +++ b/module/todo/ui/create.html.php @@ -35,8 +35,6 @@ $cycleTypeOptions = array( $days = array(); for($day = 1; $day <= 31; $day ++) $days[$day] = $day . $lang->todo->day; -$isInModal = isAjaxRequest('modal'); - formPanel ( set::title(''), @@ -600,4 +598,4 @@ formPanel ) ); -render($isInModal ? 'modalDialog' : 'page'); +render(isAjaxRequest('modal') ? 'modalDialog' : 'page'); diff --git a/module/todo/ui/edit.html.php b/module/todo/ui/edit.html.php index 518297c084..38f649900f 100644 --- a/module/todo/ui/edit.html.php +++ b/module/todo/ui/edit.html.php @@ -769,4 +769,4 @@ formPanel ) ); -render(); +render(isAjaxRequest('modal') ? 'modalDialog' : 'page');