From 4432a1ce65e8a5be9dcc02ccaa71c4f364a65f87 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 25 Oct 2023 16:53:48 +0800 Subject: [PATCH] * Adjust product browse in lite. --- extension/lite/product/ext/control/browse.php | 104 ++---------------- module/product/control.php | 1 - 2 files changed, 12 insertions(+), 93 deletions(-) diff --git a/extension/lite/product/ext/control/browse.php b/extension/lite/product/ext/control/browse.php index b1e665c622..d22f4a9d88 100644 --- a/extension/lite/product/ext/control/browse.php +++ b/extension/lite/product/ext/control/browse.php @@ -1,13 +1,13 @@ loadModel('datatable'); $this->loadModel('execution'); $this->loadModel('user'); + $isProjectStory = $this->app->rawModule == 'projectstory'; $projectProducts = $this->loadModel('product')->getProducts($projectID); $productPlans = $this->execution->getPlans(array_keys($projectProducts)); @@ -15,14 +15,12 @@ class product extends control foreach($projectProducts as $productID => $product) $this->products[$productID] = $product->name; reset($projectProducts); - $productID = key($projectProducts); + if(empty($productID)) $productID = key($projectProducts); $product = $projectProducts[$productID]; $showBranch = $this->loadModel('branch')->showBranch($productID, 0, $projectID); - if(!empty($product)) $this->session->set('currentProductType', $product->type); /* Set menu. */ - $this->session->set('storyList', $this->app->getURI(true), 'project'); $this->loadModel('project')->setMenu($projectID); $branches = $this->loadModel('branch')->getList($productID, $projectID, 'all'); @@ -67,18 +65,10 @@ class product extends control $branch = $this->cookie->treeBranch; } - /* If in project story and not chose product, get project story mdoules. */ - $moduleTree = $this->loadModel('tree')->getTreeMenu($productID, 'story', $startModuleID = 0, array('treeModel', $createModuleLink), array('projectID' => $projectID, 'productID' => $productID), 'all', "¶m=$param&storyType=$storyType"); - - if($browseType != 'bymodule') $this->session->set('storyBrowseType', $browseType); - /* Process the order by field. */ if(!$orderBy) $orderBy = $this->cookie->productStoryOrder ? $this->cookie->productStoryOrder : 'id_desc'; setcookie('productStoryOrder', $orderBy, 0, $this->config->webRoot, '', $this->config->cookieSecure, true); - /* Append id for second sort. */ - $sort = common::appendOrder($orderBy); - /* Load pager. */ $this->app->loadClass('pager', $static = true); if($this->app->getViewType() == 'xhtml') $recPerPage = 10; @@ -88,102 +78,32 @@ class product extends control $showBranch = $this->loadModel('branch')->showBranch($productID); $product = $this->product->getById($productID); + $project = $projectID ? $this->loadModel('project')->getByID($projectID) : null; /* Get stories. */ if(in_array($browseType, array('reviewing', 'draft', 'changing'))) $browseType .= 'story'; - $stories = $this->product->getStories($productID, $branchID, $browseType, $queryID, $moduleID, $storyType, $sort, $pager); - - /* Display status of branch. */ - $branchOption = array(); - $branchTagOption = array(); - foreach($branches as $branchInfo) - { - $branchOption[$branchInfo->id] = $branchInfo->name; - $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); - } + $stories = $this->productZen->getStories($projectID, $productID, $branchID, $moduleID, $param, $storyType, $browseType, $orderBy, $pager); /* Process the sql, get the conditon partion, save it to session. */ $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story', ($browseType != 'bysearch' and $browseType != 'reviewbyme' and $this->app->rawModule != 'projectstory')); - if(!empty($stories)) $stories = $this->loadModel('story')->mergeReviewer($stories); - - /* Get related tasks, bugs, cases count of each story. */ - $storyIdList = array(); - foreach($stories as $story) - { - $storyIdList[$story->id] = $story->id; - if(!empty($story->children)) - { - foreach($story->children as $child) $storyIdList[$child->id] = $child->id; - } - } - $storyTasks = $this->loadModel('task')->getStoryTaskCounts($storyIdList); - $storyBugs = $this->loadModel('bug')->getStoryBugCounts($storyIdList); - $storyCases = $this->loadModel('testcase')->getStoryCaseCounts($storyIdList); - - /* Change for requirement story title. */ - if($storyType == 'requirement') - { - $this->lang->story->title = str_replace($this->lang->SRCommon, $this->lang->URCommon, $this->lang->story->title); - $this->lang->story->create = str_replace($this->lang->SRCommon, $this->lang->URCommon, $this->lang->story->create); - $this->config->product->search['fields']['title'] = $this->lang->story->title; - unset($this->config->product->search['fields']['plan']); - unset($this->config->product->search['fields']['stage']); - } + /* Save session. */ + $this->productZen->saveSession4Browse($product, $storyType, $browseType, $isProjectStory); /* Build search form. */ - $rawModule = $this->app->rawModule; - $rawMethod = $this->app->rawMethod; - - $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(0, $this->products, $queryID, $actionURL, $branch); - - $showModule = !empty($this->config->datatable->productBrowse->showModule) ? $this->config->datatable->productBrowse->showModule : ''; + $this->productZen->buildSearchFormForBrowse($project, $projectID, $productID, $branch, $param, $storyType, $browseType, $isProjectStory); + $showModule = !empty($this->config->datatable->productBrowse->showModule) ? $this->config->datatable->productBrowse->showModule : ''; $productName = ($this->app->rawModule == 'projectstory' and empty($productID)) ? $this->lang->product->all : $this->products[$productID]; /* Assign. */ $this->view->title = $productName . $this->lang->colon . $this->lang->product->browse; - $this->view->position[] = $productName; - $this->view->position[] = $this->lang->product->browse; - $this->view->productID = $productID; - $this->view->product = $product; - $this->view->productName = $productName; $this->view->moduleID = $moduleID; - $this->view->stories = $stories; - $this->view->plans = $this->loadModel('productplan')->getPairs($productID, $branch === 'all' ? '' : $branch, '', true); - $this->view->productPlans = isset($productPlans) ? array(0 => '') + $productPlans : array(); - $this->view->summary = $this->product->summary($stories, $storyType); - $this->view->moduleTree = $moduleTree; - $this->view->parentModules = $this->tree->getParents($moduleID); $this->view->pager = $pager; - $this->view->users = $this->user->getPairs('noletter|pofirst|nodeleted'); - $this->view->teamMembers = $this->user->getTeamMemberPairs($projectID); $this->view->orderBy = $orderBy; - $this->view->browseType = $browseType; - $this->view->modules = $this->tree->getOptionMenu($productID, 'story', 0, $branchID); - $this->view->moduleID = $moduleID; - $this->view->moduleName = ($moduleID and $moduleID !== 'all') ? $this->tree->getById($moduleID)->name : $this->lang->tree->allMenu; - $this->view->branch = $branch; - $this->view->branchID = $branchID; - $this->view->branchOption = $branchOption; - $this->view->branchTagOption = $branchTagOption; - $this->view->showBranch = $showBranch; - $this->view->storyStages = $this->product->batchGetStoryStage($stories); - $this->view->setModule = true; - $this->view->storyTasks = $storyTasks; - $this->view->storyBugs = $storyBugs; - $this->view->storyCases = $storyCases; + $this->view->moduleTree = $this->productZen->getModuleTree($projectID, $productID, $branch, $param, $storyType, $browseType); $this->view->param = $param; - $this->view->projectID = $projectID; - $this->view->products = $this->products; - $this->view->projectProducts = isset($projectProducts) ? $projectProducts : array(); - $this->view->storyType = $storyType; - $this->view->from = $this->app->tab; - $this->view->modulePairs = $showModule ? $this->tree->getModulePairs($productID, 'story', $showModule) : array(); - $this->display(); + + $this->productZen->assignBrowseData($stories, $browseType, $storyType, $isProjectStory, $product, $project, $branch, $branchID); } } diff --git a/module/product/control.php b/module/product/control.php index c8ecf17fa2..7945024181 100755 --- a/module/product/control.php +++ b/module/product/control.php @@ -165,7 +165,6 @@ class product extends control $this->view->moduleID = $moduleID; $this->view->pager = $pager; $this->view->orderBy = $orderBy; - $this->view->moduleID = $moduleID; $this->view->param = $param; $this->view->moduleTree = $this->productZen->getModuleTree($projectID, $productID, $branch, $param, $storyType, $browseType);