* Add merge request list view.

This commit is contained in:
dingguodong
2021-08-16 17:44:52 +08:00
parent fa062b6b84
commit fc3a74c1d4
7 changed files with 75 additions and 11 deletions
+15 -4
View File
@@ -30,12 +30,23 @@ class mr extends control
$this->display();
}
public function list($repoID)
public function list($repoID, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
$this->loadModel('gitlab');
$gitlab = $this->mr->getGitlabProjectByRepo($repoID);
$resp = $this->mr->apiGetMRList($gitlab->gitlabID, $gitlab->projectID);
a($resp);
return $resp;
$mrList = $this->mr->apiGetMRList($gitlab->gitlabID, $gitlab->projectID);
$this->app->loadClass('pager', $static = true);
$recTotal = count($mrList);
$pager = new pager($recTotal, $recPerPage, $pageID);
$mrList = array_chunk($mrList, $pager->recPerPage);
$this->view->title = $this->lang->mr->browse;
$this->view->orderBy = $orderBy;
$this->view->pager = $pager;
$this->view->mrList = empty($mrList) ? $mrList: $mrList[$pageID - 1];;
$this->display();
}
public function create()
+2
View File
@@ -10,6 +10,8 @@ $(function()
{
$('#projectID').html('').append(response);
$('#projectID').chosen().trigger("chosen:updated");;
$('#sourceProject').html('').append(response);
$('#sourceProject').chosen().trigger("chosen:updated");;
});
});
+9 -6
View File
@@ -5,16 +5,19 @@ $lang->mr->browse = "浏览{$lang->mr->common}";
$lang->mr->list = $lang->mr->browse;
$lang->mr->edit = "编辑{$lang->mr->common}";
$lang->mr->delete = "删除{$lang->mr->common}";
$lang->mr->add = "添加GitLab项目";
$lang->mr->detail = "详情";
$lang->mr->addGitlab = "添加GitLab项目";
$lang->mr->id = 'ID';
$lang->mr->iid = "{$lang->mr->common}ID";
$lang->mr->name = '名称';
$lang->mr->source = '源项目分支';
$lang->mr->targer = '目标分支';
$lang->mr->pipeline = '流水线';
$lang->mr->audit = '审核状态';
$lang->mr->execute = '执行状态';
$lang->mr->title = $lang->mr->name;
$lang->mr->status = '状态';
$lang->mr->author = '创建人';
$lang->mr->assignee = '指派给';
$lang->mr->reviewer = '评审人';
$lang->mr->link = 'GitLab链接';
$lang->mr->sourceProject = '源项目';
$lang->mr->sourceBranch = '源分支';
+1
View File
@@ -92,6 +92,7 @@ class mrModel extends model
$targetProject = $this->post->targetProject;
$targetBranch = $this->post->targetBranch;
if($projectID != $sourceProject) return false;
}
+1 -1
View File
@@ -1,7 +1,7 @@
<?php include '../../common/view/header.html.php';?>
<div id="mainMenu" class="clearfix">
<div class='pull-right'>
<?php if(common::hasPriv('repo', 'create')) echo html::a(helper::createLink('repo', 'create'), "<i class='icon icon-plus'></i> " . $lang->mr->add, '', "class='btn btn-primary'");?>
<?php if(common::hasPriv('repo', 'create')) echo html::a(helper::createLink('repo', 'create'), "<i class='icon icon-plus'></i> " . $lang->mr->addGitlab, '', "class='btn btn-primary'");?>
</div>
</div>
<div id='mainContent'>
+1
View File
@@ -26,6 +26,7 @@
<th><?php echo $lang->mr->sourceProject;?></th>
<td class='required'>
<div class='input-group'>
<!-- sourceProject same as projectID -->
<?php echo html::select('sourceProject', array(''), '', "class='form-control chosen'");?>
<span class='input-group-addon fix-border'><?php echo $lang->mr->sourceBranch ?></span>
<?php echo html::select('sourceBranch', array(''), '', "class='form-control chosen'");?>
+46
View File
@@ -0,0 +1,46 @@
<?php include '../../common/view/header.html.php';?>
<div id="mainMenu" class="clearfix">
<div class='pull-right'>
<?php if(common::hasPriv('mr', 'create')) echo html::a(helper::createLink('mr', 'create'), "<i class='icon icon-plus'></i> " . $lang->mr->create, '', "class='btn btn-primary'");?>
</div>
</div>
<div id='mainContent'>
<form class='main-table' id='ajaxForm' method='post'>
<table id='mrList' class='table has-sort-head table-fixed'>
<thead>
<tr>
<?php $vars = "orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}"; ?>
<th class='w-60px text-left'><?php common::printOrderLink('id', $orderBy, $vars, $lang->mr->id); ?></th>
<th class='w-200px text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->mr->name); ?></th>
<th class='w-200px text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->mr->sourceProject); ?></th>
<th class='w-200px text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->mr->targetProject); ?></th>
<th class='w-200px text-left'><?php common::printOrderLink('status', $orderBy, $vars, $lang->mr->status); ?></th>
<th class='w-100px c-actions-4'><?php echo $lang->actions; ?></th>
</tr>
</thead>
<tbody>
<?php foreach($mrList as $mr):?>
<tr>
<td class='text'><?php echo $mr->id; ?></td>
<td class='text'><?php echo html::a($this->createLink('mr', 'browse', "mrID={$mr->id}"), $mr->title);?></td>
<td class='text'><?php echo $mr->source_project_id . ":" . $mr->source_branch;?></td>
<td class='text'><?php echo $mr->target_project_id . ":" . $mr->target_branch;?></td>
<td class='text'><?php echo $mr->state;?></td>
<td class='text-left c-actions'>
<?php
common::printLink('mr', 'list', "mr={$mr->id}", '<i class="icon icon-review"></i>', '', "title='{$lang->mr->list}' class='btn btn-info'");
common::printLink('mr', 'create', "mr={$mr->id}", '<i class="icon icon-plus"></i>', '', "title='{$lang->mr->create}' class='btn btn-info'");
common::printLink('mr', 'edit', "mrID=$mr->id", '<i class="icon icon-edit"></i>', '', "title='{$lang->mr->edit}' class='btn btn-info'");
if(common::hasPriv('mr', 'delete')) echo html::a($this->createLink('mr', 'delete', "mrID=$mr->id"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->mr->delete}' class='btn'");
?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php if($mrList):?>
<div class='table-footer'><?php $pager->show('rignt', 'pagerjs');?></div>
<?php endif;?>
</form>
</div>
<?php include '../../common/view/footer.html.php'; ?>