* Finish task #75240.

This commit is contained in:
daitingting
2022-11-09 06:13:07 +00:00
parent 78a793670b
commit 8125b5bf8b
7 changed files with 42 additions and 25 deletions
+3
View File
@@ -2,6 +2,9 @@ ALTER TABLE `zt_product` ADD `shadow` tinyint(1) unsigned NOT NULL AFTER `code`;
ALTER TABLE `zt_project` ADD `hasProduct` tinyint(1) unsigned NOT NULL DEFAULT 1 AFTER `code`;
ALTER table `zt_project` ADD `multiple` enum('0', '1') NOT NULL DEFAULT '1';
ALTER TABLE `zt_repo` ADD `projects` varchar(255) NOT NULL AFTER `product`;
ALTER TABLE `zt_release` CHANGE `project` `project` varchar(255) NOT NULL;
ALTER TABLE `zt_release` CHANGE `branch` `branch` varchar(255) NOT NULL;
ALTER TABLE `zt_release` CHANGE `build` `build` varchar(255) NOT NULL;
CREATE OR REPLACE VIEW `ztv_normalproduct` AS SELECT * FROM `zt_product` WHERE `shadow` = 0;
+3 -3
View File
@@ -1280,10 +1280,10 @@ CREATE TABLE IF NOT EXISTS `zt_relation` (
-- DROP TABLE IF EXISTS `zt_release`;
CREATE TABLE IF NOT EXISTS `zt_release` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`project` mediumint(8) unsigned NOT NULL,
`project` varchar(255) NOT NULL,
`product` mediumint(8) unsigned NOT NULL default '0',
`branch` mediumint(8) unsigned NOT NULL default '0',
`build` mediumint(8) unsigned NOT NULL,
`branch` varchar(255) unsigned NOT NULL default '0',
`build` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL default '',
`marker` enum('0','1') NOT NULL default '0',
`date` date NOT NULL,
+2 -1
View File
@@ -228,7 +228,7 @@ class buildModel extends model
$allBuilds = $this->dao->select('t1.id, t1.name, t1.deleted, t2.status as objectStatus, t3.id as releaseID, t3.status as releaseStatus, t4.name as branchName, t5.type as productType')->from(TABLE_BUILD)->alias('t1')
->beginIF($objectType === 'execution')->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.execution = t2.id')->fi()
->beginIF($objectType === 'project')->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')->fi()
->leftJoin(TABLE_RELEASE)->alias('t3')->on('t1.id = t3.build')
->leftJoin(TABLE_RELEASE)->alias('t3')->on("FIND_IN_SET(t1.id,t3.build)")
->leftJoin(TABLE_BRANCH)->alias('t4')->on('t1.branch = t4.id')
->leftJoin(TABLE_PRODUCT)->alias('t5')->on('t1.product = t5.id')
->where(1)->eq(1)
@@ -246,6 +246,7 @@ class buildModel extends model
{
if(empty($build->releaseID) and (strpos($params, 'nodone') !== false) and ($build->objectStatus === 'done')) continue;
if((strpos($params, 'noterminate') !== false) and ($build->releaseStatus === 'terminate')) continue;
if($build->deleted == 1) $build->name .= ' (' . $this->lang->build->deleted . ')';
$branchName = $build->branchName ? $build->branchName : $this->lang->branch->main;
+7 -10
View File
@@ -70,21 +70,21 @@ class release extends control
{
$releaseID = $this->release->create($productID, $branch);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->loadModel('action')->create('release', $releaseID, 'opened');
$message = $this->executeHooks($releaseID);
if($message) $this->lang->saveSuccess = $message;
$result = $this->executeHooks($releaseID);
$message = $result ? $result : $this->lang->saveSuccess;
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $releaseID));
if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadProductBuilds($productID)"));
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $message, 'id' => $releaseID));
if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $message, 'closeModal' => true, 'callback' => "parent.loadProductBuilds($productID)"));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "releaseID=$releaseID")));
return $this->send(array('result' => 'success', 'message' => $message, 'locate' => inlink('view', "releaseID=$releaseID")));
}
$builds = $this->loadModel('build')->getBuildPairs($productID, $branch, 'notrunk|withbranch', 0, 'execution', '', false);
$releasedBuilds = $this->release->getReleasedBuilds($productID, $branch);
foreach($releasedBuilds as $build) unset($builds[$build]);
unset($builds['trunk']);
/* Get the builds of the linked stories or bugs. */
$notEmptyBuilds = array();
@@ -138,20 +138,17 @@ class release extends control
/* Get release and build. */
$release = $this->release->getById((int)$releaseID);
$this->commonAction($release->product, $release->branch);
$build = $this->build->getById($release->build);
$builds = $this->loadModel('build')->getBuildPairs($release->product, $release->branch, 'notrunk|withbranch', $release->project, 'project', $release->build, false);
$releasedBuilds = $this->release->getReleasedBuilds($release->product, $release->branch);
foreach($releasedBuilds as $releasedBuild)
{
if($releasedBuild != $build->id) unset($builds[$releasedBuild]);
if(strpos(',' . trim($release->build, ',') . ',', ",{$releasedBuild},") === false) unset($builds[$releasedBuild]);
}
unset($builds['trunk']);
$this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->release->edit;
$this->view->position[] = $this->lang->release->edit;
$this->view->release = $release;
$this->view->build = $build;
$this->view->builds = $builds;
$this->view->users = $this->loadModel('user')->getPairs('noclosed');
+25 -9
View File
@@ -96,12 +96,19 @@ class releaseModel extends model
*/
public function getReleasedBuilds($productID, $branch = 'all')
{
$releases = $this->dao->select('build')->from(TABLE_RELEASE)
$builds = $this->dao->select('build')->from(TABLE_RELEASE)
->where('deleted')->eq(0)
->andWhere('product')->eq($productID)
->beginIF($branch !== 'all')->andWhere('branch')->eq($branch)->fi()
->fetchAll('build');
return array_keys($releases);
->fetchPairs('build');
$buildIDList = array();
foreach($builds as $build)
{
$build = explode(',', $build);
$buildIDList = array_merge($buildIDList, $build);
}
return $buildIDList;
}
/**
@@ -146,6 +153,7 @@ class releaseModel extends model
->setDefault('stories', '')
->setDefault('createdBy', $this->app->user->account)
->setDefault('createdDate', helper::now())
->join('build', ',')
->join('stories', ',')
->join('bugs', ',')
->join('mailto', ',')
@@ -196,14 +204,21 @@ class releaseModel extends model
if($release->build)
{
$buildInfo = $this->dao->select('project, branch, stories, bugs')->from(TABLE_BUILD)->where('id')->eq($release->build)->fetch();
$release->branch = $buildInfo->branch;
$release->project = $buildInfo->project;
if($this->post->sync == 'true')
$builds = $this->dao->select('project, branch, stories, bugs')->from(TABLE_BUILD)->where('id')->in($release->build)->fetchAll();
foreach($builds as $build)
{
$release->stories = $buildInfo->stories;
$release->bugs = $buildInfo->bugs;
$branches[$build->branch] = $build->branch;
$projects[$build->project] = $build->project;
if($this->post->sync == 'true')
{
$release->stories .= $build->stories;
$release->bugs .= $build->bugs;
}
}
$release->branch = implode(',', $branches);
$release->project = implode(',', $projects);
}
$release = $this->loadModel('file')->processImgURL($release, $this->config->release->editor->create['id'], $this->post->uid);
$this->dao->insert(TABLE_RELEASE)->data($release)
@@ -271,6 +286,7 @@ class releaseModel extends model
->add('branch', (int)$branch)
->setDefault('mailto', '')
->setDefault('deleteFiles', array())
->join('build', ',')
->join('mailto', ',')
->setIF(!$this->post->marker, 'marker', 0)
->cleanInt('product')
+1 -1
View File
@@ -35,7 +35,7 @@
</tr>
<tr>
<th><?php echo $lang->release->build;?></th>
<td><?php echo html::select('build', $builds, '', "class='form-control chosen'");?></td>
<td><?php echo html::select('build[]', $builds, '', "class='form-control chosen' multiple");?></td>
<td>
<icon class='icon icon-help' data-toggle='popover' data-trigger='focus hover' data-placement='right' data-tip-class='text-muted popover-sm' data-content="<?php echo $lang->release->tips;?>"></icon>
</td>
+1 -1
View File
@@ -37,7 +37,7 @@
</tr>
<tr>
<th><?php echo $lang->release->build;?></th>
<td><?php echo html::select('build', $builds, $release->build, "class='form-control chosen' required"); ?></td>
<td><?php echo html::select('build[]', $builds, $release->build, "class='form-control chosen' required multiple"); ?></td>
</tr>
<tr>
<th><?php echo $lang->release->date;?></th>