* Code for task #95401.
This commit is contained in:
@@ -261,7 +261,7 @@ class branch extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetBranches($productID, $oldBranch = 0, $browseType = 'all', $projectID = 0, $withMainBranch = true, $isTwins = 'no', $fieldID = '0', $multiple = '')
|
||||
public function ajaxGetBranches(int $productID, int $oldBranch = 0, string $browseType = 'all', int $projectID = 0, bool $withMainBranch = true, string $isTwins = 'no', string $fieldID = '0', string $multiple = '')
|
||||
{
|
||||
$product = $this->loadModel('product')->getById($productID);
|
||||
if(empty($product) or $product->type == 'normal') return;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.items-center {align-items: center !important;}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Load branches
|
||||
*
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
window.loadBranches = function(productID)
|
||||
{
|
||||
productID = parseInt(productID);
|
||||
if(!productID) productID = $(this).val();
|
||||
if($('input[name=isIntegrated]:checked').val() == 'yes')
|
||||
{
|
||||
$('#branch').closest('.form-row').addClass('hidden');
|
||||
return false;
|
||||
}
|
||||
|
||||
let oldBranch = 0;
|
||||
if(typeof(productGroups[productID]) != "undefined")
|
||||
{
|
||||
oldBranch = productGroups[productID]['branches'];
|
||||
}
|
||||
|
||||
$.get($.createLink('branch', 'ajaxGetBranches', 'productID=' + productID + '&oldBranch=0¶m=active&projectID=' + $('#execution').val() + '&withMainBranch=true&isSiblings=no&fieldID=0&multiple=multiple'), function(data)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
$('#branch').replaceWith(data);
|
||||
$('#branch').closest('.form-row').removeClass('hidden');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#branch').closest('.form-row').addClass('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
$().ready(function()
|
||||
{
|
||||
$(document).on('click', '#lastBuildBtn', function()
|
||||
{
|
||||
$('#name').val($(this).text());
|
||||
});
|
||||
|
||||
$(document).on('change', '#product, #branch', function()
|
||||
{
|
||||
var projectID = $('#project').val();
|
||||
var productID = $('#product').val();
|
||||
$.get($.createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=builds&build=&branch=all&index=&needCreate=&type=noempty,notrunk,separate,singled&extra=multiple'), function(data)
|
||||
{
|
||||
$('#builds').replaceWith(data);
|
||||
$('#builds').attr('data-placeholder', multipleSelect);
|
||||
});
|
||||
|
||||
$.get($.createLink('product', 'ajaxGetProductById', 'produtID=' + productID), function(data)
|
||||
{
|
||||
$('#branch').closest('.form-label').text(data.branchName);
|
||||
}, 'json');
|
||||
});
|
||||
|
||||
$(document).on('change', 'input[name=isIntegrated]', function()
|
||||
{
|
||||
var projectID = $('#project').val();
|
||||
var executionID = $('#execution').val();
|
||||
|
||||
if($(this).val() == 'no')
|
||||
{
|
||||
$('#execution').closest('.form-row').removeClass('hidden');
|
||||
$('#builds').closest('.form-row').addClass('hidden');
|
||||
loadProducts(executionID);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#execution').closest('.form-row').addClass('hidden');
|
||||
$('#builds').closest('.form-row').removeClass('hidden');
|
||||
|
||||
loadProducts(projectID);
|
||||
var productID = $('#product').val();
|
||||
$.get($.createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=builds&build=&branch=all&index=&needCreate=&type=noempty,notrunk,separate,singled&extra=multiple'), function(data)
|
||||
{
|
||||
$('#builds').replaceWith(data);
|
||||
$('#builds').attr('data-placeholder', multipleSelect);
|
||||
});
|
||||
}
|
||||
});
|
||||
loadBranches();
|
||||
});
|
||||
|
||||
/**
|
||||
* Load products.
|
||||
*
|
||||
* @param int $executionID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadProducts(executionID)
|
||||
{
|
||||
executionID = parseInt(executionID);
|
||||
if(!executionID) executionID = $(this).val();
|
||||
$.get($.createLink('product', 'ajaxGetProducts', 'executionID=' + executionID), function(data)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
if(data.indexOf("required") != -1)
|
||||
{
|
||||
$('#productBox').addClass('required');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#productBox').removeClass('required');
|
||||
}
|
||||
|
||||
$('#product').replaceWith(data);
|
||||
|
||||
$.get($.createLink('product', 'ajaxGetProductById', 'produtID=' + $("#product").val()), function(data)
|
||||
{
|
||||
$('#branch').closest('.form-label').text(data.branchName);
|
||||
}, 'json');
|
||||
|
||||
loadBranches($('#product').val());
|
||||
}
|
||||
});
|
||||
|
||||
loadLastBuild();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load last build
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadLastBuild()
|
||||
{
|
||||
var isIntegrated = $('input[name=isIntegrated]:checked').val();
|
||||
var projectID = $('#project').val();
|
||||
var executionID = $('#execution').val();
|
||||
if(isIntegrated == 'yes') executionID = 0;
|
||||
$.get($.createLink('build', 'ajaxGetLastBuild', 'projectID=' + projectID + '&executionID=' + executionID), function(data)
|
||||
{
|
||||
$('#lastBuildBox').html(data);
|
||||
});
|
||||
}
|
||||
@@ -808,7 +808,7 @@ class buildModel extends model
|
||||
* @param object $build
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function buildOperateMenu(object $build, string $type = 'view'): array
|
||||
{
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The create view file of build module of ZenTaoPMS.
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Shujie Tian<tianshujie@easycorp.ltd>
|
||||
* @package build
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
/* zin: Set variables to define picker options for form. */
|
||||
jsVar('multipleSelect', $lang->build->placeholder->multipleSelect);
|
||||
jsVar('projectID', $projectID);
|
||||
jsVar('executionID', $executionID);
|
||||
jsVar('productGroups', $productGroups);
|
||||
|
||||
$integratedRow = '';
|
||||
if($app->tab == 'project' && !empty($multipleProject))
|
||||
{
|
||||
$integratedRow = formRow(
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::label($lang->build->integrated),
|
||||
radioList
|
||||
(
|
||||
set::name('isIntegrated'),
|
||||
set::items($lang->build->isIntegrated),
|
||||
set::value('no'),
|
||||
set::inline(true)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$executionRow = '';
|
||||
if(!empty($multipleProject))
|
||||
{
|
||||
$executionRow = formRow(
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::name('execution'),
|
||||
set::label($lang->executionCommon),
|
||||
set::value($executionID),
|
||||
set::items($executions),
|
||||
set::required(true),
|
||||
on::change('loadProducts')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$productRow = '';
|
||||
if(!$hidden)
|
||||
{
|
||||
$productBox = '';
|
||||
if(!empty($products) || !$executionID)
|
||||
{
|
||||
$productBox = formGroup(
|
||||
set::width('1/2'),
|
||||
set::id('productBox'),
|
||||
set::name('product'),
|
||||
set::label($lang->build->product),
|
||||
set::value(empty($product) ? '' : $product->id),
|
||||
set::items($products),
|
||||
set::required(true),
|
||||
on::change('loadBranches')
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$productBox = formGroup(
|
||||
set::width('1/2'),
|
||||
set::id('productBox'),
|
||||
set::label($lang->build->product),
|
||||
setClass('items-center'),
|
||||
html(sprintf($lang->build->noProduct, helper::createLink('execution', 'manageproducts', "executionID={$executionID}&from=buildCreate", '', true), $app->tab)),
|
||||
);
|
||||
}
|
||||
$productRow = formRow(
|
||||
$productBox,
|
||||
);
|
||||
}
|
||||
|
||||
if(empty($product)) $product = new stdclass();
|
||||
$productType = zget($product, 'type', 'normal');
|
||||
$productBranches = zget($product, 'branches', array());
|
||||
|
||||
formPanel
|
||||
(
|
||||
set::title($lang->build->create),
|
||||
$integratedRow,
|
||||
$executionRow,
|
||||
$productRow,
|
||||
formRow
|
||||
(
|
||||
setClass(!empty($product) && $product->type != 'normal' ? '' : 'hidden'),
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::name('branch[]'),
|
||||
set::label($lang->product->branchName[$productType]),
|
||||
set::value(key($productBranches)),
|
||||
set::items($branches),
|
||||
)
|
||||
),
|
||||
formRow
|
||||
(
|
||||
setClass('hidden'),
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::name('builds[]'),
|
||||
set::label($lang->build->builds),
|
||||
set::items(array()),
|
||||
),
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
setClass('ml-4 items-center'),
|
||||
icon('help')
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::name('name'),
|
||||
set::label($lang->build->nameAB),
|
||||
),
|
||||
$lastBuild ? formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
setClass('items-center'),
|
||||
div
|
||||
(
|
||||
set::id('lastBuildBox'),
|
||||
setClass('text-gray'),
|
||||
div
|
||||
(
|
||||
setClass('help-block'),
|
||||
html(' ' . $lang->build->last . ': <a class="code label label-badge label-light" id="lastBuildBtn">' . $lastBuild->name . '</a>'),
|
||||
),
|
||||
)
|
||||
) : '',
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::name('builder'),
|
||||
set::label($lang->build->builder),
|
||||
set::value($app->user->account),
|
||||
set::items($users),
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::width('1/2'),
|
||||
set::name('date'),
|
||||
set::label($lang->build->date),
|
||||
set::control('date'),
|
||||
set::value(helper::today()),
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::name('scmPath'),
|
||||
set::label($lang->build->scmPath),
|
||||
set::placeholder($lang->build->placeholder->scmPath),
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::name('filePath'),
|
||||
set::label($lang->build->filePath),
|
||||
set::placeholder($lang->build->placeholder->filePath),
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::name('files[]'),
|
||||
set::label($lang->build->files),
|
||||
set::control('file')
|
||||
),
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::label($lang->build->desc),
|
||||
editor
|
||||
(
|
||||
set::name('desc'),
|
||||
set::rows('10'),
|
||||
)
|
||||
),
|
||||
formGroup
|
||||
(
|
||||
setClass('hidden'),
|
||||
set::name('project'),
|
||||
set::value($projectID),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
/* ====== Render page ====== */
|
||||
render();
|
||||
@@ -883,7 +883,7 @@ class product extends control
|
||||
$products = $this->product->getProductPairsByProject($executionID, $status);
|
||||
|
||||
if(empty($products)) return printf($this->lang->build->noProduct, $this->createLink('execution', 'manageproducts', "executionID=$executionID&from=buildCreate", '', 'true'), 'project');
|
||||
return print(html::select('product', $products, '', "onchange='loadBranches(this.value);' class='form-control chosen' required data-toggle='modal' data-type='iframe'"));
|
||||
return print(html::select('product', $products, '', "onchange='loadBranches();' class='form-control chosen' required"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user