diff --git a/module/execution/js/batchedit.js b/module/execution/js/batchedit.js new file mode 100644 index 0000000000..9017c3682f --- /dev/null +++ b/module/execution/js/batchedit.js @@ -0,0 +1,13 @@ +$(function() +{ + $('[id^="projects"]').change(function() + { + executionID = $(this).attr('id').replace('projects', ''); + $td = $(this).closest('td'); + if($td.find('[id^="syncStories"]').length == 0) + { + $td.append(""); + } + $("#syncStories" + executionID).val(confirm(confirmSyncStories) ? 'yes' : 'no'); + }) +}); diff --git a/module/execution/js/edit.js b/module/execution/js/edit.js index e17d014f62..6149182c46 100644 --- a/module/execution/js/edit.js +++ b/module/execution/js/edit.js @@ -19,10 +19,14 @@ $(function() $(this).siblings('div').find('span').attr('title', tip); } }); - + oldProject = $("#project").val(); $('#project').change(function() { - if(!confirm('修改所属项目后,执行关联的原项目需求如果要更改所属项目,需手动修改到新项目,是否继续修改?')) $("#project").val(oldProject).trigger("chosen:updated"); + if($('#submit').closest('td').find('#syncStories').length == 0) + { + $('#submit').after(""); + } + $("#syncStories").val(confirm(confirmSyncStories) ? 'yes' : 'no'); }); }) diff --git a/module/execution/lang/zh-cn.php b/module/execution/lang/zh-cn.php index d3b5f6dea1..b0b406b2b5 100644 --- a/module/execution/lang/zh-cn.php +++ b/module/execution/lang/zh-cn.php @@ -315,6 +315,7 @@ $lang->execution->linkAllStoryTip = "(项目下还未关联{$lang->SRCommon} $lang->execution->confirmDelete = "您确定删除{$lang->executionCommon}[%s]吗?"; $lang->execution->confirmUnlinkMember = "您确定从该{$lang->executionCommon}中移除该用户吗?"; $lang->execution->confirmUnlinkStory = "您确定从该{$lang->executionCommon}中移除该{$lang->SRCommon}吗?"; +$lang->execution->confirmSyncStories = "修改所属项目后,执行关联的{$lang->SRCommon}是否同步到新项目中?"; $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 35a0472e04..48aac5c2a0 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -473,7 +473,7 @@ class executionModel extends model ->setDefault('team', $this->post->name) ->join('whitelist', ',') ->stripTags($this->config->execution->editor->edit['id'], $this->config->allowedTags) - ->remove('products, branch, uid, plans') + ->remove('products, branch, uid, plans, syncStories') ->get(); if($this->config->systemMode == 'new' and (empty($execution->project) or $execution->project == $oldExecution->project)) $this->checkBeginAndEndDate($oldExecution->project, $execution->begin, $execution->end); @@ -544,7 +544,7 @@ class executionModel extends model { $execution->parent = $execution->project; $execution->path = ",{$execution->project},{$executionID},"; - $this->changeProject($execution->project, $oldExecution->project, $executionID); + $this->changeProject($execution->project, $oldExecution->project, $executionID, $this->post->syncStories); } $this->file->updateObjectID($this->post->uid, $executionID, 'execution'); @@ -649,7 +649,7 @@ class executionModel extends model { $execution->parent = $execution->project; $execution->path = ",{$execution->project},{$executionID},"; - $this->changeProject($execution->project, $oldExecution->project, $executionID); + $this->changeProject($execution->project, $oldExecution->project, $executionID, isset($_POST['syncStories'][$executionID]) ? $_POST['syncStories'][$executionID] : 'no'); } $changedAccounts = array(); @@ -2104,10 +2104,11 @@ class executionModel extends model * @param int $newProject * @param int $oldProject * @param int $executionID + * @param string $syncStories yes|no * @access public * @return void */ - public function changeProject($newProject, $oldProject, $executionID) + public function changeProject($newProject, $oldProject, $executionID, $syncStories = 'no') { if($newProject == $oldProject) return; @@ -2157,6 +2158,22 @@ class executionModel extends model $addedAccounts[$account] = $account; } + /* Sync stories to new project. */ + if($syncStories == 'yes') + { + $this->loadModel('action'); + $projectLinkedStories = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($newProject)->fetchPairs('story', 'story'); + $executionLinkedStories = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($executionID)->fetchAll(); + foreach($executionLinkedStories as $linkedStory) + { + if(isset($projectLinkedStories[$linkedStory->story])) continue; + + $linkedStory->project = $newProject; + $this->dao->insert(TABLE_PROJECTSTORY)->data($linkedStory)->exec(); + $this->action->create('story', $linkedStory->story, 'linked2project', '', $newProject); + } + } + if($addedAccounts) $this->loadModel('user')->updateUserView($newProject, 'project', $addedAccounts); } diff --git a/module/execution/view/batchedit.html.php b/module/execution/view/batchedit.html.php index 8d9d0ed0de..027eddac5e 100755 --- a/module/execution/view/batchedit.html.php +++ b/module/execution/view/batchedit.html.php @@ -132,4 +132,5 @@ execution->weekend);?> +execution->confirmSyncStories);?> diff --git a/module/execution/view/edit.html.php b/module/execution/view/edit.html.php index 3014a6f578..3e614444a5 100644 --- a/module/execution/view/edit.html.php +++ b/module/execution/view/edit.html.php @@ -173,4 +173,5 @@ execution->errorSameProducts);?> execution->notAllowRemoveProducts);?> +execution->confirmSyncStories);?>