Merge branch 'sprint/178_hufangzhou_mergeBranch' into 'master'
* Finish task #46096. See merge request easycorp/zentaopms!1095
This commit is contained in:
@@ -325,4 +325,18 @@ class branch extends control
|
||||
|
||||
return $this->send(array('message' => $this->lang->saveSuccess, 'result' => 'success'));
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX: Get target branches for merge branch.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param string $mergedBranches
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function ajaxGetTargetBranches($productID, $mergedBranches = '')
|
||||
{
|
||||
$branchPairs = $this->branch->getPairs($productID, 'active', 0, $mergedBranches);
|
||||
return print(html::select('targetBranch', $branchPairs, '', "class='form-control chosen'"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,3 +9,4 @@ td.flex .label-primary {min-width: 40px;}
|
||||
td.flex .setDefault {min-width: 120px;}
|
||||
|
||||
#mergeBranch .form-actions {padding-top: 20px;}
|
||||
.modal-body {padding-top: 0;}
|
||||
|
||||
+61
-18
@@ -78,35 +78,78 @@ $(function()
|
||||
}
|
||||
});
|
||||
|
||||
$('#saveButton').on('click', function()
|
||||
$("#merge").click(function()
|
||||
{
|
||||
var mergedBranchIDList = [];
|
||||
var mergedBranchName = '';
|
||||
|
||||
$("input:checkbox[name^='branchIDList']:checked").each(function()
|
||||
{
|
||||
mergedBranchIDList.push($(this).val());
|
||||
mergedBranchName += ',' + $(this).closest('tr').find('.branchName').attr('title');
|
||||
});
|
||||
mergedBranchName = mergedBranchName.substr(1);
|
||||
mergedBranchIDList = mergedBranchIDList.join(',');
|
||||
|
||||
$.get(createLink('branch', 'ajaxGetTargetBranches', "productID=" + productID + "&mergedBranches=" + mergedBranchIDList), function(data)
|
||||
{
|
||||
$('#targetBranch').replaceWith(data);
|
||||
$('#targetBranch_chosen').remove();
|
||||
$('#targetBranch').chosen();
|
||||
})
|
||||
})
|
||||
|
||||
$('#saveButton').on('click', function()
|
||||
{
|
||||
var mergedBranchIDList = [];
|
||||
var mergedBranchName = '';
|
||||
var targetBranchName = $('#targetBranch_chosen').find('span').text();
|
||||
|
||||
$("input:checkbox[name^='branchIDList']:checked").each(function()
|
||||
{
|
||||
mergedBranchIDList.push($(this).val());
|
||||
mergedBranchName += ',' + $(this).closest('tr').find('.branchName').attr('title');
|
||||
});
|
||||
|
||||
mergedBranchName = mergedBranchName.substr(1);
|
||||
targetBranchName = $('#createBranch').prop('checked') ? $('#name').val() : targetBranchName;
|
||||
|
||||
var confirmMergeMessage = branchLang.confirmMerge.replace(/(.*)mergedBranch(.*)targetBranch(.*)/, "$1" + mergedBranchName + "$2" + targetBranchName + "$3");
|
||||
|
||||
var isChecked = $('#createBranch').attr('checked') ? 1 : 0;
|
||||
var postData = {'name' : $('#name').val(), 'desc' : $('#desc').val(), 'createBranch' : isChecked, 'mergedBranchIDList' : mergedBranchIDList, 'targetBranch' : $('#targetBranch').val()};
|
||||
$.ajax(
|
||||
if(isChecked && $('#name').val() == '')
|
||||
{
|
||||
url: createLink('branch', 'mergeBranch', 'productID=' + productID),
|
||||
dataType: 'json',
|
||||
method: 'post',
|
||||
data: postData,
|
||||
success: function(data)
|
||||
alert(branchLang.nameNotEmpty);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(confirm(confirmMergeMessage))
|
||||
{
|
||||
var postData = {'name' : $('#name').val(), 'desc' : $('#desc').val(), 'createBranch' : isChecked, 'mergedBranchIDList' : mergedBranchIDList, 'targetBranch' : $('#targetBranch').val()};
|
||||
$.ajax(
|
||||
{
|
||||
if(data.result == 'fail')
|
||||
url: createLink('branch', 'mergeBranch', 'productID=' + productID),
|
||||
dataType: 'json',
|
||||
method: 'post',
|
||||
data: postData,
|
||||
success: function(data)
|
||||
{
|
||||
alert(data.message.name)
|
||||
return false;
|
||||
if(data.result == 'fail')
|
||||
{
|
||||
alert(data.message)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#mergeBranch').modal('hide');
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#mergeBranch').modal('hide');
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
else
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
@@ -22,7 +22,7 @@ $lang->branch->batchEdit = 'Batch Edit';
|
||||
$lang->branch->defaultBranch = 'Default Branch';
|
||||
$lang->branch->setDefault = 'Set Default';
|
||||
$lang->branch->setDefaultAction = 'Set Default';
|
||||
$lang->branch->mergeTo = 'Merge branch to';
|
||||
$lang->branch->mergeTo = 'Merge to';
|
||||
$lang->branch->mergeBranch = 'Merge branch';
|
||||
$lang->branch->mergeBranchAction = 'Merge branch';
|
||||
|
||||
@@ -45,8 +45,10 @@ $lang->branch->nameNotEmpty = 'Name must not be empty!';
|
||||
$lang->branch->confirmClose = 'Do you want to close this @branch@?';
|
||||
$lang->branch->confirmActivate = 'Do you want to activate this @branch@?';
|
||||
$lang->branch->existName = '@branch@ name already exists.';
|
||||
$lang->branch->mergeTips = '(Trunk does not support being merged. After the branch is merged, the corresponding releases, plans, modules, requirements, bugs, and cases under the branch will be merged into the new branch)';
|
||||
$lang->branch->targetBranchTips = 'Note: You can merge it into an existing branch, merge it into the trunk, or create a new branch.';
|
||||
$lang->branch->mergedMain = 'Trunk does not support being merged.';
|
||||
$lang->branch->mergeTips = 'After the branch is merged, the corresponding releases, plans, modules, requirements, bugs, and cases under the branch will be merged into the new branch';
|
||||
$lang->branch->targetBranchTips = 'You can merge it into an existing branch, merge it into the trunk, or create a new branch.';
|
||||
$lang->branch->confirmMerge = 'The data of "mergedBranch" will be merged into "targetBranch", please confirm whether you want to perform the branch merge operation, the data will not be restored after the merge!';
|
||||
|
||||
$lang->branch->noData = 'No branches.';
|
||||
$lang->branch->mainBranch = 'The default main %s of the product.';
|
||||
|
||||
@@ -45,8 +45,10 @@ $lang->branch->nameNotEmpty = '名称不能为空!';
|
||||
$lang->branch->confirmClose = '是否关闭该@branch@?';
|
||||
$lang->branch->confirmActivate = '是否激活该@branch@?';
|
||||
$lang->branch->existName = '@branch@名称已存在';
|
||||
$lang->branch->mergeTips = '(主干不支持被合并,合并@branch@后,会将@branch@下面对应的发布、计划、模块、需求、Bug、用例都合并到新的@branch@下)';
|
||||
$lang->branch->targetBranchTips = '注:您可以将其合并到已有的一个@branch@,也可以合并到主干,也可以新创建一个@branch@。';
|
||||
$lang->branch->mergedMain = '主干不支持被合并。';
|
||||
$lang->branch->mergeTips = '合并@branch@后,会将@branch@下面对应的发布、计划、模块、需求、Bug、用例都合并到新的@branch@下';
|
||||
$lang->branch->targetBranchTips = '您可以将其合并到已有的一个@branch@,也可以合并到主干,也可以新创建一个@branch@。';
|
||||
$lang->branch->confirmMerge = '"mergedBranch"的数据将被合并到"targetBranch",请确认是否要执行分支合并操作,合并后数据将不可再恢复!';
|
||||
|
||||
$lang->branch->noData = '暂时没有分支。';
|
||||
$lang->branch->mainBranch = '产品默认主干%s。';
|
||||
|
||||
@@ -96,10 +96,11 @@ class branchModel extends model
|
||||
* @param int $productID
|
||||
* @param string $params
|
||||
* @param int $executionID
|
||||
* @param string $mergedBranches
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getPairs($productID, $params = '', $executionID = 0)
|
||||
public function getPairs($productID, $params = '', $executionID = 0, $mergedBranches = '')
|
||||
{
|
||||
$executionBranches = array();
|
||||
if($executionID)
|
||||
@@ -116,6 +117,7 @@ class branchModel extends model
|
||||
->beginIF($productID)->andWhere('product')->eq($productID)->fi()
|
||||
->beginIF($productID and $executionID)->andWhere('id')->in(array_keys($executionBranches))->fi()
|
||||
->beginIF(strpos($params, 'active') !== false)->andWhere('status')->eq('active')->fi()
|
||||
->beginIF(!empty($mergedBranches))->andWhere('id')->notIN($mergedBranches)->fi()
|
||||
->orderBy('`order`')
|
||||
->fetchPairs('id', 'name');
|
||||
foreach($branches as $branchID => $branchName) $branches[$branchID] = htmlspecialchars_decode($branchName);
|
||||
@@ -598,10 +600,10 @@ class branchModel extends model
|
||||
/**
|
||||
* Merge multiple branches into one branch.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param string $mergedBranches
|
||||
* @param int $productID
|
||||
* @param string $mergedBranches
|
||||
* @access public
|
||||
* @return int
|
||||
* @return int|bool
|
||||
*/
|
||||
public function mergeBranch($productID, $mergedBranches)
|
||||
{
|
||||
@@ -609,7 +611,6 @@ class branchModel extends model
|
||||
|
||||
/* Get the target branch. */
|
||||
$targetBranch = $data->createBranch ? $this->create($productID, true) : $data->targetBranch;
|
||||
if(!$targetBranch and $targetBranch != BRANCH_MAIN) return false;
|
||||
if($data->createBranch) $this->loadModel('action')->create('branch', $targetBranch, 'Opened');
|
||||
|
||||
/* Branch. */
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
<?php echo $isMain ? '' : '<i class="icon icon-move"></i>';?>
|
||||
</td>
|
||||
<?php endif;?>
|
||||
<td class='c-name flex' title='<?php echo $branch->name;?>'>
|
||||
<td class='c-name flex branchName' title='<?php echo $branch->name;?>'>
|
||||
<span class="text-ellipsis"><?php echo $branch->name;?> </span>
|
||||
<?php
|
||||
if($branch->default)
|
||||
@@ -126,7 +126,7 @@
|
||||
<?php
|
||||
$batchEditLink = $this->createLink('branch', 'batchEdit', "productID=$productID");
|
||||
echo html::submitButton($lang->edit, "data-form-action='$batchEditLink'", 'btn');
|
||||
if($browseType != 'closed') echo html::a('#mergeBranch', $lang->branch->merge, '', "data-toggle='modal' class='btn'");
|
||||
if(($browseType != 'closed' and common::hasPriv('branch', 'mergeBranch'))) echo html::a('#mergeBranch', $lang->branch->merge, '', "data-toggle='modal' class='btn' id='merge'");
|
||||
?>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
@@ -143,14 +143,22 @@
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="icon icon-close"></i></button>
|
||||
<span class="modal-title"><?php echo $lang->branch->mergeBranch;?></span>
|
||||
<small> <?php echo $lang->branch->mergeTips;?></small>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form method='post' enctype='multipart/form-data' class="form-ajax">
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='thWidth'><?php echo $lang->branch->mergeTo;?></th>
|
||||
<td>
|
||||
<td colspan="8">
|
||||
<div class="alert alert-info no-margin">
|
||||
<p><?php echo $lang->branch->mergedMain;?></p>
|
||||
<p><?php echo $lang->branch->mergeTips;?></p>
|
||||
<p><?php echo $lang->branch->targetBranchTips;?></p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->branch->mergeTo;?></th>
|
||||
<td colspan="7">
|
||||
<div class="input-group">
|
||||
<?php echo html::select('targetBranch', $branchPairs, '', "class='form-control chosen'");?>
|
||||
<span class='input-group-addon'>
|
||||
@@ -158,15 +166,10 @@
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"><span><?php echo $lang->branch->targetBranchTips;?></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='3' class='text-center form-actions'>
|
||||
<td colspan='8' class='text-center form-actions'>
|
||||
<?php echo html::commonButton($lang->save, "id='saveButton'", 'btn btn-primary btn-wide');?>
|
||||
<?php echo html::linkButton($lang->goback, $this->createLink('branch', 'manage', "productID=$productID"), 'self', '', 'btn btn-wide');?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user