From c5dd642138ae26298541dc379fa86f8ab96c8fec Mon Sep 17 00:00:00 2001 From: holan20180123 <56391770@qq.com> Date: Wed, 12 May 2021 15:44:04 +0800 Subject: [PATCH] * Return id when create object by API. --- module/bug/control.php | 10 ++++++++++ module/bug/model.php | 2 +- module/build/control.php | 1 + module/caselib/control.php | 8 ++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/module/bug/control.php b/module/bug/control.php index cccc23e0c0..31bbc18fff 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -385,6 +385,9 @@ class bug extends control $this->executeHooks($bugID); + /* Return bug id when call the API. */ + if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $bugID)); + /* If link from no head then reload. */ if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); @@ -613,6 +616,13 @@ class bug extends control { $actions = $this->bug->batchCreate($productID, $branch); + /* Return bug id list when call the API. */ + if($this->viewType == 'json') + { + $bugIDList = array_keys($actions); + $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $bugIDList)); + } + setcookie('bugModule', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, false); die(js::locate($this->createLink('bug', 'browse', "productID={$productID}&branch=$branch&browseType=unclosed¶m=0&orderBy=id_desc"), 'parent')); } diff --git a/module/bug/model.php b/module/bug/model.php index 913347b1dc..992abf3804 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -161,7 +161,7 @@ class bugModel extends model $bug->openedBy = $this->app->user->account; $bug->openedDate = $now; $bug->product = (int)$productID; - $bug->branch = (int)$data->branches[$i]; + $bug->branch = isset($data->branches) ? (int)$data->branches[$i] : 0; $bug->module = (int)$data->modules[$i]; $bug->execution = (int)$data->executions[$i]; $bug->openedBuild = implode(',', $data->openedBuilds[$i]); diff --git a/module/build/control.php b/module/build/control.php index d626567243..98a8af08d8 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -37,6 +37,7 @@ class build extends control $this->executeHooks($buildID); + if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $buildID)); if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadExecutionBuilds($executionID)")); // Code for task #5126. $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('build', 'view', "buildID=$buildID"))); } diff --git a/module/caselib/control.php b/module/caselib/control.php index f2e28ecbd8..01030be398 100644 --- a/module/caselib/control.php +++ b/module/caselib/control.php @@ -42,6 +42,14 @@ class caselib extends control $this->send($response); } $this->loadModel('action')->create('caselib', $libID, 'opened'); + + /* Return lib id when call the API. */ + if($this->viewType == 'json') + { + $response['id'] = $libID; + $this->send($response); + } + $response['locate'] = $this->createLink('caselib', 'browse', "libID=$libID"); $this->send($response); }