diff --git a/module/build/config.php b/module/build/config.php index 52496f86be..350e441a74 100644 --- a/module/build/config.php +++ b/module/build/config.php @@ -3,7 +3,7 @@ $config->build = new stdclass(); $config->build->create = new stdclass(); $config->build->edit = new stdclass(); $config->build->create->requiredFields = 'product,name,builder,date'; -$config->build->edit->requiredFields = 'product,name,builder,date'; +$config->build->edit->requiredFields = 'product,project,name,builder,date'; $config->build->editor = new stdclass(); $config->build->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); diff --git a/module/build/control.php b/module/build/control.php index cf2ae8e6df..0bf61d2910 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -149,6 +149,9 @@ class build extends control $project->name = ''; } + $projects = $this->loadModel('product')->getProjectPairs($build->product, $build->branch, 'nodeleted'); + if(!isset($projects[$build->project])) $projects[$build->project] = $project->name; + $productGroups = $this->project->getProducts($build->project); $products = array(); @@ -164,6 +167,7 @@ class build extends control $this->view->position[] = $this->lang->build->edit; $this->view->product = isset($productGroups[$build->product]) ? $productGroups[$build->product] : ''; $this->view->branches = (isset($productGroups[$build->product]) and $productGroups[$build->product]->type == 'normal') ? array() : $this->loadModel('branch')->getPairs($build->product); + $this->view->projects = $projects; $this->view->orderBy = $orderBy; } @@ -173,7 +177,7 @@ class build extends control $this->view->build = $build; $this->display(); } - + /** * View a build. * diff --git a/module/build/js/edit.js b/module/build/js/edit.js new file mode 100644 index 0000000000..604c054727 --- /dev/null +++ b/module/build/js/edit.js @@ -0,0 +1,15 @@ +var projectID = $('#project').val(); +function loadProjects() +{ + var productID = $('#product').val(); + var branchID = $('#branch').length > 0 ? $('#branch').val() : 0; + $('#projectsBox').load(createLink('product', 'ajaxGetProjects', 'productID=' + productID + '&projectID=' + projectID + '&branch=' + branchID), function() + { + $('#projectsBox #project').chosen().removeAttr('onchange'); + }); +} + +$(document).on('change', '#product,#branch', function() +{ + loadProjects(); +}) diff --git a/module/build/lang/zh-cn.php b/module/build/lang/zh-cn.php index fbc2dfe7bc..bd399b1527 100644 --- a/module/build/lang/zh-cn.php +++ b/module/build/lang/zh-cn.php @@ -48,6 +48,9 @@ $lang->build->generatedBugs = '产生的Bug'; $lang->build->noProduct = " 该{$lang->projectCommon}没有关联{$lang->productCommon},无法创建版本,请先关联{$lang->productCommon}"; $lang->build->noBuild = '暂时没有版本。'; +$lang->build->notice = new stdclass(); +$lang->build->notice->changeProduct = "已经关联{$lang->storyCommon}或Bug的版本,不能修改其所属产品"; + $lang->build->finishStories = " 本次共完成 %s 个{$lang->storyCommon}"; $lang->build->resolvedBugs = ' 本次共解决 %s 个Bug'; $lang->build->createdBugs = ' 本次共产生 %s 个Bug'; diff --git a/module/build/model.php b/module/build/model.php index 3b46e41f86..3a1a6494f5 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -236,10 +236,11 @@ class buildModel extends model $buildID = (int)$buildID; $oldBuild = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->eq($buildID)->fetch(); $build = fixer::input('post')->stripTags($this->config->build->editor->edit['id'], $this->config->allowedTags) + ->setDefault('product', $oldBuild->product) + ->setDefault('branch', $oldBuild->branch) ->cleanInt('product,branch') ->remove('allchecker,resolvedBy,files,labels,uid') ->get(); - if(!isset($build->branch)) $build->branch = $oldBuild->branch; $build = $this->loadModel('file')->processImgURL($build, $this->config->build->editor->edit['id'], $this->post->uid); $this->dao->update(TABLE_BUILD)->data($build) diff --git a/module/build/view/edit.html.php b/module/build/view/edit.html.php index 16b71e5987..78386ca79a 100644 --- a/module/build/view/edit.html.php +++ b/module/build/view/edit.html.php @@ -26,18 +26,29 @@ build->product;?> + stories or $build->bugs) $disabled = 'disabled'; + ?>
- product, "onchange='loadBranches(this.value);' class='form-control chosen' required");?> + product, "onchange='loadBranches(this.value);' class='form-control chosen' $disabled required");?> productType != 'normal' and isset($branches[$product->branch])) { if($product->branch) $branches = array($product->branch => $branches[$product->branch]); - echo "" . html::select('branch', $branches, $build->branch, "class='form-control chosen'"); + echo "" . html::select('branch', $branches, $build->branch, "class='form-control chosen' $disabled"); } ?>
- + + build->notice->changeProduct;?> + config->global->flow != 'onlyTest'):?> + + build->project;?> + project, "class='form-control chosen' required");?> + + build->name;?> name, "class='form-control' required");?> @@ -71,7 +82,6 @@ - global->flow != 'onlyTest' ? html::hidden('project', $build->project) : '';?>