* Adjust the picker.

This commit is contained in:
daitingting
2023-07-14 07:21:41 +00:00
parent 14467c05e1
commit 3a174e0cc0
5 changed files with 45 additions and 17 deletions
+17 -4
View File
@@ -419,9 +419,12 @@ class build extends control
}
$builds = $this->build->getBuildPairs($productID, $branch, $type, 0, 'project', $build, false);
if(strpos($extra, 'multiple') !== false) $varName .= '[]';
if($isJsonView) return print(json_encode($builds));
return print(html::select($varName, $builds, $build, "class='form-control' $extra"));
$items = array();
foreach($builds as $buildID => $buildName) $items[] = array('text' => $buildName, 'value' => $buildID);
return print(json_encode($items));
}
/**
@@ -475,6 +478,7 @@ class build extends control
}
if(empty($projectID)) return $this->ajaxGetProductBuilds($productID, $varName, $build, $branch, $index, $type, $extra);
$builds = $this->build->getBuildPairs($productID, $branch, $type, $projectID, 'project', $build, false);
if($isJsonView) return print(json_encode($builds));
@@ -484,7 +488,10 @@ class build extends control
if(empty($id)) continue;
$items[] = array('text' => $name, 'value' => $id, 'keys' => $name);
}
if($isJsonView) return print(json_encode($builds));
return print(json_encode($items));
}
/**
@@ -502,7 +509,7 @@ class build extends control
* @access public
* @return string
*/
public function ajaxGetExecutionBuilds($executionID, $productID, $varName, $build = '', $branch = 'all', $index = 0, $needCreate = false, $type = 'normal', $number = '')
public function ajaxGetExecutionBuilds(int $executionID, int $productID, string $varName, string $build = '', string|int $branch = 'all', int $index = 0, bool $needCreate = false, string $type = 'normal', string $number = '')
{
$isJsonView = $this->app->getViewType() == 'json';
if($varName == 'openedBuild')
@@ -539,7 +546,13 @@ class build extends control
$builds = $this->build->getBuildPairs($productID, $branch, 'noempty,notrunk', $executionID, 'execution', '', false);
if($isJsonView) return print(json_encode($builds));
return print(html::select('build', array('') + $builds, $build, "class='form-control'"));
$items = array();
foreach($builds as $buildID => $buildName)
{
$items[] = array('text' => $buildName, 'value' => $buildID);
}
return print(json_encode($items));
}
if($varName == 'dropdownList')
{
+7 -3
View File
@@ -1576,11 +1576,15 @@ class testtask extends control
* @access public
* @return void
*/
public function ajaxGetTestReports($productID)
public function ajaxGetTestReports(int $productID)
{
/* Testreport list. */
$pairs = $this->loadModel('testreport')->getPairs($productID);
return print(html::select('testreport', array('') + $pairs, '', "class='form-control chosen'"));
$testReportPairs = $this->loadModel('testreport')->getPairs($productID);
$items = array();
foreach($testReportPairs as $testReportID => $testReportName) $items[] = array('text' => $testReportName, 'value' => $testReportID);
return print(json_encode($items));
}
/**
+17 -8
View File
@@ -26,15 +26,21 @@ function loadExecutionRelated()
*/
function loadExecutionBuilds(executionID)
{
var selectedBuild = $('#build').val();
const productID = $('[name=product]').val();
var selectedBuild = $('[name=build]').val();
if(!selectedBuild) selectedBuild = 0;
var link = $.createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + $('#product').val() + '&varName=testTaskBuild&build=' + selectedBuild);
if(executionID == 0) link = $.createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + $('#product').val() + '&varName=build&build=' + selectedBuild + '&branch=&index=&needCreate=&type=noempty,notrunk,withexecution');
var link = $.createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + '&varName=testTaskBuild&build=' + selectedBuild);
if(executionID == 0) link = $.createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=build&build=' + selectedBuild + '&branch=&index=&needCreate=&type=noempty,notrunk,withexecution');
$.get(link, function(data)
{
$('#build').replaceWith(data);
if(data)
{
data = JSON.parse(data);
$('#build').picker({items: data});
$('#build').picker('setValue', '0');
}
});
}
@@ -47,11 +53,14 @@ function loadExecutionBuilds(executionID)
*/
function loadTestReports(productID)
{
link = $.createLink('testtask', 'ajaxGetTestReports', 'productID=' + productID);
$.get(link, function(data)
$.get($.createLink('testtask', 'ajaxGetTestReports', 'productID=' + productID), function(data)
{
if(!data) data = '<select id="testreport" name="testreport" class="form-control"></select>';
$('#testreport').replaceWith(data);
if(data)
{
data = JSON.parse(data);
$('#testreport').picker({items: data});
$('#testreport').picker('setValue', '0');
}
});
}
+3 -2
View File
@@ -6,11 +6,12 @@
*/
function loadProductRelated()
{
const productID = $('[name=product]').val();
const productID = $('[name=product]').val();
const executionID = $('[name=execution]').val();
loadExecutions(productID);
loadTestReports(productID);
loadExecutionBuilds(productID)
loadExecutionBuilds(executionID)
}
/**
+1
View File
@@ -54,6 +54,7 @@ formPanel
set::seg(true),
picker
(
setID('build'),
set::name('build'),
set::items($builds),
set::required(true),