From 84baf0c896ccdbe054a1c5626dc0c44f75e823ef Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Mon, 29 Nov 2021 21:28:42 +0800 Subject: [PATCH 1/3] * Code for task#45080. --- module/story/view/header.html.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/module/story/view/header.html.php b/module/story/view/header.html.php index 5c9c2f0f6f..068c1ada4f 100644 --- a/module/story/view/header.html.php +++ b/module/story/view/header.html.php @@ -28,8 +28,6 @@ function loadProduct(productID) oldProductID = $('#product').val(); loadProductBranches(productID) - loadProductModules(productID); - loadProductPlans(productID); } function loadBranch() @@ -44,7 +42,7 @@ function loadProductBranches(productID) { $('#branch').remove(); $('#branch_chosen').remove(); - $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID), function(data) + $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID + "&oldBranch=0¶m=&projectID=" + executionID), function(data) { var $product = $('#product'); var $inputGroup = $product.closest('.input-group'); @@ -55,12 +53,15 @@ function loadProductBranches(productID) $('#branch').css('width', config.currentMethod == 'create' ? '120px' : '65px').chosen(); } $inputGroup.fixInputGroup(); + + loadProductModules(productID, $('#branch').val()); + loadProductPlans(productID, $('#branch').val()); }) } function loadProductModules(productID, branch) { - if(typeof(branch) == 'undefined') branch = 0; + if(typeof(branch) == 'undefined') branch = $('#branch').val(); if(!branch) branch = 0; var moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=story&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=&needManage=true'); var $moduleIDBox = $('#moduleIdBox'); From 888fbfe73be7aad2235794b8db44593a2a22dc16 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Tue, 30 Nov 2021 15:05:16 +0800 Subject: [PATCH 2/3] * Code for task#45080. --- module/bug/js/common.js | 12 +++---- module/story/control.php | 36 ++++++++++++--------- module/story/view/edit.html.php | 1 + module/testcase/control.php | 30 +++++++++-------- module/testcase/js/common.js | 9 +++--- module/testcase/js/importfromlib.js | 24 +++++++++++++- module/testcase/view/batchedit.html.php | 6 ++-- module/testcase/view/importfromlib.html.php | 2 +- 8 files changed, 76 insertions(+), 44 deletions(-) diff --git a/module/bug/js/common.js b/module/bug/js/common.js index c6cfc14dc0..f5069b73c7 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -55,12 +55,6 @@ function loadAll(productID) $('#taskIdBox').innerHTML = ''; // Reset the task. $('#task').chosen(); loadProductBranches(productID) - loadProductModules(productID); - loadProductProjects(productID); - loadProductBuilds(productID); - loadProductplans(productID); - loadProductStories(productID); - //loadTestTasks(productID); } } @@ -502,6 +496,12 @@ function loadProductBranches(productID) $('#branch').css('width', page == 'create' ? '120px' : '65px'); $('#branch').chosen(); } + + loadProductModules(productID); + loadProductProjects(productID); + loadProductBuilds(productID); + loadProductplans(productID); + loadProductStories(productID); }) } diff --git a/module/story/control.php b/module/story/control.php index e3745d3bff..815465f497 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -436,13 +436,25 @@ class story extends control } } - /* Set products and module. */ + /* Set branch and module. */ $product = $this->product->getById($productID); $products = $this->product->getPairs(); - $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch === 'all' ? 0 : $branch); - if($product) $this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); + if($executionID != 0) + { + $productBranches = $product->type != 'normal' ? $this->loadModel('execution')->getBranchByProduct($productID, $executionID) : array(); + $branches = isset($productBranches[$productID]) ? $productBranches[$productID] : array(); + $branch = key($branches); + } + else + { + $branches = $product->type != 'normal' ? $this->loadModel('branch')->getPairs($productID, 'active') : array(); + } + + $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch === 'all' ? 0 : $branch); + $moduleOptionMenu['ditto'] = $this->lang->story->ditto; + /* Init vars. */ $planID = $plan; $pri = 0; @@ -462,8 +474,6 @@ class story extends control $this->view->titles = $titles; } - $moduleOptionMenu['ditto'] = $this->lang->story->ditto; - $plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch === 'all' ? 0 : $branch, 'skipParent'); $plans['ditto'] = $this->lang->story->ditto; @@ -501,16 +511,6 @@ class story extends control $showFields = str_replace('plan', '', $showFields); } - if($executionID != 0) - { - $productBranches = $product->type != 'normal' ? $this->loadModel('execution')->getBranchByProduct($productID, $executionID) : array(); - $branches = isset($productBranches[$productID]) ? $productBranches[$productID] : array(); - } - else - { - $branches = $product->type != 'normal' ? $this->loadModel('branch')->getPairs($productID, 'active') : array(); - } - $this->view->customFields = $customFields; $this->view->showFields = $showFields; @@ -628,6 +628,7 @@ class story extends control if($product->status == 'normal' and !($product->PO == $this->app->user->account)) $othersProducts[$product->id] = $product->name; if($product->status == 'closed') continue; } + $products = $myProducts + $othersProducts; /* Assign. */ $story = $this->story->getById($storyID, 0, true); @@ -652,6 +653,9 @@ class story extends control $objectID = $this->app->tab == 'project' ? $this->session->project : $this->session->execution; $productBranches = $product->type != 'normal' ? $this->loadModel('execution')->getBranchByProduct($story->product, $objectID) : array(); $branches = isset($productBranches[$story->product]) ? $productBranches[$story->product] : array(); + $products = $this->product->getProductPairsByProject($objectID); + + $this->view->objectID = $objectID; } else { @@ -667,7 +671,7 @@ class story extends control $this->view->users = $users; $this->view->product = $product; $this->view->plans = $this->loadModel('productplan')->getPairsForStory($story->product, $story->branch, 'skipParent'); - $this->view->products = $myProducts + $othersProducts; + $this->view->products = $products; $this->view->branches = $branches; $this->view->reviewers = implode(',', $reviewerList); $this->view->reviewedReviewer = $reviewedReviewer; diff --git a/module/story/view/edit.html.php b/module/story/view/edit.html.php index 7fba2b462d..45eac663dc 100644 --- a/module/story/view/edit.html.php +++ b/module/story/view/edit.html.php @@ -278,4 +278,5 @@ type);?> + diff --git a/module/testcase/control.php b/module/testcase/control.php index 5d358961f6..2d0499357c 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -371,6 +371,20 @@ class testcase extends control $this->qa->setMenu($this->products, $productID, $branch); } + /* Set branch. */ + $product = $this->product->getById($productID); + if($this->app->tab == 'execution' or $this->app->tab == 'project') + { + $objectID = $this->app->tab == 'project' ? $projectID : $executionID; + $productBranches = (isset($product->type) and $product->type != 'normal') ? $this->execution->getBranchByProduct($productID, $objectID) : array(); + $branches = isset($productBranches[$productID]) ? $productBranches[$productID] : array(); + $branch = key($branches); + } + else + { + $branches = (isset($product->type) and $product->type != 'normal') ? $this->loadModel('branch')->getPairs($productID, 'active') : array(); + } + /* Init vars. */ $type = 'feature'; $stage = ''; @@ -456,18 +470,6 @@ class testcase extends control /* Set custom. */ foreach(explode(',', $this->config->testcase->customCreateFields) as $field) $customFields[$field] = $this->lang->testcase->$field; - $product = $this->product->getById($productID); - if($this->app->tab == 'execution' or $this->app->tab == 'project') - { - $objectID = $this->app->tab == 'project' ? $projectID : $executionID; - $productBranches = (isset($product->type) and $product->type != 'normal') ? $this->execution->getBranchByProduct($productID, $objectID) : array(); - $branches = isset($productBranches[$productID]) ? $productBranches[$productID] : array(); - $branch = key($branches); - } - else - { - $branches = (isset($product->type) and $product->type != 'normal') ? $this->loadModel('branch')->getPairs($productID, 'active') : array(); - } $this->view->customFields = $customFields; $this->view->showFields = $this->config->testcase->custom->createFields; @@ -1720,7 +1722,9 @@ class testcase extends control $queryID = (int)$queryID; $product = $this->loadModel('product')->getById($productID); $branches = array(); - if($product->type != 'normal') $branches = array('0' => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($productID, '', $projectID); + + $this->loadModel('branch'); + if($product->type != 'normal') $branches = array('0' => $this->lang->branch->main) + $this->branch->getPairs($productID, '', $projectID); if($_POST) { diff --git a/module/testcase/js/common.js b/module/testcase/js/common.js index f5503151a3..9835f94fbd 100644 --- a/module/testcase/js/common.js +++ b/module/testcase/js/common.js @@ -22,8 +22,6 @@ var newRowID = 0; function loadAll(productID) { loadProductBranches(productID) - loadProductModules(productID); - setStories(); } /** @@ -58,6 +56,9 @@ function loadProductBranches(productID) $('#product').closest('.input-group').append(data); $('#branch').css('width', config.currentMethod == 'create' ? '120px' : '95px'); } + + loadProductModules(productID); + setStories(); }) } @@ -81,7 +82,7 @@ function loadModuleRelated() */ function loadProductModules(productID, branch) { - if(typeof(branch) == 'undefined') branch = 0; + if(typeof(branch) == 'undefined') branch = $('#branch').val(); if(!branch) branch = 0; link = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=case&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=&needManage=true'); $('#moduleIdBox').load(link, function() @@ -126,7 +127,7 @@ function setStories() branch = $('#branch').val(); if(typeof(branch) == 'undefined') branch = 0; link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=50&type=full&hasParent=1&executionID=' + executionID); - + $.get(link, function(stories) { var value = $('#story').val(); diff --git a/module/testcase/js/importfromlib.js b/module/testcase/js/importfromlib.js index af09e8720c..1afb6d67b1 100644 --- a/module/testcase/js/importfromlib.js +++ b/module/testcase/js/importfromlib.js @@ -23,7 +23,29 @@ $(function() }) function reload(libID) -{ +{ link = createLink('testcase','importFromLib','productID='+ productID + '&branch=' + branch + '&libID='+libID); location.href = link; } + +/** + * Load modules. + * + * @param int $productID + * @param int $branch + * @param int $caseID + * @access public + * @return void + */ +function loadModules(productID, branch, caseID) +{ + if(typeof(branch) == 'undefined') branch = 0; + + moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=case&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=&needManage=true'); + var $tr = $('#module' + caseID).closest('tr'); + $('#module' + caseID).parent('td').load(moduleLink, function(data) + { + $tr.find('#module').chosen(); + $tr.find('#module').attr({"id": 'module' + caseID, "name": 'module[' + caseID + ']'}); + }); +} diff --git a/module/testcase/view/batchedit.html.php b/module/testcase/view/batchedit.html.php index 618903907c..46908c484f 100644 --- a/module/testcase/view/batchedit.html.php +++ b/module/testcase/view/batchedit.html.php @@ -69,10 +69,10 @@ branch) ? $cases[$caseID]->branch : 0; - if((!$productID and !$cases[$caseID]->lib) or $app->tab != 'qa') + if(!$productID and !$cases[$caseID]->lib) { $caseProductID = $cases[$caseID]->product; - $product = isset($product) ? $product : $products[$caseProductID]; + $product = $products[$caseProductID]; $branches = isset($branches) ? $branches : array('' => ''); if($product->type != 'normal') { @@ -103,7 +103,7 @@ id;?> type == 'normal') ? "disabled='disabled'" : '';?> - branch, "class='form-control chosen' onchange='loadBranches($branchProductID, this.value, $caseID)', $disabled");?> + '') + $branches, $product->type == 'normal' ? '' : $cases[$caseID]->branch, "class='form-control chosen' onchange='loadBranches($branchProductID, this.value, $caseID)', $disabled");?> diff --git a/module/testcase/view/importfromlib.html.php b/module/testcase/view/importfromlib.html.php index a78f7b88b0..df10fd4979 100644 --- a/module/testcase/view/importfromlib.html.php +++ b/module/testcase/view/importfromlib.html.php @@ -55,7 +55,7 @@ id);?> type != 'normal'):?> - id}]", $branches, $branch, "class='form-control'")?> + id}]", $branches, $branch, "class='form-control' onchange='loadModules($productID, this.value, $case->id)'")?> pri;?>' title='testcase->priList, $case->pri, $case->pri);?>'>pri == '0' ? '' : zget($lang->testcase->priList, $case->pri, $case->pri);?> id", $case->title)) echo $case->title;?> From 70d803975072abbd3de99c9b6b9b69cebc955825 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Tue, 30 Nov 2021 15:31:10 +0800 Subject: [PATCH 3/3] * Add comment. --- module/story/control.php | 2 +- module/story/view/header.html.php | 36 +++++++++++++++++++++++++++++ module/testcase/js/importfromlib.js | 7 ++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/module/story/control.php b/module/story/control.php index 815465f497..d1ca84915a 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -650,7 +650,7 @@ class story extends control if($this->app->tab == 'project' or $this->app->tab == 'execution') { - $objectID = $this->app->tab == 'project' ? $this->session->project : $this->session->execution; + $objectID = $this->app->tab == 'project' ? $this->session->project : $this->session->execution; $productBranches = $product->type != 'normal' ? $this->loadModel('execution')->getBranchByProduct($story->product, $objectID) : array(); $branches = isset($productBranches[$story->product]) ? $productBranches[$story->product] : array(); $products = $this->product->getProductPairsByProject($objectID); diff --git a/module/story/view/header.html.php b/module/story/view/header.html.php index 068c1ada4f..e6375f5545 100644 --- a/module/story/view/header.html.php +++ b/module/story/view/header.html.php @@ -1,6 +1,13 @@