* Finish task #8197.
This commit is contained in:
@@ -8,3 +8,20 @@ $config->build->edit->requiredFields = 'product,project,name,builder,date';
|
||||
$config->build->editor = new stdclass();
|
||||
$config->build->editor->create = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
$config->build->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools');
|
||||
|
||||
global $lang;
|
||||
$config->build->search['module'] = 'build';
|
||||
$config->build->search['fields']['name'] = $lang->build->name;
|
||||
$config->build->search['fields']['id'] = $lang->build->id;
|
||||
$config->build->search['fields']['product'] = '所属' . $lang->build->product;
|
||||
$config->build->search['fields']['scmPath'] = $lang->build->scmPath;
|
||||
$config->build->search['fields']['filePath'] = $lang->build->filePath;
|
||||
$config->build->search['fields']['date'] = $lang->build->date;
|
||||
$config->build->search['fields']['builder'] = $lang->build->builder;
|
||||
|
||||
$config->build->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
|
||||
$config->build->search['params']['product'] = array('operator' => '=', 'control' => 'select', 'values' => 'products');
|
||||
$config->build->search['params']['scmPath'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
|
||||
$config->build->search['params']['filePath'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
|
||||
$config->build->search['params']['date'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date');
|
||||
$config->build->search['params']['builder'] = array('operator' => '=', 'control' => 'select', 'values' => 'users');
|
||||
|
||||
+47
-2
@@ -52,11 +52,13 @@ class buildModel extends model
|
||||
/**
|
||||
* Get builds of a project.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $projectID
|
||||
* @param string $type all|product|bysearch
|
||||
* @param int|string $param productID|buildQuery
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProjectBuilds($projectID)
|
||||
public function getProjectBuilds($projectID, $type, $param)
|
||||
{
|
||||
return $this->dao->select('t1.*, t2.name as projectName, t3.name as productName, t4.name as branchName')
|
||||
->from(TABLE_BUILD)->alias('t1')
|
||||
@@ -65,10 +67,53 @@ class buildModel extends model
|
||||
->leftJoin(TABLE_BRANCH)->alias('t4')->on('t1.branch = t4.id')
|
||||
->where('t1.project')->eq((int)$projectID)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->beginIF($type == 'product' and $param)->andWhere('t1.product')->eq($param)->fi()
|
||||
->beginIF($type == 'bysearch')->andWhere($param)->fi()
|
||||
->orderBy('t1.date DESC, t1.id desc')
|
||||
->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get builds of a project by search.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $queryID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProjectBuildsBySearch($projectID, $queryID)
|
||||
{
|
||||
/* If there are saved query conditions, reset the session. */
|
||||
if($queryID)
|
||||
{
|
||||
$query = $this->loadModel('search')->getQuery($queryID);
|
||||
if($query)
|
||||
{
|
||||
$this->session->set('projectBuildQuery', $query->sql);
|
||||
$this->session->set('projectBuildForm', $query->form);
|
||||
}
|
||||
}
|
||||
|
||||
$allProduct = "`product` = 'all'";
|
||||
$buildQuery = $this->session->projectBuildQuery;
|
||||
if(strpos($this->session->projectBuildQuery, $allProduct) !== false)
|
||||
{
|
||||
$buildQuery = str_replace($allProduct, '1', $this->session->projectBuildQuery);
|
||||
}
|
||||
|
||||
/* Distinguish between repeated fields. */
|
||||
$fields = array('id' => '`id`', 'name' => '`name`', 'product' => '`product`');
|
||||
foreach($fields as $field)
|
||||
{
|
||||
if(strpos($this->session->projectBuildQuery, $field) !== false)
|
||||
{
|
||||
$buildQuery = str_replace($field, "t1." . $field, $buildQuery);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->getProjectBuilds($projectID, 'bysearch', $buildQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get builds of a project in pairs.
|
||||
*
|
||||
|
||||
@@ -856,33 +856,59 @@ class project extends control
|
||||
* Browse builds of a project.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param string $type all|product|bysearch
|
||||
* @param int $param
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function build($projectID = 0)
|
||||
public function build($projectID = 0, $type = 'all', $param = 0)
|
||||
{
|
||||
/* Load module and set session. */
|
||||
$this->loadModel('testtask');
|
||||
$this->session->set('buildList', $this->app->getURI(true));
|
||||
|
||||
$project = $this->commonAction($projectID);
|
||||
$projectID = $project->id;
|
||||
|
||||
/* Header and position. */
|
||||
$this->view->title = $project->name . $this->lang->colon . $this->lang->project->build;
|
||||
$this->view->position[] = html::a(inlink('browse', "projectID=$projectID"), $project->name);
|
||||
$this->view->position[] = $this->lang->project->build;
|
||||
/* Get products' list. */
|
||||
$products = $this->loadModel('product')->getPairs('nocode');
|
||||
$products = array($this->lang->company->product) + $products;
|
||||
|
||||
$builds = $this->loadModel('build')->getProjectBuilds((int)$projectID);
|
||||
/* Build the search form. */
|
||||
$type = strtolower($type);
|
||||
$queryID = ($type == 'bysearch') ? (int)$param : 0;
|
||||
$actionURL = $this->createLink('project', 'build', "projectID=$projectID&type=bysearch&queryID=myQueryID");
|
||||
$this->project->buildVersionSearchForm($products, $queryID, $actionURL);
|
||||
|
||||
/* Get builds. */
|
||||
if($type == 'bysearch')
|
||||
{
|
||||
$builds = $this->loadModel('build')->getProjectBuildsBySearch((int)$projectID, $param);
|
||||
}
|
||||
else
|
||||
{
|
||||
$builds = $this->loadModel('build')->getProjectBuilds((int)$projectID, $type, $param);
|
||||
}
|
||||
|
||||
/* Set project builds. */
|
||||
$projectBuilds = array();
|
||||
if(!empty($builds))
|
||||
{
|
||||
foreach($builds as $build) $projectBuilds[$build->product][] = $build;
|
||||
}
|
||||
|
||||
/* Get builds. */
|
||||
/* Header and position. */
|
||||
$this->view->title = $project->name . $this->lang->colon . $this->lang->project->build;
|
||||
$this->view->position[] = html::a(inlink('browse', "projectID=$projectID"), $project->name);
|
||||
$this->view->position[] = $this->lang->project->build;
|
||||
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->buildsTotal = count($builds);
|
||||
$this->view->projectBuilds = $projectBuilds;
|
||||
$this->view->projectID = $projectID;
|
||||
$this->view->product = $type == 'product' ? $param : 'all';
|
||||
$this->view->products = $products;
|
||||
$this->view->type = $type;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Change product.
|
||||
*
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function changeProduct(productID)
|
||||
{
|
||||
link = createLink('project', 'build', 'projectID=' + projectID + '&type=product¶m=' + productID);
|
||||
location.href = link;
|
||||
}
|
||||
@@ -2485,6 +2485,31 @@ class projectModel extends model
|
||||
$this->loadModel('search')->setSearchParams($this->config->project->search);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build version search form.
|
||||
*
|
||||
* @param array $products
|
||||
* @param int $queryID
|
||||
* @param string $actionURL
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function buildVersionSearchForm($products, $queryID, $actionURL)
|
||||
{
|
||||
/* Load model and set products. */
|
||||
$this->loadModel('build');
|
||||
$products['0'] = '';
|
||||
$products['all'] = $this->lang->product->allProduct;
|
||||
|
||||
/* Set search param. */
|
||||
$this->config->build->search['module'] = 'projectBuild';
|
||||
$this->config->build->search['actionURL'] = $actionURL;
|
||||
$this->config->build->search['queryID'] = $queryID;
|
||||
$this->config->build->search['params']['product']['values'] = $products;
|
||||
|
||||
$this->loadModel('search')->setSearchParams($this->config->build->search);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Kanban tasks
|
||||
*
|
||||
|
||||
@@ -12,18 +12,28 @@
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php js::set('confirmDelete', $lang->build->confirmDelete)?>
|
||||
<?php js::set('projectID', $projectID)?>
|
||||
<div id="mainMenu" class="clearfix table-row">
|
||||
<div class="btn-toolbar pull-left">
|
||||
<span class='btn btn-link btn-active-text'>
|
||||
<span class='text'><?php echo $lang->project->build;?></span>
|
||||
<span class='label label-light label-badge'><?php echo $buildsTotal;?></span>
|
||||
</span>
|
||||
<?php
|
||||
$label = "<span class='text'>{$lang->project->build}</span>";
|
||||
$active = '';
|
||||
if($type == 'all')
|
||||
{
|
||||
$active = 'btn-active-text';
|
||||
$label .= " <span class='label label-light label-badge'>{$buildsTotal}</span>";
|
||||
}
|
||||
echo html::a(inlink('build', "projectID={$projectID}&type=all"), $label, '', "class='btn btn-link $active' id='all'")
|
||||
?>
|
||||
<div class="input-control space w-150px"><?php echo html::select('product', $products, $product, 'onchange=changeProduct(this.value) class="form-control chosen"');?></div>
|
||||
</div>
|
||||
<a class="btn btn-link querybox-toggle" id="bysearchTab"><i class="icon icon-search muted"></i> <?php echo $lang->project->byQuery;?></a>
|
||||
<div class="btn-toolbar pull-right">
|
||||
<?php common::printLink('build', 'create', "project=$project->id", "<i class='icon icon-plus'></i> " . $lang->build->create, '', "class='btn btn-primary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mainContent">
|
||||
<div class="cell <?php if($type == 'bysearch') echo 'show';?>" id="queryBox" data-module='projectBuild'></div>
|
||||
<?php if(empty($projectBuilds)):?>
|
||||
<div class="table-empty-tip">
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user