From 9024dae71eaa6c5fe9692363fcd6a3cb50cc90cb Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Mon, 28 Feb 2022 10:15:16 +0800 Subject: [PATCH] * 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];