* Merge the cells of a table.

This commit is contained in:
tianshujie
2023-07-31 10:37:46 +08:00
parent ea686149b6
commit f07878484f
3 changed files with 52 additions and 11 deletions
+21 -10
View File
@@ -12,12 +12,8 @@ window.renderCell = function(result, {col, row})
if(col.name == 'build')
{
result[0] = '';
for(key in row.data.builds)
{
let moduleName = row.data.builds[key].execution > 0 ? 'build' : 'projectbuild';
let branchLabel = showBranch ? "<span class='label label-outline label-badge'>" + row.data.builds[key].branchName + '</span> ' : '';
result[result.length] = {html: branchLabel + "<a href='" + $.createLink(moduleName, 'view', 'buildID=' + row.data.builds[key].id) + "' title='" + row.data.builds[key].name + "'>" + row.data.builds[key].name + '</a>'}
}
let branchLabel = showBranch ? "<span class='label label-outline label-badge mr-1'>" + row.data.build.branchName + '</span> ' : '';
result[result.length] = {html: branchLabel + "<a href='" + row.data.build.link + "' title='" + row.data.build.name + "'>" + row.data.build.name + '</a>'}
return result;
}
@@ -25,10 +21,8 @@ window.renderCell = function(result, {col, row})
{
result[0] = '';
if(row.data.builds.length == 0) return result;
for(key in row.data.builds)
{
result[result.length] = {html: row.data.builds[key].projectName};
}
result[result.length] = {html: row.data.build.projectName};
return result;
}
@@ -74,3 +68,20 @@ window.setStatistics = function()
return {html: summary};
}
/**
* 合并单元格。
* cell span in the column.
*
* @param object cell
* @access public
* @return object
*/
window.getCellSpan = function(cell)
{
if(['id', 'name', 'branch', 'status', 'date', 'actions'].includes(cell.col.name) && cell.row.data.rowspan)
{
return {rowSpan: cell.row.data.rowspan};
}
}
+2
View File
@@ -41,7 +41,9 @@ dtable
(
set::cols(array_values($config->release->dtable->fieldList)),
set::data(array_values($releases)),
set::plugins(array('cellspan')),
set::onRenderCell(jsRaw('window.renderCell')),
set::getCellSpan(jsRaw('window.getCellSpan')),
set::sortLink(jsRaw('createSortLink')),
set::footer([jsRaw('function(){return window.setStatistics.call(this);}'), 'flex', 'pager']),
set::footPager(
+29 -1
View File
@@ -21,12 +21,40 @@ class releaseZen extends release
*/
protected function processReleaseListData(array $releaseList): array
{
$releases = array();
$this->loadModel('project');
$this->loadModel('execution');
foreach($releaseList as $release)
{
$buildCount = count($release->builds);
$release->rowspan = $buildCount;
$release->actions = $this->release->buildActionList($release);
if(!empty($release->builds))
{
foreach($release->builds as $build)
{
$releaseInfo = clone $release;
$moduleName = $build->execution ? 'build' : 'projectbuild';
$canClickable = false;
if($moduleName == 'projectbuild' && $this->project->checkPriv($build->project)) $canClickable = true;
if($moduleName == 'build' && $this->execution->checkPriv($build->execution)) $canClickable = true;
$build->link = $canClickable ? $this->createLink($moduleName, 'view', "buildID={$build->id}") : '';
$releaseInfo->build = $build;
$releases[] = $releaseInfo;
}
}
else
{
$releases[] = $release;
}
}
return array_values($releaseList);
return $releases;
}
}