From 80b9d18d73d3223fb3948de159f24a5bfdaef92b Mon Sep 17 00:00:00 2001 From: chenfeiCF Date: Wed, 9 Mar 2016 13:03:06 +0800 Subject: [PATCH] * add link story method when edit a story. --- module/bug/view/edit.html.php | 4 +- module/story/control.php | 134 +++++++++++++++++++++++++++++++- module/story/lang/en.php | 4 + module/story/lang/zh-cn.php | 4 + module/story/model.php | 61 +++++++++++++++ module/story/view/edit.html.php | 32 +++++++- module/story/view/view.html.php | 4 +- 7 files changed, 235 insertions(+), 8 deletions(-) diff --git a/module/bug/view/edit.html.php b/module/bug/view/edit.html.php index 35c314d4cf..07b4fc5d8e 100644 --- a/module/bug/view/edit.html.php +++ b/module/bug/view/edit.html.php @@ -234,10 +234,12 @@ js::set('oldResolvedBuild' , $bug->resolvedBuild); bug->linkBug;?> linkBug, 'class="form-control"');?> + case):?> - bug->case;?> + bug->fromCase;?> case, 'class="form-control"');?> + diff --git a/module/story/control.php b/module/story/control.php index c138abd7bb..fdfedff45b 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -556,8 +556,8 @@ class story extends control /** * Delete a story. - * - * @param int $storyID + * + * @param int $storyID * @param string $confirm yes|no * @access public * @return void @@ -903,6 +903,136 @@ class story extends control $this->display(); } + /** + * Link stories. + * + * @param int $storyID + * @param string $linkType + * @param string $stories + * @param string $browseType + * @param int $param + * @access public + * @return void + */ + public function linkStory($storyID, $linkType = '', $stories = '', $browseType = '', $param = 0) + { + /* Get story, product, and products. */ + $story = $this->story->getById($storyID); + $product = $this->product->getById($story->product); + $products = $this->product->getPairs(); + + /* Set menu. */ + $this->product->setMenu($products, $product->id, $story->branch); + + $queryID = ($browseType == 'bySearch') ? (int)$param : 0; + $browseLink = $this->createLink('story', 'edit', "storyID=$storyID"); + $branches = $product->type != 'normal' ? $this->loadModel('branch')->getPairs($story->product) : array(); + + /* Link stories. */ + if(!empty($_POST)) + { + $linkedStories = $this->story->linkStories($storyID, $linkType, $stories); + if(isonlybody()) die(js::closeModal('parent.parent', '', "function(){parent.parent.loadLinkedStories('$storyID', '$linkType', '$linkedStories')}")); + die(js::locate($browseLink, 'parent')); + } + + /* Build search form. */ + unset($this->config->product->search['fields']['module']); + $this->config->product->search['actionURL'] = $this->createLink('story', 'linkStory', "storyID=$storyID&linkType=$linkType&stories=$stories&browseType=bySearch&queryID=myQueryID", '', true); + $this->config->product->search['queryID'] = $queryID; + $this->config->product->search['params']['product']['values'] = array($story->product => $products[$story->product], 'all' => $this->lang->product->allProduct); + $this->config->product->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts($products); + unset($this->lang->story->statusList['draft']); + if($product->type != 'normal') + { + $this->config->product->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); + $this->config->product->search['params']['branch']['values'] = array('' => '') + $branches; + } + else + { + unset($this->config->product->search['fields']['branch']); + unset($this->config->product->search['params']['branch']); + } + $this->config->product->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $this->lang->story->statusList); + $this->loadModel('search')->setSearchParams($this->config->product->search); + + /* Get stories to link. */ + if($browseType == 'bySearch') + { + $allStories = $this->story->getBySearch($story->product, $queryID, 'id', null); + } + else + { + $allStories = $this->story->getProductStories($story->product, 0, $moduleID = '0'); + } + + $title = $this->lang->story->linkStory; + $position[] = html::a($browseLink, $story->title); + $position[] = $this->lang->story->linkStory; + + $this->view->title = $title; + $this->view->position = $position; + $this->view->product = $product; + $this->view->products = $products; + $this->view->branches = $branches; + $this->view->linkType = $linkType; + $this->view->story = $story; + $this->view->allStories = $allStories; + $this->view->browseType = $browseType; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); + $this->display(); + } + + /** + * AJAX: Get linked story. + * + * @param int $storyID + * @param string $type + * @param string $linkedStories + * @access public + * @return void + */ + public function ajaxGetLinkedStories($storyID, $type = '', $linkedStories) + { + $stories = $this->story->getLinkedStories($linkedStories); + $story = $this->story->getById($storyID); + $output = "'; + + die($output); + } + + /** + * AJAX: delete linked story. + * + * @param int $storyID + * @param string $type + * @param int $deleteStory + * @access public + * @return void + */ + public function ajaxDeleteLinkedStory($storyID, $type = '', $deleteStory) + { + $stories = $this->story->deleteLinkedStory($storyID, $type, $deleteStory); + $story = $this->story->getById($storyID); + $output = "'; + + die($output); + } + /** * AJAX: get stories of a project in html select. * diff --git a/module/story/lang/en.php b/module/story/lang/en.php index 8cfa8c1d5c..5a3b705dfb 100644 --- a/module/story/lang/en.php +++ b/module/story/lang/en.php @@ -196,6 +196,10 @@ $lang->story->action->linked2plan = array('main' => '$date, linked to pl $lang->story->action->unlinkedfromplan = array('main' => '$date, removed from $extra> by $actor'); $lang->story->action->linked2project = array('main' => '$date, linked to ' . $lang->projectCommon . ' $extra by $actor.'); $lang->story->action->unlinkedfromproject = array('main' => '$date, removed from ' . $lang->projectCommon . ' $extra by $actor.'); +$lang->story->action->linkstories = array('main' => '$date, linked stories $extra by $actor.'); +$lang->story->action->childstories = array('main' => '$date, subdivied to $extra by $actor.'); +$lang->story->action->mvchildstories = array('main' => '$date, removed child stories $extra by $actor.'); +$lang->story->action->mvlinkstories = array('main' => '$date, removed link stories $extra by $actor.'); /* Report*/ $lang->story->report = new stdclass(); diff --git a/module/story/lang/zh-cn.php b/module/story/lang/zh-cn.php index ad298baaed..4020a30272 100644 --- a/module/story/lang/zh-cn.php +++ b/module/story/lang/zh-cn.php @@ -196,6 +196,10 @@ $lang->story->action->linked2plan = array('main' => '$date, 由 $lang->story->action->unlinkedfromplan = array('main' => '$date, 由 $actor 从计划 $extra 移除。'); $lang->story->action->linked2project = array('main' => '$date, 由 $actor 关联到' . $lang->projectCommon . ' $extra。'); $lang->story->action->unlinkedfromproject = array('main' => '$date, 由 $actor 从' . $lang->projectCommon . ' $extra 移除。'); +$lang->story->action->linkstories = array('main' => '$date, 由 $actor 关联相关需求 $extra。'); +$lang->story->action->childstories = array('main' => '$date, 由 $actor 细分为需求 $extra。'); +$lang->story->action->mvchildstories = array('main' => '$date, 由 $actor 移除细分需求 $extra。'); +$lang->story->action->mvlinkstories = array('main' => '$date, 由 $actor 移除相关需求 $extra。'); /* 统计报表。*/ $lang->story->report = new stdclass(); diff --git a/module/story/model.php b/module/story/model.php index 129eaeace9..d40593ac07 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1035,6 +1035,67 @@ class storyModel extends model return; } + /** + * Link stories. + * + * @param int $storyID + * @param string $linkType + * @param string $stories + * @access public + * @return void + */ + public function linkStories($storyID, $linkType, $linkedStories) + { + if($this->post->stories == false) return false; + $stories = implode(',', $this->post->stories) . ',' . trim($linkedStories, ','); + $this->dao->update(TABLE_STORY)->set($linkType)->eq($stories)->where('id')->eq($storyID)->exec(); + + if(dao::isError()) die(js::error(dao::getError())); + $this->loadModel('action')->create('story', $storyID, $linkType, '', implode(',', $this->post->stories)); + + return $stories; + } + + /** + * Delete linked story. + * + * @param int $storyID + * @param string $type + * @param int $deleteStory + * @access public + * @return void + */ + public function deleteLinkedStory($storyID, $type, $deleteStory) + { + $story = $this->getById($storyID); + $stories = explode(',', trim($story->$type, ',')); + foreach($stories as $key => $storyId) + { + if($storyId == $deleteStory) unset($stories[$key]); + } + $stories = implode(',', $stories); + + $this->dao->update(TABLE_STORY)->set($type)->eq($stories)->where('id')->eq($storyID)->exec(); + if(dao::isError()) die(js::error(dao::getError())); + + $action = 'mv' . $type; + $this->loadModel('action')->create('story', $storyID, $action, '', $deleteStory); + + return $this->getLinkedStories($stories); + } + + /** + * Get linked stories. + * + * @param string $stories + * @access public + * @return void + */ + public function getLinkedStories($stories) + { + return $this->dao->select('id, title')->from(TABLE_STORY)->where('id')->in($stories)->fetchPairs(); + } + /** * Get stories list of a product. * diff --git a/module/story/view/edit.html.php b/module/story/view/edit.html.php index 01b7a2734c..0fb6df9cfb 100644 --- a/module/story/view/edit.html.php +++ b/module/story/view/edit.html.php @@ -39,6 +39,8 @@ +
linkStories);?>
+
childStories);?>
lastEditedDate); @@ -167,13 +169,35 @@ story->duplicateStory;?> duplicateStory, "class='form-control'");?> - + story->linkStories;?> - linkStories, "class='form-control'");?> + +
    + createLink('story', 'linkStory', "storyID=$story->id&linkType=linkStories&stories=$story->linkStories", '', true), $lang->story->linkStory, '', "class='iframe' data-width='85%'");?> + linkStories); + foreach($linkStories as $linkStoryID) + { + if(isset($story->extraStories[$linkStoryID])) echo '
  • ' . html::a(inlink('view', "storyID=$linkStoryID"), "#$linkStoryID " . $story->extraStories[$linkStoryID]) . html::a("javascript:deleteLinkedStory($story->id, \"linkStories\", $linkStoryID)", '', '', "style='float:right'"); + } + ?> +
+ - + story->childStories;?> - childStories, "class='form-control'");?> + +
    + createLink('story', 'linkStory', "storyID=$story->id&linkType=childStories&stories=$story->childStories", '', true), $lang->story->linkStory, '', "class='iframe' data-width='85%'");?> + childStories); + foreach($childStories as $childStoryID) + { + if(isset($story->extraStories[$childStoryID])) echo '
  • ' . html::a(inlink('view', "storyID=$childStoryID"), "#$childStoryID" . $story->extraStories[$childStoryID]) . html::a("javascript:deleteLinkedStory($story->id, \"childStories\", $childStoryID)", '', '', "style='float:right'") . '
  • '; + } + ?> +
+ diff --git a/module/story/view/view.html.php b/module/story/view/view.html.php index 2000f46e27..f6f09fb967 100644 --- a/module/story/view/view.html.php +++ b/module/story/view/view.html.php @@ -275,14 +275,16 @@
+ +
story->legendFromBug;?>
    - id $fromBug->title'>" . html::a($this->createLink('bug', 'view', "bugID=$fromBug->id"), "#$fromBug->id $fromBug->title") . '';?> + id $fromBug->title'>" . html::a($this->createLink('bug', 'view', "bugID=$fromBug->id"), "#$fromBug->id $fromBug->title") . '';?>
story->legendBugs;?>