From ba83f43b15e2675832e7fee5b69c6534175b6463 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 6 May 2015 15:42:23 +0800 Subject: [PATCH] * finish task #2242. --- module/project/control.php | 7 +- module/project/view/story.html.php | 225 +++++++++++++++-------------- module/story/model.php | 5 +- module/tree/model.php | 27 +++- 4 files changed, 151 insertions(+), 113 deletions(-) diff --git a/module/project/control.php b/module/project/control.php index e86fecd892..2c8976786e 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -526,7 +526,7 @@ class project extends control * @access public * @return void */ - public function story($projectID = 0, $orderBy = '') + public function story($projectID = 0, $orderBy = '', $type = 'byModule', $param = 0) { /* Load these models. */ $this->loadModel('story'); @@ -552,7 +552,7 @@ class project extends control $position[] = $this->lang->project->story; /* The pager. */ - $stories = $this->story->getProjectStories($projectID, $sort); + $stories = $this->story->getProjectStories($projectID, $sort, $type, $param); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story', false); $storyTasks = $this->task->getStoryTaskCounts(array_keys($stories), $projectID); $users = $this->user->getPairs('noletter'); @@ -574,7 +574,10 @@ class project extends control $this->view->stories = $stories; $this->view->summary = $this->product->summary($stories); $this->view->orderBy = $orderBy; + $this->view->type = $type; + $this->view->param = $param; $this->view->storyTasks = $storyTasks; + $this->view->moduleTree = $this->loadModel('tree')->getTaskTreeMenu($projectID, $productID = 0, $startModuleID = 0, array('treeModel', 'createProjectStoryLink')); $this->view->tabID = 'story'; $this->view->users = $users; diff --git a/module/project/view/story.html.php b/module/project/view/story.html.php index 84c9cffa54..4fd97898bd 100644 --- a/module/project/view/story.html.php +++ b/module/project/view/story.html.php @@ -12,6 +12,7 @@ ?> + project->confirmUnlinkStory)?>
icons['story']);?> project->story;?>
@@ -28,114 +29,128 @@
-
- - - - id}&orderBy=%s"; ?> - - - - - - - - - - - - - - - $story):?> - createLink('story', 'view', "storyID=$story->id"); - $totalEstimate += $story->estimate; - ?> - - - - - - - - - - - + + + + + + + + +
idAB);?> priAB);?> story->title);?> openedByAB);?> assignedToAB);?> story->estimateAB);?> statusAB);?> story->stageAB);?> story->taskCount;?> actions;?>
- - - - id));?> - story->priList, $story->pri, $story->pri)?>'>story->priList, $story->pri, $story->pri);?>title);?>openedBy];?>assignedTo];?>estimate;?>story->statusList[$story->status];?>story->stageList[$story->stage];?> - id}&story={$story->id}&moduleID={$story->module}"; - $lang->task->create = $lang->project->wbs; - common::printIcon('task', 'create', $param, '', 'list', 'smile'); +
+ +
+
+
+ icons['project']);?> name;?> +
+
+
+
+
+
+ + + + + id}&orderBy=%s&type=$type¶m=$param"; ?> + + + + + + + + + + + + + + + $story):?> + createLink('story', 'view', "storyID=$story->id"); + $totalEstimate += $story->estimate; + ?> + + + + + + + + + + + - - - - - - - - -
idAB);?> priAB);?> story->title);?> openedByAB);?> assignedToAB);?> story->estimateAB);?> statusAB);?> story->stageAB);?> story->taskCount;?> actions;?>
+ + + + id));?> + story->priList, $story->pri, $story->pri)?>'>story->priList, $story->pri, $story->pri);?>title);?>openedBy];?>assignedTo];?>estimate;?>story->statusList[$story->status];?>story->stageList[$story->stage];?> + id}&story={$story->id}&moduleID={$story->module}"; - $lang->task->batchCreate = $lang->project->batchWBS; - common::printIcon('task', 'batchCreate', "projectID={$project->id}&story={$story->id}", '', 'list', 'stack'); + $lang->task->create = $lang->project->wbs; + common::printIcon('task', 'create', $param, '', 'list', 'smile'); - $lang->testcase->batchCreate = $lang->testcase->create; - if($productID) common::printIcon('testcase', 'batchCreate', "productID=$story->product&moduleID=$story->module&storyID=$story->id", '', 'list', 'sitemap'); + $lang->task->batchCreate = $lang->project->batchWBS; + common::printIcon('task', 'batchCreate', "projectID={$project->id}&story={$story->id}", '', 'list', 'stack'); - if(common::hasPriv('project', 'unlinkStory')) - { - $unlinkURL = $this->createLink('project', 'unlinkStory', "projectID=$project->id&storyID=$story->id&confirm=yes"); - echo html::a("javascript:ajaxDelete(\"$unlinkURL\",\"storyList\",confirmUnlinkStory)", '', '', "class='btn-icon' title='{$lang->project->unlinkStory}'"); - } - ?> -
-
- " . html::selectButton() . '
'; + $lang->testcase->batchCreate = $lang->testcase->create; + if($productID) common::printIcon('testcase', 'batchCreate', "productID=$story->product&moduleID=$story->module&storyID=$story->id", '', 'list', 'sitemap'); - echo "
"; - if($canBatchEdit) - { - $actionLink = $this->createLink('story', 'batchEdit', "productID=0&projectID=$project->id"); - echo html::commonButton($lang->edit, "onclick=\"setFormAction('$actionLink')\""); - } - echo ""; - echo "
'; - } - echo "
" . $summary . '
'; - ?> - -
- + if(common::hasPriv('project', 'unlinkStory')) + { + $unlinkURL = $this->createLink('project', 'unlinkStory', "projectID=$project->id&storyID=$story->id&confirm=yes"); + echo html::a("javascript:ajaxDelete(\"$unlinkURL\",\"storyList\",confirmUnlinkStory)", '', '', "class='btn-icon' title='{$lang->project->unlinkStory}'"); + } + ?> +
+
+ " . html::selectButton() . '
'; + + echo "
"; + if($canBatchEdit) + { + $actionLink = $this->createLink('story', 'batchEdit', "productID=0&projectID=$project->id"); + echo html::commonButton($lang->edit, "onclick=\"setFormAction('$actionLink')\""); + } + echo ""; + echo "
'; + } + echo "
" . $summary . '
'; + ?> + +
+ + diff --git a/module/story/model.php b/module/story/model.php index 0fab563a04..c95488dfd3 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1191,11 +1191,14 @@ class storyModel extends model * @access public * @return array */ - public function getProjectStories($projectID = 0, $orderBy = 'pri_asc,id_desc') + public function getProjectStories($projectID = 0, $orderBy = 'pri_asc,id_desc', $type = 'byModule', $param = 0) { + if($type == 'byModule' and $param) $modules = $this->dao->select('*')->from(TABLE_MODULE)->where('path')->like("%,$param,%")->andWhere('type')->eq('story')->fetchPairs('id', 'id'); $stories = $this->dao->select('t1.*, t2.*')->from(TABLE_PROJECTSTORY)->alias('t1') ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') ->where('t1.project')->eq((int)$projectID) + ->beginIF($type == 'byProduct')->andWhere('t1.product')->eq($param)->fi() + ->beginIF($type == 'byModule' and $param)->andWhere('t2.module')->in($modules)->fi() ->andWhere('t2.deleted')->eq(0) ->orderBy($orderBy) ->fetchAll('id'); diff --git a/module/tree/model.php b/module/tree/model.php index 91035362a3..a84170a7be 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -353,7 +353,8 @@ class treeModel extends model } else { - $menu .= "
  • " . html::a(helper::createLink('project', 'task', "root=$rootID&status=byProduct&praram=$id"), $product, '_self', "id='product$id'"); + $link = $userFunc[1] == 'createProjectStoryLink' ? helper::createLink('project', 'story', "root=$rootID&orderBy=&status=byProduct&praram=$id") : helper::createLink('project', 'task', "root=$rootID&status=byProduct&praram=$id"); + $menu .= "
  • " . html::a($link, $product, '_self', "id='product$id'"); } /* tree menu. */ @@ -620,6 +621,23 @@ class treeModel extends model return $linkHtml; } + /** + * Create link of project story. + * + * @param string $type + * @param object $module + * @param array $extra + * @access public + * @return string + */ + public function createProjectStoryLink($type, $module, $extra) + { + $projectID = $extra['projectID']; + $productID = $extra['productID']; + $linkHtml = html::a(helper::createLink('project', 'story', "root={$projectID}&orderBy=&type=byModule¶m={$module->id}"), $module->name, '_self', "id='module{$module->id}'"); + return $linkHtml; + } + /** * Create link of a doc. * @@ -1035,8 +1053,7 @@ class treeModel extends model { $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) + ->where('t1.module')->in($childIds) ->andWhere('t2.product')->eq($before) ->fetchAll('id'); $projects = array(); @@ -1052,8 +1069,8 @@ class treeModel extends model $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])) + if(!isset($projectProduct[$project]) or !in_array($after, array_keys($projectProduct[$project]))) $this->dao->insert(TABLE_PROJECTPRODUCT)->set('project')->eq($project)->set('product')->eq($after)->exec(); + if(isset($linkedProduct[$project]) and !in_array($before, array_keys($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();