* finish task #2236.
This commit is contained in:
@@ -198,6 +198,7 @@ class tree extends control
|
||||
$this->view->module = $module;
|
||||
$this->view->type = $type;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted', $module->owner);
|
||||
if($type == 'story') $this->view->products = $this->loadModel('product')->getPairs();
|
||||
|
||||
/* Remove self and childs from the $optionMenu. Because it's parent can't be self or childs. */
|
||||
$childs = $this->tree->getAllChildId($moduleID);
|
||||
|
||||
@@ -44,3 +44,4 @@ $lang->tree->child = 'Child';
|
||||
$lang->tree->owner = 'Owner';
|
||||
$lang->tree->order = 'Order';
|
||||
$lang->tree->projectDoc = 'Project doc';
|
||||
$lang->tree->product = 'Product';
|
||||
|
||||
@@ -44,3 +44,4 @@ $lang->tree->child = '子模块';
|
||||
$lang->tree->owner = '负责人';
|
||||
$lang->tree->order = '排序';
|
||||
$lang->tree->projectDoc = '项目文档';
|
||||
$lang->tree->product = '所属产品';
|
||||
|
||||
+50
-5
@@ -170,6 +170,7 @@ class treeModel extends model
|
||||
$projectModules = $this->getTaskTreeModules($rootID, false, false);
|
||||
$noProductModules = $this->dao->select('*')->from(TABLE_MODULE)->where("root = $rootID and type = 'task' and parent = 0")->fetchPairs('id', 'name');
|
||||
|
||||
/* Fix for not in product modules. */
|
||||
foreach(array('product' => $products, 'noProduct' => $noProductModules) as $type => $rootModules)
|
||||
{
|
||||
foreach($rootModules as $id => $rootModule)
|
||||
@@ -1009,7 +1010,54 @@ class treeModel extends model
|
||||
$this->dao->update(TABLE_MODULE)->set('grade = grade + 1')->where('id')->in($childs)->andWhere('id')->ne($moduleID)->exec();
|
||||
$this->dao->update(TABLE_MODULE)->set('owner')->eq($this->post->owner)->where('id')->in($childs)->andWhere('owner')->eq('')->exec();
|
||||
$this->dao->update(TABLE_MODULE)->set('owner')->eq($this->post->owner)->where('id')->in($childs)->andWhere('owner')->eq($self->owner)->exec();
|
||||
$this->fixModulePath($self->root, $self->type);
|
||||
if(isset($module->root)) $this->dao->update(TABLE_MODULE)->set('root')->eq($module->root)->where('id')->in($childs)->exec();
|
||||
$this->fixModulePath(isset($module->root) ? $module->root : $self->root, $self->type);
|
||||
if(isset($module->root) and $module->root != $self->root) $this->changeRoot($moduleID, $self->root, $module->root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change root.
|
||||
*
|
||||
* @param int $moduleID
|
||||
* @param int $before
|
||||
* @param int $after
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function changeRoot($moduleID, $before, $after)
|
||||
{
|
||||
$childIds = $this->dao->select('id')->from(TABLE_MODULE)->where('path')->like("%,$moduleID,%")->fetchPairs('id', 'id');
|
||||
$this->dao->update(TABLE_STORY)->set('product')->eq($after)->where('module')->in($childIds)->exec();
|
||||
$this->dao->update(TABLE_BUG)->set('product')->eq($after)->where('module')->in($childIds)->exec();
|
||||
$this->dao->update(TABLE_CASE)->set('product')->eq($after)->where('module')->in($childIds)->exec();
|
||||
|
||||
$linkedStories = $this->dao->select('DISTINCT t1.id,t1.version,t2.project')->from(TABLE_STORY)->alias('t1')
|
||||
->leftJoin(TABLE_PROJECTSTORY)->alias('t2')->on('t1.id=t2.story')
|
||||
->where('t1.version=t2.version')
|
||||
->andWhere('t1.module')->in($childIds)
|
||||
->andWhere('t2.product')->eq($before)
|
||||
->fetchAll('id');
|
||||
$projects = array();
|
||||
foreach($linkedStories as $story)
|
||||
{
|
||||
$this->dao->update(TABLE_PROJECTSTORY)->set('product')->eq($after)->where('project')->eq($story->project)->andWhere('story')->eq($story->id)->andWhere('version')->eq($story->version)->exec();
|
||||
$projects[$story->project] = $story->project;
|
||||
}
|
||||
|
||||
if($projects)
|
||||
{
|
||||
$projectProduct = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('project')->in($projects)->fetchGroup('project', 'product');
|
||||
$linkedProduct = $this->dao->select('DISTINCT project,product')->from(TABLE_PROJECTSTORY)->where('project')->in($projects)->fetchGroup('project', 'product');
|
||||
foreach($projects as $project)
|
||||
{
|
||||
if(!isset($projectProduct[$project]) or !in_array($after, $projectProduct[$project])) $this->dao->insert(TABLE_PROJECTPRODUCT)->set('project')->eq($project)->set('product')->eq($after)->exec();
|
||||
if(isset($linkedProduct[$project]) and !in_array($before, $linkedProduct[$project]))
|
||||
{
|
||||
$this->dao->delete()->from(TABLE_PROJECTPRODUCT)->where('project')->eq($project)->andWhere('product')->eq($before)->exec();
|
||||
$this->dao->update(TABLE_BUILD)->set('product')->eq($after)->where('product')->eq($before)->andWhere('project')->eq($project)->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1092,9 +1140,6 @@ class treeModel extends model
|
||||
}
|
||||
|
||||
/* Save modules to database. */
|
||||
foreach($modules as $module)
|
||||
{
|
||||
$this->dao->update(TABLE_MODULE)->data($module)->where('id')->eq($module->id)->limit(1)->exec();
|
||||
}
|
||||
foreach($modules as $module) $this->dao->update(TABLE_MODULE)->data($module)->where('id')->eq($module->id)->limit(1)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
$webRoot = $this->app->getWebRoot();
|
||||
$jsRoot = $webRoot . "js/";
|
||||
?>
|
||||
<?php include '../../common/view/chosen.html.php'?>
|
||||
<div class='modal-dialog w-500px'>
|
||||
<div class='modal-body'>
|
||||
<div id='titlebar'>
|
||||
@@ -24,6 +25,12 @@ $jsRoot = $webRoot . "js/";
|
||||
</div>
|
||||
<form action="<?php echo inlink('edit', 'module=' . $module->id .'&type=' .$type);?>" target='hiddenwin' class='form-condensed' method='post' class='mt-10px' id='dataform'>
|
||||
<table class='table table-form'>
|
||||
<?php if($type == 'story'):?>
|
||||
<tr>
|
||||
<th class='w-80px'><?php echo $lang->tree->product;?></th>
|
||||
<td><?php echo html::select('root', $products, $module->root, "class='form-control chosen' onchange='getProductModules(this.value)'");?></td>
|
||||
</tr>
|
||||
<?php endif;?>
|
||||
<?php $hidden = ($type != 'story' and $module->type == 'story');?>
|
||||
<tr <?php if($hidden) echo "style='display:none'";?>>
|
||||
<th class='w-80px'><?php echo $lang->tree->parent;?></th>
|
||||
@@ -48,3 +55,18 @@ $jsRoot = $webRoot . "js/";
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var currentRoot = <?php echo $module->root;?>;
|
||||
var currentParent = <?php echo $module->parent;?>;
|
||||
function getProductModules(productID)
|
||||
{
|
||||
$.get(createLink('tree', 'ajaxGetOptionMenu', 'rootID=' + productID + '&viewType=story&rootModuleID=0&returnType=json'), function(data)
|
||||
{
|
||||
var newOption = '';
|
||||
for(i in data) newOption += '<option value="' + i + '">' + data[i] + '</option>';
|
||||
$('#parent').html(newOption);
|
||||
if(productID == currentRoot) $('#parent').val(currentParent);
|
||||
$('#parent').trigger('chosen:updated')
|
||||
}, 'json');
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user