* task modules tree support product.

This commit is contained in:
Catouse
2016-04-18 13:08:20 +08:00
parent eb14a93895
commit 35c45afc19
3 changed files with 32 additions and 8 deletions
+1 -1
View File
@@ -155,7 +155,7 @@ class tree extends control
$this->view->currentProject = $currentProject;
$this->view->projectModules = $this->tree->getTaskOptionMenu($currentProject, $productID);
$this->view->currentModuleID = $currentModuleID;
$this->view->tree = $this->tree->getFullTaskTree($rootID, $productID);
$this->view->tree = $this->tree->getFullTaskTree($rootID, $productID, 0, $newModule);
$this->display();
}
+16 -6
View File
@@ -429,26 +429,36 @@ class treeModel extends model
/**
* Get full task tree
* @param integer $rootID, common value is project id
* @param integer $projectID, common value is project id
* @param integer $productID
* @param integer $moduleID
* @access public
* @return object
*/
public function getFullTaskTree($rootID, $productID, $moduleID = 0)
public function getFullTaskTree($projectID, $productID, $moduleID = 0, $newModule = false)
{
$tree = array_values($this->getTaskSons($rootID, $productID, $moduleID));
$tree = array_values($this->getTaskSons($projectID, $productID, $moduleID));
if(!$moduleID)
{
$products = $this->loadModel('project')->getProducts($projectID);
if($newModule and $products)
{
$productModulesTree = array();
foreach ($products as $product)
{
$productModulesTree[] = array('type' => 'product', 'name' => $product->name, 'actions' => false, 'id' => 'product' . $product->id, 'children' => $this->getFullTree($product->id, 'story'));
}
$tree = array_merge($productModulesTree, $tree);
}
// TODO: get product moduels for the project
$productModulesTree = array();
$tree = array_merge($tree, $productModulesTree);
}
if(count($tree))
{
foreach ($tree as $node)
{
$children = $this->getFullTaskTree($rootID, $productID, $node->id);
$children = $this->getFullTaskTree($projectID, $productID, $node->id);
if(count($children))
{
$node->children = $children;
+15 -1
View File
@@ -55,6 +55,11 @@
</div>
</div>
</div>
<style>
.story-item .tree-action[data-type='sort'],
.story-item .tree-action[data-type='edit'],
.story-item .tree-action[data-type='delete'] {display: none!important}
</style>
<script>
$(function()
{
@@ -66,11 +71,20 @@ $(function()
data: data,
itemCreator: function($li, item)
{
var $toggle = $('<span class="tree-toggle"><span class="module-name" data-id="' + item.id + '">' + item.name + '</span></span>');
var title = (item.type === 'product' ? '<i class="icon icon-cube text-muted"></i> ' : '') + item.name;
var $toggle = $('<span class="tree-toggle"><span class="module-name" data-id="' + item.id + '">' + title + '</span></span>');
if(item.short)
{
$toggle.append('&nbsp; <span class="module-manager text-muted">(' + item.short + ')</span>');
}
if(item.type === 'task')
{
$toggle.append('&nbsp; <span class="text-muted">[T]</span>');
}
if(item.type === 'story')
{
$li.addClass('story-item');
}
$li.append($toggle);
return true;
},