From de50683bc3e2cfc5d49c41436bb8ee0cccbdb358 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 18 Aug 2014 09:02:04 +0000 Subject: [PATCH] * finish task #2050. --- module/project/model.php | 29 ++++++++++++++++------------- module/task/js/batchcreate.js | 1 + module/tree/model.php | 11 +++++++++-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/module/project/model.php b/module/project/model.php index d3bb09b804..922c3186ae 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -929,40 +929,43 @@ class projectModel extends model public function importBug($projectID) { $this->loadModel('bug'); - $bugLang = $this->app->loadLang('bug'); $this->loadModel('task'); $this->loadModel('story'); - $now = helper::now(); - $BugToTasks = fixer::input('post')->get(); - foreach($BugToTasks->import as $key => $value) + $now = helper::now(); + $modules = $this->loadModel('tree')->getTaskOptionMenu($projectID); + + $bugToTasks = fixer::input('post')->get(); + $bugs = $this->bug->getByList(array_keys($bugToTasks->import)); + foreach($bugToTasks->import as $key => $value) { - $bug = $this->bug->getById($key); + $bug = $bugs[$key]; $task = new stdClass(); $task->project = $projectID; $task->story = $bug->story; - $task->storyVersion = $bug->story; + $task->storyVersion = $bug->storyVersion; + $task->module = isset($modules[$bug->module]) ? $bug->module : 0; $task->fromBug = $key; $task->name = $bug->title; $task->type = 'devel'; - $task->pri = $BugToTasks->pri[$key]; + $task->pri = $bugToTasks->pri[$key]; $task->consumed = 0; $task->status = 'wait'; - $task->desc = $bugLang->bug->resolve . ':' . '#' . html::a(helper::createLink('bug', 'view', "bugID=$key"), sprintf('%03d', $key)); + $task->desc = $this->lang->bug->resolve . ':' . '#' . html::a(helper::createLink('bug', 'view', "bugID=$key"), sprintf('%03d', $key)); $task->openedDate = $now; $task->openedBy = $this->app->user->account; - if(!empty($BugToTasks->estimate[$key])) + if(!empty($bugToTasks->estimate[$key])) { - $task->estimate = $BugToTasks->estimate[$key]; + $task->estimate = $bugToTasks->estimate[$key]; $task->left = $task->estimate; } - if(!empty($BugToTasks->assignedTo[$key])) + if(!empty($bugToTasks->assignedTo[$key])) { - $task->assignedTo = $BugToTasks->assignedTo[$key]; + $task->assignedTo = $bugToTasks->assignedTo[$key]; $task->assignedDate = $now; } if(!$bug->confirmed) $this->dao->update(TABLE_BUG)->set('confirmed')->eq(1)->where('id')->eq($bug->id)->exec(); - $this->dao->insert(TABLE_TASK)->data($task)->checkIF($BugToTasks->estimate[$key] != '', 'estimate', 'float')->exec(); + $this->dao->insert(TABLE_TASK)->data($task)->checkIF($bugToTasks->estimate[$key] != '', 'estimate', 'float')->exec(); if(dao::isError()) { diff --git a/module/task/js/batchcreate.js b/module/task/js/batchcreate.js index 33b7b30fab..6c2e32aef2 100755 --- a/module/task/js/batchcreate.js +++ b/module/task/js/batchcreate.js @@ -37,6 +37,7 @@ function setStoryRelated(num) $.get(link, function(moduleID) { $('#module' + num).val(moduleID); + $('#module' + num).trigger("chosen:updated"); }); } } diff --git a/module/tree/model.php b/module/tree/model.php index d04140e670..e994727b61 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -439,8 +439,7 @@ class treeModel extends model if($linkStory) { /* Get story paths of this project. */ - $paths = $this->dao->select('t3.' . $field) - ->from(TABLE_PROJECTSTORY)->alias('t1') + $paths = $this->dao->select('DISTINCT t3.' . $field)->from(TABLE_PROJECTSTORY)->alias('t1') ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') ->leftJoin(TABLE_MODULE)->alias('t3')->on('t2.module = t3.id') ->where('t1.project')->eq($projectID) @@ -461,6 +460,14 @@ class treeModel extends model ->andWhere('type')->eq('task') ->fetchPairs(); + /* Add task paths of this project for has existed. */ + $paths += $this->dao->select('DISTINCT t1.' . $field)->from(TABLE_MODULE)->alias('t1') + ->leftJoin(TABLE_TASK)->alias('t2')->on('t1.id=t2.module') + ->where('t2.module')->ne(0) + ->andWhere('t2.deleted')->eq(0) + ->andWhere('t1.type')->eq('story') + ->fetchPairs(); + /* Get all modules from paths. */ foreach($paths as $path) {