From 65fff67e58fecd7b583b079fd5c0e225b083c121 Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Thu, 12 May 2022 00:30:00 +0000 Subject: [PATCH] * finish task #53651. --- module/execution/js/batchedit.js | 3 +++ module/execution/js/edit.js | 27 +++++++++++++++++---------- module/execution/model.php | 21 +++++++++++++++++++++ module/execution/view/edit.html.php | 4 ++-- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/module/execution/js/batchedit.js b/module/execution/js/batchedit.js index 6c0e349d09..e7644bfab4 100644 --- a/module/execution/js/batchedit.js +++ b/module/execution/js/batchedit.js @@ -1,12 +1,15 @@ function changeProject(obj, executionID, projectID) { var $td = $(obj).closest('td'); + if($td.find('[id^="syncStories"]').length == 0) { $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/js/edit.js b/module/execution/js/edit.js index 0c09b6bfe8..fb7987b974 100644 --- a/module/execution/js/edit.js +++ b/module/execution/js/edit.js @@ -63,14 +63,21 @@ $(function() } } }); - - oldProject = $("#project").val(); - $('#project').change(function() - { - if($('#submit').closest('td').find('#syncStories').length == 0) - { - $('#submit').after(""); - } - $("#syncStories").val(confirm(confirmSyncStories) ? 'yes' : 'no'); - }); }) + +function changeProject(projectID) +{ + if($('#submit').closest('td').find('#syncStories').length == 0) + { + $('#submit').after(""); + } + + var confirmVal = confirm(confirmSync); + $("#syncStories").val(confirmVal ? 'yes' : 'no'); + + if(!confirmVal) + { + $('#project').val(projectID).trigger("chosen:updated"); + console.log($('#project').val(projectID)); + } +}; diff --git a/module/execution/model.php b/module/execution/model.php index 66a706f4ab..78c88adcef 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -565,6 +565,27 @@ class executionModel extends model /* Fix bug#3074, Update views for team members. */ if($execution->acl != 'open') $this->updateUserView($executionID, 'sprint', $changedAccounts); + if(isset($execution->project)) + { + $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($diffProductIdList as $key => $newProductID) + { + $data = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT) + ->where('project')->eq($executionID) + ->andWhere('product')->eq($newProductID) + ->fetch(); + $data->project = $execution->project; + $this->dao->insert(TABLE_PROJECTPRODUCT)->data($data)->exec(); + } + } + } + if(!dao::isError()) { if(isset($execution->project) and $execution->project != $oldExecution->project) diff --git a/module/execution/view/edit.html.php b/module/execution/view/edit.html.php index 7c664b9c0a..0397a0255f 100644 --- a/module/execution/view/edit.html.php +++ b/module/execution/view/edit.html.php @@ -28,7 +28,7 @@ systemMode == 'new'):?> execution->projectName;?> - project, "class='form-control chosen' required");?> + project, "class='form-control chosen' onchange='changeProject($execution->project)' required");?> @@ -220,6 +220,6 @@ execution->notAllowRemoveProducts);?> -execution->confirmSyncStories);?> +execution->confirmSync);?> systemMode);?>