Merge branch 'sprint/zentaopms271_lanzongjun'

This commit is contained in:
Yagami
2022-12-07 09:35:30 +08:00
15 changed files with 121 additions and 43 deletions
+5
View File
@@ -0,0 +1,5 @@
ALTER TABLE `zt_story` ADD COLUMN `siblings` varchar(255) NOT NULL AFTER `linkRequirements`;
ALTER TABLE `zt_productplan` MODIFY COLUMN `branch` varchar(255) NOT NULL DEFAULT '0';
ALTER TABLE `zt_build` MODIFY COLUMN `branch` varchar(255) NOT NULL DEFAULT '0';
+1 -1
View File
@@ -321,7 +321,7 @@ CREATE TABLE IF NOT EXISTS `zt_build` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`project` mediumint(8) unsigned NOT NULL,
`product` mediumint(8) unsigned NOT NULL default '0',
`branch` mediumint(8) unsigned NOT NULL default '0',
`branch` varchar(255) NOT NULL DEFAULT '0',
`execution` mediumint(8) unsigned NOT NULL default '0',
`builds` varchar(255) NOT NULL,
`name` char(150) NOT NULL,
+7 -4
View File
@@ -257,20 +257,21 @@ class branch extends control
*
* @param int $productID
* @param int $oldBranch
* @param string $param
* @param string $browseType
* @param int $projectID
* @param bool $withMainBranch
* @param string $isSiblings
* @param string $fieldID
* @param string $multiple
* @access public
* @return void
*/
public function ajaxGetBranches($productID, $oldBranch = 0, $param = 'all', $projectID = 0, $withMainBranch = true, $isSiblings = 'no', $fieldID = '0')
public function ajaxGetBranches($productID, $oldBranch = 0, $browseType = 'all', $projectID = 0, $withMainBranch = true, $isSiblings = 'no', $fieldID = '0', $multiple = '')
{
$product = $this->loadModel('product')->getById($productID);
if(empty($product) or $product->type == 'normal') return;
$branches = $this->loadModel('branch')->getList($productID, $projectID, $param, 'order', null, $withMainBranch);
$branches = $this->loadModel('branch')->getList($productID, $projectID, $browseType, 'order', null, $withMainBranch);
$branchTagOption = array();
foreach($branches as $branchInfo)
{
@@ -282,8 +283,10 @@ class branch extends control
$branchTagOption[$oldBranch] = $oldBranch == BRANCH_MAIN ? $branch : ($branch->name . ($branch->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''));
}
$name = $multiple == 'multiple' ? 'branch[]' : 'branch';
if($isSiblings == 'yes') return print(html::select("branches[$fieldID]", $branchTagOption, $oldBranch, "onchange='loadBranchRelation(this.value, $fieldID);' class='form-control chosen control-branch'"));
return print(html::select('branch', $branchTagOption, $oldBranch, "class='form-control' onchange='loadBranch(this)' data-last='{$oldBranch}'"));
return print(html::select($name, $branchTagOption, $oldBranch, "class='form-control' $multiple onchange='loadBranch(this)' data-last='{$oldBranch}'"));
}
/**
+15 -2
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 = empty($branchName) ? $this->lang->branch->main : $branchName;
$this->view->childBuilds = empty($build->builds) ? array() : $this->dao->select('id,name,bugs,stories')->from(TABLE_BUILD)->where('id')->in($build->builds)->fetchAll();
if($this->app->getViewType() == 'json')
+12 -2
View File
@@ -7,6 +7,11 @@
*/
function loadBranches(productID)
{
if($('input[name=isIntegrated]:checked').val() == 'yes')
{
$('#branchBox').closest('tr').addClass('hidden');
return false;
}
$('#branch').remove();
$('#branch_chosen').remove();
var oldBranch = 0;
@@ -16,12 +21,17 @@ function loadBranches(productID)
}
projectID = currentTab == 'execution' ? executionID : projectID;
$.get(createLink('branch', 'ajaxGetBranches', 'productID=' + productID + '&oldBranch=0&param=active&projectID=' + projectID), function(data)
$.get(createLink('branch', 'ajaxGetBranches', 'productID=' + productID + '&oldBranch=0&param=active&projectID=' + projectID + '&withMainBranch=true&isSiblings=no&fieldID=0&multiple=multiple'), function(data)
{
if(data)
{
$('#product').closest('.input-group').append(data);
$('#branchBox').append(data);
$('#branch').chosen();
$('#branchBox').closest('tr').removeClass('hidden');
}
else
{
$('#branchBox').closest('tr').addClass('hidden');
}
});
}
+1 -2
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();
+1 -2
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();
+38 -5
View File
@@ -382,21 +382,44 @@ class buildModel extends model
->setDefault('product', 0)
->setDefault('branch', 0)
->setDefault('builds', '')
->cleanInt('product,branch')
->cleanInt('product')
->add('createdBy', $this->app->user->account)
->add('createdDate', helper::now())
->stripTags($this->config->build->editor->create['id'], $this->config->allowedTags)
->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 $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->create['id'], $this->post->uid);
$this->dao->insert(TABLE_BUILD)->data($build)
->autoCheck()
->batchCheck($this->config->build->create->requiredFields, 'notempty')
->check('name', 'unique', "product = {$build->product} AND branch = {$build->branch} AND deleted = '0'")
->check('name', 'unique', "product = {$build->product} AND branch = '{$build->branch}' AND deleted = '0'")
->checkFlow()
->exec();
@@ -426,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();
+8 -6
View File
@@ -33,12 +33,6 @@
<td>
<div class='input-group' id='productBox'>
<?php echo html::select('product', $products, empty($product) ? '' : $product->id, "onchange='loadBranches(this.value);' class='form-control chosen' required");?>
<?php
if(!empty($product) and $product->type != 'normal')
{
echo "<span class='input-group-addon fix-padding fix-border'></span>" . html::select('branch', $branches, key($product->branches), "class='form-control chosen'");
}
?>
</div>
</td>
<?php else:?>
@@ -50,6 +44,14 @@
<?php endif;?>
<td></td>
</tr>
<tr class='<?php if(!empty($product) and $product->type == 'normal') echo 'hidden'?>'>
<th class='w-120px'><?php echo $lang->build->branch;?></th>
<td>
<div class='input-group' id='branchBox'>
<?php echo html::select('branch[]', $branches, key($product->branches), "class='form-control chosen' multiple required"); ?>
</div>
</td>
</tr>
<tr class='hide'>
<th class='w-120px'><?php echo $lang->build->builds;?></th>
<td id='buildBox'><?php echo html::select('builds[]', array(), '', "class='form-control chosen' multiple data-placeholder='{$lang->build->placeholder->multipleSelect}'");?></td>
+9 -6
View File
@@ -32,16 +32,19 @@
?>
<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>
<tr>
<tr class='<?php if(!empty($product) and $product->type == 'normal') echo 'hidden'?>'>
<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 $disabled = $testtaskID ? 'disabled' : '';?>
<?php if(!$build->execution):?>
<tr>
+1 -1
View File
@@ -4145,7 +4145,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]);
+1 -1
View File
@@ -2940,7 +2940,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;
+2 -2
View File
@@ -325,7 +325,7 @@ class productplanModel extends model
->andWhere('deleted')->eq(0)
->beginIF(strpos($param, 'unexpired') !== false)->andWhere('end')->ge($date)->fi()
->beginIF(strpos($param, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi()
->beginIF($branch !== 'all' and $branch !== '')->andWhere($branchQuery)->fi()
->beginIF($branch !== 'all' and $branch !== '' and !empty($branchQuery))->andWhere($branchQuery)->fi()
->orderBy('begin desc')
->fetchAll('id');
@@ -1054,7 +1054,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;
+10 -2
View File
@@ -298,7 +298,11 @@ class story extends control
}
$users = $this->user->getPairs('pdfirst|noclosed|nodeleted');
$branchData = explode(',', $branch);
$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. */
@@ -440,7 +444,8 @@ class story extends control
$this->view->users = $users;
$this->view->moduleID = $moduleID;
$this->view->moduleOptionMenu = $moduleOptionMenu;
$this->view->plans = str_replace('2030-01-01', $this->lang->story->undetermined, $this->loadModel('productplan')->getPairsForStory($productID, $branch == 0 ? '' : $branch, 'skipParent|unexpired|noclosed')); $this->view->planID = $planID;
$this->view->plans = str_replace('2030-01-01', $this->lang->story->undetermined, $this->loadModel('productplan')->getPairsForStory($productID, $branch == 0 ? '' : $branch, 'skipParent|unexpired|noclosed'));
$this->view->planID = $planID;
$this->view->source = $source;
$this->view->sourceNote = $sourceNote;
$this->view->color = $color;
@@ -658,7 +663,10 @@ class story extends control
$branches = $product->type != 'normal' ? $this->loadModel('branch')->getPairs($productID, 'active') : array();
}
$moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch === 'all' ? 0 : $branch);
$branchData = explode(',', $branch);
$branch = current($branchData);
$moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch === 'all' ? 0 : $branch);
$moduleOptionMenu['ditto'] = $this->lang->story->ditto;
/* Get reviewers. */
+10 -7
View File
@@ -2229,14 +2229,17 @@ class storyModel extends model
if($oldStory->stage == 'wait') $story->stage = 'planned';
if($this->session->currentProductType and $this->session->currentProductType != 'normal' and $oldStory->branch == 0)
{
if(!isset($oldStoryStages[$storyID][$plan->branch]))
foreach(explode(',', $plan->branch) as $planBranch)
{
$story->stage = 'planned';
$newStoryStage = new stdclass();
$newStoryStage->story = $storyID;
$newStoryStage->branch = $plan->branch;
$newStoryStage->stage = $story->stage;
$this->dao->insert(TABLE_STORYSTAGE)->data($newStoryStage)->autoCheck()->exec();
if(!isset($oldStoryStages[$storyID][$planBranch]))
{
$story->stage = 'planned';
$newStoryStage = new stdclass();
$newStoryStage->story = $storyID;
$newStoryStage->branch = $planBranch;
$newStoryStage->stage = $story->stage;
$this->dao->insert(TABLE_STORYSTAGE)->data($newStoryStage)->autoCheck()->exec();
}
}
}
}