From 543078c4ee22ab8f8755ade5cf81e079deb3df67 Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Tue, 23 Mar 2021 14:21:53 +0800 Subject: [PATCH] * Fix linkstory bug. --- module/common/lang/menu.php | 4 +- module/execution/control.php | 49 +++++++++++++----------- module/execution/lang/en.php | 14 +++---- module/execution/lang/zh-cn.php | 14 +++---- module/execution/model.php | 1 + module/execution/view/linkstory.html.php | 14 +++---- module/product/control.php | 5 ++- module/project/model.php | 5 ++- module/projectstory/lang/en.php | 1 + module/projectstory/lang/zh-cn.php | 1 + module/story/model.php | 2 +- module/testcase/control.php | 21 ++-------- 12 files changed, 63 insertions(+), 68 deletions(-) diff --git a/module/common/lang/menu.php b/module/common/lang/menu.php index 41c1984590..2a38657757 100644 --- a/module/common/lang/menu.php +++ b/module/common/lang/menu.php @@ -155,7 +155,7 @@ $lang->project->dividerMenu = ',execution,programplan,doc,dynamic,'; $lang->scrum->menu = new stdclass(); $lang->scrum->menu->index = array('link' => "{$lang->dashboard}|project|index|project=%s"); $lang->scrum->menu->execution = array('link' => "$lang->executionCommon|project|execution|projectID=%s"); -$lang->scrum->menu->story = array('link' => "$lang->SRCommon|projectstory|story|projectID=%s", 'alias' => 'story,track'); +$lang->scrum->menu->story = array('link' => "$lang->SRCommon|projectstory|story|projectID=%s", 'subModule' => 'projectstory', 'alias' => 'story,track'); $lang->scrum->menu->doc = array('link' => "{$lang->doc->common}|doc|objectLibs|type=project&objectID=%s", 'subModule' => 'doc'); $lang->scrum->menu->qa = array('link' => "{$lang->qa->common}|project|qa|projectID=%s", 'subModule' => 'testcase,testtask,bug', 'alias' => 'bug,testtask,testcase'); $lang->scrum->menu->devops = array('link' => "{$lang->devops->common}|repo|browse|repoID=0&objectID=%s", 'subModule' => 'repo'); @@ -198,7 +198,7 @@ $lang->waterfall->menu->programplan = array('link' => "{$lang->productplan->shor $lang->waterfall->menu->execution = array('link' => "$lang->executionCommon|execution|all|status=all&projectID=%s", 'subModule' => ',project,task,'); $lang->waterfall->menu->doc = array('link' => "{$lang->doc->common}|doc|index|project=%s"); $lang->waterfall->menu->weekly = array('link' => "{$lang->project->report}|weekly|index|project=%s", 'subModule' => ',milestone,'); -$lang->waterfall->menu->story = array('link' => "$lang->SRCommon|projectstory|story|project=%s"); +$lang->waterfall->menu->story = array('link' => "$lang->SRCommon|projectstory|story|project=%s", 'subModule' => 'projectstory'); $lang->waterfall->menu->design = array('link' => "$lang->design|design|browse|product=0&project=%s"); $lang->waterfall->menu->repo = array('link' => "{$lang->devops->common}|repo|browse|repoID=0&objectID=%s", 'subModule' => 'repo'); $lang->waterfall->menu->track = array('link' => "$lang->track|projectstory|track", 'alias' => 'track'); diff --git a/module/execution/control.php b/module/execution/control.php index ec4fb0ec62..6259117f48 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2222,7 +2222,7 @@ class execution extends control /** * Link stories to an execution. * - * @param int $executionID + * @param int $objectID * @param string $browseType * @param int $param * @param int $recTotal @@ -2231,33 +2231,41 @@ class execution extends control * @access public * @return void */ - public function linkStory($executionID = 0, $browseType = '', $param = 0, $recTotal = 0, $recPerPage = 50, $pageID = 1) + public function linkStory($objectID = 0, $browseType = '', $param = 0, $recTotal = 0, $recPerPage = 50, $pageID = 1) { $this->loadModel('story'); $this->loadModel('product'); - /* Get executions and products. */ - $execution = $this->execution->getById($executionID); - $products = $this->execution->getProducts($executionID); - $browseLink = $this->createLink('execution', 'story', "executionID=$executionID"); - if($execution->type == 'project') $browseLink = $this->createLink('projectstory', 'story', "projectID=$executionID"); + /* Get projects, executions and products. */ + $object = $this->project->getByID($objectID, $this->app->openApp == 'project' ? 'project' : 'sprint,stage'); + $products = $this->project->getProducts($objectID); + $browseLink = $this->createLink($this->app->openApp == 'project' ? 'projectstory' : 'execution', 'story', "objectID=$objectID"); $this->session->set('storyList', $this->app->getURI(true), 'product'); // Save session. - if($execution->type != 'execution') $this->execution->setMenu($execution->id); // Set menu. + /* Only execution can have no products. */ if(empty($products)) { echo js::alert($this->lang->execution->errorNoLinkedProducts); - die(js::locate($this->createLink('execution', 'manageproducts', "executionID=$executionID"))); + die(js::locate($this->createLink('execution', 'manageproducts', "executionID=$objectID"))); } if(!empty($_POST)) { - $this->execution->linkStory($executionID); - if($execution->project != 0) $this->execution->linkStory($execution->project); + $this->execution->linkStory($objectID); + if($object->type != 'project' and $object->project != 0) $this->execution->linkStory($object->project); die(js::locate($browseLink)); } + if($object->type == 'project') + { + $this->project->setMenu($object->id); + } + else if($object->type == 'sprint' or $object->type == 'stage') + { + $this->execution->setMenu($object->id); + } + $queryID = ($browseType == 'bySearch') ? (int)$param : 0; /* Set modules and branches. */ @@ -2282,28 +2290,24 @@ class execution extends control } /* Build the search form. */ - $actionURL = $this->createLink($this->app->rawModule, 'linkStory', "executionID=$executionID&browseType=bySearch&queryID=myQueryID"); + $actionURL = $this->createLink($this->app->rawModule, 'linkStory', "objectID=$objectID&browseType=bySearch&queryID=myQueryID"); $branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), 'noempty'); $this->execution->buildStorySearchForm($products, $branchGroups, $modules, $queryID, $actionURL, 'linkStory'); if($browseType == 'bySearch') { - $allStories = $this->story->getBySearch('', 0, $queryID, 'id', $executionID); + $allStories = $this->story->getBySearch('', 0, $queryID, 'id', $objectID); } else { $allStories = $this->story->getProductStories(array_keys($products), $branches, $moduleID = '0', $status = 'active', 'story', 'id_desc', $hasParent = false, '', $pager = null); } - if($execution->project != 0) $projectStories = $this->story->getExecutionStoryPairs($execution->project); - - $executionStories = $this->story->getExecutionStoryPairs($executionID); + $linkedStories = $this->story->getExecutionStoryPairs($objectID); foreach($allStories as $id => $story) { - if(isset($executionStories[$story->id])) unset($allStories[$id]); - + if(isset($linkedStories[$story->id])) unset($allStories[$id]); if($story->parent < 0) unset($allStories[$id]); - if(!empty($projectStories) and !isset($projectStories[$story->id])) unset($allStories[$id]); } /* Pager. */ @@ -2313,13 +2317,12 @@ class execution extends control $allStories = array_chunk($allStories, $pager->recPerPage); /* Assign. */ - $this->view->title = $execution->name . $this->lang->colon . $this->lang->execution->linkStory; - $this->view->position[] = html::a($browseLink, $execution->name); + $this->view->title = $object->name . $this->lang->colon . $this->lang->execution->linkStory; + $this->view->position[] = html::a($browseLink, $object->name); $this->view->position[] = $this->lang->execution->linkStory; - $this->view->execution = $execution; + $this->view->object = $object; $this->view->products = $products; - $this->view->executionStories = empty($executionStories) ? '' : $executionStories; $this->view->allStories = empty($allStories) ? $allStories : $allStories[$pageID - 1];; $this->view->pager = $pager; $this->view->browseType = $browseType; diff --git a/module/execution/lang/en.php b/module/execution/lang/en.php index 2ba7d17453..409a3ac81c 100644 --- a/module/execution/lang/en.php +++ b/module/execution/lang/en.php @@ -251,12 +251,12 @@ $lang->execution->byQuery = 'Search'; /* Query condition list. */ $lang->execution->allExecution = "All {$lang->executionCommon}s"; -$lang->execution->aboveAllProduct = "All the above {$lang->productCommon}s"; +$lang->execution->aboveAllProduct = "All the above {$lang->productCommon}s"; $lang->execution->aboveAllExecution = "All the above {$lang->executionCommon}s"; /* Page prompt. */ $lang->execution->linkStoryByPlanTips = "This action will link all stories in this plan to the {$lang->executionCommon}."; -$lang->execution->selectExecution = "Select {$lang->executionCommon}"; +$lang->execution->selectExecution = "Select {$lang->executionCommon}"; $lang->execution->selectExecution = "Select Stage/Sprint/Iteration"; $lang->execution->beginAndEnd = 'Duration'; $lang->execution->lblStats = 'Efforts'; @@ -275,7 +275,7 @@ $lang->execution->howToUpdateBurn = " Link Stories now."; $lang->execution->haveDraft = "%s stories in draft, so they can't be linked."; -$lang->execution->doneExecutions = 'Finished'; +$lang->execution->doneExecutions = 'Finished'; $lang->execution->selectDept = 'Select Department'; $lang->execution->selectDeptTitle = 'Select User'; $lang->execution->copyTeam = 'Copy Team'; @@ -283,15 +283,15 @@ $lang->execution->copyFromTeam = "Copy from {$lang->executionCommon} Team $lang->execution->noMatched = "No $lang->executionCommon including '%s'can be found."; $lang->execution->copyTitle = "Choose a {$lang->executionCommon} to copy."; $lang->execution->copyTeamTitle = "Choose a {$lang->executionCommon} Team to copy."; -$lang->execution->copyNoExecution = "No {$lang->executionCommon} can be copied."; -$lang->execution->copyFromExecution = "Copy from {$lang->executionCommon} %s"; +$lang->execution->copyNoExecution = "No {$lang->executionCommon} can be copied."; +$lang->execution->copyFromExecution = "Copy from {$lang->executionCommon} %s"; $lang->execution->cancelCopy = 'Cancel Copy'; $lang->execution->byPeriod = 'By Time'; $lang->execution->byUser = 'By User'; -$lang->execution->noExecution = "No {$lang->executionCommon}. "; +$lang->execution->noExecution = "No {$lang->executionCommon}. "; $lang->execution->noMembers = 'No team members yet. '; $lang->execution->workloadTotal = "The cumulative workload ratio should not exceed 100, and the total workload under the current product is: %s"; -$lang->execution->linkPRJStoryTip = "(Link {$lang->SRCommon} comes from {$lang->SRCommon} linked under the execution)"; +// $lang->execution->linkProjectStoryTip = "(Link {$lang->SRCommon} comes from {$lang->SRCommon} linked under the execution)"; $lang->execution->linkAllStoryTip = "({$lang->SRCommon} has never been linked under the execution, and can be directly linked with {$lang->SRCommon} of the product linked with the sprint/stage)"; /* Interactive prompts. */ diff --git a/module/execution/lang/zh-cn.php b/module/execution/lang/zh-cn.php index 6258f10cc6..c38f6dd3db 100644 --- a/module/execution/lang/zh-cn.php +++ b/module/execution/lang/zh-cn.php @@ -251,12 +251,12 @@ $lang->execution->byQuery = '搜索'; /* 查询条件列表。*/ $lang->execution->allExecution = "所有{$lang->executionCommon}"; -$lang->execution->aboveAllProduct = "以上所有{$lang->productCommon}"; +$lang->execution->aboveAllProduct = "以上所有{$lang->productCommon}"; $lang->execution->aboveAllExecution = "以上所有{$lang->executionCommon}"; /* 页面提示。*/ $lang->execution->linkStoryByPlanTips = "此操作会将所选计划下面的{$lang->SRCommon}全部关联到此{$lang->executionCommon}中"; -$lang->execution->selectExecution = "请选择{$lang->executionCommon}"; +$lang->execution->selectExecution = "请选择{$lang->executionCommon}"; $lang->execution->selectExecution = "请选择阶段/迭代/冲刺"; $lang->execution->beginAndEnd = '起止时间'; $lang->execution->lblStats = '工时统计'; @@ -275,7 +275,7 @@ $lang->execution->howToUpdateBurn = "关联{$lang->SRCommon}。"; $lang->execution->haveDraft = "有%s条草稿状态的{$lang->SRCommon}无法关联到该{$lang->executionCommon}"; -$lang->execution->doneExecutions = '已结束'; +$lang->execution->doneExecutions = '已结束'; $lang->execution->selectDept = '选择部门'; $lang->execution->selectDeptTitle = '选择一个部门的成员'; $lang->execution->copyTeam = '复制团队'; @@ -283,15 +283,15 @@ $lang->execution->copyFromTeam = "复制自{$lang->executionCommon}团队 $lang->execution->noMatched = "找不到包含'%s'的$lang->executionCommon"; $lang->execution->copyTitle = "请选择一个{$lang->executionCommon}来复制"; $lang->execution->copyTeamTitle = "选择一个{$lang->executionCommon}团队来复制"; -$lang->execution->copyNoExecution = "没有可用的{$lang->executionCommon}来复制"; -$lang->execution->copyFromExecution = "复制自{$lang->executionCommon} %s"; +$lang->execution->copyNoExecution = "没有可用的{$lang->executionCommon}来复制"; +$lang->execution->copyFromExecution = "复制自{$lang->executionCommon} %s"; $lang->execution->cancelCopy = '取消复制'; $lang->execution->byPeriod = '按时间段'; $lang->execution->byUser = '按用户'; -$lang->execution->noExecution = "暂时没有{$lang->executionCommon}。"; +$lang->execution->noExecution = "暂时没有{$lang->executionCommon}。"; $lang->execution->noMembers = '暂时没有团队成员。'; $lang->execution->workloadTotal = "工作量占比累计不应当超过100, 当前产品下的工作量之和为%s"; -$lang->execution->linkPRJStoryTip = "(关联{$lang->SRCommon}来源于项目下所关联的{$lang->SRCommon})"; +// $lang->execution->linkProjectStoryTip = "(关联{$lang->SRCommon}来源于项目下所关联的{$lang->SRCommon})"; $lang->execution->linkAllStoryTip = "(项目下还未关联{$lang->SRCommon},可直接关联该迭代/阶段/冲刺所关联产品的{$lang->SRCommon})"; /* 交互提示。*/ diff --git a/module/execution/model.php b/module/execution/model.php index 5dc71b3f15..f56423580e 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1465,6 +1465,7 @@ class executionModel extends model if(!$withBranch) return $this->loadModel('tutorial')->getProductPairs(); return $this->loadModel('tutorial')->getExecutionProducts(); } + $query = $this->dao->select('t2.id, t2.name, t2.type, t1.branch, t1.plan')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2') ->on('t1.product = t2.id') diff --git a/module/execution/view/linkstory.html.php b/module/execution/view/linkstory.html.php index ae3a756b38..ee8c0c38de 100644 --- a/module/execution/view/linkstory.html.php +++ b/module/execution/view/linkstory.html.php @@ -18,14 +18,12 @@
@@ -45,9 +43,9 @@ idAB;?> priAB;?> + story->title;?> story->product;?> story->module;?> - story->title;?> story->plan;?> story->stage;?> @@ -67,14 +65,14 @@ id]", $story->product);?> pri;?>' title='story->priList, $story->pri, $story->pri);?>'>story->priList, $story->pri, $story->pri);?> - createLink('product', 'browse', "productID=$story->product&branch=$story->branch"), $products[$story->product]->name, '_blank');?> - '>module, '')?> parent > 0) echo "{$lang->story->childrenAB}"; echo html::a($storyLink, $story->title); ?> + createLink('product', 'browse', "productID=$story->product&branch=$story->branch"), $products[$story->product]->name, '_blank');?> + '>module, '')?> planTitle;?> story->stageList, $story->stage);?> @@ -97,7 +95,7 @@
-

execution->whyNoStories;?>

+

{$app->rawModule}->whyNoStories;?>

diff --git a/module/product/control.php b/module/product/control.php index fe8310d6a1..2ce4e15582 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -251,7 +251,10 @@ class product extends control /* Build search form. */ $rawModule = $this->app->rawModule; $rawMethod = $this->app->rawMethod; - $actionURL = $this->createLink($rawModule, $rawMethod, "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID&storyType=$storyType"); + + $params = $rawModule == 'projectstory' ? "projectID=$projectID&" : ''; + $actionURL = $this->createLink($rawModule, $rawMethod, $params . "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID&storyType=$storyType"); + $this->config->product->search['onMenuBar'] = 'yes'; $this->product->buildSearchForm($productID, $this->products, $queryID, $actionURL); diff --git a/module/project/model.php b/module/project/model.php index df058794a3..835970f96d 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -160,12 +160,13 @@ class projectModel extends model * Get a project by id. * * @param int $projectID + * @param string $type project|sprint,stage * @access public * @return object */ - public function getByID($projectID) + public function getByID($projectID, $type = 'project') { - $project = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->andWhere('`type`')->eq('project')->fetch(); + $project = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->andWhere('`type`')->in($type)->fetch(); if(!$project) return false; if($project->end == '0000-00-00') $project->end = ''; diff --git a/module/projectstory/lang/en.php b/module/projectstory/lang/en.php index 3817c007aa..e6a2df7b19 100644 --- a/module/projectstory/lang/en.php +++ b/module/projectstory/lang/en.php @@ -7,6 +7,7 @@ $lang->projectstory->track = 'Tracking Matrix'; $lang->projectstory->linkStory = 'Linked' . $lang->SRCommon; $lang->projectstory->unlinkStory = 'Unlinked' . $lang->SRCommon; $lang->projectstory->importplanstories = 'Linked by plan' . $lang->SRCommon; +$lang->projectstory->whyNoStories = "No story can be linked. Please check whether there is any story in project which is linked to {$lang->productCommon} and make sure it has been reviewed."; global $app; $app->loadLang('product'); diff --git a/module/projectstory/lang/zh-cn.php b/module/projectstory/lang/zh-cn.php index e7284ccb34..57e2e30b7a 100644 --- a/module/projectstory/lang/zh-cn.php +++ b/module/projectstory/lang/zh-cn.php @@ -7,6 +7,7 @@ $lang->projectstory->track = '矩阵'; $lang->projectstory->linkStory = '关联' . $lang->SRCommon; $lang->projectstory->unlinkStory = '移除' . $lang->SRCommon; $lang->projectstory->importplanstories = '按计划关联' . $lang->SRCommon; +$lang->projectstory->whyNoStories = "看起来没有{$lang->SRCommon}可以关联。请检查下项目关联的{$lang->productCommon}中有没有{$lang->SRCommon},而且要确保它们已经审核通过。"; global $app; $app->loadLang('product'); diff --git a/module/story/model.php b/module/story/model.php index 1948f5347b..7147f2b1b7 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2191,7 +2191,7 @@ class storyModel extends model { if($executionID != '') { - $products = $this->loadModel('execution')->getProducts($executionID); + $products = $this->loadModel('project')->getProducts($executionID); } else { diff --git a/module/testcase/control.php b/module/testcase/control.php index 0a5cf54f22..010bece620 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -42,22 +42,6 @@ class testcase extends control /* Set test case menu group. */ $this->projectID = isset($_GET['PRJ']) ? $_GET['PRJ'] : 0; - if($this->app->openApp == 'qa') - { - $this->app->loadConfig('qa'); - foreach($this->config->qa->menuList as $module) $this->lang->navGroup->$module = 'qa'; - } - elseif($this->app->openApp == 'project') - { - $this->lang->testcase->menu = $this->lang->projectQa->menu; - $this->lang->testcase->subMenu = $this->lang->projectQa->subMenu; - } - elseif($this->app->openApp == 'execution') - { - $this->lang->testcase->menu = $this->lang->execution->qaMenu; - $this->lang->testcase->subMenu = ''; - } - $this->view->products = $this->products = $this->product->getProductPairsByProject($this->projectID); if(empty($this->products)) die($this->locate($this->createLink('product', 'showErrorNone', "fromModule=testcase"))); } @@ -251,7 +235,10 @@ class testcase extends control */ public function create($productID, $branch = '', $moduleID = 0, $from = '', $param = 0, $storyID = 0, $extras = '') { - if($this->app->openApp == 'execution') commonModel::setAppObjectID('execution', $this->session->execution); + if($this->app->openApp == 'execution') + { + $this->loadModel('execution')->setMenu($this->session->execution); + } $testcaseID = $from == 'testcase' ? $param : 0; $bugID = $from == 'bug' ? $param : 0;