* Finish Task #78664

This commit is contained in:
lanzongjun
2022-12-06 16:51:58 +08:00
parent 0adbd8e27a
commit 55aac8c426
9 changed files with 66 additions and 34 deletions

View File

@@ -199,7 +199,10 @@ class build extends control
{
$branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : '');
}
if(!isset($branchTagOption[$build->branch])) $branchTagOption[$build->branch] = $this->branch->getById($build->branch, 0, 'name');
foreach(explode(',', $build->branch) as $buildBranch)
{
if(!isset($branchTagOption[$buildBranch])) $branchTagOption[$buildBranch] = $this->branch->getById($buildBranch, 0, 'name');
}
foreach($productGroups as $product) $products[$product->id] = $product->name;
@@ -306,6 +309,16 @@ class build extends control
$this->view->generatedBugPager = $generatedBugPager;
$this->executeHooks($buildID);
$branchName = '';
if($build->productType != 'normal')
{
foreach(explode(',', $build->branch) as $buildBranch)
{
$branchName .= $this->loadModel('branch')->getById($buildBranch);
$branchName .= ',';
}
$branchName = trim($branchName, ',');
}
/* Assign. */
$this->view->canBeChanged = common::canBeChanged('build', $build); // Determines whether an object is editable.
@@ -321,7 +334,7 @@ class build extends control
$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->view->branchName = $branchName;
if($this->app->getViewType() == 'json')
{

View File

@@ -9,8 +9,7 @@ $().ready(function()
{
var projectID = $('#project').val();
var productID = $('#product').val();
var branch = $('#branch').length > 0 ? $('#branch').val() : '';
$.get(createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=builds&build=&branch=' + branch + '&index=&needCreate=&type=noempty,notrunk,separate,singled&extra=multiple'), function(data)
$.get(createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=builds&build=&branch=all&index=&needCreate=&type=noempty,notrunk,separate,singled&extra=multiple'), function(data)
{
if(data) $('#buildBox').html(data);
$('#builds').attr('data-placeholder', multipleSelect).chosen();

View File

@@ -10,8 +10,7 @@ $().ready(function()
else
{
var productID = $('#product').val();
var branch = $('#branch').val();
$.get(createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=builds&build=&branch=' + branch + '&index=&needCreate=&type=noempty,notrunk,separate,singled&extra=multiple'), function(data)
$.get(createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=builds&build=&branch=all&index=&needCreate=&type=noempty,notrunk,separate,singled&extra=multiple'), function(data)
{
if(data) $('#buildBox').html(data);
$('#builds').attr('data-placeholder', multipleSelect).chosen();

View File

@@ -386,15 +386,28 @@ class buildModel extends model
->add('createdBy', $this->app->user->account)
->add('createdDate', helper::now())
->stripTags($this->config->build->editor->create['id'], $this->config->allowedTags)
->join('builds,', ',')
->join('builds', ',')
->join('branch', ',')
->remove('resolvedBy,allchecker,files,labels,isIntegrated,uid')
->get();
if($this->post->isIntegrated == 'yes') $build->execution = 0;
if($this->post->isIntegrated == 'yes')
{
$build->execution = 0;
$branchPairs = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->in($build->builds)->fetchPairs();
$relationBranch = array();
foreach($branchPairs as $branches)
{
foreach(explode(',', $branches) as $branch)
{
if(!isset($relationBranch[$branch])) $relationBranch[$branch] = $branch;
}
}
$build->branch = implode(',', $relationBranch);
}
$product = $this->loadModel('product')->getByID($build->product);
if($product->type != 'normal' and !isset($_POST['branch']))
if($product->type != 'normal' and $this->post->isIntegrated == 'no' and !isset($_POST['branch']))
{
$this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
dao::$errors['branch'] = sprintf($this->lang->error->notempty, $this->lang->product->branch);
@@ -436,17 +449,27 @@ class buildModel extends model
->setIF(!isset($_POST['branch']), 'branch', $oldBuild->branch)
->setDefault('product', $oldBuild->product)
->setDefault('builds', '')
->cleanInt('product,branch,execution')
->cleanInt('product,execution')
->join('builds', ',')
->join('branch', ',')
->remove('allchecker,resolvedBy,files,labels,uid')
->get();
$product = $this->loadModel('product')->getByID($build->product);
if($product->type != 'normal' and $this->post->isIntegrated == 'no' and !isset($_POST['branch']))
{
$this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
dao::$errors['branch'] = sprintf($this->lang->error->notempty, $this->lang->product->branch);
}
if(dao::isError()) return false;
$build = $this->loadModel('file')->processImgURL($build, $this->config->build->editor->edit['id'], $this->post->uid);
$this->dao->update(TABLE_BUILD)->data($build)
->autoCheck()
->batchCheck($this->config->build->edit->requiredFields, 'notempty')
->where('id')->eq($buildID)
->check('name', 'unique', "id != $buildID AND product = {$build->product} AND branch = {$build->branch} AND deleted = '0'")
->check('name', 'unique', "id != $buildID AND product = {$build->product} AND branch = '{$build->branch}' AND deleted = '0'")
->checkFlow()
->exec();
if(isset($build->branch) and $oldBuild->branch != $build->branch) $this->dao->update(TABLE_RELEASE)->set('branch')->eq($build->branch)->where('build')->eq($buildID)->exec();

View File

@@ -32,16 +32,20 @@
?>
<div class='input-group'>
<?php echo html::select('product', $products, $build->product, "onchange='loadBranches(this.value);' class='form-control chosen' $disabled required");?>
<?php
if($build->productType != 'normal')
{
echo "<span class='input-group-addon fix-padding fix-border'></span>" . html::select('branch', $branchTagOption, $build->branch, "class='form-control chosen' $disabled");
}
?>
</div>
</td>
<td><?php if($disabled) echo $lang->build->notice->changeProduct;?></td>
</tr>
<?php if(!empty($product) and $product->type != 'normal'): ?>
<tr>
<th class='w-120px'><?php echo $lang->build->branch;?></th>
<td>
<div class='input-group' id='branchBox'>
<?php echo html::select('branch[]', $branchTagOption, $build->branch, "class='form-control chosen' multiple required $disabled"); ?>
</div>
</td>
</tr>
<?php endif; ?>
<?php $disabled = $testtaskID ? 'disabled' : '';?>
<?php if(!$build->execution):?>
<tr>

View File

@@ -4144,7 +4144,7 @@ class execution extends control
foreach($planStory as $id => $story)
{
$projectBranches = zget($projectProducts, $story->product, array());
if($story->status == 'draft' or $story->status == 'reviewing' or (!empty($story->branch) and !empty($projectBranches) and !isset($projectBranches[$story->branch])))
if($story->status != 'active' or (!empty($story->branch) and !empty($projectBranches) and !isset($projectBranches[$story->branch])))
{
$count++;
unset($planStory[$id]);

View File

@@ -2937,7 +2937,7 @@ class executionModel extends model
{
foreach($planStory as $id => $story)
{
if($story->status == 'draft' or $story->status == 'reviewing' or (!empty($story->branch) and !empty($executionBranches) and !isset($executionBranches[$story->branch])))
if($story->status != 'active' or (!empty($story->branch) and !empty($executionBranches) and !isset($executionBranches[$story->branch])))
{
unset($planStory[$id]);
continue;

View File

@@ -1069,7 +1069,7 @@ class productplanModel extends model
foreach($planStory as $id => $story)
{
$projectBranches = zget($projectProducts, $story->product, array());
if($story->status == 'draft' or $story->status == 'reviewing' or (!empty($story->branch) and !empty($projectBranches) and !isset($projectBranches[$story->branch])))
if($story->status == 'active' or (!empty($story->branch) and !empty($projectBranches) and !isset($projectBranches[$story->branch])))
{
unset($planStory[$id]);
continue;

View File

@@ -298,14 +298,11 @@ class story extends control
}
$users = $this->user->getPairs('pdfirst|noclosed|nodeleted');
$branchData = explode(',', $branch);
foreach($branchData as $branchItem)
{
$branch = $branchItem;
$moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch === 'all' ? 0 : $branch);
break;
}
$branch = current($branchData);
$moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch === 'all' ? 0 : $branch);
if(empty($moduleOptionMenu)) return print(js::locate(helper::createLink('tree', 'browse', "productID=$productID&view=story")));
/* Init vars. */
@@ -667,13 +664,10 @@ class story extends control
}
$branchData = explode(',', $branch);
foreach($branchData as $branchItem)
{
$branch = $branchItem;
$moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch === 'all' ? 0 : $branch);
$moduleOptionMenu['ditto'] = $this->lang->story->ditto;
break;
}
$branch = current($branchData);
$moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch === 'all' ? 0 : $branch);
$moduleOptionMenu['ditto'] = $this->lang->story->ditto;
/* Get reviewers. */
$reviewers = $product->reviewer;