From 532bef39f38e04fcc22aabcbe6fa6c46604d766a Mon Sep 17 00:00:00 2001 From: wangyuting <851424971@qq.com> Date: Thu, 17 Nov 2022 08:03:03 +0000 Subject: [PATCH] * Finish task #76434. --- module/build/control.php | 7 ++++- module/build/js/create.js | 50 ++++++++++++++++++++++++++++++ module/build/lang/de.php | 5 +++ module/build/lang/en.php | 5 +++ module/build/lang/fr.php | 5 +++ module/build/lang/zh-cn.php | 5 +++ module/build/model.php | 23 ++++---------- module/build/view/create.html.php | 13 ++++++-- module/common/lang/menu.php | 2 +- module/group/lang/resource.php | 2 -- module/product/control.php | 21 +++++++++++++ module/project/view/build.html.php | 2 +- 12 files changed, 115 insertions(+), 25 deletions(-) diff --git a/module/build/control.php b/module/build/control.php index 0abe7eb54e..14d1f9d9f7 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -54,7 +54,7 @@ class build extends control if(defined('TUTORIAL')) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true)); // Fix bug #21095. - $buildID = $this->build->create($executionID, $projectID); + $buildID = $this->build->create(); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('build', $buildID, 'opened'); @@ -72,6 +72,8 @@ class build extends control if($this->app->tab == 'project') { $this->project->setMenu($projectID); + $executions = $this->execution->getPairs($projectID, 'all', 'stagefilter'); + $executionID = empty($executionID) ? key($executions) : $executionID; $productGroups = $this->product->getProducts($projectID); $branchGroups = $this->project->getBranchesByProject($projectID); $this->session->set('project', $projectID); @@ -79,6 +81,7 @@ class build extends control elseif($this->app->tab == 'execution') { $execution = $this->execution->getByID($executionID); + $executions = $this->execution->getPairs($execution->project); $projectID = $execution->project; $productGroups = $this->product->getProducts($executionID); $branchGroups = $this->project->getBranchesByProject($executionID); @@ -89,6 +92,7 @@ class build extends control { $execution = $this->execution->getByID($executionID); $projectID = $execution ? $execution->project : 0; + $executions = $this->execution->getPairs($projectID); $productGroups = $this->product->getProducts($executionID); $branchGroups = $this->project->getBranchesByProject($executionID); } @@ -119,6 +123,7 @@ class build extends control $this->view->executionID = $executionID; $this->view->products = $products; $this->view->projectID = $projectID; + $this->view->executions = $executions; $this->view->lastBuild = $this->build->getLast($executionID, $projectID); $this->view->productGroups = $productGroups; $this->view->users = $this->user->getPairs('nodeleted|noclosed'); diff --git a/module/build/js/create.js b/module/build/js/create.js index 24e9448c82..c70dafe3f1 100644 --- a/module/build/js/create.js +++ b/module/build/js/create.js @@ -15,5 +15,55 @@ $().ready(function() $('#builds').chosen(); }); }); + + $('input[name=type]').change(function() + { + if($(this).val() == 'execution') + { + $('#execution').closest('tr').show(); + $('#buildBox').closest('tr').hide(); + loadProducts($('#execution').val()); + } + else + { + $('#execution').closest('tr').hide(); + $('#buildBox').closest('tr').show(); + loadProducts($('#project').val()); + } + }); $('#product').change(); }); + +/** + * Load products. + * + * @param int $executionID + * @access public + * @return void + */ +function loadProducts(executionID) +{ + $('#product').remove(); + $('#product_chosen').remove(); + $('#branch').remove(); + $('#branch_chosen').remove(); + $('#noProduct').remove(); + $.get(createLink('product', 'ajaxGetProducts', 'executionID=' + executionID), function(data) + { + if(data) + { + if(data.indexOf("required") != -1) + { + $('#productBox').addClass('required'); + } + else + { + $('#productBox').removeClass('required'); + } + + $('#productBox').append(data); + $('#product').chosen(); + loadBranches($("#product").val()); + } + }); +} diff --git a/module/build/lang/de.php b/module/build/lang/de.php index 39f5f213c7..b6987753bd 100644 --- a/module/build/lang/de.php +++ b/module/build/lang/de.php @@ -33,6 +33,7 @@ $lang->build->project = 'Project'; $lang->build->branch = 'Platform/Branch'; $lang->build->branchName = '%s'; $lang->build->execution = $lang->executionCommon; +$lang->build->type = 'Type'; $lang->build->builds = 'Linked Builds'; $lang->build->name = 'Name'; $lang->build->date = 'Datum'; @@ -73,3 +74,7 @@ $lang->build->action->buildopened = '$date, erstellt von $actor $lang->backhome = 'zurück'; $lang->build->featureBar['browse']['all'] = 'Build List'; + +$lang->build->typeList = array(); +$lang->build->typeList['execution'] = "{$lang->executionCommon}版本"; +$lang->build->typeList['project'] = '项目版本'; diff --git a/module/build/lang/en.php b/module/build/lang/en.php index df6d81e8d1..9a1e7727cc 100644 --- a/module/build/lang/en.php +++ b/module/build/lang/en.php @@ -34,6 +34,7 @@ $lang->build->branch = 'Platform/Branch'; $lang->build->branchName = '%s'; $lang->build->execution = $lang->executionCommon; $lang->build->builds = 'Linked Builds'; +$lang->build->type = 'Type'; $lang->build->name = 'Name'; $lang->build->date = 'Date'; $lang->build->builder = 'Builder'; @@ -73,3 +74,7 @@ $lang->build->action->buildopened = '$date, created by $actor, $lang->backhome = 'back'; $lang->build->featureBar['browse']['all'] = 'Build List'; + +$lang->build->typeList = array(); +$lang->build->typeList['execution'] = "{$lang->executionCommon}版本"; +$lang->build->typeList['project'] = '项目版本'; diff --git a/module/build/lang/fr.php b/module/build/lang/fr.php index 30ed628f70..e5e151b4e4 100644 --- a/module/build/lang/fr.php +++ b/module/build/lang/fr.php @@ -33,6 +33,7 @@ $lang->build->project = 'Project'; $lang->build->branch = 'Plateforme/Branche'; $lang->build->branchName = '%s'; $lang->build->execution = $lang->executionCommon; +$lang->build->type = 'Type'; $lang->build->builds = 'Linked Builds'; $lang->build->name = 'Nom'; $lang->build->date = 'Date'; @@ -73,3 +74,7 @@ $lang->build->action->buildopened = '$date, Build $extra créé $lang->backhome = 'Retour'; $lang->build->featureBar['browse']['all'] = 'Build List'; + +$lang->build->typeList = array(); +$lang->build->typeList['execution'] = "{$lang->executionCommon}版本"; +$lang->build->typeList['project'] = '项目版本'; diff --git a/module/build/lang/zh-cn.php b/module/build/lang/zh-cn.php index 0be8d8c8b5..13da7f11b3 100644 --- a/module/build/lang/zh-cn.php +++ b/module/build/lang/zh-cn.php @@ -33,6 +33,7 @@ $lang->build->project = '所属项目'; $lang->build->branch = '平台/分支'; $lang->build->branchName = '所属%s'; $lang->build->execution = '所属' . $lang->executionCommon; +$lang->build->type = '版本类型'; $lang->build->builds = '关联版本'; $lang->build->name = '名称编号'; $lang->build->date = '打包日期'; @@ -71,3 +72,7 @@ $lang->build->action = new stdclass(); $lang->build->action->buildopened = '$date, 由 $actor 创建版本 $extra。' . "\n"; $lang->backhome = '返回'; + +$lang->build->typeList = array(); +$lang->build->typeList['execution'] = "{$lang->executionCommon}版本"; +$lang->build->typeList['project'] = '项目版本'; diff --git a/module/build/model.php b/module/build/model.php index 695656a2f1..44791f4da6 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -302,42 +302,31 @@ class buildModel extends model /** * Create a build * - * @param int $executionID - * @param int $projectID * @access public * @return void */ - public function create($executionID = 0, $projectID = 0) + public function create() { $build = new stdclass(); $build->stories = ''; $build->bugs = ''; - if($projectID && !$executionID) - { - $project = $this->loadModel('project')->getByID($projectID); - if(!$project->multiple) $executionID = $this->dao->select('id')->from(TABLE_EXECUTION)->where('project')->eq($projectID)->fetch('id'); - } - else if($executionID && !$projectID) - { - $execution = $this->loadModel('execution')->getByID($executionID); - $projectID = $execution->project; - } - $build = fixer::input('post') - ->setDefault('project', $projectID) + ->setDefault('project', 0) + ->setDefault('execution', 0) ->setDefault('product', 0) ->setDefault('branch', 0) ->setDefault('builds', '') ->cleanInt('product,branch') - ->add('execution', $executionID) ->add('createdBy', $this->app->user->account) ->add('createdDate', helper::now()) ->stripTags($this->config->build->editor->create['id'], $this->config->allowedTags) ->join('builds', ',') - ->remove('resolvedBy,allchecker,files,labels,uid') + ->remove('resolvedBy,allchecker,files,labels,type,uid') ->get(); + if($this->post->type == 'project') $build->execution = 0; + $build = $this->loadModel('file')->processImgURL($build, $this->config->build->editor->create['id'], $this->post->uid); $this->dao->insert(TABLE_BUILD)->data($build) ->autoCheck() diff --git a/module/build/view/create.html.php b/module/build/view/create.html.php index 6a26488df3..e7b45afe8f 100644 --- a/module/build/view/create.html.php +++ b/module/build/view/create.html.php @@ -19,6 +19,14 @@