From 1723a78c924bf390c86d900558098c72c0038349 Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Tue, 10 May 2022 09:11:06 +0000 Subject: [PATCH 1/5] * Finish task #53651. --- module/execution/js/batchedit.js | 7 ++++--- module/execution/lang/en.php | 2 +- module/execution/lang/zh-cn.php | 2 +- module/execution/model.php | 21 +++++++++++++++++++++ module/execution/view/batchedit.html.php | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/module/execution/js/batchedit.js b/module/execution/js/batchedit.js index f9fca2bb2b..8eb547e84f 100644 --- a/module/execution/js/batchedit.js +++ b/module/execution/js/batchedit.js @@ -4,10 +4,11 @@ $(function() { var executionID = $(this).attr('id').replace('projects', ''); var $td = $(this).closest('td'); - if($td.find('[id^="syncStories"]').length == 0) + if($td.find('[id^="sync"]').length == 0) { - $td.append(""); + $td.append(""); } - $("#syncStories" + executionID).val(confirm(confirmSyncStories) ? 'yes' : 'no'); + alert(confirmSync); + $("#sync" + executionID).val('yes'); }) }); diff --git a/module/execution/lang/en.php b/module/execution/lang/en.php index c9aa6aa2f0..0c7530ff03 100644 --- a/module/execution/lang/en.php +++ b/module/execution/lang/en.php @@ -340,7 +340,7 @@ if($config->systemMode == 'new') $lang->execution->copyTeamTitle = "Choose a $lang->execution->confirmDelete = "Do you want to delete the {$lang->executionCommon}[%s]?"; $lang->execution->confirmUnlinkMember = "Do you want to unlink this User from {$lang->executionCommon}?"; $lang->execution->confirmUnlinkStory = "After {$lang->SRCommon} is removed, cased linked to {$lang->SRCommon} will be reomoved and tasks linked to {$lang->SRCommon} will be cancelled. Do you want to continue?"; -$lang->execution->confirmSyncStories = "After modifying the project, synchronize the execution related {$lang->SRCommon} to the new project?"; +$lang->execution->confirmSync = "After modifying the project, in order to maintain the consistency of data, the data of products, requirements, teams and whitelist associated with the implementation will be synchronized to the new project. Please know."; $lang->execution->confirmUnlinkExecutionStory = "Do you want to unlink this Story from the execution?"; $lang->execution->notAllowedUnlinkStory = "This {$lang->SRCommon} is linked to the {$lang->executionCommon} of the execution. Remove it from the {$lang->executionCommon}, then try again."; $lang->execution->notAllowRemoveProducts = "The story of this product is linked with the {$lang->executionCommon}. Unlink it before doing any action."; diff --git a/module/execution/lang/zh-cn.php b/module/execution/lang/zh-cn.php index 9248f804cb..b3cd85caf9 100644 --- a/module/execution/lang/zh-cn.php +++ b/module/execution/lang/zh-cn.php @@ -340,7 +340,7 @@ if($config->systemMode == 'new') $lang->execution->copyTeamTitle = "选择 $lang->execution->confirmDelete = "您确定删除{$lang->executionCommon}[%s]吗?"; $lang->execution->confirmUnlinkMember = "您确定从该{$lang->executionCommon}中移除该用户吗?"; $lang->execution->confirmUnlinkStory = "移除该{$lang->SRCommon}后,该{$lang->SRCommon}关联的用例将被移除,该{$lang->SRCommon}关联的任务将被取消,请确认。"; -$lang->execution->confirmSyncStories = "修改所属项目后,执行关联的{$lang->SRCommon}是否同步到新项目中?"; +$lang->execution->confirmSync = "修改所属项目后,为了保持数据的一致性,该执行所关联的产品、需求、团队和白名单数据将会同步到新的项目中,请知悉。"; $lang->execution->confirmUnlinkExecutionStory = "您确定从该项目中移除该{$lang->SRCommon}吗?"; $lang->execution->notAllowedUnlinkStory = "该{$lang->SRCommon}已经与项目下{$lang->executionCommon}相关联,请从{$lang->executionCommon}中移除后再操作。"; $lang->execution->notAllowRemoveProducts = "该{$lang->productCommon}中的{$lang->SRCommon}已与该{$lang->executionCommon}进行了关联,请取消关联后再操作。"; diff --git a/module/execution/model.php b/module/execution/model.php index 9cc2b97457..0f939e781d 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -690,6 +690,27 @@ class executionModel extends model $projectID = isset($execution->project) ? $execution->project : $oldExecution->project; $project = $this->project->getByID($projectID); + if(isset($execution->project)) + { + $executionProducts = $this->loadModel('product')->getProducts($executionID); + $projectProducts = $this->product->getProducts($execution->project); + $executionProducts = array_keys($executionProducts); + $projectProducts = array_keys($projectProducts); + $diffProducts = array_diff($executionProducts, $projectProducts); + if(!empty($diffProducts)) + { + foreach($diffProducts as $key => $newProduct) + { + $data = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT) + ->where('project')->eq($executionID) + ->andWhere('product')->eq($newProduct) + ->fetch(); + $data->project = $execution->project; + $this->dao->insert(TABLE_PROJECTPRODUCT)->data($data)->exec(); + } + } + } + if($project and $execution->begin < $project->begin) { dao::$errors['begin'] = sprintf($this->lang->execution->errorLetterProject, $project->begin); diff --git a/module/execution/view/batchedit.html.php b/module/execution/view/batchedit.html.php index 2ad0a2b496..d33fbb88b5 100755 --- a/module/execution/view/batchedit.html.php +++ b/module/execution/view/batchedit.html.php @@ -137,5 +137,5 @@ execution->weekend);?> -execution->confirmSyncStories);?> +execution->confirmSync);?> From da5cd2aa447c205a536c997b6614da33c49ffdf3 Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Wed, 11 May 2022 03:02:28 +0000 Subject: [PATCH 2/5] * Finish task #53651. --- module/execution/js/batchedit.js | 25 ++++++++++++------------ module/execution/view/batchedit.html.php | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/module/execution/js/batchedit.js b/module/execution/js/batchedit.js index 8eb547e84f..79b1c266ef 100644 --- a/module/execution/js/batchedit.js +++ b/module/execution/js/batchedit.js @@ -1,14 +1,15 @@ -$(function() +function sync(obj, executionID, projectID) { - $('[id^="projects"]').change(function() + var $td = $(obj).closest('td'); + if($td.find('[id^="syncStories"]').length == 0) { - var executionID = $(this).attr('id').replace('projects', ''); - var $td = $(this).closest('td'); - if($td.find('[id^="sync"]').length == 0) - { - $td.append(""); - } - alert(confirmSync); - $("#sync" + executionID).val('yes'); - }) -}); + console.log($td); + $td.append(""); + } + var confirmVal = confirm(confirmSync); + $("#syncStories" + executionID).val(confirmVal ? 'yes' : 'no'); + if(!confirmVal) + { + $(obj).val(projectID).trigger("chosen:updated"); + } +}; diff --git a/module/execution/view/batchedit.html.php b/module/execution/view/batchedit.html.php index d33fbb88b5..e82cb7b529 100755 --- a/module/execution/view/batchedit.html.php +++ b/module/execution/view/batchedit.html.php @@ -83,7 +83,7 @@ systemMode == 'new' and isset($project) and $project->model == 'scrum'):?> - project, "class='form-control picker-select'");?> + project, "class='form-control picker-select' onchange='sync(this, $executionID, {$executions[$executionID]->project})'");?> name, "class='form-control'");?> code, "class='form-control'");?> From cec71ebfd8b5eb53b91903a4d3ec6fa2895ff7e5 Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Wed, 11 May 2022 04:10:30 +0000 Subject: [PATCH 3/5] * Finish task #53651. --- module/execution/control.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 25f8e63cb8..ba411988dd 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1678,8 +1678,9 @@ class execution extends control if($this->app->tab == 'project') { $projectID = $this->session->project; + $project = $this->project->getById($projectID); $this->project->setMenu($projectID); - $this->view->project = $this->project->getById($projectID); + $this->view->project = $project; } if(!$this->post->executionIDList) return print(js::locate($this->session->executionList, 'parent')); @@ -1717,7 +1718,7 @@ class execution extends control $this->view->position[] = $this->lang->execution->batchEdit; $this->view->executionIDList = $executionIDList; $this->view->executions = $executions; - $this->view->allProjects = $this->project->getPairsByModel('all', 0, 'noclosed', isset($projectID) ? $projectID : 0); + $this->view->allProjects = $this->project->getPairsByModel($project->model, 0, 'noclosed', isset($projectID) ? $projectID : 0); $this->view->pmUsers = $pmUsers; $this->view->poUsers = $poUsers; $this->view->qdUsers = $qdUsers; From ca827e1d6c75474c6f8fd0b4c9368162a81b9328 Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Wed, 11 May 2022 05:32:48 +0000 Subject: [PATCH 4/5] * Finish task #53651. --- module/execution/js/batchedit.js | 3 +-- module/execution/model.php | 16 ++++++++-------- module/execution/view/batchedit.html.php | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/module/execution/js/batchedit.js b/module/execution/js/batchedit.js index 79b1c266ef..6c0e349d09 100644 --- a/module/execution/js/batchedit.js +++ b/module/execution/js/batchedit.js @@ -1,9 +1,8 @@ -function sync(obj, executionID, projectID) +function changeProject(obj, executionID, projectID) { var $td = $(obj).closest('td'); if($td.find('[id^="syncStories"]').length == 0) { - console.log($td); $td.append(""); } var confirmVal = confirm(confirmSync); diff --git a/module/execution/model.php b/module/execution/model.php index 0f939e781d..7c16ea38d6 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -692,18 +692,18 @@ class executionModel extends model if(isset($execution->project)) { - $executionProducts = $this->loadModel('product')->getProducts($executionID); - $projectProducts = $this->product->getProducts($execution->project); - $executionProducts = array_keys($executionProducts); - $projectProducts = array_keys($projectProducts); - $diffProducts = array_diff($executionProducts, $projectProducts); - if(!empty($diffProducts)) + $executionProductsList = $this->loadModel('product')->getProducts($executionID); + $projectProductsList = $this->product->getProducts($execution->project); + $executionProductsID = array_keys($executionProductsList); + $projectProductsID = array_keys($projectProductsList); + $diffProductsID = array_diff($executionProductsID, $projectProductsID); + if(!empty($diffProductsID)) { - foreach($diffProducts as $key => $newProduct) + foreach($diffProductsID as $key => $newProductID) { $data = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT) ->where('project')->eq($executionID) - ->andWhere('product')->eq($newProduct) + ->andWhere('product')->eq($newProductID) ->fetch(); $data->project = $execution->project; $this->dao->insert(TABLE_PROJECTPRODUCT)->data($data)->exec(); diff --git a/module/execution/view/batchedit.html.php b/module/execution/view/batchedit.html.php index e82cb7b529..5520f67890 100755 --- a/module/execution/view/batchedit.html.php +++ b/module/execution/view/batchedit.html.php @@ -83,7 +83,7 @@ systemMode == 'new' and isset($project) and $project->model == 'scrum'):?> - project, "class='form-control picker-select' onchange='sync(this, $executionID, {$executions[$executionID]->project})'");?> + project, "class='form-control picker-select' onchange='changeProject(this, $executionID, {$executions[$executionID]->project})'");?> name, "class='form-control'");?> code, "class='form-control'");?> From c0886b850df8ef90ee3117926a14abf2e9fe8d3a Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Wed, 11 May 2022 05:49:21 +0000 Subject: [PATCH 5/5] * Finish task #53651. --- module/execution/model.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index 7c16ea38d6..66a706f4ab 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -692,14 +692,14 @@ class executionModel extends model if(isset($execution->project)) { - $executionProductsList = $this->loadModel('product')->getProducts($executionID); - $projectProductsList = $this->product->getProducts($execution->project); - $executionProductsID = array_keys($executionProductsList); - $projectProductsID = array_keys($projectProductsList); - $diffProductsID = array_diff($executionProductsID, $projectProductsID); - if(!empty($diffProductsID)) + $executionProductList = $this->loadModel('product')->getProducts($executionID); + $projectProductList = $this->product->getProducts($execution->project); + $executionProductIdList = array_keys($executionProductList); + $projectProductIdList = array_keys($projectProductList); + $diffProductIdList = array_diff($executionProductIdList, $projectProductIdList); + if(!empty($diffProductIdList)) { - foreach($diffProductsID as $key => $newProductID) + foreach($diffProductIdList as $key => $newProductID) { $data = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT) ->where('project')->eq($executionID)