From b4a34e2ed6f1de3124745058764eced1e1d42f98 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Wed, 18 May 2022 10:10:06 +0800 Subject: [PATCH] * Fix bug #22585. --- module/caselib/control.php | 1 - module/caselib/model.php | 23 ++++++++++---------- module/caselib/view/batchcreatecase.html.php | 2 +- module/caselib/view/createcase.html.php | 4 ++-- module/testcase/model.php | 5 +++++ module/testcase/view/batchedit.html.php | 2 +- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/module/caselib/control.php b/module/caselib/control.php index 586b756ccb..c6766c3411 100644 --- a/module/caselib/control.php +++ b/module/caselib/control.php @@ -249,7 +249,6 @@ class caselib extends control if(!empty($_POST)) { $this->loadModel('testcase'); - $this->config->testcase->create->requiredFields = $this->config->caselib->createcase->requiredFields; setcookie('lastLibCaseModule', (int)$this->post->module, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, false); $caseResult = $this->testcase->create($bugID = 0); if(!$caseResult or dao::isError()) return print(js::error(dao::getError())); diff --git a/module/caselib/model.php b/module/caselib/model.php index ba94410657..9e19a18c39 100644 --- a/module/caselib/model.php +++ b/module/caselib/model.php @@ -586,8 +586,7 @@ class caselibModel extends model if(dao::isError()) { - echo js::error(dao::getError()); - return print(js::reload('parent')); + return helper::end(js::error(dao::getError())); } $caseID = $this->dao->lastInsertID(); @@ -597,10 +596,10 @@ class caselibModel extends model } /** - * Build case lib menu. - * - * @param object $object - * @param string $type + * Build case lib menu. + * + * @param object $object + * @param string $type * @access public * @return string */ @@ -611,9 +610,9 @@ class caselibModel extends model } /** - * Build case lib view menu. - * - * @param object $lib + * Build case lib view menu. + * + * @param object $lib * @access public * @return string */ @@ -632,9 +631,9 @@ class caselibModel extends model } /** - * Build case lib browse menu. - * - * @param object $case + * Build case lib browse menu. + * + * @param object $case * @access public * @return string */ diff --git a/module/caselib/view/batchcreatecase.html.php b/module/caselib/view/batchcreatecase.html.php index 8324c93b9a..19bf7f080d 100644 --- a/module/caselib/view/batchcreatecase.html.php +++ b/module/caselib/view/batchcreatecase.html.php @@ -25,7 +25,7 @@ idAB;?> - testcase->module;?> + '>testcase->module;?> testcase->title;?> testcase->type;?> testcase->pri;?> diff --git a/module/caselib/view/createcase.html.php b/module/caselib/view/createcase.html.php index 5f1e0ef23c..aba94f16c8 100644 --- a/module/caselib/view/createcase.html.php +++ b/module/caselib/view/createcase.html.php @@ -33,11 +33,11 @@ - + testcase->create->requiredFields, 'module') ? ' class="required"' : '';?>>
testcase->module?> "; diff --git a/module/testcase/model.php b/module/testcase/model.php index 514112aaf5..bfa6428df2 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -62,6 +62,8 @@ class testcaseModel extends model $result = $this->loadModel('common')->removeDuplicate('case', $case, $param); if($result and $result['stop']) return array('status' => 'exists', 'id' => $result['duplicate']); + if(empty($case->product)) $this->config->testcase->create->requiredFields = str_replace('story', '', $this->config->testcase->create->requiredFields); + /* Value of story may be showmore. */ $case->story = (int)$case->story; $this->dao->insert(TABLE_CASE)->data($case)->autoCheck()->batchCheck($this->config->testcase->create->requiredFields, 'notempty')->checkFlow()->exec(); @@ -729,6 +731,7 @@ class testcaseModel extends model ->get(); $requiredFields = $this->config->testcase->edit->requiredFields; + if($oldCase->lib != 0) { /* Remove the require field named story when the case is a lib case.*/ @@ -975,6 +978,8 @@ class testcaseModel extends model unset($case); } + if(empty($case->product)) $this->config->testcase->edit->requiredFields = str_replace('story', '', $this->config->testcase->edit->requiredFields); + /* Update cases. */ $this->loadModel('action'); foreach($cases as $caseID => $case) diff --git a/module/testcase/view/batchedit.html.php b/module/testcase/view/batchedit.html.php index 76f55c3eac..8a7aca5fb6 100644 --- a/module/testcase/view/batchedit.html.php +++ b/module/testcase/view/batchedit.html.php @@ -54,7 +54,7 @@ testcase->branch;?> - '>testcase->module;?> + '>testcase->module;?> '>testcase->story;?> testcase->title;?> testcase->type;?>