From a9c203b8665604df9164eba366a8448ca853b426 Mon Sep 17 00:00:00 2001 From: mayue Date: Mon, 11 Apr 2022 08:38:13 +0800 Subject: [PATCH] * Fix bug #21616. --- module/testcase/control.php | 9 ++++++++- module/testcase/js/common.js | 27 +++++++++++++++++-------- module/testcase/model.php | 10 ++++----- module/testcase/view/batchedit.html.php | 2 ++ 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/module/testcase/control.php b/module/testcase/control.php index 5896cf1b99..69ae38ebc1 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -964,6 +964,10 @@ class testcase extends control $libID = $productID; $libraries = $this->loadModel('caselib')->getLibraries(); + /* Remove story custom fields from caselib */ + $this->config->testcase->customBatchEditFields = str_replace(',story', '', $this->config->testcase->customBatchEditFields); + $this->config->testcase->custom->batchEditFields = str_replace(',story', '', $this->config->testcase->custom->batchEditFields); + /* Set caselib menu. */ $this->caselib->setLibMenu($libraries, $libID); @@ -1029,11 +1033,11 @@ class testcase extends control $productIdList = array(); foreach($cases as $case) $productIdList[$case->product] = $case->product; - $branches = 0; $branchTagOption = array(); $products = $this->product->getByIdList($productIdList); foreach($products as $product) { + $branches = 0; if($product->type != 'normal') { $branches = $this->loadModel('branch')->getList($product->id, 0, 'all'); @@ -1055,6 +1059,9 @@ class testcase extends control $showSuhosinInfo = common::judgeSuhosinSetting($countInputVars); if($showSuhosinInfo) $this->view->suhosinInfo = extension_loaded('suhosin') ? sprintf($this->lang->suhosinInfo, $countInputVars) : sprintf($this->lang->maxVarsInfo, $countInputVars); + $stories = $this->loadModel('story')->getProductStoryPairs($productID, $branch); + $this->view->stories = array('' => '', 'ditto' => $this->lang->testcase->ditto) + $stories; + /* Set custom. */ foreach(explode(',', $this->config->testcase->customBatchEditFields) as $field) $customFields[$field] = $this->lang->testcase->$field; $this->view->customFields = $customFields; diff --git a/module/testcase/js/common.js b/module/testcase/js/common.js index f70847fd18..5d5f4c368c 100644 --- a/module/testcase/js/common.js +++ b/module/testcase/js/common.js @@ -366,16 +366,27 @@ function loadStories(productID, moduleID, num) var storyLink = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branchID + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=50&type=full&hasParent=1&executionID=0&number=' + num); $.get(storyLink, function(stories) { - if(!stories) modules = ''; + if(!stories) stories = ''; + if(config.currentMethod == 'batchcreate') + { for(var i = num; i < 10 ; i ++) { - if(i != num && $('#module' + i).val() != 'ditto') break; - var nowStories = stories.replaceAll('story' + num, 'story' + i); - $('#story' + i).replaceWith(nowStories); - $('#story' + i + "_chosen").remove(); - $('#story' + i).next('.picker').remove(); - $('#story' + i).attr('name', 'story[' + i + ']'); - $('#story' + i).chosen(); + if(i != num && $('#module' + i).val() != 'ditto') break; + var nowStories = stories.replaceAll('story' + num, 'story' + i); + $('#story' + i).replaceWith(nowStories); + $('#story' + i + "_chosen").remove(); + $('#story' + i).next('.picker').remove(); + $('#story' + i).attr('name', 'story[' + i + ']'); + $('#story' + i).chosen(); } + } + else + { + $('#story' + num).replaceWith(stories); + $('#story' + num + "_chosen").remove(); + $('#story' + num).next('.picker').remove(); + $('#story' + num).attr('name', 'story[' + i + ']'); + $('#story' + num).chosen(); + } }); } diff --git a/module/testcase/model.php b/module/testcase/model.php index f5c10aab36..67c27ead33 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -895,11 +895,10 @@ class testcaseModel extends model foreach($caseIDList as $caseID) { if($data->pris[$caseID] == 'ditto') $data->pris[$caseID] = isset($prev['pri']) ? $prev['pri'] : 3; - if($data->branches[$caseID] == 'ditto') $data->branches[$caseID] = isset($prev['branch']) ? $prev['branch'] : 0; if($data->modules[$caseID] == 'ditto') $data->modules[$caseID] = isset($prev['module']) ? $prev['module'] : 0; - if($data->story[$caseID] == 'ditto') $data->story[$caseID] = isset($prev['story']) ? $prev['story'] : 0; if($data->types[$caseID] == 'ditto') $data->types[$caseID] = isset($prev['type']) ? $prev['type'] : ''; - if($data->story[$caseID] == '') $data->story[$caseID] = 0; + if(isset($data->branches[$caseID]) and $data->branches[$caseID] == 'ditto') $data->branches[$caseID] = isset($prev['branch']) ? $prev['branch'] : 0; + if(!empty($data->story[$caseID]) and $data->story[$caseID] == 'ditto') $data->story[$caseID] = isset($prev['story']) ? $prev['story'] : 0; $prev['pri'] = $data->pris[$caseID]; $prev['type'] = $data->types[$caseID]; @@ -953,8 +952,9 @@ class testcaseModel extends model if(!dao::isError()) { - $isLibCase = ($oldCase->lib and empty($oldCase->product)); - $titleChanged = ($case->title != $oldCase->title); + $isLibCase = ($oldCase->lib and empty($oldCase->product)); + $titleChanged = ($case->title != $oldCase->title); + $case->product = $oldCase->product; if($isLibCase and $titleChanged) $this->dao->update(TABLE_CASE)->set('`title`')->eq($case->title)->where('`fromCaseID`')->eq($caseID)->exec(); $this->updateCase2Project($oldCase, $case, $caseID); diff --git a/module/testcase/view/batchedit.html.php b/module/testcase/view/batchedit.html.php index 2bbe8ce596..d58a558d58 100644 --- a/module/testcase/view/batchedit.html.php +++ b/module/testcase/view/batchedit.html.php @@ -52,6 +52,7 @@ testcase->branch;?> '>testcase->module;?> + '>testcase->story;?> testcase->title;?> testcase->type;?> '>testcase->precondition;?> @@ -91,6 +92,7 @@ ' style='overflow:visible'> '/')), $cases[$caseID]->module, "class='form-control chosen' onchange='loadStories($productID, this.value, $caseID)'");?> + ' style='overflow:visible'>story, "class='form-control chosen'");?>