diff --git a/module/execution/js/build.ui.js b/module/execution/js/build.ui.js index cb59139096..37b8158501 100644 --- a/module/execution/js/build.ui.js +++ b/module/execution/js/build.ui.js @@ -3,7 +3,7 @@ window.renderCell = function(result, {col, row}) if(col.name == 'path') { result[0] = ''; - if(row.data.scmPath) + if(row.data.pathType == 'scmPath' && row.data.scmPath) { const colorStyle = row.data.scmPath.indexOf('http') === 0 ? "style='color:#2463c7;'" : ''; let scmPathHtml = ''; @@ -15,7 +15,7 @@ window.renderCell = function(result, {col, row}) result[result.length] = {html: scmPathHtml}; } - if(row.data.filePath) + if(row.data.pathType == 'filePath' && row.data.filePath) { const colorStyle = row.data.filePath.indexOf('http') === 0 ? "style='color:#2463c7;'" : ''; let filePathHtml = ''; @@ -42,3 +42,19 @@ window.changeProduct = function() const link = changeProductLink.replace('{productID}', $(this).val()); loadPage(link); } + +/** + * 合并单元格。 + * cell span in the column. + * + * @param object cell + * @access public + * @return object + */ +window.getCellSpan = function(cell) +{ + if(['id', 'name', 'productName', 'branchName', 'builder', 'date', 'actions'].includes(cell.col.name) && cell.row.data.rowspan) + { + return {rowSpan: cell.row.data.rowspan}; + } +} diff --git a/module/execution/ui/build.html.php b/module/execution/ui/build.html.php index 7867875d07..eda15a4eef 100644 --- a/module/execution/ui/build.html.php +++ b/module/execution/ui/build.html.php @@ -47,14 +47,16 @@ jsVar('confirmDelete', $lang->build->confirmDelete); dtable ( set::userMap($users), - set::cols(array_values($config->build->dtable->fieldList)), - set::data(array_values($builds)), + set::cols($config->build->dtable->fieldList), + set::data($builds), + set::plugins(array('cellspan')), set::sortLink(jsRaw('createSortLink')), set::onRenderCell(jsRaw('window.renderCell')), + set::getCellSpan(jsRaw('window.getCellSpan')), set::footPager( usePager ( - array('linkCreator' => helper::createLink('execution', 'build', "executionID={$execution->id}&type={$type}¶m={$param}&orderBy={$orderBy}&recTotal={recTotal}&recPerPage={page}")), + array('linkCreator' => helper::createLink('execution', 'build', "executionID={$execution->id}&type={$type}¶m={$param}&orderBy={$orderBy}&recTotal={recTotal}&recPerPage={page}"), 'recTotal' => $pager->recTotal, 'recPerPage' => $pager->recPerPage), ), ), ); diff --git a/module/execution/zen.php b/module/execution/zen.php index 6069ea7fac..02cf669259 100644 --- a/module/execution/zen.php +++ b/module/execution/zen.php @@ -30,6 +30,7 @@ class executionZen extends execution /* Get branch name. */ $showBranch = false; $branchGroups = $this->loadModel('branch')->getByProducts($productIdList); + $builds = array(); foreach($buildList as $build) { $build->branchName = ''; @@ -44,12 +45,34 @@ class executionZen extends execution $build->branchName = trim($build->branchName, ','); } $build->actions = $this->build->buildActionList($build, $executionID, 'execution'); + + if($build->scmPath && $build->filePath) + { + $build->rowspan = 2; + + $buildInfo = clone $build; + $buildInfo->pathType = 'scmPath'; + $buildInfo->path = $build->scmPath; + $builds[] = $buildInfo; + + $buildInfo = clone $build; + $buildInfo->pathType = 'filePath'; + $buildInfo->path = $build->filePath; + $builds[] = $buildInfo; + } + else + { + $build->pathType = empty($build->scmPath) ? 'filePath' : 'scmPath'; + $build->path = empty($build->scmPath) ? $build->filePath : $build->scmPath; + + $builds[] = $build; + } } if(!$showBranch) unset($this->config->build->dtable->fieldList['branch']); unset($this->config->build->dtable->fieldList['execution']); - return array_values($buildList); + return $builds; } /** diff --git a/module/project/js/build.ui.js b/module/project/js/build.ui.js index b014060d37..fe8e4920e6 100644 --- a/module/project/js/build.ui.js +++ b/module/project/js/build.ui.js @@ -3,7 +3,7 @@ window.renderCell = function(result, {col, row}) if(col.name == 'path') { result[0] = ''; - if(row.data.scmPath) + if(row.data.pathType == 'scmPath' && row.data.scmPath) { const colorStyle = row.data.scmPath.indexOf('http') === 0 ? "style='color:#2463c7;'" : ''; let scmPathHtml = ''; @@ -15,7 +15,7 @@ window.renderCell = function(result, {col, row}) result[result.length] = {html: scmPathHtml}; } - if(row.data.filePath) + if(row.data.pathType == 'filePath' && row.data.filePath) { const colorStyle = row.data.filePath.indexOf('http') === 0 ? "style='color:#2463c7;'" : ''; let filePathHtml = ''; @@ -37,25 +37,9 @@ window.renderCell = function(result, {col, row}) if(col.name == 'execution') { - if(row.data.execution == 0) - { - result[0] = ''; - let executionIdList = []; - for(key in row.data.builds) - { - const build = row.data.builds[key]; - if(executionIdList.indexOf(build.execution) !== -1) continue; - - result[result.length] = {html: "" + build.executionName + ""}; - executionIdList.push(build.execution); - } - } - else - { - let executionHtml = "" + row.data.executionName + ''; - if(row.data.executionDeleted == 1) executionHtml += " " + deletedTip + ''; - result[0] = {html: executionHtml}; - } + let executionHtml = "" + row.data.executionName + ''; + if(row.data.executionDeleted == 1) executionHtml += " " + deletedTip + ''; + result[0] = {html: executionHtml}; return result; } @@ -73,3 +57,29 @@ window.changeProduct = function() const link = changeProductLink.replace('{productID}', $(this).val()); loadPage(link); } + +/** + * 合并单元格。 + * cell span in the column. + * + * @param object cell + * @access public + * @return object + */ +window.getCellSpan = function(cell) +{ + if(['id', 'name', 'productName', 'branchName', 'builder', 'date', 'actions'].includes(cell.col.name) && cell.row.data.rowspan) + { + return {rowSpan: cell.row.data.rowspan}; + } + + if(cell.col.name == 'path' && cell.row.data.pathRowspan) + { + return {rowSpan: cell.row.data.pathRowspan}; + } + + if(cell.col.name == 'execution' && cell.row.data.executionRowspan) + { + return {rowSpan: cell.row.data.executionRowspan}; + } +} diff --git a/module/project/ui/build.html.php b/module/project/ui/build.html.php index e966baddbf..81a7396a9e 100644 --- a/module/project/ui/build.html.php +++ b/module/project/ui/build.html.php @@ -54,14 +54,16 @@ jsVar('deletedTip', $lang->build->deleted); dtable ( set::userMap($users), - set::cols(array_values($config->build->dtable->fieldList)), - set::data(array_values($builds)), + set::cols($config->build->dtable->fieldList), + set::data($builds), + set::plugins(array('cellspan')), set::sortLink(jsRaw('createSortLink')), set::onRenderCell(jsRaw('window.renderCell')), + set::getCellSpan(jsRaw('window.getCellSpan')), set::footPager( usePager ( - array('linkCreator' => helper::createLink($app->rawModule, $app->rawMethod, "projectID={$project->id}&type={$type}¶m={$param}&orderBy={$orderBy}&recTotal={recTotal}&recPerPage={recPerPage}&pageID={pageID}")), + array('linkCreator' => helper::createLink($app->rawModule, $app->rawMethod, "projectID={$project->id}&type={$type}¶m={$param}&orderBy={$orderBy}&recTotal={recTotal}&recPerPage={recPerPage}&pageID={page}"), 'recTotal' => $pager->recTotal, 'recPerPage' => $pager->recPerPage), ), ), ); diff --git a/module/project/zen.php b/module/project/zen.php index 4c8657acd1..88857ed10e 100644 --- a/module/project/zen.php +++ b/module/project/zen.php @@ -989,23 +989,25 @@ class projectZen extends project * 处理版本列表展示数据。 * Process build list display data. * - * @param array $builds + * @param array $buildList * @param int $projectID * @access protected * @return object[] */ - protected function processBuildListData(array $builds, int $projectID): array + protected function processBuildListData(array $buildList, int $projectID): array { $this->loadModel('build'); $this->loadModel('branch'); $showBranch = false; $productIdList = array(); - foreach($builds as $build) $productIdList[$build->product] = $build->product; + foreach($buildList as $build) $productIdList[$build->product] = $build->product; /* Get branch name. */ $branchGroups = $this->branch->getByProducts($productIdList); - foreach($builds as $build) + $builds = array(); + $project = $this->project->getByID($projectID); + foreach($buildList as $build) { $build->branchName = ''; if(isset($branchGroups[$build->product])) @@ -1021,17 +1023,104 @@ class projectZen extends project if(empty($build->branchName) and empty($build->builds)) $build->branchName = $this->lang->branch->main; } $build->actions = $this->build->buildActionList($build, 0, 'projectbuild'); + + if($project->multiple && empty($build->execution)) + { + $rowspan = $build->scmPath && $build->filePath ? 2 : 1; + $buildCount = count($build->builds); + $rowspan = $buildCount > $rowspan ? $buildCount : $rowspan; + $pathRowspan = $build->scmPath && $build->filePath ? floor($rowspan/2) : $rowspan; + + if($buildCount >= 2) + { + $i = 1; + foreach($build->builds as $childBuild) + { + $buildInfo = clone $build; + $buildInfo->executionName = $childBuild->executionName; + $buildInfo->rowspan = $rowspan; + if($i <= $pathRowspan) + { + $buildInfo->pathRowspan = $pathRowspan; + $buildInfo->pathType = empty($build->scmPath) ? 'filePath' : 'scmPath'; + $buildInfo->path = empty($build->scmPath) ? $build->filePath : $build->scmPath; + } + elseif($i > $pathRowspan) + { + $buildInfo->pathRowspan = $rowspan - $pathRowspan; + $buildInfo->pathType = 'filePath'; + $buildInfo->path = $build->filePath; + } + $builds[] = $buildInfo; + + $i ++; + } + } + else + { + $childBuild = !empty($build->builds) ? current($build->builds) : array(); + $build->executionName = !empty($childBuild) ? $childBuild->executionName : ''; + + if($build->scmPath && $build->filePath) + { + $build->rowspan = 2; + $build->executionRowspan = 2; + + $buildInfo = clone $build; + $buildInfo->pathType = 'scmPath'; + $buildInfo->path = $build->scmPath; + $builds[] = $buildInfo; + + $buildInfo = clone $build; + $buildInfo->pathType = 'filePath'; + $buildInfo->path = $build->filePath; + $builds[] = $buildInfo; + } + else + { + $build->pathType = empty($build->scmPath) ? 'filePath' : 'scmPath'; + $build->path = empty($build->scmPath) ? $build->filePath : $build->scmPath; + + $builds[] = $build; + } + } + + } + else + { + if($build->scmPath && $build->filePath) + { + $build->rowspan = 2; + $build->executionRowspan = 2; + + $buildInfo = clone $build; + $buildInfo->pathType = 'scmPath'; + $buildInfo->path = $build->scmPath; + $builds[] = $buildInfo; + + $buildInfo = clone $build; + $buildInfo->pathType = 'filePath'; + $buildInfo->path = $build->filePath; + $builds[] = $buildInfo; + } + else + { + $build->pathType = empty($build->scmPath) ? 'filePath' : 'scmPath'; + $build->path = empty($build->scmPath) ? $build->filePath : $build->scmPath; + + $builds[] = $build; + } + } } /* Set data table column. */ - $project = $this->project->getByID($projectID); if(!$project->hasProduct) unset($this->config->build->dtable->fieldList['product']); if(!$showBranch || !$project->hasProduct) unset($this->config->build->dtable->fieldList['branch']); if(!$project->multiple) unset($this->config->build->dtable->fieldList['execution']); $this->config->build->dtable->fieldList['name']['link'] = helper::createLink('projectbuild', 'view', 'buildID={id}'); $this->config->build->dtable->fieldList['execution']['title'] = zget($this->lang->project->executionList, $project->model); - return array_values($builds); + return $builds; } /** diff --git a/module/release/js/browse.ui.js b/module/release/js/browse.ui.js index 5d1d41538f..3307306cda 100644 --- a/module/release/js/browse.ui.js +++ b/module/release/js/browse.ui.js @@ -69,7 +69,6 @@ window.setStatistics = function() return {html: summary}; } - /** * 合并单元格。 * cell span in the column.