* [bug#50477,done,0.2h] fixed an issue record effort when data is not changed.
This commit is contained in:
@@ -211,13 +211,15 @@ class task extends control
|
||||
if($this->post->name)
|
||||
{
|
||||
/* Batch edit tasks. */
|
||||
$taskData = $this->taskZen->buildTasksForBatchEdit();
|
||||
$taskData = form::batchData()->get();
|
||||
$oldTasks = $taskData ? $this->task->getByIdList(array_keys($taskData)) : array();
|
||||
$taskData = $this->taskZen->buildTasksForBatchEdit($taskData, $oldTasks);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$allChanges = $this->task->batchUpdate($taskData);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$this->task->afterBatchUpdate($taskData);
|
||||
$this->task->afterBatchUpdate($taskData, $oldTasks);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$response = $this->taskZen->responseAfterBatchEdit($allChanges);
|
||||
|
||||
@@ -126,10 +126,11 @@ class taskModel extends model
|
||||
* other data process after task batch edit.
|
||||
*
|
||||
* @param object[] $tasks
|
||||
* @param object[] $oldTasks
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function afterBatchUpdate(array $tasks): bool
|
||||
public function afterBatchUpdate(array $tasks, array $oldTasks = array()): bool
|
||||
{
|
||||
$this->loadModel('story');
|
||||
$this->loadModel('kanban');
|
||||
@@ -137,13 +138,12 @@ class taskModel extends model
|
||||
|
||||
$today = helper::today();
|
||||
$currentAccount = $this->app->user->account;
|
||||
$oldTasks = $tasks ? $this->getByIdList(array_keys($tasks)) : array();
|
||||
foreach($tasks as $taskID => $task)
|
||||
{
|
||||
$oldTask = zget($oldTasks, $taskID);
|
||||
|
||||
/* Record effort. */
|
||||
if(!empty($task->consumed))
|
||||
if(!empty($task->consumed) && $task->consumed != $oldTask->consumed)
|
||||
{
|
||||
$record = new stdclass();
|
||||
$record->account = $currentAccount;
|
||||
|
||||
+4
-4
@@ -598,14 +598,14 @@ class taskZen extends task
|
||||
* 构造批量编辑的任务数据。
|
||||
* Build the tasks data to batch edit.
|
||||
*
|
||||
* @param array $taskData
|
||||
* @param array $oldTasks
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function buildTasksForBatchEdit(): false|array
|
||||
protected function buildTasksForBatchEdit(array $taskData, array $oldTasks): false|array
|
||||
{
|
||||
$taskData = form::batchData()->get();
|
||||
$oldTasks = $taskData ? $this->task->getByIdList(array_keys($taskData)) : array();
|
||||
$now = helper::now();
|
||||
$now = helper::now();
|
||||
foreach($taskData as $taskID => $task)
|
||||
{
|
||||
$oldTask = $oldTasks[$taskID];
|
||||
|
||||
Reference in New Issue
Block a user