* Link project and repo.
This commit is contained in:
+3
-1
@@ -1,4 +1,6 @@
|
||||
ALTER TABLE `zt_product` ADD `shadow` tinyint(1) unsigned NOT NULL AFTER `code`;
|
||||
ALTER TABLE `zt_project` ADD `hasProduct` tinyint(1) unsigned NOT NULL DEFAULT 1 AFTER `code`;
|
||||
|
||||
ALTER TABLE `zt_product` MODIFY `name` varchar(110) NOT NULL;
|
||||
ALTER TABLE `zt_product` MODIFY `name` varchar(110) NOT NULL;
|
||||
|
||||
ALTER TABLE `zt_repo` ADD `projectList` varchar(200) NOT NULL AFTER `product`;
|
||||
|
||||
+41
-8
@@ -147,6 +147,7 @@ class repo extends control
|
||||
$this->view->groups = $this->loadModel('group')->getPairs();
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted|noclosed');
|
||||
$this->view->products = $products;
|
||||
$this->view->projectList = array();
|
||||
$this->view->productID = $productID;
|
||||
$this->view->serviceHosts = $this->loadModel('gitlab')->getPairs();
|
||||
$this->view->objectID = $objectID;
|
||||
@@ -202,14 +203,23 @@ class repo extends control
|
||||
$this->view->projects = $options;
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->edit;
|
||||
$this->view->repo = $repo;
|
||||
$this->view->repoID = $repoID;
|
||||
$this->view->objectID = $objectID;
|
||||
$this->view->groups = $this->loadModel('group')->getPairs();
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted|noclosed');
|
||||
$this->view->products = $objectID ? $this->loadModel('product')->getProductPairsByProject($objectID) : $this->loadModel('product')->getPairs();
|
||||
$this->view->serviceHosts = array('' => '') + $this->loadModel('pipeline')->getPairs($repo->SCM);
|
||||
$productList = explode(',', $repo->product);
|
||||
$projectOptions = array();
|
||||
foreach($productList as $productID)
|
||||
{
|
||||
$projects = $this->loadModel('product')->getProjectListByProduct($productID);
|
||||
$projectOptions = $projectOptions + array_combine(array_column($projects, 'id'), array_column($projects, 'name'));
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->edit;
|
||||
$this->view->repo = $repo;
|
||||
$this->view->repoID = $repoID;
|
||||
$this->view->objectID = $objectID;
|
||||
$this->view->groups = $this->loadModel('group')->getPairs();
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted|noclosed');
|
||||
$this->view->products = $objectID ? $this->loadModel('product')->getProductPairsByProject($objectID) : $this->loadModel('product')->getPairs();
|
||||
$this->view->projectList = $projectOptions;
|
||||
$this->view->serviceHosts = array('' => '') + $this->loadModel('pipeline')->getPairs($repo->SCM);
|
||||
|
||||
$this->view->position[] = html::a(inlink('maintain'), $this->lang->repo->common);
|
||||
$this->view->position[] = $this->lang->repo->edit;
|
||||
@@ -1200,6 +1210,29 @@ class repo extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get projects list by product id list by ajax.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxProjectsOfProducts()
|
||||
{
|
||||
$postData = fixer::input('post')
|
||||
->setDefault('productList', array())
|
||||
->setDefault('projectList', array())
|
||||
->get();
|
||||
|
||||
$projectOptions = array();
|
||||
foreach($postData->productList as $productID)
|
||||
{
|
||||
$projects = $this->loadModel('product')->getProjectListByProduct($productID);
|
||||
$projectOptions = $projectOptions + array_combine(array_column($projects, 'id'), array_column($projects, 'name'));
|
||||
}
|
||||
|
||||
return print html::select('projectList[]', $projectOptions, $postData->projectList, "class='form-control chosen' multiple");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get hosts.
|
||||
*
|
||||
|
||||
@@ -23,6 +23,17 @@ $(function()
|
||||
}
|
||||
});
|
||||
|
||||
$('#product').change(function()
|
||||
{
|
||||
var projectList = $('#projectList').val();
|
||||
var productList = $('#product').val();
|
||||
$.post(createLink('repo', 'ajaxProjectsOfProducts'), { productList, projectList }, function(response)
|
||||
{
|
||||
$('#projectContainer').html('').append(response);
|
||||
$('#projectList').chosen().trigger("chosen:updated");
|
||||
});
|
||||
});
|
||||
|
||||
$('#serviceHost').change(function()
|
||||
{
|
||||
var host = $('#serviceHost').val();
|
||||
|
||||
@@ -7,6 +7,17 @@ $(function()
|
||||
$form.css('min-height', $form.height());
|
||||
})
|
||||
|
||||
$('#product').change(function()
|
||||
{
|
||||
var projectList = $('#projectList').val();
|
||||
var productList = $('#product').val();
|
||||
$.post(createLink('repo', 'ajaxProjectsOfProducts'), { productList, projectList }, function(response)
|
||||
{
|
||||
$('#projectContainer').html('').append(response);
|
||||
$('#projectList').chosen().trigger("chosen:updated");
|
||||
});
|
||||
});
|
||||
|
||||
$('#serviceHost').change(function()
|
||||
{
|
||||
host = $('#serviceHost').val();
|
||||
|
||||
@@ -3,6 +3,7 @@ $lang->repo->common = '代码';
|
||||
$lang->repo->browse = '浏览';
|
||||
$lang->repo->viewRevision = '查看修订';
|
||||
$lang->repo->product = '所属产品';
|
||||
$lang->repo->project = '所属项目';
|
||||
$lang->repo->execution = '所属' . $lang->execution->common;
|
||||
$lang->repo->create = '创建';
|
||||
$lang->repo->maintain = '代码库列表';
|
||||
|
||||
@@ -200,6 +200,7 @@ class repoModel extends model
|
||||
->skipSpecial('path,client,account,password')
|
||||
->setDefault('product', '')
|
||||
->join('product', ',')
|
||||
->setDefault('projectList', '')->join('projectList', ',')
|
||||
->get();
|
||||
|
||||
$data->acl = empty($data->acl) ? '' : json_encode($data->acl);
|
||||
@@ -265,6 +266,7 @@ class repoModel extends model
|
||||
->setDefault('product', '')
|
||||
->skipSpecial('path,client,account,password')
|
||||
->join('product', ',')
|
||||
->setDefault('projectList', '')->join('projectList', ',')
|
||||
->get();
|
||||
|
||||
if($data->path != $repo->path) $data->synced = 0;
|
||||
|
||||
@@ -24,8 +24,12 @@
|
||||
<form id='repoForm' method='post' class='form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th><?php echo $lang->repo->product; ?></th>
|
||||
<td class='required'><?php echo html::select('product[]', $products, empty($objectID) ? '' : array_keys($products), "class='form-control chosen' multiple"); ?></td>
|
||||
<th><?php echo $lang->repo->product;?></th>
|
||||
<td class='required'><?php echo html::select('product[]', $products, empty($objectID) ? '' : array_keys($products), "class='form-control chosen' multiple");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->repo->project; ?></th>
|
||||
<td id='projectContainer'><?php echo html::select('projectList[]', $projectList, array(), "class='form-control chosen' multiple"); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='thWidth'><?php echo $lang->repo->type; ?></th>
|
||||
|
||||
@@ -29,7 +29,11 @@
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th><?php echo $lang->repo->product; ?></th>
|
||||
<td class='required'><?php echo html::select('product[]', $products, $repo->product, "class='form-control chosen' multiple"); ?></td>
|
||||
<td class='required'><?php echo html::select('product[]', $products, $repo->product, "class='form-control chosen' multiple");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->repo->project; ?></th>
|
||||
<td id='projectContainer'><?php echo html::select('projectList[]', $projectList, $repo->projectList, "class='form-control chosen' multiple"); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='thWidth'><?php echo $lang->repo->type; ?></th>
|
||||
|
||||
Reference in New Issue
Block a user