* Sync stories to new project when change execution project.

This commit is contained in:
王怡栋
2021-09-02 13:13:04 +08:00
parent 553255a1bf
commit 76945e64ff
6 changed files with 43 additions and 6 deletions
+13
View File
@@ -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("<input type='hidden' id='syncStories" + executionID + "' name='syncStories[" + executionID + "]' value='no' />");
}
$("#syncStories" + executionID).val(confirm(confirmSyncStories) ? 'yes' : 'no');
})
});
+6 -2
View File
@@ -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("<input type='hidden' id='syncStories' name='syncStories' value='no' />");
}
$("#syncStories").val(confirm(confirmSyncStories) ? 'yes' : 'no');
});
})
+1
View File
@@ -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}进行了关联,请取消关联后再操作。";
+21 -4
View File
@@ -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);
}
+1
View File
@@ -132,4 +132,5 @@
</form>
</div>
<?php js::set('weekend', $config->execution->weekend);?>
<?php js::set('confirmSyncStories', $lang->execution->confirmSyncStories);?>
<?php include '../../common/view/footer.html.php';?>
+1
View File
@@ -173,4 +173,5 @@
<?php js::set('errorSameProducts', $lang->execution->errorSameProducts);?>
<?php js::set('unmodifiableProducts',$unmodifiableProducts);?>
<?php js::set('tip', $lang->execution->notAllowRemoveProducts);?>
<?php js::set('confirmSyncStories', $lang->execution->confirmSyncStories);?>
<?php include '../../common/view/footer.html.php';?>