* Refact edit build page and build list page.

* Display dropdown list of builds in detail page of build.
This commit is contained in:
liugang
2018-04-25 17:45:29 +08:00
parent c5371ac7e8
commit aff4e31c97
4 changed files with 91 additions and 57 deletions
+13 -2
View File
@@ -196,7 +196,7 @@ class build extends control
if($this->config->global->flow == 'onlyTest')
{
$products = $this->loadModel('product')->getPairs();
$this->product->setMenu($products, $build->product);
$this->product->setMenu($products, $build->product, $buildID);
$this->lang->build->menu = $this->lang->product->menu;
$this->view->title = "BUILD #$build->id $build->name - " . $build->productName;
@@ -211,7 +211,7 @@ class build extends control
$stages = $this->dao->select('*')->from(TABLE_STORYSTAGE)->where('story')->in($build->stories)->andWhere('branch')->eq($build->branch)->fetchPairs('story', 'stage');
foreach($stages as $storyID => $stage)$stories[$storyID]->stage = $stage;
$this->loadModel('project')->setMenu($this->project->getPairs(), $build->project);
$this->loadModel('project')->setMenu($this->project->getPairs(), $build->project, $buildID);
$projects = $this->project->getPairs('empty');
$this->view->title = "BUILD #$build->id $build->name - " . $projects[$build->project];
@@ -355,6 +355,17 @@ class build extends control
if($isJsonView) die(json_encode($builds));
else die(html::select('build', $builds, $build, "class='form-control'"));
}
if($varName == 'dropdownList')
{
$builds = $this->build->getProjectBuildPairs($projectID, $productID, $branch, 'noempty,notrunk');
if($isJsonView) die(json_encode($builds));
$list = "<div class='list-group'>";
foreach($builds as $buildID => $buildName) $list .= html::a(inlink('view', "buildID={$buildID}"), $buildName);
$list .= '</div>';
die($list);
}
}
/**
+3 -3
View File
@@ -16,9 +16,9 @@
<div class='center-block'>
<div class='main-header'>
<h2>
<span class='prefix'><?php echo html::icon($lang->icons['build']);?> <strong><?php echo $build->id;?></strong></span>
<strong><?php echo html::a($this->createLink('build', 'view', 'build=' . $build->id), $build->name, '_blank');?></strong>
<small class='text-muted'> <?php echo $lang->build->edit;?> <?php echo html::icon($lang->icons['edit']);?></small>
<span class='label-id'><?php echo $build->id;?></span>
<?php echo html::a($this->createLink('build', 'view', 'build=' . $build->id), $build->name);?>
<small><?php echo $lang->arrow . $lang->build->edit;?></small>
</h2>
</div>
<form class='load-indicator main-form form-ajax' method='post' id='dataform' enctype='multipart/form-data'>
+20 -3
View File
@@ -64,11 +64,12 @@ class projectModel extends model
*
* @param array $projects
* @param int $projectID
* @param int $buildID
* @param string $extra
* @access public
* @return void
*/
public function setMenu($projects, $projectID, $extra = '')
public function setMenu($projects, $projectID, $buildID = 0, $extra = '')
{
/* Check the privilege. */
$project = $this->getById($projectID);
@@ -99,7 +100,7 @@ class projectModel extends model
$this->cookie->projectMode = 'all';
}
$selectHtml = $this->select($projects, $projectID, $moduleName, $methodName, $extra);
$selectHtml = $this->select($projects, $projectID, $buildID, $moduleName, $methodName, $extra);
$label = $this->lang->project->index;
if($moduleName == 'project' && $methodName == 'all') $label = $this->lang->project->allProjects;
@@ -126,13 +127,14 @@ class projectModel extends model
*
* @param array $projects
* @param int $projectID
* @param int $buildID
* @param string $currentModule
* @param string $currentMethod
* @param string $extra
* @access public
* @return string
*/
public function select($projects, $projectID, $currentModule, $currentMethod, $extra = '')
public function select($projects, $projectID, $buildID, $currentModule, $currentMethod, $extra = '')
{
if(!$projectID) return;
@@ -146,6 +148,21 @@ class projectModel extends model
$output .= '<div class="input-control search-box search-box-circle has-icon-left has-icon-right search-example"><input type="search" class="form-control search-input" /><label class="input-control-icon-left search-icon"><i class="icon icon-search"></i></label><a class="input-control-icon-right search-clear-btn"><i class="icon icon-close icon-sm"></i></a></div>';
$output .= "</div></div></div>";
if($isMobile) $output = "<a id='currentItem' href=\"javascript:showSearchMenu('project', '$projectID', '$currentModule', '$currentMethod', '$extra')\">{$currentProject->name} <span class='icon-caret-down'></span></a><div id='currentItemDropMenu' class='hidden affix enter-from-bottom layer'></div>";
if($buildID)
{
setCookie('lastBuild', $buildID, $this->config->cookieLife, $this->config->webRoot);
$currentBuild = $this->loadModel('build')->getById($buildID);
if($currentBuild)
{
$dropMenuLink = helper::createLink('build', 'ajaxGetProjectBuilds', "projectID=$projectID&productID=&varName=dropdownList");
$output .= "<div class='btn-group angle-btn'><div class='btn-group'><button data-toggle='dropdown' type='button' class='btn btn-limit' id='currentItem'>{$currentBuild->name} <span class='caret'></span></button><div id='dropMenu' class='dropdown-menu search-list' data-ride='searchList' data-url='$dropMenuLink'>";
$output .= '<div class="input-control search-box search-box-circle has-icon-left has-icon-right search-example"><input type="search" class="form-control search-input" /><label class="input-control-icon-left search-icon"><i class="icon icon-search"></i></label><a class="input-control-icon-right search-clear-btn"><i class="icon icon-close icon-sm"></i></a></div>';
$output .= "</div></div></div>";
}
}
return $output;
}
+55 -49
View File
@@ -17,56 +17,62 @@
<span class='btn btn-link btn-active-text'> <span class='text'><?php echo $lang->project->build;?></span></span>
</div>
<div class="btn-toolbar pull-right">
<?php common::printIcon('build', 'create', "project=$project->id");?>
<?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" class='main-content'>
<table class="main-table table has-sort-head" id='buildList'>
<thead>
<tr>
<th class='w-id'><?php echo $lang->build->id;?></th>
<th class='w-120px'><?php echo $lang->build->product;?></th>
<th><?php echo $lang->build->name;?></th>
<th><?php echo $lang->build->scmPath;?></th>
<th><?php echo $lang->build->filePath;?></th>
<th class='w-100px'><?php echo $lang->build->date;?></th>
<th class='w-user'><?php echo $lang->build->builder;?></th>
<th class='w-200px'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
<?php foreach($builds as $build):?>
<tr>
<td><?php echo $build->id;?></td>
<td class='nobr' title='<?php echo $build->productName?>'><?php echo $build->productName;?></td>
<td class='text-left nobr'>
<?php if($build->branchName) echo "<span class='label label-info label-badge'>{$build->branchName}</span>"?>
<?php echo html::a($this->createLink('build', 'view', "build=$build->id"), $build->name);?>
</td>
<td class='text-left' title="<?php echo $build->scmPath?>"><?php echo strpos($build->scmPath, 'http') === 0 ? html::a($build->scmPath) : $build->scmPath;?></td>
<td class='text-left' title="<?php echo $build->filePath?>"><?php echo strpos($build->filePath, 'http') === 0 ? html::a($build->filePath) : $build->filePath;?></td>
<td><?php echo $build->date?></td>
<td><?php echo $users[$build->builder]?></td>
<td class='c-actions'>
<?php
if(common::hasPriv('build', 'linkstory') and common::hasPriv('build', 'view'))
{
echo html::a($this->createLink('build', 'view', "buildID=$build->id&type=story&link=true"), "<i class='icon icon-link'></i>", '', "class='btn' title='{$lang->build->linkStory}'");
}
common::printIcon('testtask', 'create', "product=$build->product&project=$project->id&build=$build->id", $build, 'list', 'bullhorn');
$lang->project->bug = $lang->project->viewBug;
common::printIcon('project', 'bug', "project=$project->id&orderBy=status&build=$build->id", $build, 'list');
common::printIcon('build', 'edit', "buildID=$build->id", $build, 'list');
if(common::hasPriv('build', 'delete', $build))
{
$deleteURL = $this->createLink('build', 'delete', "buildID=$build->id&confirm=yes");
echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"buildList\",confirmDelete)", '<i class="icon-trash"></i>', '', "class='btn' title='{$lang->build->delete}'");
}
?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<div id="mainContent">
<div class='main-table'>
<table class="table" id='buildList'>
<thead>
<tr class='text-center'>
<th class='w-id'><?php echo $lang->build->id;?></th>
<th class='w-120px'><?php echo $lang->build->product;?></th>
<th><?php echo $lang->build->name;?></th>
<th><?php echo $lang->build->scmPath;?></th>
<th><?php echo $lang->build->filePath;?></th>
<th class='w-100px'><?php echo $lang->build->date;?></th>
<th class='w-user'><?php echo $lang->build->builder;?></th>
<th class='c-actions-3'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
<?php foreach($builds as $build):?>
<tr>
<td class='text-center'><?php echo $build->id;?></td>
<td class='nobr' title='<?php echo $build->productName?>'><?php echo $build->productName;?></td>
<td class='nobr'>
<?php if($build->branchName) echo "<span class='label label-info label-badge'>{$build->branchName}</span>"?>
<?php echo html::a($this->createLink('build', 'view', "build=$build->id"), $build->name);?>
</td>
<td title="<?php echo $build->scmPath?>"><?php echo strpos($build->scmPath, 'http') === 0 ? html::a($build->scmPath) : $build->scmPath;?></td>
<td title="<?php echo $build->filePath?>"><?php echo strpos($build->filePath, 'http') === 0 ? html::a($build->filePath) : $build->filePath;?></td>
<td><?php echo $build->date?></td>
<td><?php echo $users[$build->builder]?></td>
<td class='c-actions'>
<div class='more'>
<?php
if(common::hasPriv('build', 'delete', $build))
{
$deleteURL = $this->createLink('build', 'delete', "buildID=$build->id&confirm=yes");
echo html::a("javascript:ajaxDelete(\"$deleteURL\",\"buildList\",confirmDelete)", '<i class="icon-trash"></i>', '', "class='btn' title='{$lang->build->delete}'");
}
?>
</div>
<?php
if(common::hasPriv('build', 'linkstory') and common::hasPriv('build', 'view'))
{
echo html::a($this->createLink('build', 'view', "buildID=$build->id&type=story&link=true"), "<i class='icon icon-link'></i>", '', "class='btn' title='{$lang->build->linkStory}'");
}
common::printIcon('testtask', 'create', "product=$build->product&project=$project->id&build=$build->id", $build, 'list', 'bullhorn');
$lang->project->bug = $lang->project->viewBug;
common::printIcon('project', 'bug', "project=$project->id&orderBy=status&build=$build->id", $build, 'list');
common::printIcon('build', 'edit', "buildID=$build->id", $build, 'list');
?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</div>
<?php include '../../common/view/footer.html.php';?>