From b6c175f837217e5abd610e13de76e8595df87a05 Mon Sep 17 00:00:00 2001 From: holan20180123 <56391770@qq.com> Date: Fri, 27 Nov 2020 15:49:52 +0800 Subject: [PATCH] * Finish task #8497. --- module/projectrelease/control.php | 21 +++------ module/projectrelease/js/common.js | 52 ---------------------- module/projectrelease/model.php | 28 +++++++----- module/projectrelease/view/browse.html.php | 10 ++--- module/projectrelease/view/create.html.php | 15 ------- 5 files changed, 28 insertions(+), 98 deletions(-) diff --git a/module/projectrelease/control.php b/module/projectrelease/control.php index 3eb4321c78..c243d1ed81 100644 --- a/module/projectrelease/control.php +++ b/module/projectrelease/control.php @@ -28,6 +28,7 @@ class projectrelease extends control $this->loadModel('product'); $this->loadModel('release'); $this->view->products = $this->products = $this->product->getProductPairsByProject($this->session->PRJ); + if(empty($this->view->products)) $this->locate($this->createLink('product', 'create')); } /** @@ -44,17 +45,13 @@ class projectrelease extends control $this->lang->product->switcherMenu = $this->loadModel('product')->getSwitcher($productID); $this->loadModel('product'); - $this->loadModel('project'); - $products = $this->product->getProductPairsByProject($this->session->PRJ); - if(empty($products)) $this->locate($this->createLink('product', 'create')); - $product = $this->product->getById($productID); + $this->view->product = $product; $this->view->branches = (isset($product->type) and $product->type == 'normal') ? array() : $this->loadModel('branch')->getPairs($productID); $this->view->branch = $branch; $this->view->project = $this->loadModel('project')->getById($this->session->PRJ); - $this->view->products = $products; - $this->product->setMenu($this->product->getPairs(), $productID ? $productID : key($products), $branch); + $this->product->setMenu($this->product->getPairs(), $productID, $branch); } /** @@ -68,13 +65,13 @@ class projectrelease extends control */ public function browse($productID = 0, $branch = 0, $type = 'all') { + if(!$productID) $productID = key($this->view->products); $this->commonAction($productID, $branch); $this->session->set('releaseList', $this->app->getURI(true)); $this->view->title = $this->view->project->name . $this->lang->colon . $this->lang->release->browse; $this->view->position[] = $this->lang->release->browse; - $this->view->releases = $this->projectrelease->getList($productID, $branch, $type, $this->session->PRJ); - $this->view->productID = $productID; + $this->view->releases = $this->projectrelease->getList($productID, $branch, $type); $this->view->type = $type; $this->display(); } @@ -91,7 +88,7 @@ class projectrelease extends control { if(!empty($_POST)) { - $releaseID = $this->projectrelease->create(); + $releaseID = $this->projectrelease->create($productID, $branch); if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('release', $releaseID, 'opened'); @@ -101,20 +98,16 @@ class projectrelease extends control $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "releaseID=$releaseID"))); } - $builds = $this->loadModel('build')->getProjectBuildPairs($this->session->PRJ, $productID, $branch, 'notrunk|withbranch'); + $builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch, 'notrunk|withbranch', false); $releaseBuilds = $this->projectrelease->getReleaseBuilds($productID, $branch); foreach($releaseBuilds as $build) unset($builds[$build]); unset($builds['trunk']); $this->commonAction($productID, $branch); - $productID = !empty($productID) ? $productID : key($this->view->products); - $this->view->title = $this->view->project->name . $this->lang->colon . $this->lang->release->create; $this->view->position[] = $this->lang->release->create; $this->view->builds = $builds; $this->view->productID = $productID; - $this->view->product = $this->product->getById($productID); - $this->view->branches = $this->loadModel('branch')->getPairs($productID); $this->view->lastRelease = $this->projectrelease->getLast($productID, $branch); $this->display(); } diff --git a/module/projectrelease/js/common.js b/module/projectrelease/js/common.js index b00a04a658..1f3ddf85b3 100644 --- a/module/projectrelease/js/common.js +++ b/module/projectrelease/js/common.js @@ -2,55 +2,3 @@ $(document).ready(function() { $("a.preview").modalTrigger({width:1000, type:'iframe'}); }) - -function loadProduct(productID) -{ - if(typeof parentStory != 'undefined' && parentStory) - { - confirmLoadProduct = confirm(moveChildrenTips); - if(!confirmLoadProduct) - { - $('#product').val(oldProductID); - $('#product').trigger("chosen:updated"); - return false; - } - } - - if(typeof hasSR != 'undefined' && hasSR) - { - confirmLoadProduct = confirm(moveSRTips);//Set hasSR variable in pro and biz. - if(!confirmLoadProduct) - { - $('#product').val(oldProductID); - $('#product').trigger("chosen:updated"); - return false; - } - } - - oldProductID = $('#product').val(); - loadProductBranches(productID) -} - -function loadBranch() -{ - var branch = $('#branch').val(); - if(typeof(branch) == 'undefined') branch = 0; -} - -function loadProductBranches(productID) -{ - $('#branch').remove(); - $('#branch_chosen').remove(); - $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID), function(data) - { - var $product = $('#product'); - var $inputGroup = $product.closest('.input-group'); - $inputGroup.find('.input-group-addon').toggleClass('hidden', !data); - if(data) - { - $inputGroup.append(data); - $('#branch').css('width', config.currentMethod == 'create' ? '120px' : '65px').chosen(); - } - $inputGroup.fixInputGroup(); - }) -} diff --git a/module/projectrelease/model.php b/module/projectrelease/model.php index 33912523cc..5a1577e4a1 100644 --- a/module/projectrelease/model.php +++ b/module/projectrelease/model.php @@ -46,21 +46,19 @@ class projectreleaseModel extends model * @param int $productID * @param int $branch * @param string $type - * @param int $projectID * @access public * @return array */ - public function getList($productID, $branch = 0, $type = 'all', $projectID = 0) + public function getList($productID, $branch = 0, $type = 'all') { return $this->dao->select('t1.*, t2.name as productName, t3.id as buildID, t3.name as buildName, t3.project') ->from(TABLE_RELEASE)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id') ->leftJoin(TABLE_BUILD)->alias('t3')->on('t1.build = t3.id') - ->where('t1.deleted')->eq(0) - ->beginIF($projectID)->andWhere('t1.PRJ')->eq((int)$projectID)->fi() - ->beginIF($productID)->andWhere('t1.product')->eq((int)$productID)->fi() + ->where('t1.product')->eq((int)$productID) ->beginIF($branch)->andWhere('t1.branch')->eq($branch)->fi() ->beginIF($type != 'all')->andWhere('t1.status')->eq($type)->fi() + ->andWhere('t1.deleted')->eq(0) ->orderBy('t1.date DESC') ->fetchAll(); } @@ -104,11 +102,16 @@ class projectreleaseModel extends model /** * Create a release. * + * @param int $productID + * @param int $branch + * * @access public * @return int */ - public function create() + public function create($productID, $branch = 0) { + $productID = (int)$productID; + $branch = (int)$branch; $buildID = 0; /* Check build if build is required. */ @@ -119,6 +122,8 @@ class projectreleaseModel extends model $release = fixer::input('post') ->add('PRJ', $this->session->PRJ) + ->add('product', (int)$productID) + ->add('branch', (int)$branch) ->setDefault('stories', '') ->join('stories', ',') ->join('bugs', ',') @@ -130,11 +135,10 @@ class projectreleaseModel extends model /* Auto create build when release is not link build. */ if(empty($release->build) and $release->name) { - $branch = isset($release->branch) ? $release->branch : 0; - $build = $this->dao->select('*')->from(TABLE_BUILD) + $build = $this->dao->select('*')->from(TABLE_BUILD) ->where('deleted')->eq('0') ->andWhere('name')->eq($release->name) - ->andWhere('product')->eq($release->product) + ->andWhere('product')->eq($productID) ->andWhere('branch')->eq($branch) ->fetch(); if($build) @@ -145,8 +149,8 @@ class projectreleaseModel extends model { $build = new stdclass(); $build->PRJ = $this->session->PRJ; - $build->product = $release->product; - $build->branch = $branch; + $build->product = (int)$productID; + $build->branch = (int)$branch; $build->name = $release->name; $build->date = $release->date; $build->builder = $this->app->user->account; @@ -156,7 +160,7 @@ class projectreleaseModel extends model $build = $this->loadModel('file')->processImgURL($build, $this->config->release->editor->create['id']); $this->dao->insert(TABLE_BUILD)->data($build) ->autoCheck() - ->check('name', 'unique', "product = {$release->product} AND branch = {$branch} AND deleted = '0'") + ->check('name', 'unique', "product = {$productID} AND branch = {$branch} AND deleted = '0'") ->batchCheck($this->config->release->create->requiredFields, 'notempty') ->exec(); if(dao::isError()) return false; diff --git a/module/projectrelease/view/browse.html.php b/module/projectrelease/view/browse.html.php index 6ac1742ad2..193f4d1d42 100644 --- a/module/projectrelease/view/browse.html.php +++ b/module/projectrelease/view/browse.html.php @@ -16,14 +16,14 @@ @@ -33,7 +33,7 @@

release->noRelease;?> - createLink('projectrelease', 'create', "productID=$productID&branch=$branch"), " " . $lang->release->create, '', "class='btn btn-info'");?> + createLink('projectrelease', 'create', "productID=$product->id&branch=$branch"), " " . $lang->release->create, '', "class='btn btn-info'");?>

diff --git a/module/projectrelease/view/create.html.php b/module/projectrelease/view/create.html.php index 0b21d031e1..8fddb38e36 100644 --- a/module/projectrelease/view/create.html.php +++ b/module/projectrelease/view/create.html.php @@ -20,21 +20,6 @@
- - - - -
release->product;?> - type != 'normal'):?> -
- - - type != 'normal'):?> - - -
- -
release->name;?>