From eedcc1aed59c2f54b33212fca549d6872561412d Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 9 Nov 2021 10:28:16 +0800 Subject: [PATCH] * Modify code logic. --- db/update15.7.1.sql | 1 + db/zentao.sql | 1 + module/branch/model.php | 1 + module/execution/control.php | 5 +---- module/execution/model.php | 5 +++-- module/project/control.php | 2 -- module/project/js/common.js | 2 +- module/project/js/create.js | 3 ++- module/project/js/edit.js | 3 ++- 9 files changed, 12 insertions(+), 11 deletions(-) diff --git a/db/update15.7.1.sql b/db/update15.7.1.sql index 2f3096c979..93a929f290 100644 --- a/db/update15.7.1.sql +++ b/db/update15.7.1.sql @@ -3,4 +3,5 @@ ALTER TABLE `zt_branch` ADD `status` enum ('active', 'closed') NOT NULL DEFAULT ALTER TABLE `zt_branch` ADD `desc` varchar(255) NOT NULL AFTER `status`; ALTER TABLE `zt_branch` ADD `createdDate` date NOT NULL AFTER `desc`; ALTER TABLE `zt_branch` ADD `closedDate` date NOT NULL AFTER `createdDate`; +ALTER TABLE `zt_projectstory` ADD `branch` mediumint(8) NOT NULL AFTER `product`; ALTER TABLE `zt_projectproduct` ADD PRIMARY KEY `project_product_branch` (`project`, `product`, `branch`), DROP INDEX `PRIMARY`; diff --git a/db/zentao.sql b/db/zentao.sql index d9ba2e42a1..f8ef1b8fc1 100644 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -853,6 +853,7 @@ CREATE TABLE IF NOT EXISTS `zt_projectspec` ( CREATE TABLE IF NOT EXISTS `zt_projectstory` ( `project` mediumint(8) unsigned NOT NULL default '0', `product` mediumint(8) unsigned NOT NULL, + `branch` mediumint(8) unsigned NOT NULL, `story` mediumint(8) unsigned NOT NULL default '0', `version` smallint(6) NOT NULL default '1', `order` smallint(6) unsigned NOT NULL, diff --git a/module/branch/model.php b/module/branch/model.php index cd7e983e44..e378fe4f1a 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -174,6 +174,7 @@ class branchModel extends model ->beginIF(strpos($params, 'noclosed') !== false)->andWhere('status')->eq('active')->fi() ->orderBy('`order`') ->fetchAll('id'); + if(!empty($appendBranch)) $branches += $this->dao->select('*')->from(TABLE_BRANCH)->where('id')->in($appendBranch)->orderBy('`order`')->fetchAll('id'); $products = $this->loadModel('product')->getByIdList($products); diff --git a/module/execution/control.php b/module/execution/control.php index 861e1db681..bedec7a200 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2440,10 +2440,7 @@ class execution extends control $productType = $product->type; if(isset($branches[$product->id])) { - foreach($branches[$product->id] as $branchID => $branch) - { - $branchPairs[$branchID] = $branchID; - } + foreach($branches[$product->id] as $branchID => $branch) $branchPairs[$branchID] = $branchID; } } } diff --git a/module/execution/model.php b/module/execution/model.php index 998818e1dc..88cabb488b 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2234,16 +2234,17 @@ class executionModel extends model $versions = $this->loadModel('story')->getVersions($stories); $linkedStories = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($executionID)->orderBy('order_desc')->fetchPairs('story', 'order'); $lastOrder = reset($linkedStories); - $statusPairs = $this->dao->select('id, status')->from(TABLE_STORY)->where('id')->in(array_values($stories))->fetchPairs(); + $storyList = $this->dao->select('id, status, branch')->from(TABLE_STORY)->where('id')->in(array_values($stories))->fetchAll('id'); foreach($stories as $key => $storyID) { $notAllowedStatus = $this->app->rawMethod == 'batchcreate' ? 'closed' : 'draft,closed'; - if(strpos($notAllowedStatus, $statusPairs[$storyID]) !== false) continue; + if(strpos($notAllowedStatus, $storyList[$storyID]->status) !== false) continue; if(isset($linkedStories[$storyID])) continue; $data = new stdclass(); $data->project = $executionID; $data->product = (int)$products[$storyID]; + $data->branch = $storyList[$storyID]->branch; $data->story = $storyID; $data->version = $versions[$storyID]; $data->order = ++$lastOrder; diff --git a/module/project/control.php b/module/project/control.php index 5d60a409ec..2895cf0c1c 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -540,7 +540,6 @@ class project extends control { array_push($unmodifiableProducts, $productID); array_push($unmodifiableBranches, $branchID); - continue; } } } @@ -1714,7 +1713,6 @@ class project extends control { array_push($unmodifiableProducts, $productID); array_push($unmodifiableBranches, $branchID); - continue; } } } diff --git a/module/project/js/common.js b/module/project/js/common.js index d8050b13a3..20ffd25075 100644 --- a/module/project/js/common.js +++ b/module/project/js/common.js @@ -142,7 +142,7 @@ function loadBranches(product) $('#productsBox select').each(function() { var $product = $(product); - if($product.val() != 0 && $product.val() == $(this).val() && $product.attr('id') != $(this).attr('id') && !abnormalProducts[$product.val()] && config.currentMethod != 'create') + if($product.val() != 0 && $product.val() == $(this).val() && $product.attr('id') != $(this).attr('id') && !abnormalProducts[$product.val()]) { alert(errorSameProducts); $product.val(0); diff --git a/module/project/js/create.js b/module/project/js/create.js index 9dac8c93c9..3700cb99c5 100644 --- a/module/project/js/create.js +++ b/module/project/js/create.js @@ -30,6 +30,7 @@ $(function() { var products = []; var existedBranch = false; + /* Determine whether the products of the same branch are linked. */ $("#productsBox select[name^='products']").each(function() { var productID = $(this).val(); @@ -50,10 +51,10 @@ $(function() products[productID][branchID] = branchID; } }) - if(existedBranch) return false; } }) + if(existedBranch) { alert(errorSameBranches); diff --git a/module/project/js/edit.js b/module/project/js/edit.js index 55187acfb7..dcc915a68e 100644 --- a/module/project/js/edit.js +++ b/module/project/js/edit.js @@ -95,6 +95,7 @@ $(function() { var products = []; var existedBranch = false; + /* Determine whether the products of the same branch are linked. */ $("#productsBox select[name^='products']").each(function() { var productID = $(this).val(); @@ -115,10 +116,10 @@ $(function() products[productID][branchID] = branchID; } }) - if(existedBranch) return false; } }) + if(existedBranch) { alert(errorSameBranches);