Merge branch 'zentaopms266_wyd' into 'master'
* code for task #77617. See merge request easycorp/zentaopms!6402
This commit is contained in:
@@ -181,6 +181,38 @@ class buildModel extends model
|
||||
return $this->getExecutionBuilds($executionID, 'bysearch', $buildQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link stories or bugs builds.
|
||||
*
|
||||
* @param array $buildIdList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getNotEmptyBuilds($buildIdList)
|
||||
{
|
||||
$notEmptyBuilds = array();
|
||||
$buildList = $this->getByList($buildIdList);
|
||||
foreach($buildList as $build)
|
||||
{
|
||||
if(!$build->execution && !empty($build->builds))
|
||||
{
|
||||
$childBuilds = $this->getByList($build->builds);
|
||||
foreach($childBuilds as $childBuild)
|
||||
{
|
||||
$childBuild->stories = trim($childBuild->stories, ',');
|
||||
$childBuild->bugs = trim($childBuild->bugs, ',');
|
||||
|
||||
if($childBuild->stories) $build->stories .= ',' . $childBuild->stories;
|
||||
if($childBuild->bugs) $build->bugs .= ',' . $childBuild->bugs;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($build->stories) or !empty($build->bugs)) $notEmptyBuilds[$build->id] = $build->id;
|
||||
}
|
||||
|
||||
return $notEmptyBuilds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get story builds.
|
||||
*
|
||||
|
||||
@@ -133,14 +133,14 @@ class projectrelease extends control
|
||||
$builds = $this->build->getBuildPairs($this->view->product->id, $this->view->branch, 'notrunk,withbranch|hasproject', $projectID, 'project');
|
||||
$releasedBuilds = $this->projectrelease->getReleasedBuilds($projectID);
|
||||
foreach($releasedBuilds as $build) unset($builds[$build]);
|
||||
unset($builds['trunk']);
|
||||
|
||||
$this->view->title = $this->view->project->name . $this->lang->colon . $this->lang->release->create;
|
||||
$this->view->projectID = $projectID;
|
||||
$this->view->builds = $builds;
|
||||
$this->view->lastRelease = $this->projectrelease->getLast($projectID);
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noclosed');
|
||||
$this->view->confirmLink = $this->lang->release->confirmLink;
|
||||
$this->view->title = $this->view->project->name . $this->lang->colon . $this->lang->release->create;
|
||||
$this->view->projectID = $projectID;
|
||||
$this->view->builds = $builds;
|
||||
$this->view->lastRelease = $this->projectrelease->getLast($projectID);
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noclosed');
|
||||
$this->view->confirmLink = $this->lang->release->confirmLink;
|
||||
$this->view->notEmptyBuilds = $this->build->getNotEmptyBuilds(array_keys($builds));
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -811,8 +811,10 @@ class projectrelease extends control
|
||||
$builds = $this->loadModel('build')->getBuildPairs($productID, $branch, 'notrunk,withbranch,hasproject', $projectID, 'project', '', false);
|
||||
$releasedBuilds = $this->projectrelease->getReleasedBuilds($projectID);
|
||||
foreach($releasedBuilds as $build) unset($builds[$build]);
|
||||
unset($builds['trunk']);
|
||||
|
||||
return print(html::select('build[]', $builds, '', "class='form-control chosen' multiple"));
|
||||
/* Get the builds of the linked stories or bugs. */
|
||||
$notEmptyBuilds = $this->build->getNotEmptyBuilds(array_keys($builds));
|
||||
|
||||
return print(html::select('build[]', $builds, '', "class='form-control chosen' multiple data-notemptybuilds='" . join(',', $notEmptyBuilds) . "'"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,27 @@
|
||||
$('#submit').click(function()
|
||||
{
|
||||
var dateFormat = new RegExp(/^\d{4}\-\d{2}\-\d{2}$/);
|
||||
var name = $('#name').val();
|
||||
var date = $('#date').val();
|
||||
var build = $('#build').val();
|
||||
if(name && build && dateFormat.test(date))
|
||||
var dateFormat = new RegExp(/^\d{4}\-\d{2}\-\d{2}$/);
|
||||
var name = $('#name').val();
|
||||
var date = $('#date').val();
|
||||
var build = $('#build').val();
|
||||
var notEmptyBuild = false;
|
||||
|
||||
$.each(build, function(index, value)
|
||||
{
|
||||
if(typeof(notEmptyBuilds[value]) != 'undefined')
|
||||
{
|
||||
notEmptyBuild = true;
|
||||
return false;
|
||||
}
|
||||
})
|
||||
|
||||
if(name && build && notEmptyBuild && dateFormat.test(date))
|
||||
{
|
||||
var result = confirm(confirmLink) ? true : false;
|
||||
$('#sync').val(result);
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-toggle="popover"]').popover();
|
||||
|
||||
/**
|
||||
* Ajax load unlinked builds with project and product.
|
||||
*
|
||||
@@ -26,6 +35,10 @@ function loadBuilds()
|
||||
$('#buildBox').load(createLink('projectrelease', 'ajaxLoadBuilds', "projectID=" + projectID + "&productID=" + productID + "&branch=" + branch), function()
|
||||
{
|
||||
$('#build').attr('data-placeholder', multipleSelect).chosen();
|
||||
$.each($('#build').attr('data-notemptybuilds').split(','), function(index, value)
|
||||
{
|
||||
notEmptyBuilds[value] = value;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/kindeditor.html.php';?>
|
||||
<?php js::set('confirmLink', $confirmLink);?>
|
||||
<?php js::set('notEmptyBuilds', $notEmptyBuilds);?>
|
||||
<?php js::set('projectID', $projectID);?>
|
||||
<div id='mainContent' class='main-content'>
|
||||
<div class='center-block'>
|
||||
|
||||
@@ -86,27 +86,6 @@ class release extends control
|
||||
$releasedBuilds = $this->release->getReleasedBuilds($productID, $branch);
|
||||
foreach($releasedBuilds as $build) unset($builds[$build]);
|
||||
|
||||
/* Get the builds of the linked stories or bugs. */
|
||||
$notEmptyBuilds = array();
|
||||
$buildList = $this->build->getByList(array_keys($builds));
|
||||
foreach($buildList as $build)
|
||||
{
|
||||
if(!$build->execution && !empty($build->builds))
|
||||
{
|
||||
$childBuilds = $this->build->getByList($build->builds);
|
||||
foreach($childBuilds as $childBuild)
|
||||
{
|
||||
$childBuild->stories = trim($childBuild->stories, ',');
|
||||
$childBuild->bugs = trim($childBuild->bugs, ',');
|
||||
|
||||
if($childBuild->stories) $build->stories .= ',' . $childBuild->stories;
|
||||
if($childBuild->bugs) $build->bugs .= ',' . $childBuild->bugs;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($build->stories) or !empty($build->bugs)) $notEmptyBuilds[$build->id] = $build->id;
|
||||
}
|
||||
|
||||
$this->commonAction($productID, $branch);
|
||||
$this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->release->create;
|
||||
$this->view->position[] = $this->lang->release->create;
|
||||
@@ -114,7 +93,7 @@ class release extends control
|
||||
$this->view->builds = $builds;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noclosed');
|
||||
$this->view->lastRelease = $this->release->getLast($productID, $branch);
|
||||
$this->view->notEmptyBuilds = $notEmptyBuilds;
|
||||
$this->view->notEmptyBuilds = $this->build->getNotEmptyBuilds(array_keys($builds));
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -21,5 +21,3 @@ $('#submit').click(function()
|
||||
$('#sync').val(result);
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-toggle="popover"]').popover();
|
||||
|
||||
@@ -149,6 +149,20 @@ class buildTest
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getNotEmptyBuilds method
|
||||
*
|
||||
* @param array $buildIdList
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getNotEmptyBuildsTest($buildIdList)
|
||||
{
|
||||
$notEmptyBuilds = $this->objectModel->getNotEmptyBuilds($buildIdList);
|
||||
sort($notEmptyBuilds);
|
||||
return empty($notEmptyBuilds) ? 'null' : join(',', $notEmptyBuilds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function getLast test by build
|
||||
*
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/build.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 buildModel->getNotEmptyBuilds();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
不传任何数据 >> null
|
||||
迭代版本未关联需求和Bug >> null
|
||||
迭代版本关联需求和Bug >> 101
|
||||
项目版本关联版本关联需求和Bug >> 102
|
||||
项目版本关联版本未关联需求和Bug >> null
|
||||
版本列表中关联需求和Bug >> 101
|
||||
版本列表中混合项目版本和迭代版本 >> 101,102
|
||||
|
||||
*/
|
||||
|
||||
$build = new buildTest();
|
||||
|
||||
$buildData = new stdclass();
|
||||
$buildData->id = 100;
|
||||
$buildData->product = 1;
|
||||
$buildData->project = 1;
|
||||
$buildData->execution = 2;
|
||||
$buildData->name = 'test1';
|
||||
$buildData->date = date('Y-m-d');
|
||||
$build->objectModel->dao->replace(TABLE_BUILD)->data($buildData)->exec();
|
||||
$buildId1 = $buildData->id;
|
||||
|
||||
$buildData->id = 101;
|
||||
$buildData->name = 'test2';
|
||||
$buildData->stories = '1,2,3';
|
||||
$build->objectModel->dao->replace(TABLE_BUILD)->data($buildData)->exec();
|
||||
$buildId2 = $buildData->id;
|
||||
|
||||
$buildData = new stdclass();
|
||||
$buildData->id = 102;
|
||||
$buildData->product = 1;
|
||||
$buildData->project = 1;
|
||||
$buildData->execution = 0;
|
||||
$buildData->builds = ",$buildId2,";
|
||||
$buildData->name = 'test3';
|
||||
$buildData->date = date('Y-m-d');
|
||||
$build->objectModel->dao->replace(TABLE_BUILD)->data($buildData)->exec();
|
||||
$buildId3 = $buildData->id;
|
||||
|
||||
$buildData = new stdclass();
|
||||
$buildData->id = 103;
|
||||
$buildData->product = 1;
|
||||
$buildData->project = 1;
|
||||
$buildData->execution = 0;
|
||||
$buildData->builds = ",$buildId1,";
|
||||
$buildData->name = 'test4';
|
||||
$buildData->date = date('Y-m-d');
|
||||
$build->objectModel->dao->replace(TABLE_BUILD)->data($buildData)->exec();
|
||||
$buildId4 = $buildData->id;
|
||||
|
||||
|
||||
r($build->getNotEmptyBuildsTest(array())) && p() && e('null'); //不传任何数据
|
||||
r($build->getNotEmptyBuildsTest(array($buildId1))) && p() && e('null'); //迭代版本未关联需求和Bug
|
||||
r($build->getNotEmptyBuildsTest(array($buildId2))) && p() && e('101'); //迭代版本关联需求和Bug
|
||||
r($build->getNotEmptyBuildsTest(array($buildId3))) && p() && e('102'); //项目版本关联版本关联需求和Bug
|
||||
r($build->getNotEmptyBuildsTest(array($buildId4))) && p() && e('null'); //项目版本关联版本未关联需求和Bug
|
||||
r($build->getNotEmptyBuildsTest(array($buildId1, $buildId2))) && p() && e('101'); //版本列表中关联需求和Bug
|
||||
r($build->getNotEmptyBuildsTest(array($buildId3, $buildId2))) && p() && e('101,102'); //版本列表中混合项目版本和迭代版本
|
||||
Reference in New Issue
Block a user