*Finish task #46095.

This commit is contained in:
songchenxuan
2021-12-20 13:44:41 +08:00
parent 43d07b8cd0
commit 1bbb985b3e
4 changed files with 77 additions and 2 deletions
+65
View File
@@ -102,6 +102,8 @@ class productplan extends control
if(!empty($_POST))
{
$changes = $this->productplan->update($planID);
$change[$planID] = $changes;
$this->synchronizeStory($change);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
if($changes)
{
@@ -144,6 +146,7 @@ class productplan extends control
elseif($_POST)
{
$changes = $this->productplan->batchUpdate($productID);
$this->productplan->synchronizeStory($changes);
$this->loadModel('action');
foreach($changes as $planID => $change)
{
@@ -651,6 +654,68 @@ class productplan extends control
die(js::locate($this->createLink('productplan', 'view', "planID=$planID&type=bug&orderBy=$orderBy"), 'parent'));
}
/**
* Synchronize story when edit plan.
* @param int $planID
* @param int $oldBranch
* @access public
* @return void
*/
public function synchronizeStory($changes)
{
$oldBranch = '';
$newBranch = '';
foreach($changes as $planID => $changes)
{
foreach($changes as $changeId => $change)
{
if($change['field'] == 'branch')
{
$oldBranch = $change['old'];
$newBranch = $change['new'];
break;
}
}
$planStories = $this->loadModel('story')->getPlanStories($planID, 'all');
if($oldBranch)
{
foreach($planStories as $storyID => $story)
{
if($story->branch and $story->branch != $newBranch)$this->productplan->unlinkStory($storyID, $planID);
}
}
$oldBranch = '';
}
}
/**
* AJAX: Get conflict story.
*
* @param int $planID
* @param int $branch
* @access public
* @return void
*/
public function ajaxGetConflictStory($planID, $oldBranch, $newBranch)
{
$planStories = $this->loadModel('story')->getPlanStories($planID, 'all');
$conflictStoryIdList = '';
if($oldBranch)
{
foreach($planStories as $storyID => $story)
{
if($story->branch and $story->branch != $newBranch) $conflictStoryIdList .= '[' . $storyID . ']';
}
}
if($conflictStoryIdList != '')
{
echo sprintf($this->lang->story->confirmChangePlan, $conflictStoryIdList);
}
else
{
echo '';
}
}
/**
* AJAX: Get last plan.
+7
View File
@@ -12,6 +12,13 @@ function convertStringToDate(dateString)
return Date.parse(dateString);
}
function loadWarning(branch)
{
$.get(createLink('productplan', 'ajaxGetConflictStory', 'planID=' + planID + '&oldBranch=' + oldBranch + '&newBranch=' + branch), function(conflictStories)
{
if(conflictStories != '') alert(conflictStories);
});
}
/**
* Compute the end date for productplan.
+3 -1
View File
@@ -15,6 +15,8 @@
<?php js::set('weekend', $config->execution->weekend);?>
<?php js::import($jsRoot . 'misc/date.js');?>
<?php js::set('today', helper::today());?>
<?php js::set('planID', $plan->id);?>
<?php js::set('oldBranch', $plan->branch);?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
@@ -30,7 +32,7 @@
<?php if($product->type != 'normal'):?>
<tr>
<th><?php echo $lang->product->branch;?></th>
<td><?php echo html::select('branch', $branches, $plan->branch, 'class="form-control"');?></td><td></td><td></td>
<td><?php echo html::select('branch', $branches, $plan->branch, "onchange='loadWarning(this.value); 'class='form-control'");?></td><td></td><td></td>
</tr>
<?php endif;?>
<tr>
+2 -1
View File
@@ -280,7 +280,8 @@ $lang->story->moveChildrenTips = "修改父{$lang->SRCommon}的所属产品
$lang->story->changeTips = '该软件需求关联的用户需求有变更,点击“不变更”忽略此条变更,点击“变更”来进行该软件需求的变更。';
$lang->story->estimateMustBeNumber = '估算值必须是数字';
$lang->story->estimateMustBePlus = '估算值不能是负数';
$lang->story->confirmChangeBranch = $lang->SRCommon . '%s已关联在之前所属分支的计划中,调整分支后,' . $lang->SRCommon . '将从之前所属分支的计划中移除,请确认是否继续修改上述' . $lang->SRCommon . '的分支。';
$lang->story->confirmChangeBranch = $lang->SRCommon . '%s已关联在之前所属分支的计划中,调整分支后,' . $lang->SRCommon . '将从之前所属分支的计划中移除,请确认是否继续修改上述' . $lang->SRCommon . '的分支。';
$lang->story->confirmChangePlan = $lang->SRCommon . '%s已关联在之前计划的所属分支中,调整分支后,' . $lang->SRCommon . '将会从计划中移除,请确认是否继续修改计划的所属分支。';
$lang->story->form = new stdclass();
$lang->story->form->area = "该{$lang->SRCommon}所属范围";