From 9fa66c3d0f19466955097230d3f66ee03376e56a Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Thu, 24 Feb 2022 14:40:14 +0800 Subject: [PATCH 01/11] * Code for task#49304. --- module/branch/model.php | 57 ++++++++++- module/bug/control.php | 55 ++++++++--- module/bug/view/batchedit.html.php | 16 ++- module/execution/control.php | 10 +- module/execution/view/linkstory.html.php | 13 +++ module/product/control.php | 27 ++++-- module/product/model.php | 4 + module/product/view/browse.html.php | 3 +- module/story/control.php | 118 ++++++++++++----------- module/story/model.php | 59 +++++++++--- module/story/view/batchedit.html.php | 16 ++- 11 files changed, 273 insertions(+), 105 deletions(-) diff --git a/module/branch/model.php b/module/branch/model.php index d32b12b34a..7692f4f7ba 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -85,8 +85,6 @@ class branchModel extends model $mainBranch->desc = sprintf($this->lang->branch->mainBranch, $this->lang->product->branchName[$product->type]); $mainBranch->order = 0; - if($productID) $product = $this->loadModel('product')->getById($productID); - if(isset($product) and $product->type == 'normal') return $branchList; return array($mainBranch) + $branchList; } @@ -351,16 +349,69 @@ class branchModel extends model /** * Unlink branches for projects when product type is normal. * - * @param int $productIDList + * @param int|array $productIDList * @access public * @return void */ public function unlinkBranch4Project($productIDList) { + $productLinkedProject = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT) + ->where('product')->in($productIDList) + ->andWhere('branch')->gt(0) + ->fetchGroup('product', 'project'); + $this->dao->delete()->from(TABLE_PROJECTPRODUCT) ->where('product')->in($productIDList) ->andWhere('branch')->gt(0) ->exec(); + + foreach($productLinkedProject as $productID => $projectList) + { + foreach($projectList as $projectID => $project) + { + $data = new stdClass(); + $data->product = $productID; + $data->project = $projectID; + $data->branch = 0; + $data->plan = 0; + + $this->dao->replace(TABLE_PROJECTPRODUCT)->data($data)->exec(); + } + } + } + + /** + * Link branches for projects when product type is not normal. + * + * @param int $productID + * @access public + * @return void + */ + public function linkBranch4Project($productID) + { + if(is_array($productID)) + { + foreach($productID as $id) $this->linkBranch4Project($id); + } + + $linkedBranchProject = $this->dao->select('project,branch')->from(TABLE_PROJECTSTORY) + ->where('product')->eq($productID) + ->andWhere('branch')->gt(0) + ->fetchGroup('project','branch'); + + foreach($linkedBranchProject as $projectID => $branchList) + { + foreach($branchList as $branchID => $branch) + { + $data = new stdClass(); + $data->product = $productID; + $data->project = $projectID; + $data->branch = $branchID; + $data->plan = 0; + + $this->dao->replace(TABLE_PROJECTPRODUCT)->data($data)->exec(); + } + } } /** diff --git a/module/bug/control.php b/module/bug/control.php index 502bedb543..e677a1b580 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -89,16 +89,23 @@ class bug extends control $this->loadModel('datatable'); $productID = $this->product->saveState($productID, $this->products); + $product = $this->product->getById($productID); + if($product->type != 'normal') + { + /* Set productID, moduleID, queryID and branch. */ + $branch = ($this->cookie->preBranch !== '' and $branch === '') ? $this->cookie->preBranch : $branch; + setcookie('preProductID', $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); + setcookie('preBranch', $branch, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); + } + else + { + $branch = 'all'; + } + $this->qa->setMenu($this->products, $productID, $branch); /* Set browse type. */ $browseType = strtolower($browseType); - - /* Set productID, moduleID, queryID and branch. */ - $branch = ($this->cookie->preBranch !== '' and $branch === '') ? $this->cookie->preBranch : $branch; - setcookie('preProductID', $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); - setcookie('preBranch', $branch, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); - if($this->cookie->preProductID != $productID or $this->cookie->preBranch != $branch or $browseType == 'bybranch') { $_COOKIE['bugModule'] = 0; @@ -191,19 +198,22 @@ class bug extends control $showModule = !empty($this->config->datatable->bugBrowse->showModule) ? $this->config->datatable->bugBrowse->showModule : ''; $productName = ($productID and isset($this->products[$productID])) ? $this->products[$productID] : $this->lang->product->allProduct; - $product = $this->product->getById($productID); - /* Display of branch label. */ - $showBranch = $this->loadModel('branch')->showBranch($productID); - - /* Display status of branch. */ - $branches = $this->loadModel('branch')->getList($productID, 0, 'all'); + $showBranch = false; $branchOption = array(); $branchTagOption = array(); - foreach($branches as $branchInfo) + if($product and $product->type != 'normal') { - $branchOption[$branchInfo->id] = $branchInfo->name; - $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + /* Display of branch label. */ + $showBranch = $this->loadModel('branch')->showBranch($productID); + + /* Display status of branch. */ + $branches = $this->loadModel('branch')->getList($productID, 0, 'all'); + foreach($branches as $branchInfo) + { + $branchOption[$branchInfo->id] = $branchInfo->name; + $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + } } /* Set view. */ @@ -985,13 +995,26 @@ class bug extends control $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); } + $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $bug->branch); + if(!isset($moduleOptionMenu[$bug->module])) + { + $bugModule = '/'; + $modulePath = $this->tree->getParents($bug->module); + foreach($modulePath as $key => $module) + { + $bugModule .= $module->name; + if(isset($modulePath[$key + 1])) $bugModule .= '/'; + } + $moduleOptionMenu += array($bug->module => $bugModule); + } + $this->view->bug = $bug; $this->view->productID = $productID; $this->view->product = $product; $this->view->productName = $this->products[$productID]; $this->view->plans = $this->loadModel('productplan')->getPairs($productID, $bug->branch, '', true); $this->view->projects = array(0 => '') + $this->product->getProjectPairsByProduct($productID, $bug->branch, $bug->project); - $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $bug->branch); + $this->view->moduleOptionMenu = $moduleOptionMenu; $this->view->currentModuleID = $currentModuleID; $this->view->executions = array(0 => '') + $this->product->getExecutionPairsByProduct($bug->product, $bug->branch, 'id_desc', $bug->project); $this->view->stories = $bug->execution ? $this->story->getExecutionStoryPairs($bug->execution) : $this->story->getProductStoryPairs($bug->product, $bug->branch); diff --git a/module/bug/view/batchedit.html.php b/module/bug/view/batchedit.html.php index 859a2abcb9..179fe2d3c7 100644 --- a/module/bug/view/batchedit.html.php +++ b/module/bug/view/batchedit.html.php @@ -92,6 +92,20 @@ $modules[$bug->product][$bug->branch] = $this->tree->getOptionMenu($bug->product, 'bug', 0, $bug->branch); } } + + $moduleList = $modules[$bug->product]; + if(!isset($moduleList[$bug->branch])) + { + $bugModule = '/'; + $modulePath = $this->tree->getParents($bug->module); + foreach($modulePath as $key => $module) + { + $bugModule .= $module->name; + if(isset($modulePath[$key + 1])) $bugModule .= '/'; + } + + $moduleList[$bug->branch] = $modules[$bug->product][0] + array($bug->module => $bugModule); + } ?> @@ -119,7 +133,7 @@ branch, "class='form-control chosen' $disabled onchange='setBranchRelated(this.value, $bug->product, $bug->id)'");?> - product][$bug->branch], $bug->module, "class='form-control chosen'");?> + branch]) ? $moduleList[$bug->branch] : array(0 => '/'), $bug->module, "class='form-control chosen'");?> ' style='overflow:visible'>plan, "class='form-control chosen'");?> ' style='overflow:visible'>assignedTo, "class='form-control chosen'");?> ' style='overflow:visible'>deadline, "class='form-control form-date'");?> diff --git a/module/execution/control.php b/module/execution/control.php index 5d73250ea5..2d999b98b4 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2573,8 +2573,8 @@ class execution extends control $this->view->unmodifiableProducts = $unmodifiableProducts; $this->view->unmodifiableBranches = $unmodifiableBranches; $this->view->linkedBranches = $linkedBranches; - $this->view->branchGroups = $this->execution->getBranchByProduct(array_keys($allProducts), $this->config->systemMode == 'new' ? $execution->project : 0); - $this->view->allBranches = $this->execution->getBranchByProduct(array_keys($allProducts), $this->config->systemMode == 'new' ? $execution->project : 0, 'all'); + $this->view->branchGroups = $this->execution->getBranchByProduct(array_keys($allProducts), $this->config->systemMode == 'new' ? $execution->project : 0, 'ignoreNormal|noclosed'); + $this->view->allBranches = $this->execution->getBranchByProduct(array_keys($allProducts), $this->config->systemMode == 'new' ? $execution->project : 0, 'ignoreNormal'); $this->display(); } @@ -2748,7 +2748,6 @@ class execution extends control /* Set modules and branches. */ $modules = array(); - $branchIDList = array(BRANCH_MAIN); $branches = $this->project->getBranchesByProject($objectID); $productType = 'normal'; $this->loadModel('tree'); @@ -2762,7 +2761,8 @@ class execution extends control } if($product->type != 'normal') { - $productType = $product->type; + $productType = $product->type; + $branchIDList = array(BRANCH_MAIN); if(isset($branches[$product->id])) { foreach($branches[$product->id] as $branchID => $branch) $branchIDList[$branchID] = $branchID; @@ -2781,7 +2781,7 @@ class execution extends control } else { - $allStories = $this->story->getProductStories(array_keys($products), $branchIDList, $moduleID = '0', $status = 'active', 'story', 'id_desc', $hasParent = false, '', $pager = null); + $allStories = $this->story->getProductStories(array_keys($products), isset($branchIDList) ? $branchIDList : 'all', $moduleID = '0', $status = 'active', 'story', 'id_desc', $hasParent = false, '', $pager = null); } $linkedStories = $this->story->getExecutionStoryPairs($objectID); diff --git a/module/execution/view/linkstory.html.php b/module/execution/view/linkstory.html.php index 0a6d336e56..c529bc0e3c 100644 --- a/module/execution/view/linkstory.html.php +++ b/module/execution/view/linkstory.html.php @@ -69,6 +69,19 @@ ?> createLink('product', 'browse', "productID=$story->product&branch=$story->branch"), $products[$story->product]->name, '_blank');?> + module])) + { + $storyModule = count($products) > 1 ? $products[$story->product]->name . '/' : '/'; + $modulePath = $this->tree->getParents($story->module); + foreach($modulePath as $key => $module) + { + $storyModule .= $module->name; + if(isset($modulePath[$key + 1])) $storyModule .= '/'; + } + $modules[$story->module] = $storyModule; + } + ?> '>module, '')?> planTitle;?> story->stageList, $story->stage);?> diff --git a/module/product/control.php b/module/product/control.php index c2f9bbfb4c..e3f6a2dcea 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -135,9 +135,18 @@ class product extends control public function browse($productID = 0, $branch = '', $browseType = '', $param = 0, $storyType = 'story', $orderBy = '', $recTotal = 0, $recPerPage = 20, $pageID = 1, $projectID = 0) { $productID = $this->app->tab != 'project' ? $this->product->saveState($productID, $this->products) : $productID; - $branches = $this->loadModel('branch')->getList($productID, $projectID, 'all'); - $branch = ($this->cookie->preBranch !== '' and $branch === '' and isset($branches[$this->cookie->preBranch])) ? $this->cookie->preBranch : $branch; - $branchID = $branch; + $product = $this->product->getById($productID); + + if($product and $product->type != 'normal') + { + $branchPairs = $this->loadModel('branch')->getPairs($productID, 'all'); + $branch = ($this->cookie->preBranch !== '' and $branch === '' and isset($branchPairs[$this->cookie->preBranch])) ? $this->cookie->preBranch : $branch; + $branchID = $branch; + } + else + { + $branchID = $branch = 'all'; + } /* Set menu. */ if($this->app->tab == 'product') @@ -224,8 +233,6 @@ class product extends control /* Display of branch label. */ $showBranch = $this->loadModel('branch')->showBranch($productID); - $product = $this->product->getById($productID); - /* Get stories. */ if($this->app->rawModule == 'projectstory') { @@ -248,10 +255,14 @@ class product extends control /* Display status of branch. */ $branchOption = array(); $branchTagOption = array(); - foreach($branches as $branchInfo) + if($product and $product->type != 'normal') { - $branchOption[$branchInfo->id] = $branchInfo->name; - $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + $branches = $this->loadModel('branch')->getList($productID, $projectID, 'all'); + foreach($branches as $branchInfo) + { + $branchOption[$branchInfo->id] = $branchInfo->name; + $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + } } /* Process the sql, get the conditon partion, save it to session. */ diff --git a/module/product/model.php b/module/product/model.php index 3d2aa99eac..14494a894e 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -695,6 +695,7 @@ class productModel extends model $this->loadModel('personnel')->updateWhitelist($whitelist, 'product', $productID); if($product->acl != 'open') $this->loadModel('user')->updateUserView($productID, 'product'); if($product->type == 'normal' and $oldProduct->type != 'normal') $this->loadModel('branch')->unlinkBranch4Project($productID); + if($product->type != 'normal' and $oldProduct->type == 'normal') $this->loadModel('branch')->linkBranch4Project($productID); return common::createChanges($oldProduct, $product); } @@ -745,6 +746,7 @@ class productModel extends model if(dao::isError()) die(js::error(dao::getError())); $unlinkProducts = array(); + $linkProducts = array(); foreach($products as $productID => $product) { $oldProduct = $oldProducts[$productID]; @@ -763,11 +765,13 @@ class productModel extends model if($product->acl == 'open') $this->loadModel('personnel')->updateWhitelist('', 'product', $productID); if($product->acl != 'open') $this->loadModel('user')->updateUserView($productID, 'product'); if($product->type == 'normal' and $oldProduct->type != 'normal') $unlinkProducts[] = $productID; + if($product->type != 'normal' and $oldProduct->type == 'normal') $linkProducts[] = $productID; $allChanges[$productID] = common::createChanges($oldProduct, $product); } if(!empty($unlinkProducts)) $this->loadModel('branch')->unlinkBranch4Project($unlinkProducts); + if(!empty($linkProducts)) $this->loadModel('branch')->linkBranch4Project($linkProducts); return $allChanges; } diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php index 6f4793f2fc..f0e66d191c 100644 --- a/module/product/view/browse.html.php +++ b/module/product/view/browse.html.php @@ -489,7 +489,8 @@ $projectIDParam = $isProjectStory ? "projectID=$projectID&" : ''; app->tab == 'project' and $browseType != 'bybranch') ? false : true;?> - + + type != 'normal' and $branchID != 'all') or $product->type == 'normal')?>
8;?> diff --git a/module/story/control.php b/module/story/control.php index e3d56248b4..95be333976 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -717,6 +717,19 @@ class story extends control $this->story->replaceURLang($story->type); + /* Process the module when branch products are switched to normal products. */ + if($product->type == 'normal' and !empty($story->branch)) + { + $storyModule = '/'; + $modulePath = $this->tree->getParents($story->module); + foreach($modulePath as $key => $module) + { + $storyModule .= $module->name; + if(isset($modulePath[$key + 1])) $storyModule .= '/'; + } + $this->view->moduleOptionMenu += array($story->module => $storyModule); + } + $this->view->title = $this->lang->story->edit . "STORY" . $this->lang->colon . $this->view->story->title; $this->view->position[] = $this->lang->story->edit; $this->view->story = $story; @@ -800,82 +813,72 @@ class story extends control $stories = $this->story->getByList($storyIdList); $this->loadModel('branch'); - if($productID or $executionID) + if($productID and !$executionID) { - if(!$executionID) + $product = $this->product->getByID($productID); + $branchProduct = $product->type == 'normal' ? false : true; + + $branches = 0; + $branchTagOption = array(); + if($branchProduct) { $branches = $this->branch->getList($productID, $executionID, 'all'); - $branchOption = array(); - $branchTagOption = array(); foreach($branches as $branchInfo) $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); - - $product = $this->product->getByID($productID); - $branchProduct = $product->type == 'normal' ? false : true; - $modulePairs = $this->tree->getOptionMenu($productID, 'story', 0, array_keys($branches)); - $branchModules = $branchProduct ? $modulePairs : array('0' => $modulePairs); - $modules = array($productID => $branchModules); - $plans = array($productID => $this->productplan->getBranchPlanPairs($productID, '', true)); - $products = array($productID => $product); - $branchTagOption = array($productID => $branchTagOption); + $branches = array_keys($branches); } - else - { - $modules = array(); - $branches = array(); - $branchTagOption = array(); - $execution = $this->execution->getByID($executionID); - $branchProduct = false; - $linkedProducts = $this->loadModel('product')->getProducts($executionID); - foreach($linkedProducts as $linkedProduct) - { - $branchList = $this->branch->getList($linkedProduct->id, $executionID, 'all'); - foreach($branchList as $branchInfo) $branches[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); - $branchTagOption[$linkedProduct->id] = array(BRANCH_MAIN => $this->lang->branch->main) + $branches; + $modulePairs = $this->tree->getOptionMenu($productID, 'story', 0, $branches); + $moduleList = $branchProduct ? $modulePairs : array(0 => $modulePairs); - $moduleList = $this->tree->getOptionMenu($linkedProduct->id, 'story', 0, array_keys($branchList)); - $modules[$linkedProduct->id] = $linkedProduct->type != 'normal' ? $moduleList : array(0 => $moduleList); - - $plans[$linkedProduct->id] = $this->productplan->getBranchPlanPairs($linkedProduct->id, array_keys($branchList), true); - if(empty($plans[$linkedProduct->id])) $plans[$linkedProduct->id][0] = $plans[$linkedProduct->id]; - - if($linkedProduct->type != 'normal') $branchProduct = true; - } - $products = $linkedProducts; - } - $this->view->title = (isset($product) ? $product->name : $execution->name) . $this->lang->colon . $this->lang->story->batchEdit; - $this->view->branchTagOption = $branchTagOption; - $this->view->modules = $modules; - $this->view->productName = isset($product) ? $product->name : ''; + $modules = array($productID => $moduleList); + $plans = array($productID => $this->productplan->getBranchPlanPairs($productID, '', true)); + $products = array($productID => $product); + $branchTagOption = array($productID => $branchTagOption); } else { - /* The stories of my. */ - $branchProduct = false; - $productIdList = array(); - foreach($stories as $story) $productIdList[$story->product] = $story->product; - $products = $this->product->getByIdList($productIdList); + $branchProduct = false; + $modules = array(); + $branchTagOption = array(); + $products = array(); + + if($executionID) + { + /* The stories of project or execution. */ + $execution = $this->execution->getByID($executionID); + $products = $this->loadModel('product')->getProducts($executionID); + } + else + { + /* The stories of my. */ + $productIdList = array(); + foreach($stories as $story) $productIdList[$story->product] = $story->product; + $products = $this->product->getByIdList($productIdList); + } + foreach($products as $storyProduct) { - $branchList = array(); - $branches = $this->branch->getList($storyProduct->id, 0, 'all'); - foreach($branches as $branchInfo) $branchList[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); - $branchIdList = array_keys($branchList) ? array_keys($branchList) : 0; - $branchTagOption[$storyProduct->id] = $branchList; + $branches = 0; + if($storyProduct->type != 'normal') + { + $branches = $this->branch->getList($storyProduct->id, $executionID, 'all'); + foreach($branches as $branchInfo) $branches[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + $branchTagOption[$storyProduct->id] = array(BRANCH_MAIN => $this->lang->branch->main) + $branches; - $modules[$storyProduct->id] = $this->tree->getOptionMenu($storyProduct->id, 'story', 0, $branchIdList); - if($storyProduct->type == 'normal') $modules[$storyProduct->id][0] = $modules[$storyProduct->id]; + $branches = array_keys($branches); + } - $plans[$storyProduct->id] = $this->productplan->getBranchPlanPairs($storyProduct->id, array_keys($branchList), true); + $modulePairs = $this->tree->getOptionMenu($storyProduct->id, 'story', 0, $branches); + $modules[$storyProduct->id] = $storyProduct->type != 'normal' ? $modulePairs : array(0 => $modulePairs); + + $plans[$storyProduct->id] = $this->productplan->getBranchPlanPairs($storyProduct->id, $branches, true); if(empty($plans[$storyProduct->id])) $plans[$storyProduct->id][0] = $plans[$storyProduct->id]; if($storyProduct->type != 'normal') $branchProduct = true; } - - $this->view->title = $this->lang->story->batchEdit; - $this->view->branchTagOption = $branchTagOption; - $this->view->modules = $modules; } + $this->view->branchTagOption = $branchTagOption; + $this->view->modules = $modules; /* Set ditto option for users. */ $users = $this->loadModel('user')->getPairs('nodeleted'); @@ -901,6 +904,7 @@ class story extends control $this->view->position[] = $this->lang->story->common; $this->view->position[] = $this->lang->story->batchEdit; + $this->view->title = $this->lang->story->batchEdit; $this->view->users = $users; $this->view->priList = array('0' => '', 'ditto' => $this->lang->story->ditto) + $this->lang->story->priList; $this->view->sourceList = array('' => '', 'ditto' => $this->lang->story->ditto) + $this->lang->story->sourceList; diff --git a/module/story/model.php b/module/story/model.php index 8f34c62857..aa87f59b2d 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2262,20 +2262,53 @@ class storyModel extends model { if(defined('TUTORIAL')) return $this->loadModel('tutorial')->getStories(); - if(is_array($branch)) $branch = join(',', $branch); + $stories = array(); + $branchProducts = array(); + $normalProducts = array(); + $productList = $this->dao->select('*')->from(TABLE_PRODUCT)->where('id')->in($productID)->fetchAll('id'); + foreach($productList as $product) + { + if($product->type != 'normal') + { + $branchProducts[$product->id] = $product->id; + continue; + } - $stories = $this->dao->select('*')->from(TABLE_STORY) - ->where('product')->in($productID) - ->beginIF(!$hasParent)->andWhere("parent")->ge(0)->fi() - ->beginIF($branch !== 'all')->andWhere("branch")->in($branch)->fi() - ->beginIF(!empty($moduleIdList))->andWhere('module')->in($moduleIdList)->fi() - ->beginIF(!empty($excludeStories))->andWhere('id')->notIN($excludeStories)->fi() - ->beginIF($status and $status != 'all')->andWhere('status')->in($status)->fi() - ->andWhere('type')->eq($type) - ->andWhere('deleted')->eq(0) - ->orderBy($orderBy) - ->page($pager) - ->fetchAll('id'); + $normalProducts[$product->id] = $product->id; + } + + if(!empty($normalProducts)) + { + $stories += $this->dao->select('*')->from(TABLE_STORY) + ->where('product')->in($normalProducts) + ->beginIF(!$hasParent)->andWhere("parent")->ge(0)->fi() + ->beginIF(!empty($moduleIdList))->andWhere('module')->in($moduleIdList)->fi() + ->beginIF(!empty($excludeStories))->andWhere('id')->notIN($excludeStories)->fi() + ->beginIF($status and $status != 'all')->andWhere('status')->in($status)->fi() + ->andWhere('type')->eq($type) + ->andWhere('deleted')->eq(0) + ->orderBy($orderBy) + ->page($pager) + ->fetchAll('id'); + } + + if(!empty($branchProducts)) + { + if(is_array($branch)) $branch = join(',', $branch); + + $stories += $this->dao->select('*')->from(TABLE_STORY) + ->where('product')->in($branchProducts) + ->beginIF(!$hasParent)->andWhere("parent")->ge(0)->fi() + ->beginIF($branch !== 'all')->andWhere("branch")->in($branch)->fi() + ->beginIF(!empty($moduleIdList))->andWhere('module')->in($moduleIdList)->fi() + ->beginIF(!empty($excludeStories))->andWhere('id')->notIN($excludeStories)->fi() + ->beginIF($status and $status != 'all')->andWhere('status')->in($status)->fi() + ->andWhere('type')->eq($type) + ->andWhere('deleted')->eq(0) + ->orderBy($orderBy) + ->page($pager) + ->fetchAll('id'); + } return $this->mergePlanTitle($productID, $stories, $branch, $type); } diff --git a/module/story/view/batchedit.html.php b/module/story/view/batchedit.html.php index 09f99ddc88..7ef476774b 100644 --- a/module/story/view/batchedit.html.php +++ b/module/story/view/batchedit.html.php @@ -77,7 +77,21 @@ foreach(explode(',', $showFields) as $field) '> - product][$story->branch]) ? $modules[$story->product][$story->branch] : array('0' => '/'), $story->module, "class='form-control chosen'");?> + product]; + if($products[$story->product]->type == 'normal' and !empty($story->branch)) + { + $storyModule = '/'; + $modulePath = $this->tree->getParents($story->module); + foreach($modulePath as $key => $module) + { + $storyModule .= $module->name; + if(isset($modulePath[$key + 1])) $storyModule .= '/'; + } + $moduleList[$story->branch] = $modules[$story->product][0] + array($story->module => $storyModule); + } + ?> + branch]) ? $moduleList[$story->branch] : array(0 => '/'), $story->module, "class='form-control chosen'");?> '> product][$story->branch]) ? array('' => '') + $plans[$story->product][$story->branch] : '', $story->plan, "class='form-control chosen'");?> From 5a518081d9f677476142fca90e38b21a565f538e Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Thu, 24 Feb 2022 16:21:20 +0800 Subject: [PATCH 02/11] * Code for task#49304. --- module/story/model.php | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/module/story/model.php b/module/story/model.php index aa87f59b2d..cf7638c946 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2565,27 +2565,49 @@ class storyModel extends model $storyQuery = str_replace($allProduct, '1', $storyQuery); $queryProductID = 'all'; } + $storyQuery = $storyQuery . ' AND `product` ' . helper::dbIN(array_keys($products)); + if($excludeStories) $storyQuery = $storyQuery . ' AND `id` NOT ' . helper::dbIN($excludeStories); if($this->app->moduleName == 'productplan') $storyQuery .= " AND `status` NOT IN ('closed') AND `parent` >= 0 "; $allBranch = "`branch` = 'all'"; if($executionID != '') { - $branches = array(BRANCH_MAIN => BRANCH_MAIN); - if($branch === '') + $normalProducts = array(); + $branchProducts = array(); + foreach($products as $product) { - foreach($products as $product) + if($product->type != 'normal') { - foreach($product->branches as $branchID) $branches[$branchID] = $branchID; + $branchProducts[$product->id] = $product; + continue; } - } - else - { - $branches[$branch] = $branch; + + $normalProducts[$product->id] = $product; } - $branches = join(',', $branches); - $storyQuery .= " AND `branch`" . helper::dbIN($branches); + $storyQuery .= ' AND ('; + if(!empty($normalProducts)) $storyQuery .= '`product` ' . helper::dbIN(array_keys($normalProducts)); + if(!empty($branchProducts)) + { + $branches = array(BRANCH_MAIN => BRANCH_MAIN); + if($branch === '') + { + foreach($branchProducts as $product) + { + foreach($product->branches as $branchID) $branches[$branchID] = $branchID; + } + } + else + { + $branches[$branch] = $branch; + } + + $branches = join(',', $branches); + $storyQuery .= " OR (`product` " . helper::dbIN(array_keys($branchProducts)) . " AND `branch` " . helper::dbIN($branches) . ")"; + } + if(empty($branchProducts) and empty($branchProducts)) $storyQuery .= '1 = 1'; + $storyQuery .= ') '; if($this->app->moduleName == 'release' or $this->app->moduleName == 'build') { From 7c65ee95555c3870c6481030175fe5efced89f36 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Thu, 24 Feb 2022 16:30:18 +0800 Subject: [PATCH 03/11] * Fix bug. --- module/execution/control.php | 2 +- module/story/model.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 2d999b98b4..966d017aba 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2748,6 +2748,7 @@ class execution extends control /* Set modules and branches. */ $modules = array(); + $branchIDList = array(BRANCH_MAIN); $branches = $this->project->getBranchesByProject($objectID); $productType = 'normal'; $this->loadModel('tree'); @@ -2762,7 +2763,6 @@ class execution extends control if($product->type != 'normal') { $productType = $product->type; - $branchIDList = array(BRANCH_MAIN); if(isset($branches[$product->id])) { foreach($branches[$product->id] as $branchID => $branch) $branchIDList[$branchID] = $branchID; diff --git a/module/story/model.php b/module/story/model.php index cf7638c946..5486a3e63e 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2604,7 +2604,8 @@ class storyModel extends model } $branches = join(',', $branches); - $storyQuery .= " OR (`product` " . helper::dbIN(array_keys($branchProducts)) . " AND `branch` " . helper::dbIN($branches) . ")"; + if(!empty($normalProducts)) $storyQuery .= " OR "; + $storyQuery .= "(`product` " . helper::dbIN(array_keys($branchProducts)) . " AND `branch` " . helper::dbIN($branches) . ")"; } if(empty($branchProducts) and empty($branchProducts)) $storyQuery .= '1 = 1'; $storyQuery .= ') '; From d15a0ea9b2d649081a610aaff5bdc261265c81d1 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Thu, 24 Feb 2022 17:07:54 +0800 Subject: [PATCH 04/11] * Modify module of testcase when change product type. --- module/productplan/view/linkstory.html.php | 13 +++++++++++++ module/productplan/view/view.html.php | 15 ++++++++++++++- module/testcase/control.php | 22 +++++++++++++--------- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/module/productplan/view/linkstory.html.php b/module/productplan/view/linkstory.html.php index c026b12eef..0920b4fad1 100644 --- a/module/productplan/view/linkstory.html.php +++ b/module/productplan/view/linkstory.html.php @@ -47,6 +47,19 @@ pri;?>' title='story->priList, $story->pri, $story->pri)?>'>story->priList, $story->pri, $story->pri)?> planTitle;?> + module])) + { + $storyModule = '/'; + $modulePath = $this->tree->getParents($story->module); + foreach($modulePath as $key => $module) + { + $storyModule .= $module->name; + if(isset($modulePath[$key + 1])) $storyModule .= '/'; + } + $modules[$story->module] = $storyModule; + } + ?> module];?> pri;?>' title='story->priList, $story->pri, $story->pri);?>'>story->priList, $story->pri, $story->pri);?> - module, '');?> + module])) + { + $storyModule = '/'; + $modulePath = $this->tree->getParents($story->module); + foreach($modulePath as $key => $module) + { + $storyModule .= $module->name; + if(isset($modulePath[$key + 1])) $storyModule .= '/'; + } + $modulePairs[$story->module] = $storyModule; + } + ?> + '>module, '');?> parent > 0) echo "story->children}>{$lang->story->childrenAB}"; diff --git a/module/testcase/control.php b/module/testcase/control.php index a8607dfbc3..f4d7f4dae4 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -175,20 +175,24 @@ class testcase extends control $moduleTree = $this->tree->getTreeMenu($productID, 'case', 0, array('treeModel', 'createCaseLink'), array('projectID' => $projectID, 'productID' => $productID), $projectID ? '' : $branch); } - /* Display of branch label. */ - $showBranch = $this->loadModel('branch')->showBranch($productID); + $product = $this->product->getById($productID); - /* Display status of branch. */ - $branches = $this->loadModel('branch')->getList($productID, $projectID, 'all'); + $showBranch = false; $branchOption = array(); $branchTagOption = array(); - foreach($branches as $branchInfo) + if($product and $product->type != 'normal') { - $branchOption[$branchInfo->id] = $branchInfo->name; - $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); - } + /* Display of branch label. */ + $showBranch = $this->loadModel('branch')->showBranch($productID); - $product = $this->product->getById($productID); + /* Display status of branch. */ + $branches = $this->loadModel('branch')->getList($productID, $projectID, 'all'); + foreach($branches as $branchInfo) + { + $branchOption[$branchInfo->id] = $branchInfo->name; + $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + } + } /* Assign. */ $tree = $moduleID ? $this->tree->getByID($moduleID) : ''; From 09f4270792bd33cf0a59eb1680b63c04810fbecc Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Fri, 25 Feb 2022 13:10:54 +0800 Subject: [PATCH 05/11] * Modify the module of test case when change product type. --- module/testcase/control.php | 12 ++++++++++++ module/testcase/view/batchedit.html.php | 16 ++++++++++++++-- module/testtask/view/batchrun.html.php | 13 ++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/module/testcase/control.php b/module/testcase/control.php index f4d7f4dae4..e34a74d96c 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -875,6 +875,18 @@ class testcase extends control } } + if(!isset($moduleOptionMenu[$case->module])) + { + $caseModule = '/'; + $modulePath = $this->tree->getParents($case->module); + foreach($modulePath as $key => $module) + { + $caseModule .= $module->name; + if(isset($modulePath[$key + 1])) $caseModule .= '/'; + } + $moduleOptionMenu[$case->module] = $caseModule; + } + /* Get product and branches. */ $product = $this->product->getById($productID); if($this->app->tab == 'execution' or $this->app->tab == 'project') diff --git a/module/testcase/view/batchedit.html.php b/module/testcase/view/batchedit.html.php index 457ed17dd7..f94d9737ad 100644 --- a/module/testcase/view/batchedit.html.php +++ b/module/testcase/view/batchedit.html.php @@ -86,6 +86,19 @@ $modules[$caseProductID][$caseBranch] = $this->tree->getOptionMenu($cases[$caseID]->product, 'case', 0, $caseBranch); } + $caseProductID = isset($caseProductID) ? $caseProductID : $productID; + $moduleList = $modules[$caseProductID]; + if(!isset($moduleList[$caseBranch])) + { + $caseModule = '/'; + $modulePath = $this->tree->getParents($cases[$caseID]->module); + foreach($modulePath as $key => $module) + { + $caseModule .= $module->name; + if(isset($modulePath[$key + 1])) $caseModule .= '/'; + } + $moduleList[$caseBranch] = $modules[$caseProductID][0] + array($cases[$caseID]->module => $caseModule); + } ?> @@ -110,8 +123,7 @@ type == 'normal' ? '' : $cases[$caseID]->branch, "class='form-control chosen' onchange='loadBranches($branchProductID, this.value, $caseID)', $disabled");?> - - ' style='overflow:visible'>module, "class='form-control chosen' onchange='loadStories($productID, this.value, $caseID)'");?> + ' style='overflow:visible'>module, "class='form-control chosen' onchange='loadStories($productID, this.value, $caseID)'");?> ' style='overflow:visible'>story, "class='form-control chosen'");?>
diff --git a/module/testtask/view/batchrun.html.php b/module/testtask/view/batchrun.html.php index 75335c475a..f0836aa3c3 100644 --- a/module/testtask/view/batchrun.html.php +++ b/module/testtask/view/batchrun.html.php @@ -37,7 +37,18 @@ echo html::hidden("caseIDList[$case->id]", $caseID); if(!isset($moduleOptionMenu[$case->module])) $moduleOptionMenu += $this->tree->getOptionMenu($case->product, 'case', 0, $case->branch); } - ?> + if(!isset($moduleOptionMenu[$case->module])) + { + $caseModule = '/'; + $modulePath = $this->tree->getParents($cases[$caseID]->module); + foreach($modulePath as $key => $module) + { + $caseModule .= $module->name; + if(isset($modulePath[$key + 1])) $caseModule .= '/'; + } + $moduleOptionMenu[$case->module] = $caseModule; + } + ?> version)?> module] . "'>" . $moduleOptionMenu[$case->module] . ""?> From 9024dae71eaa6c5fe9692363fcd6a3cb50cc90cb Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Mon, 28 Feb 2022 10:15:16 +0800 Subject: [PATCH 06/11] * Modify linked products when edit product. --- module/branch/model.php | 52 +++++++++++++++++++++++-- module/story/model.php | 2 +- module/testcase/view/batchedit.html.php | 8 +++- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/module/branch/model.php b/module/branch/model.php index 7692f4f7ba..6d399261e2 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -394,14 +394,60 @@ class branchModel extends model foreach($productID as $id) $this->linkBranch4Project($id); } - $linkedBranchProject = $this->dao->select('project,branch')->from(TABLE_PROJECTSTORY) + $linkedBranchProject = array(); + + $storyLinkedBranchProject = $this->dao->select('project,branch')->from(TABLE_PROJECTSTORY) ->where('product')->eq($productID) ->andWhere('branch')->gt(0) - ->fetchGroup('project','branch'); + ->fetchGroup('project', 'branch'); + foreach($storyLinkedBranchProject as $projectID => $branchList) + { + foreach($branchList as $branchID => $branch) $linkedBranchProject[$projectID][$branchID] = $branchID; + } + + $bugLinkedBranchProject = $this->dao->select('project,branch')->from(TABLE_BUG) + ->where('product')->eq($productID) + ->andWhere('branch')->gt(0) + ->andWhere('project')->ne(0) + ->fetchGroup('project', 'branch'); + foreach($bugLinkedBranchProject as $projectID => $branchList) + { + foreach($branchList as $branchID => $branch) $linkedBranchProject[$projectID][$branchID] = $branchID; + } + + $bugLinkedBranchExecution = $this->dao->select('execution,branch')->from(TABLE_BUG) + ->where('product')->eq($productID) + ->andWhere('branch')->gt(0) + ->andWhere('execution')->ne(0) + ->fetchGroup('execution', 'branch'); + foreach($bugLinkedBranchExecution as $executionID => $branchList) + { + foreach($branchList as $branchID => $branch) $linkedBranchProject[$executionID][$branchID] = $branchID; + } + + $caseLinkedBranchProject = $this->dao->select('project,branch')->from(TABLE_CASE) + ->where('product')->eq($productID) + ->andWhere('branch')->gt(0) + ->andWhere('project')->ne(0) + ->fetchGroup('project', 'branch'); + foreach($caseLinkedBranchProject as $projectID => $branchList) + { + foreach($branchList as $branchID => $branch) $linkedBranchProject[$projectID][$branchID] = $branchID; + } + + $caseLinkedBranchExecution = $this->dao->select('execution,branch')->from(TABLE_CASE) + ->where('product')->eq($productID) + ->andWhere('branch')->gt(0) + ->andWhere('execution')->ne(0) + ->fetchGroup('execution', 'branch'); + foreach($caseLinkedBranchExecution as $executionID => $branchList) + { + foreach($branchList as $branchID => $branch) $linkedBranchProject[$executionID][$branchID] = $branchID; + } foreach($linkedBranchProject as $projectID => $branchList) { - foreach($branchList as $branchID => $branch) + foreach($branchList as $branchID) { $data = new stdClass(); $data->product = $productID; diff --git a/module/story/model.php b/module/story/model.php index 5486a3e63e..9c24455077 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2607,7 +2607,7 @@ class storyModel extends model if(!empty($normalProducts)) $storyQuery .= " OR "; $storyQuery .= "(`product` " . helper::dbIN(array_keys($branchProducts)) . " AND `branch` " . helper::dbIN($branches) . ")"; } - if(empty($branchProducts) and empty($branchProducts)) $storyQuery .= '1 = 1'; + if(empty($normalProducts) and empty($branchProducts)) $storyQuery .= '1 = 1'; $storyQuery .= ') '; if($this->app->moduleName == 'release' or $this->app->moduleName == 'build') diff --git a/module/testcase/view/batchedit.html.php b/module/testcase/view/batchedit.html.php index f94d9737ad..eb39ab9f5d 100644 --- a/module/testcase/view/batchedit.html.php +++ b/module/testcase/view/batchedit.html.php @@ -82,9 +82,13 @@ $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); } foreach($branchTagOption as $branchID => $branchName) $branchTagOption[$branchID] = '/' . $product->name . '/' . $branchName; - } - $modules[$caseProductID][$caseBranch] = $this->tree->getOptionMenu($cases[$caseID]->product, 'case', 0, $caseBranch); + $modules[$caseProductID][$caseBranch] = $this->tree->getOptionMenu($cases[$caseID]->product, 'case', 0, $caseBranch); + } + else + { + $modules[$caseProductID][0] = $this->tree->getOptionMenu($cases[$caseID]->product, 'case'); + } } $caseProductID = isset($caseProductID) ? $caseProductID : $productID; $moduleList = $modules[$caseProductID]; From 5f6c2bec3b04ce487129853d5f4c9930fbbee58a Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Mon, 28 Feb 2022 10:44:41 +0800 Subject: [PATCH 07/11] * Delete unused code. --- module/execution/control.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 966d017aba..7e7c3efb8f 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2762,7 +2762,7 @@ class execution extends control } if($product->type != 'normal') { - $productType = $product->type; + $productType = $product->type; if(isset($branches[$product->id])) { foreach($branches[$product->id] as $branchID => $branch) $branchIDList[$branchID] = $branchID; @@ -2781,7 +2781,7 @@ class execution extends control } else { - $allStories = $this->story->getProductStories(array_keys($products), isset($branchIDList) ? $branchIDList : 'all', $moduleID = '0', $status = 'active', 'story', 'id_desc', $hasParent = false, '', $pager = null); + $allStories = $this->story->getProductStories(array_keys($products), $branchIDList, $moduleID = '0', $status = 'active', 'story', 'id_desc', $hasParent = false, '', $pager = null); } $linkedStories = $this->story->getExecutionStoryPairs($objectID); From 5cd1872e93a3d47b462df9c1782288a46c5f338f Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Mon, 28 Feb 2022 17:04:12 +0800 Subject: [PATCH 08/11] * Modify edit bug and batch edit bug. --- module/bug/control.php | 97 ++++++++++++++---------------- module/bug/view/batchedit.html.php | 39 +----------- 2 files changed, 49 insertions(+), 87 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index e677a1b580..33657d063f 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -996,17 +996,7 @@ class bug extends control } $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $bug->branch); - if(!isset($moduleOptionMenu[$bug->module])) - { - $bugModule = '/'; - $modulePath = $this->tree->getParents($bug->module); - foreach($modulePath as $key => $module) - { - $bugModule .= $module->name; - if(isset($modulePath[$key + 1])) $bugModule .= '/'; - } - $moduleOptionMenu += array($bug->module => $bugModule); - } + if(!isset($moduleOptionMenu[$bug->module])) $moduleOptionMenu += $this->tree->getModulesName($bug->module); $this->view->bug = $bug; $this->view->productID = $productID; @@ -1088,57 +1078,58 @@ class bug extends control $plans = array('' => '', 'ditto' => $this->lang->bug->ditto) + $plans; /* Set branches and modules. */ - $branches = array(); + $branches = 0; $branchTagOption = array(); - $modules = array(); + $modules = array(); if($product->type != 'normal') { $branches = $this->loadModel('branch')->getList($productID, 0 ,'all'); - foreach($branches as $branchInfo) - { - $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); - } - foreach($branchTagOption as $branchID => $branchName) - { - $modules[$productID][$branchID] = $this->tree->getOptionMenu($productID, 'bug', 0, $branchID); - } - } - else - { - $modules[$productID][0] = $this->tree->getOptionMenu($productID, 'bug'); + foreach($branches as $branchInfo) $branchTagOption[$productID][$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + $branches = array_keys($branches); } + $modulePairs = $this->tree->getOptionMenu($productID, 'bug', 0, $branches); + $modules[$productID] = $product->type != 'normal' ? $modulePairs : array(0 => $modulePairs); + /* Set product menu. */ $this->qa->setMenu($this->products, $productID, $branch); - $this->view->title = $product->name . $this->lang->colon . "BUG" . $this->lang->bug->batchEdit; - $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID&branch=$branch"), $this->products[$productID]); - $this->view->plans = $plans; - $this->view->branchTagOption = $branchTagOption; - $this->view->modules = $modules; + $this->view->title = $product->name . $this->lang->colon . "BUG" . $this->lang->bug->batchEdit; + $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID&branch=$branch"), $this->products[$productID]); + $this->view->plans = $plans; } /* The bugs of my. */ else { - $branchProduct = false; - $productIdList = array(); + $branchProduct = false; + $productIdList = array(); + $branchTagOption = array(); foreach($bugs as $bug) $productIdList[$bug->product] = $bug->product; - $products = $this->product->getByIdList($productIdList); - foreach($products as $product) + $productList = $this->product->getByIdList($productIdList); + foreach($productList as $product) { + $branches = 0; if($product->type != 'normal') { + $branches = $this->loadModel('branch')->getList($product->id, 0 ,'all'); + foreach($branches as $branchInfo) $branchTagOption[$product->id][$branchInfo->id] = '/' . $product->name . '/' . $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + + $branches = array_keys($branches); $branchProduct = true; - break; } + + $modulePairs = $this->tree->getOptionMenu($product->id, 'bug', 0, $branches); + $modules[$product->id] = $product->type != 'normal' ? $modulePairs : array(0 => $modulePairs); } $this->app->loadLang('my'); $this->lang->task->menu = $this->lang->my->menu->work; $this->lang->my->menu->work['subModule'] = 'bug'; - $this->view->position[] = html::a($this->createLink('my', 'bug'), $this->lang->my->bug); - $this->view->title = "BUG" . $this->lang->bug->batchEdit; + $this->view->position[] = html::a($this->createLink('my', 'bug'), $this->lang->my->bug); + $this->view->title = "BUG" . $this->lang->bug->batchEdit; + $this->view->plans = $this->loadModel('productplan')->getPairs($product->id, $branch); + $this->view->productList = $productList; } /* Judge whether the editedBugs is too large and set session. */ @@ -1157,25 +1148,29 @@ class bug extends control { $appendUsers[$bug->assignedTo] = $bug->assignedTo; $appendUsers[$bug->resolvedBy] = $bug->resolvedBy; + + if(!isset($modules[$bug->product][$bug->branch])) $modules[$bug->product][$bug->branch] = $modules[$bug->product][0] + $this->tree->getModulesName($bug->module); } $users = $this->user->getPairs('devfirst', $appendUsers, $this->config->maxCount); $users = array('' => '', 'ditto' => $this->lang->bug->ditto) + $users; /* Assign. */ - $this->view->position[] = $this->lang->bug->common; - $this->view->position[] = $this->lang->bug->batchEdit; - $this->view->productID = $productID; - $this->view->branchProduct = $branchProduct; - $this->view->severityList = array('ditto' => $this->lang->bug->ditto) + $this->lang->bug->severityList; - $this->view->typeList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->typeList; - $this->view->priList = array('0' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->priList; - $this->view->resolutionList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->resolutionList; - $this->view->statusList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->statusList; - $this->view->osList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->osList; - $this->view->browserList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->browserList; - $this->view->bugs = $bugs; - $this->view->branch = $branch; - $this->view->users = $users; + $this->view->position[] = $this->lang->bug->common; + $this->view->position[] = $this->lang->bug->batchEdit; + $this->view->productID = $productID; + $this->view->branchProduct = $branchProduct; + $this->view->severityList = array('ditto' => $this->lang->bug->ditto) + $this->lang->bug->severityList; + $this->view->typeList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->typeList; + $this->view->priList = array('0' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->priList; + $this->view->resolutionList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->resolutionList; + $this->view->statusList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->statusList; + $this->view->osList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->osList; + $this->view->browserList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->browserList; + $this->view->bugs = $bugs; + $this->view->branch = $branch; + $this->view->users = $users; + $this->view->modules = $modules; + $this->view->branchTagOption = $branchTagOption; $this->display(); } diff --git a/module/bug/view/batchedit.html.php b/module/bug/view/batchedit.html.php index 179fe2d3c7..985b4645c4 100644 --- a/module/bug/view/batchedit.html.php +++ b/module/bug/view/batchedit.html.php @@ -74,38 +74,6 @@ $bug):?> config->user->moreLink)) $this->config->moreLinks["assignedTos[$bugID]"] = $this->config->user->moreLink; - if(!$productID) - { - $branchTagOption = array(); - $product = $this->product->getByID($bug->product); - $plans = $this->loadModel('productplan')->getPairs($bug->product, $branch); - $branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getList($product->id, 0 ,'all'); - foreach($branches as $branchInfo) - { - $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); - } - - $modules[$bug->product][0] = $this->tree->getOptionMenu($bug->product, 'bug'); - if($product->type != 'normal') - { - foreach($branchTagOption as $branchID => $branchName) $branchTagOption[$branchID] = '/' . $product->name . '/' . $branchName; - $modules[$bug->product][$bug->branch] = $this->tree->getOptionMenu($bug->product, 'bug', 0, $bug->branch); - } - } - - $moduleList = $modules[$bug->product]; - if(!isset($moduleList[$bug->branch])) - { - $bugModule = '/'; - $modulePath = $this->tree->getParents($bug->module); - foreach($modulePath as $key => $module) - { - $bugModule .= $module->name; - if(isset($modulePath[$key + 1])) $bugModule .= '/'; - } - - $moduleList[$bug->branch] = $modules[$bug->product][0] + array($bug->module => $bugModule); - } ?> @@ -128,12 +96,11 @@ - id;?> - type == 'normal') ? "disabled='disabled'" : '';?> - branch, "class='form-control chosen' $disabled onchange='setBranchRelated(this.value, $bug->product, $bug->id)'");?> + product]->type == 'normal') ? "disabled='disabled'" : '';?> + product], $bug->branch, "class='form-control chosen' $disabled onchange='setBranchRelated(this.value, $bug->product, $bug->id)'");?> - branch]) ? $moduleList[$bug->branch] : array(0 => '/'), $bug->module, "class='form-control chosen'");?> + product][$bug->branch]) ? $modules[$bug->product][$bug->branch] : array(0 => '/'), $bug->module, "class='form-control chosen'");?> ' style='overflow:visible'>plan, "class='form-control chosen'");?> ' style='overflow:visible'>assignedTo, "class='form-control chosen'");?> ' style='overflow:visible'>deadline, "class='form-control form-date'");?> From af76bc5b462c10a026f4651c6c51394e9b3aa432 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Mon, 28 Feb 2022 17:50:06 +0800 Subject: [PATCH 09/11] * Append story module when change product type. --- module/execution/control.php | 7 +++++++ module/execution/view/linkstory.html.php | 13 ------------- module/productplan/control.php | 16 ++++++++++++++-- module/productplan/view/linkstory.html.php | 13 ------------- module/productplan/view/view.html.php | 13 ------------- 5 files changed, 21 insertions(+), 41 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 7e7c3efb8f..ffbd27ee75 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2789,6 +2789,13 @@ class execution extends control { if(isset($linkedStories[$story->id])) unset($allStories[$id]); if($story->parent < 0) unset($allStories[$id]); + + if(!isset($modules[$story->module])) + { + $storyModule = $this->tree->getModulesName($story->module); + $productName = count($products) > 1 ? $products[$story->product]->name : ''; + $modules[$story->module] = $productName . $storyModule[$story->module]; + } } /* Pager. */ diff --git a/module/execution/view/linkstory.html.php b/module/execution/view/linkstory.html.php index c529bc0e3c..0a6d336e56 100644 --- a/module/execution/view/linkstory.html.php +++ b/module/execution/view/linkstory.html.php @@ -69,19 +69,6 @@ ?> createLink('product', 'browse', "productID=$story->product&branch=$story->branch"), $products[$story->product]->name, '_blank');?> - module])) - { - $storyModule = count($products) > 1 ? $products[$story->product]->name . '/' : '/'; - $modulePath = $this->tree->getParents($story->module); - foreach($modulePath as $key => $module) - { - $storyModule .= $module->name; - if(isset($modulePath[$key + 1])) $storyModule .= '/'; - } - $modules[$story->module] = $storyModule; - } - ?> '>module, '')?> planTitle;?> story->stageList, $story->stage);?> diff --git a/module/productplan/control.php b/module/productplan/control.php index 0eae192bfb..c7aec77188 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -362,8 +362,14 @@ class productplan extends control if($plan->branch > 0) $this->view->branchStatus = $this->loadModel('branch')->getById($plan->branch, $plan->product, 'status'); + $modulePairs = $this->loadModel('tree')->getOptionMenu($plan->product, 'story', 0, 'all'); + foreach($planStories as $story) + { + if(!isset($modulePairs[$story->module])) $modulePairs += $this->tree->getModulesName($story->module); + } + $this->loadModel('datatable'); - $this->view->modulePairs = $this->loadModel('tree')->getOptionMenu($plan->product, 'story', 0, 'all'); + $this->view->modulePairs = $modulePairs; $this->view->title = "PLAN #$plan->id $plan->title/" . zget($products, $plan->product, ''); $this->view->position[] = $this->lang->productplan->view; $this->view->planStories = $planStories; @@ -606,6 +612,12 @@ class productplan extends control $allStories = $this->story->getProductStories($this->view->product->id, $plan->branch ? "0,{$plan->branch}" : 0, $moduleID = '0', $status = 'draft,active,changed', 'story', 'id_desc', $hasParent = false, array_keys($planStories), $pager); } + $modules = $this->loadModel('tree')->getOptionMenu($plan->product, 'story', 0, 'all'); + foreach($allStories as $story) + { + if(!isset($modules[$story->module])) $modules += $this->tree->getModulesName($story->module); + } + $this->view->allStories = $allStories; $this->view->planStories = $planStories; $this->view->products = $products; @@ -613,7 +625,7 @@ class productplan extends control $this->view->plans = $this->dao->select('id, end')->from(TABLE_PRODUCTPLAN)->fetchPairs(); $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->browseType = $browseType; - $this->view->modules = $this->loadModel('tree')->getOptionMenu($plan->product, 'story', 0, 'all'); + $this->view->modules = $modules; $this->view->param = $param; $this->view->orderBy = $orderBy; $this->view->pager = $pager; diff --git a/module/productplan/view/linkstory.html.php b/module/productplan/view/linkstory.html.php index 0920b4fad1..c026b12eef 100644 --- a/module/productplan/view/linkstory.html.php +++ b/module/productplan/view/linkstory.html.php @@ -47,19 +47,6 @@ pri;?>' title='story->priList, $story->pri, $story->pri)?>'>story->priList, $story->pri, $story->pri)?> planTitle;?> - module])) - { - $storyModule = '/'; - $modulePath = $this->tree->getParents($story->module); - foreach($modulePath as $key => $module) - { - $storyModule .= $module->name; - if(isset($modulePath[$key + 1])) $storyModule .= '/'; - } - $modules[$story->module] = $storyModule; - } - ?> module];?> pri;?>' title='story->priList, $story->pri, $story->pri);?>'>story->priList, $story->pri, $story->pri);?> - module])) - { - $storyModule = '/'; - $modulePath = $this->tree->getParents($story->module); - foreach($modulePath as $key => $module) - { - $storyModule .= $module->name; - if(isset($modulePath[$key + 1])) $storyModule .= '/'; - } - $modulePairs[$story->module] = $storyModule; - } - ?> '>module, '');?> Date: Tue, 1 Mar 2022 14:40:00 +0800 Subject: [PATCH 10/11] * Optimize the code. --- module/story/control.php | 30 ++++++++------ module/story/model.php | 53 ++++++++++++------------ module/story/view/batchedit.html.php | 16 +------- module/testcase/control.php | 54 ++++++++++++------------- module/testcase/view/batchedit.html.php | 47 +++------------------ module/testtask/control.php | 9 +++-- module/testtask/view/batchrun.html.php | 20 +-------- 7 files changed, 81 insertions(+), 148 deletions(-) diff --git a/module/story/control.php b/module/story/control.php index 95be333976..227242b916 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -718,17 +718,7 @@ class story extends control $this->story->replaceURLang($story->type); /* Process the module when branch products are switched to normal products. */ - if($product->type == 'normal' and !empty($story->branch)) - { - $storyModule = '/'; - $modulePath = $this->tree->getParents($story->module); - foreach($modulePath as $key => $module) - { - $storyModule .= $module->name; - if(isset($modulePath[$key + 1])) $storyModule .= '/'; - } - $this->view->moduleOptionMenu += array($story->module => $storyModule); - } + if($product->type == 'normal' and !empty($story->branch)) $this->view->moduleOptionMenu += $this->tree->getModulesName($story->module); $this->view->title = $this->lang->story->edit . "STORY" . $this->lang->colon . $this->view->story->title; $this->view->position[] = $this->lang->story->edit; @@ -877,8 +867,6 @@ class story extends control if($storyProduct->type != 'normal') $branchProduct = true; } } - $this->view->branchTagOption = $branchTagOption; - $this->view->modules = $modules; /* Set ditto option for users. */ $users = $this->loadModel('user')->getPairs('nodeleted'); @@ -902,6 +890,20 @@ class story extends control $showSuhosinInfo = common::judgeSuhosinSetting($countInputVars); if($showSuhosinInfo) $this->view->suhosinInfo = extension_loaded('suhosin') ? sprintf($this->lang->suhosinInfo, $countInputVars) : sprintf($this->lang->maxVarsInfo, $countInputVars); + /* Append module when change product type. */ + $moduleList = array(0 => '/'); + foreach($stories as $story) + { + if(isset($modules[$story->product][$story->branch])) + { + $moduleList[$story->id] = $modules[$story->product][$story->branch]; + } + else + { + $moduleList[$story->id] = $modules[$story->product][0] + $this->tree->getModulesName($story->module); + } + } + $this->view->position[] = $this->lang->story->common; $this->view->position[] = $this->lang->story->batchEdit; $this->view->title = $this->lang->story->batchEdit; @@ -919,6 +921,8 @@ class story extends control $this->view->storyType = $storyType; $this->view->stories = $stories; $this->view->executionID = $executionID; + $this->view->branchTagOption = $branchTagOption; + $this->view->moduleList = $moduleList; $this->display(); } diff --git a/module/story/model.php b/module/story/model.php index 9c24455077..50b943ef82 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2277,38 +2277,35 @@ class storyModel extends model $normalProducts[$product->id] = $product->id; } - if(!empty($normalProducts)) - { - $stories += $this->dao->select('*')->from(TABLE_STORY) - ->where('product')->in($normalProducts) - ->beginIF(!$hasParent)->andWhere("parent")->ge(0)->fi() - ->beginIF(!empty($moduleIdList))->andWhere('module')->in($moduleIdList)->fi() - ->beginIF(!empty($excludeStories))->andWhere('id')->notIN($excludeStories)->fi() - ->beginIF($status and $status != 'all')->andWhere('status')->in($status)->fi() - ->andWhere('type')->eq($type) - ->andWhere('deleted')->eq(0) - ->orderBy($orderBy) - ->page($pager) - ->fetchAll('id'); - } - + $productQuery = '('; + if(!empty($normalProducts)) $productQuery .= '`product` ' . helper::dbIN(array_keys($normalProducts)); if(!empty($branchProducts)) { - if(is_array($branch)) $branch = join(',', $branch); + if(!empty($normalProducts)) $productQuery .= " OR "; + $productQuery .= "(`product` " . helper::dbIN(array_keys($branchProducts)); - $stories += $this->dao->select('*')->from(TABLE_STORY) - ->where('product')->in($branchProducts) - ->beginIF(!$hasParent)->andWhere("parent")->ge(0)->fi() - ->beginIF($branch !== 'all')->andWhere("branch")->in($branch)->fi() - ->beginIF(!empty($moduleIdList))->andWhere('module')->in($moduleIdList)->fi() - ->beginIF(!empty($excludeStories))->andWhere('id')->notIN($excludeStories)->fi() - ->beginIF($status and $status != 'all')->andWhere('status')->in($status)->fi() - ->andWhere('type')->eq($type) - ->andWhere('deleted')->eq(0) - ->orderBy($orderBy) - ->page($pager) - ->fetchAll('id'); + if($branch !== 'all') + { + if(is_array($branch)) $branch = join(',', $branch); + $productQuery .= " AND `branch` " . helper::dbIN($branch); + } + $productQuery .= ')'; } + if(empty($normalProducts) and empty($branchProducts)) $productQuery .= '1 = 1'; + $productQuery .= ') '; + + $stories = $this->dao->select('*')->from(TABLE_STORY) + ->where('product')->in($productID) + ->andWhere($productQuery) + ->beginIF(!$hasParent)->andWhere("parent")->ge(0)->fi() + ->beginIF(!empty($moduleIdList))->andWhere('module')->in($moduleIdList)->fi() + ->beginIF(!empty($excludeStories))->andWhere('id')->notIN($excludeStories)->fi() + ->beginIF($status and $status != 'all')->andWhere('status')->in($status)->fi() + ->andWhere('type')->eq($type) + ->andWhere('deleted')->eq(0) + ->orderBy($orderBy) + ->page($pager) + ->fetchAll('id'); return $this->mergePlanTitle($productID, $stories, $branch, $type); } diff --git a/module/story/view/batchedit.html.php b/module/story/view/batchedit.html.php index 7ef476774b..68dc1de905 100644 --- a/module/story/view/batchedit.html.php +++ b/module/story/view/batchedit.html.php @@ -77,21 +77,7 @@ foreach(explode(',', $showFields) as $field) '> - product]; - if($products[$story->product]->type == 'normal' and !empty($story->branch)) - { - $storyModule = '/'; - $modulePath = $this->tree->getParents($story->module); - foreach($modulePath as $key => $module) - { - $storyModule .= $module->name; - if(isset($modulePath[$key + 1])) $storyModule .= '/'; - } - $moduleList[$story->branch] = $modules[$story->product][0] + array($story->module => $storyModule); - } - ?> - branch]) ? $moduleList[$story->branch] : array(0 => '/'), $story->module, "class='form-control chosen'");?> + id, array(0 => '/')), $story->module, "class='form-control chosen'");?> '> product][$story->branch]) ? array('' => '') + $plans[$story->product][$story->branch] : '', $story->plan, "class='form-control chosen'");?> diff --git a/module/testcase/control.php b/module/testcase/control.php index e34a74d96c..cd09abb4d3 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -875,17 +875,7 @@ class testcase extends control } } - if(!isset($moduleOptionMenu[$case->module])) - { - $caseModule = '/'; - $modulePath = $this->tree->getParents($case->module); - foreach($modulePath as $key => $module) - { - $caseModule .= $module->name; - if(isset($modulePath[$key + 1])) $caseModule .= '/'; - } - $moduleOptionMenu[$case->module] = $caseModule; - } + if(!isset($moduleOptionMenu[$case->module])) $moduleOptionMenu += $this->tree->getModulesName($case->module); /* Get product and branches. */ $product = $this->product->getById($productID); @@ -976,7 +966,6 @@ class testcase extends control /* Set modules. */ $modules[$productID][$branch] = $this->tree->getOptionMenu($libID, 'caselib', 0, $branch); - $this->view->modules = $modules; $this->view->title = $libraries[$libID] . $this->lang->colon . $this->lang->testcase->batchEdit; $this->view->position[] = html::a($this->createLink('caselib', 'browse', "libID=$libID"), $libraries[$libID]); } @@ -1008,8 +997,7 @@ class testcase extends control $modules[$productID][BRANCH_MAIN] = $this->tree->getOptionMenu($productID, 'case'); } - $this->view->branchTagOption = $branchTagOption; - $this->view->modules = $modules; + $this->view->branchTagOption = array($productID => $branchTagOption); $this->view->position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]); $this->view->title = $product->name . $this->lang->colon . $this->lang->testcase->batchEdit; $this->view->product = $product; @@ -1037,31 +1025,27 @@ class testcase extends control $productIdList = array(); foreach($cases as $case) $productIdList[$case->product] = $case->product; - $products = $this->product->getByIdList($productIdList); + $branches = 0; + $branchTagOption = array(); + $products = $this->product->getByIdList($productIdList); foreach($products as $product) { if($product->type != 'normal') { + $branches = $this->loadModel('branch')->getList($product->id, 0, 'all'); + foreach($branches as $branchInfo) $branchTagOption[$product->id][$branchInfo->id] = '/' . $product->name . '/' . $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + $branches = array_keys($branches); $branchProduct = true; - break; } - } - if($this->app->tab == 'project') - { - $productBranches = $this->loadModel('execution')->getBranchByProduct(array_keys($products), $this->session->project, 'all'); - } - else - { - $productBranches = $this->loadModel('branch')->getByProducts(array_keys($products), 'ignoreNormal'); + $modulePairs = $this->tree->getOptionMenu($product->id, 'case', 0, $branches); + $modules[$product->id] = $product->type != 'normal' ? $modulePairs : array(0 => $modulePairs); } $this->view->products = $products; - $this->view->productBranches = $productBranches; + $this->view->branchTagOption = $branchTagOption; } - // if(!$this->testcase->forceNotReview()) unset($this->lang->testcase->statusList['wait']); /* Bug#1343 */ - /* Judge whether the editedCases is too large and set session. */ $countInputVars = count($cases) * (count(explode(',', $this->config->testcase->custom->batchEditFields)) + 3); $showSuhosinInfo = common::judgeSuhosinSetting($countInputVars); @@ -1075,6 +1059,21 @@ class testcase extends control $this->view->customFields = $customFields; $this->view->showFields = $this->config->testcase->custom->batchEditFields; + /* Append module when change product type. */ + $modulePairs = array(0 => '/'); + foreach($cases as $case) + { + $caseProduct = $type == 'lib' ? $productID : $case->product; + if(isset($modules[$caseProduct][$case->branch])) + { + $modulePairs[$case->id] = $modules[$caseProduct][$case->branch]; + } + else + { + $modulePairs[$case->id] = $modules[$caseProduct][0] + $this->tree->getModulesName($case->module); + } + } + /* Assign. */ $this->view->position[] = $this->lang->testcase->common; $this->view->position[] = $this->lang->testcase->batchEdit; @@ -1085,6 +1084,7 @@ class testcase extends control $this->view->typeList = array('' => '', 'ditto' => $this->lang->testcase->ditto) + $this->lang->testcase->typeList; $this->view->cases = $cases; $this->view->forceNotReview = $this->testcase->forceNotReview(); + $this->view->modulePairs = $modulePairs; $this->display(); } diff --git a/module/testcase/view/batchedit.html.php b/module/testcase/view/batchedit.html.php index eb39ab9f5d..8917eb5884 100644 --- a/module/testcase/view/batchedit.html.php +++ b/module/testcase/view/batchedit.html.php @@ -66,44 +66,7 @@ - branch) ? $cases[$caseID]->branch : 0; - if(!$productID and !$cases[$caseID]->lib) - { - $caseProductID = $cases[$caseID]->product; - $product = $products[$caseProductID]; - $branchTagOption = array(); - if($product->type != 'normal') - { - $branches = $this->loadModel('branch')->getList($product->id, 0, 'all'); - foreach($branches as $branchInfo) - { - $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); - } - foreach($branchTagOption as $branchID => $branchName) $branchTagOption[$branchID] = '/' . $product->name . '/' . $branchName; - - $modules[$caseProductID][$caseBranch] = $this->tree->getOptionMenu($cases[$caseID]->product, 'case', 0, $caseBranch); - } - else - { - $modules[$caseProductID][0] = $this->tree->getOptionMenu($cases[$caseID]->product, 'case'); - } - } - $caseProductID = isset($caseProductID) ? $caseProductID : $productID; - $moduleList = $modules[$caseProductID]; - if(!isset($moduleList[$caseBranch])) - { - $caseModule = '/'; - $modulePath = $this->tree->getParents($cases[$caseID]->module); - foreach($modulePath as $key => $module) - { - $caseModule .= $module->name; - if(isset($modulePath[$key + 1])) $caseModule .= '/'; - } - $moduleList[$caseBranch] = $modules[$caseProductID][0] + array($cases[$caseID]->module => $caseModule); - } - ?> + '> pri, 'class=form-control');?> @@ -122,12 +85,12 @@ - id;?> - type == 'normal') ? "disabled='disabled'" : '';?> - type == 'normal' ? '' : $cases[$caseID]->branch, "class='form-control chosen' onchange='loadBranches($branchProductID, this.value, $caseID)', $disabled");?> + product;?> + + branch : '', "class='form-control chosen' onchange='loadBranches($branchProductID, this.value, $caseID)', $disabled");?> - ' style='overflow:visible'>module, "class='form-control chosen' onchange='loadStories($productID, this.value, $caseID)'");?> + ' style='overflow:visible'> '/')), $cases[$caseID]->module, "class='form-control chosen' onchange='loadStories($productID, this.value, $caseID)'");?> ' style='overflow:visible'>story, "class='form-control chosen'");?>
diff --git a/module/testtask/control.php b/module/testtask/control.php index c63bef95ac..911ef8af1a 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -1246,7 +1246,6 @@ class testtask extends control { $this->loadModel('qa')->setMenu($this->products, $productID, $taskID); } - $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, 'case', 0, 'all'); $cases = $this->dao->select('*')->from(TABLE_CASE)->where('id')->in($caseIDList)->fetchAll('id'); } @@ -1269,11 +1268,13 @@ class testtask extends control ->leftJoin(TABLE_TESTRUN)->alias('t2')->on('t1.id = t2.case') ->where('t2.id')->in($caseIDList) ->fetchAll('id'); - - $caseIDList = array(); - foreach($cases as $case) $caseIDList[] = $case->id; } + /* Set modules. */ + $moduleOptionMenu = array(0 => '/'); + foreach($cases as $case) $moduleOptionMenu += $this->tree->getModulesName($case->module); + $this->view->moduleOptionMenu = $moduleOptionMenu; + /* If case has changed and not confirmed, remove it. */ if($from == 'testtask') { diff --git a/module/testtask/view/batchrun.html.php b/module/testtask/view/batchrun.html.php index f0836aa3c3..13dab61fc0 100644 --- a/module/testtask/view/batchrun.html.php +++ b/module/testtask/view/batchrun.html.php @@ -28,27 +28,9 @@ testcase->stepDesc . '/' . $lang->testcase->stepExpect?> - $case):?> status == 'wait') continue;?> - id]", $caseID); - if(!isset($moduleOptionMenu[$case->module])) $moduleOptionMenu += $this->tree->getOptionMenu($case->product, 'case', 0, $case->branch); - } - if(!isset($moduleOptionMenu[$case->module])) - { - $caseModule = '/'; - $modulePath = $this->tree->getParents($cases[$caseID]->module); - foreach($modulePath as $key => $module) - { - $caseModule .= $module->name; - if(isset($modulePath[$key + 1])) $caseModule .= '/'; - } - $moduleOptionMenu[$case->module] = $caseModule; - } - ?> + id]", $caseID); ?> version)?> module] . "'>" . $moduleOptionMenu[$case->module] . ""?> From d4211b3f56be3f76561bc60ce948bb502eb2dd4c Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Tue, 1 Mar 2022 14:58:32 +0800 Subject: [PATCH 11/11] * Fix bug. --- module/testcase/view/batchedit.html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/testcase/view/batchedit.html.php b/module/testcase/view/batchedit.html.php index 8917eb5884..61df4b4a53 100644 --- a/module/testcase/view/batchedit.html.php +++ b/module/testcase/view/batchedit.html.php @@ -86,8 +86,8 @@ product;?> - - branch : '', "class='form-control chosen' onchange='loadBranches($branchProductID, this.value, $caseID)', $disabled");?> + type != 'normal' ? '' : "disabled='disabled'";?> + type != 'normal' ? $cases[$caseID]->branch : '', "class='form-control chosen' onchange='loadBranches($branchProductID, this.value, $caseID)', $disabled");?> ' style='overflow:visible'> '/')), $cases[$caseID]->module, "class='form-control chosen' onchange='loadStories($productID, this.value, $caseID)'");?>