* Finish Task #78665.
This commit is contained in:
@@ -2,4 +2,3 @@ ALTER TABLE `zt_story` ADD COLUMN `siblings` varchar(255) NOT NULL AFTER `linkRe
|
||||
ALTER TABLE `zt_productplan` MODIFY COLUMN `branch` varchar(255) NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `zt_effort` ADD `extra` text COLLATE 'utf8_general_ci' NOT NULL AFTER `end`;
|
||||
ALTER TABLE `zt_build` MODIFY COLUMN `branch` varchar(255) NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `zt_bug` ADD COLUMN `build` mediumint(8) unsigned NOT NULL DEFAULT '0';
|
||||
|
||||
@@ -506,11 +506,11 @@ class bugModel extends model
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getPlanBugs($PlanID, $status = 'all', $orderBy = 'id_desc', $pager = null)
|
||||
public function getPlanBugs($planID, $status = 'all', $orderBy = 'id_desc', $pager = null)
|
||||
{
|
||||
if(strpos($orderBy, 'pri_') !== false) $orderBy = str_replace('pri_', 'priOrder_', $orderBy);
|
||||
$bugs = $this->dao->select("*, IF(`pri` = 0, {$this->config->maxPriValue}, `pri`) as priOrder")->from(TABLE_BUG)
|
||||
->where('plan')->eq((int)$PlanID)->fi()
|
||||
->where('plan')->eq((int)$planID)->fi()
|
||||
->beginIF(!$this->app->user->admin)->andWhere('execution')->in('0,' . $this->app->user->view->sprints)->fi()
|
||||
->beginIF($status != 'all')->andWhere('status')->in($status)->fi()
|
||||
->andWhere('deleted')->eq(0)
|
||||
|
||||
@@ -144,6 +144,8 @@ class build extends control
|
||||
$changes = $this->build->update($buildID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
$files = $this->loadModel('file')->saveUpload('build', $buildID);
|
||||
$change[$buildID] = $changes;
|
||||
$this->unlinkOldBranch($change);
|
||||
|
||||
if($changes or $files)
|
||||
{
|
||||
@@ -716,7 +718,7 @@ class build extends control
|
||||
$buildStories = $this->loadModel('story')->getByList($build->allStories);
|
||||
$buildBugs = $this->loadModel('bug')->getByList($build->allBugs);
|
||||
$branchPairs = $this->loadModel('branch')->getPairs($build->product);
|
||||
$this->app->loadLang('branc');
|
||||
$this->app->loadLang('branch');
|
||||
|
||||
$removeBranches = '';
|
||||
foreach(explode(',', $oldBranch) as $oldBranchID)
|
||||
@@ -771,6 +773,46 @@ class build extends control
|
||||
return print(js::locate($this->createLink('build', 'view', "buildID=$buildID&type=story"), 'parent'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlink story and bug when edit branch of build.
|
||||
* @param int $buildID
|
||||
* @param int $oldBranch
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function unlinkOldBranch($changes)
|
||||
{
|
||||
foreach($changes as $buildID => $changes)
|
||||
{
|
||||
$oldBranch = '';
|
||||
$newBranch = '';
|
||||
foreach($changes as $changeId => $change)
|
||||
{
|
||||
if($change['field'] == 'branch')
|
||||
{
|
||||
$oldBranch = $change['old'];
|
||||
$newBranch = $change['new'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$build = $this->build->getByID($buildID);
|
||||
$planStories = $this->loadModel('story')->getByList($build->allStories);
|
||||
$planBugs = $this->loadModel('bug')->getByList($build->allBugs);
|
||||
if($oldBranch)
|
||||
{
|
||||
foreach($planStories as $storyID => $story)
|
||||
{
|
||||
if($story->branch and strpos(",$newBranch,", ",$story->branch,") === false) $this->build->unlinkStory($storyID, $buildID);
|
||||
}
|
||||
|
||||
foreach($planBugs as $bugID => $bug)
|
||||
{
|
||||
if($bug->branch and strpos(",$newBranch,", ",$bug->branch,") === false) $this->build->unlinkBug($bugID, $buildID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Link bugs.
|
||||
*
|
||||
|
||||
@@ -103,7 +103,7 @@ tbody tr td:first-child input {display: none;}
|
||||
<tbody class='text-center'>
|
||||
<?php foreach($stories as $storyID => $story):?>
|
||||
<?php
|
||||
$unlinkClass = strpos(",$build->stories,", ",$story->id,") !== false ? '' : "disabled";
|
||||
$unlinkClass = strpos(",$build->allStories,", ",$story->id,") !== false ? '' : "disabled";
|
||||
$buildName = $build->name;
|
||||
if($unlinkClass == 'disabled')
|
||||
{
|
||||
@@ -224,7 +224,7 @@ tbody tr td:first-child input {display: none;}
|
||||
<?php foreach($bugs as $bug):?>
|
||||
<?php $bugLink = $this->createLink('bug', 'view', "bugID=$bug->id", '', true);?>
|
||||
<?php
|
||||
$unlinkClass = strpos(",$build->bugs,", ",$bug->id,") !== false ? '' : "disabled";
|
||||
$unlinkClass = strpos(",$build->allBugs,", ",$bug->id,") !== false ? '' : "disabled";
|
||||
$buildName = $build->name;
|
||||
if($unlinkClass == 'disabled')
|
||||
{
|
||||
|
||||
@@ -959,7 +959,7 @@ class productplan extends control
|
||||
$plan = $this->productplan->getByID($planID);
|
||||
$oldBranch = $plan->branch;
|
||||
$planStories = $this->loadModel('story')->getPlanStories($planID, 'all');
|
||||
$planBugs = $this->loadModel('bug')->getLinkBugs($planID, 'all');
|
||||
$planBugs = $this->loadModel('bug')->getPlanBugs($planID, 'all');
|
||||
$branchPairs = $this->loadModel('branch')->getPairs($plan->product);
|
||||
|
||||
$removeBranches = '';
|
||||
|
||||
@@ -3997,7 +3997,7 @@ class storyModel extends model
|
||||
$orderBy = $this->post->orderBy;
|
||||
if(strpos($orderBy, 'order') !== false) $orderBy = str_replace('order', 'id', $orderBy);
|
||||
|
||||
$stories = $this->loadModel('story')->getLinkStories($planID, 'all');
|
||||
$stories = $this->loadModel('story')->getPlanStories($planID, 'all');
|
||||
$storyIDList = array_keys($stories);
|
||||
|
||||
if(strpos($this->post->orderBy, 'order') !== false and !empty($planOrder)) $stories = $this->sortPlanStory($stories, $planOrder, $orderBy);
|
||||
@@ -5875,7 +5875,7 @@ class storyModel extends model
|
||||
$orderBy = common::appendOrder($orderBy);
|
||||
|
||||
/* Get all stories by plan. */
|
||||
$stories = $this->getLinkStories($planID, 'all', $orderBy);
|
||||
$stories = $this->getPlanStories($planID, 'all', $orderBy);
|
||||
$storyIDList = array_keys($stories);
|
||||
|
||||
/* Calculate how many numbers there are before the sort list and after the sort list. */
|
||||
|
||||
@@ -159,10 +159,11 @@ class treeModel extends model
|
||||
if($branch != 'all' and strpos('story|bug|case', $type) !== false)
|
||||
{
|
||||
$product = $this->loadModel('product')->getById($rootID);
|
||||
if(strpos($branch, ',') !== false) $buildBranch = explode(',', $branch);
|
||||
if($product and $product->type != 'normal')
|
||||
{
|
||||
$branchPairs = $this->loadModel('branch')->getPairs($rootID, 'all');
|
||||
$branches = array($branch => $branchPairs[$branch]);
|
||||
foreach($buildBranch as $buildKey) $branches = array($buildKey => $branchPairs[$buildKey]);
|
||||
}
|
||||
elseif($product and $product->type == 'normal')
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user