* Code for task #36041.
This commit is contained in:
@@ -196,6 +196,7 @@ class upgrade extends control
|
||||
{
|
||||
$this->session->set('upgrading', true);
|
||||
$this->app->loadLang('program');
|
||||
$this->app->loadLang('product');
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
@@ -226,11 +227,11 @@ class upgrade extends control
|
||||
}
|
||||
|
||||
/* Create Program. */
|
||||
list($programID, $projectID) = $this->upgrade->createProgram($linkedProducts, $linkedSprints);
|
||||
list($programID, $projectID, $lineID) = $this->upgrade->createProgram($linkedProducts, $linkedSprints);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
|
||||
/* Process merged products and projects. */
|
||||
$this->upgrade->processMergedData($programID, $projectID, $linkedProducts, $linkedSprints);
|
||||
$this->upgrade->processMergedData($programID, $projectID, $lineID, $linkedProducts, $linkedSprints);
|
||||
|
||||
/* Process unlinked sprint and product. */
|
||||
foreach($linkedProducts as $productID => $product)
|
||||
@@ -259,11 +260,11 @@ class upgrade extends control
|
||||
}
|
||||
|
||||
/* Create Program. */
|
||||
list($programID, $projectID) = $this->upgrade->createProgram($linkedProducts, $linkedSprints);
|
||||
list($programID, $projectID, $lineID) = $this->upgrade->createProgram($linkedProducts, $linkedSprints);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
|
||||
/* Process merged products and projects. */
|
||||
$this->upgrade->processMergedData($programID, $projectID, $linkedProducts, $linkedSprints);
|
||||
$this->upgrade->processMergedData($programID, $projectID, $lineID, $linkedProducts, $linkedSprints);
|
||||
|
||||
/* Process unlinked product. */
|
||||
if($unlinkSprints) $this->dao->delete()->from(TABLE_PROJECTPRODUCT)->where('project')->in($unlinkSprints)->exec();
|
||||
@@ -273,10 +274,10 @@ class upgrade extends control
|
||||
$linkedSprints = $this->post->sprints;
|
||||
|
||||
/* Create Program. */
|
||||
list($programID, $projectID) = $this->upgrade->createProgram(array(), $linkedSprints);
|
||||
list($programID, $projectID, $lineID) = $this->upgrade->createProgram(array(), $linkedSprints);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
|
||||
$this->upgrade->processMergedData($programID, $projectID, array(), $linkedSprints);
|
||||
$this->upgrade->processMergedData($programID, $projectID, $lineID, array(), $linkedSprints);
|
||||
}
|
||||
elseif($type == 'moreLink')
|
||||
{
|
||||
@@ -285,7 +286,7 @@ class upgrade extends control
|
||||
$sprintID = $this->post->sprints[$i];
|
||||
|
||||
/* Change program field for product and project. */
|
||||
$this->upgrade->processMergedData(0, $projectID, array(), array($sprintID));
|
||||
$this->upgrade->processMergedData(0, $projectID, 0, array(), array($sprintID));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +320,7 @@ class upgrade extends control
|
||||
/* Get products and projects group by product line. */
|
||||
if($type == 'productline')
|
||||
{
|
||||
$productlines = $this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('line')->orderBy('id_desc')->fetchAll('id');
|
||||
$productlines = $this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('line')->andWhere('root')->eq(0)->orderBy('id_desc')->fetchAll('id');
|
||||
|
||||
$noMergedProducts = $this->dao->select('*')->from(TABLE_PRODUCT)->where('line')->in(array_keys($productlines))->orderBy('id_desc')->fetchAll('id');
|
||||
if(empty($productlines) || empty($noMergedProducts)) $this->locate($this->createLink('upgrade', 'mergeProgram', 'type=product'));
|
||||
@@ -451,6 +452,7 @@ class upgrade extends control
|
||||
$this->view->programs = $programs;
|
||||
$this->view->programID = $programID;
|
||||
$this->view->projects = array('' => '') + $this->upgrade->getProjectPairsByProgram($currentProgramID);
|
||||
$this->view->lines = $currentProgramID ? array('' => '') + $this->loadModel('product')->getLinePairs($currentProgramID) : array();
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noclosed|noempty');
|
||||
$this->view->groups = $this->loadModel('group')->getPairs();
|
||||
$this->display();
|
||||
@@ -499,6 +501,20 @@ class upgrade extends control
|
||||
die(html::select('projects', $projects, '', 'class="form-control prj-exist"'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lines of the program it belongs to.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetLinesPairsByProgram($programID = 0)
|
||||
{
|
||||
$lines = array('' => '');
|
||||
if($programID) $lines += $this->loadModel('product')->getLinePairs($programID);
|
||||
die(html::select('lines', $lines, '', 'class="form-control line-exist"'));
|
||||
}
|
||||
|
||||
/**
|
||||
* After execute.
|
||||
*
|
||||
|
||||
@@ -116,6 +116,7 @@ $(function()
|
||||
|
||||
toggleProgram($('form #newProgram0'));
|
||||
toggleProject($('form #newProject0'));
|
||||
toggleProject($('form #newLine0'));
|
||||
|
||||
hiddenProject();
|
||||
});
|
||||
@@ -133,6 +134,27 @@ function getProjectByProgram(obj)
|
||||
$('#projects').addClass('hidden');
|
||||
}
|
||||
})
|
||||
|
||||
getLineByProgram();
|
||||
}
|
||||
|
||||
function getLineByProgram()
|
||||
{
|
||||
var programID = $('#programs').val();
|
||||
var link = createLink('upgrade', 'ajaxGetLinesPairsByProgram', 'programID=' + programID);
|
||||
|
||||
$.post(link, function(data)
|
||||
{
|
||||
$('#lines').replaceWith(data);
|
||||
if($('#newLine0').is(':checked'))
|
||||
{
|
||||
$('#lines').attr('disabled', 'disabled');
|
||||
$('#lines').addClass('hidden');
|
||||
}
|
||||
})
|
||||
|
||||
if(!programID) $('lineBox').addClass('hidden');
|
||||
if(programID) $('lineBox').removeClass('hidden');
|
||||
}
|
||||
|
||||
function toggleProgram(obj)
|
||||
@@ -149,7 +171,9 @@ function toggleProgram(obj)
|
||||
$('.PGMStatus').show();
|
||||
|
||||
$('form #newProject0').prop('checked', true);
|
||||
$('form #newLine0').prop('checked', true);
|
||||
toggleProject($('form #newProject0'));
|
||||
toggleLine($('form #newProject0'));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -160,6 +184,34 @@ function toggleProgram(obj)
|
||||
}
|
||||
}
|
||||
|
||||
function toggleLine(obj)
|
||||
{
|
||||
var $obj = $(obj);
|
||||
if($obj.length == 0) return false;
|
||||
|
||||
var $lines = $obj.closest('table').find('#lines');
|
||||
var $programs = $obj.closest('table').find('#programs');
|
||||
|
||||
if($obj.prop('checked'))
|
||||
{
|
||||
$('form .line-no-exist').removeClass('hidden');
|
||||
$('form .line-exist').addClass('hidden');
|
||||
$lines.attr('disabled', 'disabled');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('form .line-exist').removeClass('hidden');
|
||||
$('form .line-no-exist').addClass('hidden');
|
||||
$('.PGMStatus').hide();
|
||||
$lines.removeAttr('disabled');
|
||||
|
||||
$('form #newProgram0').prop('checked', false);
|
||||
toggleProgram($('form #newProgram0'));
|
||||
|
||||
getLineByProgram();
|
||||
}
|
||||
}
|
||||
|
||||
function toggleProject(obj)
|
||||
{
|
||||
var $obj = $(obj);
|
||||
|
||||
@@ -81,6 +81,7 @@ $lang->upgrade->line = 'Product Line';
|
||||
$lang->upgrade->program = 'Merge Project';
|
||||
$lang->upgrade->existPGM = 'Existing programs';
|
||||
$lang->upgrade->existPRJ = 'Existing projects';
|
||||
$lang->upgrade->existLine = 'Existing' . $lang->productCommon . ' lines';
|
||||
$lang->upgrade->product = $lang->productCommon;
|
||||
$lang->upgrade->project = 'Iteration';
|
||||
$lang->upgrade->repo = 'Repo';
|
||||
|
||||
@@ -81,6 +81,7 @@ $lang->upgrade->line = 'Product Line';
|
||||
$lang->upgrade->program = 'Merge Project';
|
||||
$lang->upgrade->existPGM = 'Existing programs';
|
||||
$lang->upgrade->existPRJ = 'Existing projects';
|
||||
$lang->upgrade->existLine = 'Existing' . $lang->productCommon . ' lines';
|
||||
$lang->upgrade->product = $lang->productCommon;
|
||||
$lang->upgrade->project = 'Iteration';
|
||||
$lang->upgrade->repo = 'Repo';
|
||||
|
||||
@@ -81,6 +81,7 @@ $lang->upgrade->line = 'Product Line';
|
||||
$lang->upgrade->program = 'Merge Project';
|
||||
$lang->upgrade->existPGM = 'Existing programs';
|
||||
$lang->upgrade->existPRJ = 'Existing projects';
|
||||
$lang->upgrade->existLine = 'Existing' . $lang->productCommon . ' lines';
|
||||
$lang->upgrade->product = $lang->productCommon;
|
||||
$lang->upgrade->project = 'Iteration';
|
||||
$lang->upgrade->repo = 'Repo';
|
||||
|
||||
@@ -81,6 +81,7 @@ $lang->upgrade->line = 'Product Line';
|
||||
$lang->upgrade->program = 'Merge Project';
|
||||
$lang->upgrade->existPGM = 'Existing programs';
|
||||
$lang->upgrade->existPRJ = 'Existing projects';
|
||||
$lang->upgrade->existLine = 'Existing' . $lang->productCommon . ' lines';
|
||||
$lang->upgrade->product = $lang->productCommon;
|
||||
$lang->upgrade->project = 'Iteration';
|
||||
$lang->upgrade->repo = 'Repo';
|
||||
|
||||
@@ -82,6 +82,7 @@ $lang->upgrade->line = '产品线';
|
||||
$lang->upgrade->program = '目标项目集和项目';
|
||||
$lang->upgrade->existPGM = '已有项目集';
|
||||
$lang->upgrade->existPRJ = '已有项目';
|
||||
$lang->upgrade->existLine = '已有' . $lang->productCommon . '线';
|
||||
$lang->upgrade->product = $lang->productCommon;
|
||||
$lang->upgrade->project = '迭代';
|
||||
$lang->upgrade->repo = '版本库';
|
||||
|
||||
@@ -4079,7 +4079,37 @@ class upgradeModel extends model
|
||||
$projectID = $data->projects;
|
||||
}
|
||||
|
||||
return array($programID, $projectID);
|
||||
if(!isset($data->lines))
|
||||
{
|
||||
if(!empty($data->lineName))
|
||||
{
|
||||
/* Insert product line. */
|
||||
$maxOrder = $this->dao->select("max(`order`) as maxOrder")->from(TABLE_MODULE)->where('type')->eq('line')->fetch('maxOrder');
|
||||
$maxOrder = $maxOrder ? $maxOrder + 10 : 0;
|
||||
|
||||
$line = new stdClass();
|
||||
$line->type = 'line';
|
||||
$line->parent = 0;
|
||||
$line->grade = 1;
|
||||
$line->name = $data->lineName;
|
||||
$line->root = $programID;
|
||||
$line->order = $maxOrder;
|
||||
$this->dao->insert(TABLE_MODULE)->data($line)->exec();
|
||||
$lineID = $this->dao->lastInsertID();
|
||||
$path = ",$lineID,";
|
||||
$this->dao->update(TABLE_MODULE)->set('path')->eq($path)->where('id')->eq($lineID)->exec();
|
||||
|
||||
if(dao::isError()) return false;
|
||||
}
|
||||
|
||||
if(empty($data->lineName)) $lineID = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lineID = $data->lines;
|
||||
}
|
||||
|
||||
return array($programID, $projectID, $lineID);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4087,12 +4117,13 @@ class upgradeModel extends model
|
||||
*
|
||||
* @param int $programID
|
||||
* @param int $projectID
|
||||
* @param int $lineID
|
||||
* @param array $productIdList
|
||||
* @param array $projectIdList
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function processMergedData($programID, $projectID, $productIdList = array(), $sprintIdList = array())
|
||||
public function processMergedData($programID, $projectID, $lineID, $productIdList = array(), $sprintIdList = array())
|
||||
{
|
||||
/* Product linked objects. */
|
||||
$this->dao->update(TABLE_STORY)->set('PRJ')->eq($programID)->where('product')->in($productIdList)->exec();
|
||||
@@ -4107,6 +4138,7 @@ class upgradeModel extends model
|
||||
$data = new stdclass();
|
||||
$data->program = $programID;
|
||||
$data->acl = $product->acl == 'custom' ? 'private' : $product->acl;
|
||||
$data->line = $product->line ? $product->line : $lineID;
|
||||
|
||||
$this->dao->update(TABLE_PRODUCT)->data($data)->where('id')->eq($product->id)->exec();
|
||||
}
|
||||
|
||||
@@ -48,6 +48,26 @@
|
||||
<th><?php echo $lang->program->PRJStatus;?></th>
|
||||
<td><?php echo html::select('PRJStatus', $lang->program->statusList, '', "class='form-control chosen'");?></td>
|
||||
</tr>
|
||||
<tr class='LineName'>
|
||||
<th>
|
||||
<span class="line-exist hidden"><?php echo $lang->upgrade->existLine;?></span>
|
||||
<span class="line-no-exist"><?php echo $lang->product->lineName;?></span>
|
||||
</th>
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<?php echo html::select("lines", $lines, '', "class='form-control hidden line-exist'");?>
|
||||
<?php echo html::input("lineName", isset($lineName) ? $lineName : '', "class='form-control line-no-exist'");?>
|
||||
<?php if(count($lines)):?>
|
||||
<span class='input-group-addon'>
|
||||
<div class="checkbox-primary">
|
||||
<input type="checkbox" name="newLine" value="0" checked onchange="toggleLine(this)" id="newLine0" />
|
||||
<label for="newLine0"><?php echo $lang->upgrade->newProgram;?></label>
|
||||
</div>
|
||||
</span>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class='PGMParams'>
|
||||
<th><?php echo $lang->program->PRJPM;?></th>
|
||||
<td><?php echo html::select('PM', array('' => '') + $users, '', "class='form-control chosen'");?></td>
|
||||
|
||||
Reference in New Issue
Block a user