From 99e9616476fe8a55833db6242eaa86968a5cbacb Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Thu, 13 Jun 2013 05:11:38 +0000 Subject: [PATCH] * code for task#1374. --- module/project/control.php | 7 +- module/project/view/task.html.php | 8 +- module/task/control.php | 2 +- module/tree/control.php | 84 ++++++--- module/tree/js/browsetask.js | 45 +++++ module/tree/model.php | 268 ++++++++++++++++++++++++--- module/tree/view/browsetask.html.php | 90 +++++++++ 7 files changed, 438 insertions(+), 66 deletions(-) create mode 100644 module/tree/js/browsetask.js create mode 100644 module/tree/view/browsetask.html.php diff --git a/module/project/control.php b/module/project/control.php index 29dd6e9ce3..df8654624e 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -109,7 +109,7 @@ class project extends control * @return void */ public function task($projectID = 0, $status = 'all', $param = 0, $orderBy = '', $recTotal = 0, $recPerPage = 100, $pageID = 1) - { + { $this->loadModel('tree'); /* Set browseType, productID, moduleID and queryID. */ @@ -167,6 +167,7 @@ class project extends control { if($this->session->taskQuery == false) $this->session->set('taskQuery', ' 1 = 1'); } + /* Limit current project when no project. */ if(strpos($this->session->taskQuery, "`project` =") === false) $this->session->set('taskQuery', $this->session->taskQuery . " AND `project` = $projectID"); if(strpos($this->session->taskQuery, "deleted =") === false) $this->session->set('taskQuery', $this->session->taskQuery . " AND deleted = '0'"); @@ -185,7 +186,7 @@ class project extends control $this->config->project->search['actionURL'] = $this->createLink('project', 'task', "projectID=$projectID&status=bySearch¶m=myQueryID"); $this->config->project->search['queryID'] = $queryID; $this->config->project->search['params']['project']['values'] = array(''=>'', $projectID => $this->projects[$projectID], 'all' => $this->lang->project->allProject); - $this->config->project->search['params']['module']['values'] = $this->tree->getOptionMenu($projectID, $viewType = 'task', $startModuleID = 0); + $this->config->project->search['params']['module']['values'] = $this->tree->getTaskOptionMenu($projectID, $startModuleID = 0); $this->loadModel('search')->setSearchParams($this->config->project->search); /* Assign. */ @@ -203,7 +204,7 @@ class project extends control $this->view->projectID = $projectID; $this->view->project = $project; $this->view->moduleID = $moduleID; - $this->view->moduleTree = $this->tree->getTreeMenu($projectID, $viewType = 'task', $startModuleID = 0, array('treeModel', 'createTaskLink')); + $this->view->moduleTree = $this->tree->getTaskTreeMenu($projectID, $productID = 0, $startModuleID = 0, array('treeModel', 'createTaskLink')); $this->view->projectTree = $this->project->tree(); $this->display(); diff --git a/module/project/view/task.html.php b/module/project/view/task.html.php index e12421583b..8327739d14 100644 --- a/module/project/view/task.html.php +++ b/module/project/view/task.html.php @@ -26,10 +26,10 @@ var browseType = '';
- edit);?> - delete, 'hiddenwin');?> - tree->manage);?> - tree->fix, 'hiddenwin');?> + edit);?> + delete, 'hiddenwin');?> + tree->manage);?> + tree->fix, 'hiddenwin');?>
diff --git a/module/task/control.php b/module/task/control.php index 6931f75634..8ddd2a6bf3 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -238,7 +238,7 @@ class task extends control $this->view->position[] = $this->lang->task->edit; $this->view->stories = $this->story->getProjectStoryPairs($this->view->project->id); $this->view->members = $this->loadModel('user')->appendDeleted($this->view->members, $this->view->task->assignedTo); - $this->view->modules = $this->tree->getOptionMenu($this->view->task->project, $viewType = 'task'); + $this->view->modules = $this->tree->getTaskOptionMenu($this->view->task->project); $this->display(); } diff --git a/module/tree/control.php b/module/tree/control.php index d6a224ca0d..827a4de727 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -31,12 +31,6 @@ class tree extends control $this->view->root = $product; $this->view->productModules = $this->tree->getOptionMenu($rootID, 'story'); } - elseif($viewType == 'task') - { - $project = $this->loadModel('project')->getById($rootID); - $this->view->root = $project; - $this->view->projectModules = $this->tree->getOptionMenu($rootID, 'task'); - } /* The viewType is doc. */ elseif(strpos($viewType, 'doc') !== false) @@ -77,25 +71,6 @@ class tree extends control $position[] = html::a($this->createLink('product', 'browse', "product=$rootID"), $product->name); $position[] = $this->lang->tree->manageProduct; } - elseif($viewType == 'task') - { - $this->lang->set('menugroup.tree', 'project'); - $this->project->setMenu($this->project->getPairs(), $rootID, 'task'); - $this->lang->tree->menu = $this->lang->project->menu; - $this->lang->tree->menuOrder = $this->lang->project->menuOrder; - - $projects = $this->project->getPairs(); - unset($projects[$rootID]); - $currentProject = key($projects); - - $this->view->allProject = $projects; - $this->view->currentProject = $currentProject; - $this->view->projectModules = $this->tree->getOptionMenu($currentProject, 'task'); - - $title = $project->name . $this->lang->colon . $this->lang->tree->manageProject; - $position[] = html::a($this->createLink('project', 'task', "projectID=$rootID"), $project->name); - $position[] = $this->lang->tree->manageProject; - } elseif($viewType == 'bug') { $this->loadModel('bug')->setMenu($this->product->getPairs(), $rootID); @@ -156,6 +131,48 @@ class tree extends control $this->display(); } + /** + * Browse task module. + * + * @param int $rootID + * @param int $productID + * @param int $currentModuleID + * @access public + * @return void + */ + public function browseTask($rootID, $productID = 0, $currentModuleID = 0) + { + $project = $this->loadModel('project')->getById($rootID); + $this->view->root = $project; + + $this->lang->set('menugroup.tree', 'project'); + $this->project->setMenu($this->project->getPairs(), $rootID); + $this->lang->tree->menu = $this->lang->project->menu; + $this->lang->tree->menuOrder = $this->lang->project->menuOrder; + + $projects = $this->project->getPairs(); + unset($projects[$rootID]); + $currentProject = key($projects); + $parentModules = $this->tree->getParents($currentModuleID); + + $title = $project->name . $this->lang->colon . $this->lang->tree->manageProject; + $position[] = html::a($this->createLink('project', 'task', "projectID=$rootID"), $project->name); + $position[] = $this->lang->tree->manageProject; + + $this->view->title = $title; + $this->view->position = $position; + $this->view->rootID = $rootID; + $this->view->productID = $productID; + $this->view->allProject = $projects; + $this->view->currentProject = $currentProject; + $this->view->projectModules = $this->tree->getTaskOptionMenu($currentProject, $productID); + $this->view->modules = $this->tree->getTaskTreeMenu($rootID, $productID, $rooteModuleID = 0, array('treeModel', 'createTaskManageLink')); + $this->view->sons = $this->tree->getTaskSons($rootID, $productID, $currentModuleID); + $this->view->currentModuleID = $currentModuleID; + $this->view->parentModules = $parentModules; + $this->display(); + } + /** * Edit a module. * @@ -171,15 +188,24 @@ class tree extends control echo js::alert($this->lang->tree->successSave); die(js::reload('parent')); } + $module = $this->tree->getById($moduleID); if($module->owner == null and $module->root != 0) { $module->owner = $this->loadModel('product')->getById($module->root)->QD; } - $this->view->module = $module; - $this->view->type = $type; - $this->view->optionMenu = $this->tree->getOptionMenu($this->view->module->root, $this->view->module->type); - $this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted'); + + if($type == 'task') + { + $this->view->optionMenu = $this->tree->getTaskOptionMenu($module->root); + } + else + { + $this->view->optionMenu = $this->tree->getOptionMenu($module->root, $module->type); + } + $this->view->module = $module; + $this->view->type = $type; + $this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted'); /* Remove self and childs from the $optionMenu. Because it's parent can't be self or childs. */ $childs = $this->tree->getAllChildId($moduleID); diff --git a/module/tree/js/browsetask.js b/module/tree/js/browsetask.js new file mode 100644 index 0000000000..15889a3e39 --- /dev/null +++ b/module/tree/js/browsetask.js @@ -0,0 +1,45 @@ +function syncModule(rootID, type) +{ + moduleID = type == 'task' ? $('#projectModule').val() : $('#productModule').val(); + type = type == 'task' ? 'task' : 'story'; + + link = createLink('tree', 'ajaxGetSonModules', 'moduleID=' + moduleID + '&rootID=' + rootID + '&type=' + type); + $.getJSON(link, function(modules) + { + $('.helplink').addClass('hidden'); + $.each(modules, function(key, value) + { + moduleName = value; + $('.text-3').each(function() + { + if(this.value == moduleName) modules[key] = null; + if(!this.value) $(this).parent().addClass('hidden'); + }) + }); + $.each(modules, function(key, value) + { + if(value) $('#sonModule').append("
"); + }) + }) +} + +function syncProject(obj) +{ + link = createLink('tree', 'ajaxGetOptionMenu', 'rootID=' + obj.value + "&viewType=task&rootModuleID=0&returnType=json"); + $.getJSON(link, function(modules) + { + $('.helplink').addClass('hidden'); + $('#' + type + 'Module').empty(); + $.each(modules, function(key, value) + { + $('#' + type + 'Module').append('