diff --git a/module/bug/control.php b/module/bug/control.php index 2362b3ae81..807c763c4e 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -766,7 +766,7 @@ class bug extends control $branchProduct = $product->type == 'normal' ? false : true; /* Set plans. */ - $plans = $this->loadModel('productplan')->getPairs($productID, $branch); + $plans = $this->loadModel('productplan')->getPairs($productID, $branch); $plans = array('' => '', 'ditto' => $this->lang->bug->ditto) + $plans; /* Set product menu. */ diff --git a/module/bug/js/common.js b/module/bug/js/common.js index b839693be8..a5d7c1c76d 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -21,7 +21,6 @@ $(function() if(page == 'create' || page == 'edit' || page == 'assignedto' || page == 'confirmbug') { oldProductID = $('#product').val(); - $("#story, #task, #mailto").chosen(); } if(window.flow != 'full') @@ -48,7 +47,7 @@ function loadAll(productID) setAssignedTo(); } - if(!changeProductConfirmed) + if(typeof(changeProductConfirmed) != 'undefined' && !changeProductConfirmed) { firstChoice = confirm(confirmChangeProduct); changeProductConfirmed = true; // Only notice the user one time. diff --git a/module/bug/model.php b/module/bug/model.php index 4a48b6a936..86f2646022 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1428,10 +1428,11 @@ class bugModel extends model * @param int $param * @param string $orderBy * @param object $pager + * @param array $excludeBugs * @access public * @return array */ - public function getProjectBugs($projectID, $build = 0, $type = '', $param = 0, $orderBy = 'id_desc', $pager = null) + public function getProjectBugs($projectID, $build = 0, $type = '', $param = 0, $orderBy = 'id_desc', $pager = null, $excludeBugs = array()) { $type = strtolower($type); if($type == 'bysearch') @@ -1461,6 +1462,7 @@ class bugModel extends model ->where($bugQuery) ->andWhere('project')->eq((int)$projectID) ->andWhere('deleted')->eq(0) + ->beginIF($excludeBugs)->andWhere('id')->notIN($excludeBugs)->fi() ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); @@ -1471,7 +1473,9 @@ class bugModel extends model ->where('deleted')->eq(0) ->beginIF(empty($build))->andWhere('project')->eq($projectID)->fi() ->beginIF($type == 'unresolved')->andWhere('status')->eq('active')->fi() + ->beginIF($type == 'noclosed')->andWhere('status')->ne('closed')->fi() ->beginIF($build)->andWhere("CONCAT(',', openedBuild, ',') like '%,$build,%'")->fi() + ->beginIF($excludeBugs)->andWhere('id')->notIN($excludeBugs)->fi() ->orderBy($orderBy)->page($pager)->fetchAll(); } @@ -1485,10 +1489,13 @@ class bugModel extends model * * @param int $build * @param int $productID + * @param int $branch + * @param string $linkedBugs + * @param object $pager * @access public * @return array */ - public function getProductLeftBugs($build, $productID, $branch = 0) + public function getProductLeftBugs($build, $productID, $branch = 0, $linkedBugs = '', $pager = null) { $build = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->eq($build)->fetch(); if(empty($build->project)) return array(); @@ -1510,7 +1517,9 @@ class bugModel extends model ->andWhere('openedDate')->le($project->end) ->andWhere("(status = 'active' OR resolvedDate > '{$project->end}')") ->andWhere('openedBuild')->notin($beforeBuilds) + ->beginIF($linkedBugs)->andWhere('id')->notIN($linkedBugs)->fi() ->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi() + ->page($pager) ->fetchAll(); return $bugs; @@ -1547,7 +1556,7 @@ class bugModel extends model * @access public * @return object */ - public function getReleaseBugs($buildID, $productID, $branch = 0) + public function getReleaseBugs($buildID, $productID, $branch = 0, $linkedBugs = '', $pager = null) { $project = $this->dao->select('t1.id,t1.begin')->from(TABLE_PROJECT)->alias('t1') ->leftJoin(TABLE_BUILD)->alias('t2')->on('t1.id = t2.project') @@ -1557,10 +1566,12 @@ class bugModel extends model ->where('resolvedDate')->ge($project->begin) ->andWhere('resolution')->ne('postponed') ->andWhere('product')->eq($productID) + ->beginIF($linkedBugs)->andWhere('id')->notIN($linkedBugs)->fi() ->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi() ->andWhere("(project != '$project->id' OR (project = '$project->id' and openedDate < '$project->begin'))") ->andWhere('deleted')->eq(0) ->orderBy('openedDate ASC') + ->page($pager) ->fetchAll(); return $bugs; } @@ -2303,10 +2314,12 @@ class bugModel extends model * @param int $queryID * @param string $orderBy * @param object $pager + * @param int $branch + * @param array $excludeBugs * @access public * @return array */ - public function getBySearch($productID, $queryID, $orderBy, $pager = null, $branch = 0) + public function getBySearch($productID, $queryID, $orderBy, $pager = null, $branch = 0, $excludeBugs = '') { if($queryID) { @@ -2345,6 +2358,7 @@ class bugModel extends model $bugs = $this->dao->select('*')->from(TABLE_BUG)->where($bugQuery) ->beginIF(!$this->app->user->admin)->andWhere('project')->in('0,' . $this->app->user->view->projects)->fi() + ->beginIF($excludeBugs)->andWhere('id')->notIN($excludeBugs)->fi() ->andWhere('deleted')->eq(0) ->orderBy($orderBy)->page($pager)->fetchAll(); return $bugs; diff --git a/module/build/control.php b/module/build/control.php index e283838191..5cd8f747ae 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -185,10 +185,17 @@ class build extends control * View a build. * * @param int $buildID + * @param string $type + * @param string $link + * @param string $param + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ - public function view($buildID, $type = 'story', $link = 'false', $param = '', $orderBy = 'id_desc') + public function view($buildID, $type = 'story', $link = 'false', $param = '', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 100, $pageID = 1) { if($type == 'story')$this->session->set('storyList', $this->app->getURI(true)); if($type == 'bug') $this->session->set('bugList', $this->app->getURI(true)); @@ -196,6 +203,10 @@ class build extends control $this->loadModel('story'); $this->loadModel('bug'); + /* Load pager. */ + $this->app->loadClass('pager', $static = true); + if($this->app->getViewType() == 'mhtml') $recPerPage = 10; + /* Set menu. */ $build = $this->build->getById((int)$buildID, true); if(!$build) die(js::error($this->lang->notFound) . js::locate('back')); @@ -203,8 +214,10 @@ class build extends control $product = $this->loadModel('product')->getById($build->product); if($product->type != 'normal') $this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); + $bugPager = new pager($type == 'bug' ? $recTotal : 0, $recPerPage, $type == 'bug' ? $pageID : 1); $bugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($build->bugs)->andWhere('deleted')->eq(0) ->beginIF($type == 'bug')->orderBy($orderBy)->fi() + ->page($bugPager) ->fetchAll(); if($this->config->global->flow == 'onlyTest') @@ -219,8 +232,10 @@ class build extends control } else { + $storyPager = new pager($type == 'story' ? $recTotal : 0, $recPerPage, $type == 'story' ? $pageID : 1); $stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($build->stories)->andWhere('deleted')->eq(0) ->beginIF($type == 'story')->orderBy($orderBy)->fi() + ->page($storyPager) ->fetchAll('id'); $stages = $this->dao->select('*')->from(TABLE_STORYSTAGE)->where('story')->in($build->stories)->andWhere('branch')->eq($build->branch)->fetchPairs('story', 'stage'); foreach($stages as $storyID => $stage)$stories[$storyID]->stage = $stage; @@ -232,9 +247,11 @@ class build extends control $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$build->project"), $projects[$build->project]); $this->view->position[] = $this->lang->build->view; $this->view->stories = $stories; - $this->view->generatedBugs = $this->bug->getProjectBugs($build->project, $build->id, '', 0, $type == 'newbug' ? $orderBy : 'status_desc,id_desc', null); - $this->view->bugs = $bugs; - $this->view->type = $type; + $this->view->storyPager = $storyPager; + + $newBugPager = new pager($type == 'newbug' ? $recTotal : 0, $recPerPage, $type == 'newbug' ? $pageID : 1); + $this->view->generatedBugs = $this->bug->getProjectBugs($build->project, $build->id, '', 0, $type == 'newbug' ? $orderBy : 'status_desc,id_desc', $newBugPager); + $this->view->newBugPager = $newBugPager; } $this->executeHooks($buildID); @@ -247,6 +264,9 @@ class build extends control $this->view->link = $link; $this->view->param = $param; $this->view->orderBy = $orderBy; + $this->view->bugs = $bugs; + $this->view->type = $type; + $this->view->bugPager = $bugPager; $this->view->branchName = $build->productType == 'normal' ? '' : $this->loadModel('branch')->getById($build->branch); $this->display(); } @@ -402,10 +422,13 @@ class build extends control * @param int $buildID * @param string $browseType * @param int $param + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ - public function linkStory($buildID = 0, $browseType = '', $param = 0) + public function linkStory($buildID = 0, $browseType = '', $param = 0, $recTotal = 0, $recPerPage = 100, $pageID = 1) { if(!empty($_POST['stories'])) { @@ -421,6 +444,11 @@ class build extends control $this->loadModel('tree'); $this->loadModel('product'); + /* Load pager. */ + $this->app->loadClass('pager', $static = true); + if($this->app->getViewType() == 'mhtml') $recPerPage = 10; + $pager = new pager($recTotal, $recPerPage, $pageID); + /* Build search form. */ $queryID = ($browseType == 'bySearch') ? (int)$param : 0; unset($this->config->product->search['fields']['product']); @@ -447,11 +475,11 @@ class build extends control if($browseType == 'bySearch') { - $allStories = $this->story->getBySearch($build->product, $queryID, 'id', null, $build->project, $build->branch); + $allStories = $this->story->getBySearch($build->product, $queryID, 'id', $pager, $build->project, $build->branch, 'story', $build->stories); } else { - $allStories = $this->story->getProjectStories($build->project); + $allStories = $this->story->getProjectStories($build->project, 't1.`order`_desc', 'byModule', 0, $pager, 'story', $build->stories); } $this->view->allStories = $allStories; @@ -460,6 +488,7 @@ class build extends control $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->browseType = $browseType; $this->view->param = $param; + $this->view->pager = $pager; $this->display(); } @@ -512,10 +541,13 @@ class build extends control * @param int $buildID * @param string $browseType * @param int $param + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ - public function linkBug($buildID = 0, $browseType = '', $param = 0) + public function linkBug($buildID = 0, $browseType = '', $param = 0, $recTotal = 0, $recPerPage = 100, $pageID = 1) { if(!empty($_POST['bugs'])) { @@ -529,6 +561,11 @@ class build extends control $product = $this->loadModel('product')->getByID($build->product); $this->loadModel('project')->setMenu($this->project->getPairs(), $build->project); + /* Load pager. */ + $this->app->loadClass('pager', $static = true); + if($this->app->getViewType() == 'mhtml') $recPerPage = 10; + $pager = new pager($recTotal, $recPerPage, $pageID); + $queryID = ($browseType == 'bysearch') ? (int)$param : 0; /* Build the search form. */ @@ -560,33 +597,19 @@ class build extends control if($browseType == 'bySearch') { - $allBugs = $this->bug->getBySearch($build->product, $queryID, 'id_desc', null, $build->branch); + $allBugs = $this->bug->getBySearch($build->product, $queryID, 'id_desc', $pager, $build->branch, $build->bugs); } else { - $projectBugs = $this->bug->getProjectBugs($build->project); - $allBugs = array(); - foreach($projectBugs as $key => $bug) - { - if($bug->status == 'resolved') - { - $allBugs[$key] = $bug; - unset($projectBugs[$key]); - } - elseif($bug->status == 'closed') - { - unset($projectBugs[$key]); - } - } - $allBugs += $projectBugs; + $allBugs = $this->bug->getProjectBugs($build->project, 0, 'noclosed', 0, 'status_desc,id_desc', $pager, $build->bugs); } $this->view->allBugs = $allBugs; - $this->view->buildBugs = empty($build->bugs) ? array() : $this->bug->getByList($build->bugs); $this->view->build = $build; $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->browseType = $browseType; $this->view->param = $param; + $this->view->pager = $pager; $this->display(); } diff --git a/module/build/js/view.js b/module/build/js/view.js index a379d16039..ef33582dd2 100644 --- a/module/build/js/view.js +++ b/module/build/js/view.js @@ -1,16 +1,45 @@ function showLink(buildID, type, param) { var method = type == 'story' ? 'linkStory' : 'linkBug'; - $.get(createLink('build', method, 'buildID=' + buildID + (typeof(param) == 'undefined' ? '' : param)), function(data) + loadURL(createLink('build', method, 'buildID=' + buildID + param), type); + + $('.actions').find("a[href*='" + type + "']").addClass('hidden'); +} + +/** + * Load URL. + * + * @param string $url + * @param string $type + * @access public + * @return void + */ +function loadURL(url, type) +{ + $.get(url, function(data) { var $pane = $(type == 'story' ? '#stories' : '#bugs'); $pane.find('.main-table').hide(); - var $linkBox = $pane.find('.linkBox').html(data).removeClass('hidden'); + var $linkBox = $pane.find('.linkBox'); + $linkBox.html(data).removeClass('hidden'); $linkBox.find('[data-ride="table"]').table(); + $linkBox.find('[data-ride="pager"]').pager(); + $linkBox.find('[data-ride="pager"] li a.pager-item').click(function() + { + loadURL($(this).attr('href'), type); + return false; + }); + $linkBox.find('[data-ride="pager"] .pager-size-menu a[data-size]').off('click'); + $linkBox.find('[data-ride="pager"] .pager-size-menu a[data-size]').click(function() + { + line = $linkBox.find('[data-ride="pager"]').attr('data-link-creator'); + line = line.replace('{recPerPage}', $(this).attr('data-size')).replace('{page}', $linkBox.find('[data-ride="pager"]').attr('data-page')); + $.cookie($linkBox.find('[data-ride="pager"]').attr('data-page-cookie'), $(this).attr('data-size'), {expires:config.cookieLife, path:config.webRoot}); + loadURL(line, type); + return false; + }); $.toggleQueryBox(true, $linkBox.find('#queryBox')); }); - - $('.actions').find("a[href*='" + type + "']").addClass('hidden'); } $(function() diff --git a/module/build/view/linkbug.html.php b/module/build/view/linkbug.html.php index 218bf90bdd..5684a9bc2f 100644 --- a/module/build/view/linkbug.html.php +++ b/module/build/view/linkbug.html.php @@ -67,6 +67,7 @@ id}&type=bug"), $lang->goback, '', "class='btn'");?>
+ show('right', 'pagerjs');?> diff --git a/module/build/view/linkstory.html.php b/module/build/view/linkstory.html.php index f55673e272..975a46f740 100644 --- a/module/build/view/linkstory.html.php +++ b/module/build/view/linkstory.html.php @@ -76,6 +76,7 @@ id}&type=story"), $lang->goback, '', "class='btn'");?> + show('right', 'pagerjs');?> diff --git a/module/build/view/view.html.php b/module/build/view/view.html.php index 52163dc109..a4f9bbec2b 100644 --- a/module/build/view/view.html.php +++ b/module/build/view/view.html.php @@ -157,8 +157,8 @@ tbody tr td:first-child input{display:none;} - -