* Modify the logic of changing branches in stories.
This commit is contained in:
@@ -217,10 +217,18 @@ class product extends control
|
||||
$this->lang->datatable->showBranch = sprintf($this->lang->datatable->showBranch, $this->lang->product->branchName[$product->type]);
|
||||
}
|
||||
|
||||
/* Get stories. */
|
||||
/* Get stories and branches. */
|
||||
if($this->app->rawModule == 'projectstory')
|
||||
{
|
||||
if(!empty($product)) $this->session->set('currentProductType', $product->type);
|
||||
$branches = array();
|
||||
if(!empty($product))
|
||||
{
|
||||
$this->session->set('currentProductType', $product->type);
|
||||
$productBranches = $product->type != 'normal' ? $this->loadModel('execution')->getBranchByProduct($product->id, $projectID) : array();
|
||||
$branches = isset($productBranches[$product->id]) ? $productBranches[$product->id] : array();
|
||||
|
||||
}
|
||||
|
||||
$this->products = $this->product->getProducts($projectID, 'all', '', false);
|
||||
$projectProducts = $this->product->getProducts($projectID);
|
||||
$productPlans = $this->execution->getPlans($projectProducts);
|
||||
@@ -231,6 +239,7 @@ class product extends control
|
||||
else
|
||||
{
|
||||
$branchID = $browseType == 'bymodule' ? 'all' : $branchID;
|
||||
$branches = $this->loadModel('branch')->getPairs($productID);
|
||||
$stories = $this->product->getStories($productID, $branchID, $browseType, $queryID, $moduleID, $storyType, $sort, $pager);
|
||||
}
|
||||
|
||||
@@ -300,7 +309,7 @@ class product extends control
|
||||
$this->view->moduleName = ($moduleID and $moduleID !== 'all') ? $this->tree->getById($moduleID)->name : $this->lang->tree->all;
|
||||
$this->view->branch = $branch;
|
||||
$this->view->branchID = $branchID;
|
||||
$this->view->branches = $this->loadModel('branch')->getPairs($productID);
|
||||
$this->view->branches = $branches;
|
||||
$this->view->storyStages = $this->product->batchGetStoryStage($stories);
|
||||
$this->view->setModule = true;
|
||||
$this->view->storyTasks = $storyTasks;
|
||||
|
||||
@@ -394,7 +394,7 @@ $projectIDParam = $isProjectStory ? "projectID=$projectID&" : '';
|
||||
echo "<li $class>" . html::a('javascript:;', $lang->story->review, '', $class) . '</li>';
|
||||
}
|
||||
|
||||
if($canBatchChangeBranch and $this->session->currentProductType and $this->session->currentProductType != 'normal')
|
||||
if($canBatchChangeBranch and $this->session->currentProductType and $this->session->currentProductType != 'normal' and $productID)
|
||||
{
|
||||
$withSearch = count($branches) > 8;
|
||||
echo "<li class='dropdown-submenu'>";
|
||||
|
||||
@@ -1450,7 +1450,7 @@ class story extends control
|
||||
{
|
||||
foreach($plans[$storyID] as $plan)
|
||||
{
|
||||
if($plan->branch != BRANCH_MAIN and $plan->branch != $branchID)
|
||||
if($plan->branch != $branchID)
|
||||
{
|
||||
$conflictStoryIdList .= '[' . $storyID . ']';
|
||||
$conflictStoryArray[] = $storyID;
|
||||
|
||||
+14
-4
@@ -1682,9 +1682,17 @@ class storyModel extends model
|
||||
*/
|
||||
public function batchChangeBranch($storyIdList, $branchID, $confirm = '', $plans = array())
|
||||
{
|
||||
$now = helper::now();
|
||||
$allChanges = array();
|
||||
$oldStories = $this->getByList($storyIdList);
|
||||
$now = helper::now();
|
||||
$allChanges = array();
|
||||
$oldStories = $this->getByList($storyIdList);
|
||||
$story = current($oldStories);
|
||||
$productID = $story->product;
|
||||
$mainModules = $this->dao->select('id')->from(TABLE_MODULE)
|
||||
->where('root')->eq($productID)
|
||||
->andWhere('branch')->eq(0)
|
||||
->andWhere('type')->eq('story')
|
||||
->fetchPairs('id');
|
||||
|
||||
foreach($storyIdList as $storyID)
|
||||
{
|
||||
$oldStory = $oldStories[$storyID];
|
||||
@@ -1693,6 +1701,7 @@ class storyModel extends model
|
||||
$story->lastEditedBy = $this->app->user->account;
|
||||
$story->lastEditedDate = $now;
|
||||
$story->branch = $branchID;
|
||||
$story->module = ($oldStory->branch != $branchID and !in_array($oldStory->module, $mainModules)) ? 0 : $oldStory->module;
|
||||
|
||||
$this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec();
|
||||
if(!dao::isError())
|
||||
@@ -1701,12 +1710,13 @@ class storyModel extends model
|
||||
{
|
||||
$planIdList = '';
|
||||
$conflictPlanIdList = '';
|
||||
|
||||
/* Determine whether there is a conflict between the branch of the story and the linked plan. */
|
||||
if($oldStory->branch != $branchID and $branchID != BRANCH_MAIN and isset($plans[$storyID]))
|
||||
{
|
||||
foreach($plans[$storyID] as $planID => $plan)
|
||||
{
|
||||
if($plan->branch != BRANCH_MAIN and $plan->branch != $branchID)
|
||||
if($plan->branch != $branchID)
|
||||
{
|
||||
$conflictPlanIdList .= $planID . ',';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user