Merge branch 'master_xieqiyu_78669' into 'master'

Master xieqiyu 78669

See merge request easycorp/zentaopms!6478
This commit is contained in:
孙广明
2022-12-06 08:08:45 +00:00
10 changed files with 99 additions and 91 deletions
+37 -15
View File
@@ -117,7 +117,7 @@ class productplan extends control
$this->view->branches = $branchPairs;
$this->view->defaultBranch = $defaultBranch;
$this->view->parent = $parent;
$this->view->parentPlanPairs = $this->productplan->getTopPlanPairs($productID, '', 'done,closed');
$this->view->parentPlanPairs = $this->productplan->getTopPlanPairs($productID, 'done,closed');
$this->display();
}
@@ -151,11 +151,19 @@ class productplan extends control
$oldBranch = array($planID => $plan->branch);
/* Get the parent plan pair exclusion itself. */
$parentPlanPairs = $this->productplan->getTopPlanPairs($plan->product, $plan->branch);
$parentPlanPairs = $this->productplan->getTopPlanPairs($plan->product);
unset($parentPlanPairs[$planID]);
$this->view->parentPlanPairs = $parentPlanPairs;
$this->commonAction($plan->product, $plan->branch);
if($plan->parent)
{
$parentPlan = $this->productplan->getByID($plan->parent);
$branchPairs = array();
foreach(explode(',', $parentPlan->branch) as $parentBranchID) $branchPairs[$parentBranchID] = $this->view->branchTagOption[$parentBranchID];
$this->view->branchTagOption = $branchPairs;
}
$this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->productplan->edit;
$this->view->position[] = $this->lang->productplan->edit;
$this->view->productID = $plan->product;
@@ -948,12 +956,17 @@ class productplan extends control
*/
public function ajaxGetConflict($planID, $newBranch)
{
if($newBranch == '') return;
$plan = $this->productplan->getByID($planID);
$oldBranch = $plan->branch;
$planStories = $this->loadModel('story')->getPlanStories($planID, 'all');
$planBugs = $this->loadModel('bug')->getPlanBugs($planID, 'all');
$branchPairs = $this->loadModel('branch')->getPairs($plan->product);
$removeBranches = '';
foreach(explode(',', $oldBranch) as $oldBranchID)
{
if($oldBranchID and strpos(",$newBranch,", ",$oldBranchID,") === false) $removeBranches .= "{$branchPairs[$oldBranchID]},";
}
$conflictStoryCounts = 0;
$conflictBugCounts = 0;
@@ -972,15 +985,15 @@ class productplan extends control
if($conflictStoryCounts and $conflictBugCounts)
{
printf($this->lang->productplan->confirmChangePlan, $conflictStoryCounts, $conflictBugCounts);
printf($this->lang->productplan->confirmChangePlan, trim($removeBranches, ','), $conflictStoryCounts, $conflictBugCounts);
}
elseif($conflictStoryCounts)
{
printf($this->lang->productplan->confirmRemoveStory, $conflictStoryCounts);
printf($this->lang->productplan->confirmRemoveStory, trim($removeBranches, ','), $conflictStoryCounts);
}
elseif($conflictBugCounts)
{
printf($this->lang->productplan->confirmRemoveBug, $conflictBugCounts);
printf($this->lang->productplan->confirmRemoveBug, trim($removeBranches, ','), $conflictBugCounts);
}
}
@@ -1000,19 +1013,28 @@ class productplan extends control
}
/**
* AJAX: Get top plan.
* AJAX: Get parent branches.
*
* @param int $productID
* @param int $branch
* @param int $planID
* @param int $parentID
* @param string $currentBranches
* @access public
* @return object
* @return void
*/
public function ajaxGetTopPlan($productID, $branch = 0, $planID = 0)
public function ajaxGetParentBranches($productID = 0, $parentID = 0, $currentBranches = '')
{
$parentPlanPairs = $this->productplan->getTopPlanPairs($productID, $branch);
if(isset($parentPlanPairs[$planID])) unset($parentPlanPairs[$planID]);
return print(html::select('parent', array(0 => '') + $parentPlanPairs, 0, 'class="form-control"'));
$branchPairs = $this->loadModel('branch')->getPairs($productID, 'active');
if(!empty($parentID))
{
$parentBranches = array();
$parentPlan = $this->productplan->getByID($parentID);
foreach(explode(',', $parentPlan->branch) as $parentBranchID)
{
$parentBranches[$parentBranchID] = $branchPairs[$parentBranchID];
if(!empty($currentBranches) and strpos(",$currentBranches,", ",$parentBranchID,") === false) $currentBranches = str_replace(",$parentBranchID,", ',', $currentBranches);
}
}
return print(html::select('branch[]', empty($parentID) ? $branchPairs : $parentBranches, trim($currentBranches, ','), "class='form-control chosen' multiple required"));
}
/**
+14 -10
View File
@@ -63,7 +63,20 @@ $('#future').on('change', function()
}
});
$('#branch').change(function()
$('#parent').change(function()
{
var parentID = $(this).val();
var currentBranches = $('#branch').val() ? $('#branch').val().toString() : '';
$.post(createLink('productplan', 'ajaxGetParentBranches', "productID=" + productID + "&parentID=" + parentID + "&currentBranches=" + currentBranches), function(data)
{
$('#branch').replaceWith(data);
$('#branch_chosen').remove();
$('#branch').chosen();
$('#branch').change();
})
})
$('#dataform').on('change', '#branch', function()
{
if(parentPlanID) return;
@@ -72,21 +85,12 @@ $('#branch').change(function()
var branchIdList = branchIdList.toString();
var lastPlanLink = createLink('productplan', 'ajaxGetLast', "productID=" + productID + "&branch=" + branchIdList);
var topPlanLink = createLink('productplan', 'ajaxGetTopPlan', "productID=" + productID + "&branch=" + branchIdList);
$.post(lastPlanLink, function(data)
{
data = JSON.parse(data);
var planTitle = data ? '(' + lastLang + ': ' + data.title + ')' : '';
$('#title').parent().next('td').html(planTitle);
})
$.post(topPlanLink, function(data)
{
$('#parent').replaceWith(data);
$('#parent_chosen').remove();
$('#parent').chosen();
})
});
$('#submit').click(function()
+14 -18
View File
@@ -13,14 +13,7 @@ function convertStringToDate(dateString)
return Date.parse(dateString);
}
/**
* Get conflict stories.
*
* @param int $planID
* @access public
* @return void
*/
function getConflictStories(planID)
$('#dataform').on('change', '#branch', function()
{
var newBranch = $('#branch').val() ? $('#branch').val().toString() : '';
$.get(createLink('productplan', 'ajaxGetConflict', 'planID=' + planID + '&newBranch=' + newBranch), function(conflictStories)
@@ -30,21 +23,12 @@ function getConflictStories(planID)
var result = confirm(conflictStories) ? true : false;
if(!result)
{
newBranch = oldBranch[planID];
$('#branch').val(oldBranch[planID].split(','));
$('#branch').trigger("chosen:updated");
}
}
var link = createLink('productplan', 'ajaxGetTopPlan', "productID=" + productID + "&branch=" + newBranch + "&planID=" + planID);
$.post(link, function(data)
{
$('#parent').replaceWith(data);
$('#parent_chosen').remove();
$('#parent').chosen();
})
});
}
});
/**
* Compute the end date for productplan.
@@ -72,6 +56,18 @@ function computeEndDate(delta)
$('#end').val(endDate).datetimepicker('update');
}
$('#parent').change(function()
{
var parentID = $(this).val();
var currentBranches = $('#branch').val() ? $('#branch').val().toString() : '';
$.post(createLink('productplan', 'ajaxGetParentBranches', "productID=" + productID + "&parentID=" + parentID + "&currentBranches=" + currentBranches), function(data)
{
$('#branch').replaceWith(data);
$('#branch_chosen').remove();
$('#branch').chosen();
})
})
$('#future').on('change', function()
{
if($(this).prop('checked'))
+4 -4
View File
@@ -75,9 +75,9 @@ $lang->productplan->projectNotEmpty = 'Project cannot be empty.';
$lang->productplan->nextStep = "Next step";
$lang->productplan->summary = "Total: <strong>%s</strong>, Parents: <strong>%s</strong>, Children: <strong>%s</strong>,Independent: <strong>%s</strong>.";
$lang->productplan->checkedSummary = "Seleted: <strong>%total%</strong>, Parents: <strong>%parent%</strong>, Children: <strong>%child%</strong>, Independent: <strong>%independent%</strong>.";
$lang->productplan->confirmChangePlan = "After the branch is unlinked, %s {$lang->SRCommon} and %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveStory = "After the branch is unlinked, %s {$lang->SRCommon} under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveBug = "After the branch is unlinked, %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmChangePlan = "After the branch of『%s』is unlinked, %s {$lang->SRCommon} and %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveStory = "After the branch of『%s』is unlinked, %s {$lang->SRCommon} under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveBug = "After the branch of『%s』is unlinked, %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->id = 'ID';
$lang->productplan->product = $lang->productCommon;
@@ -139,7 +139,7 @@ $lang->productplan->beginGreaterChildTip = "The start date of the parent plan[%s
$lang->productplan->endLetterChildTip = "The completion date of the parent plan[%s]: %s, cannot be less than the completion date of the child plan: %s.";
$lang->productplan->beginLetterParentTip = "The start date of the child plan[%s]: %s, cannot be less than the start date of the parent plan: %s.";
$lang->productplan->endGreaterParentTip = "The completion date of the child plan[%s]: %s, cannot be greater than the completion date of the parent plan: %s.";
$lang->productplan->diffBranchesTip = "The @branch@ %s of parent plan is not linked with the child plan. @branch@'s stories and bugs whill be removed from the plan. Do you want to save?";
$lang->productplan->diffBranchesTip = "The @branch@『%s』 of parent plan is not linked with the child plan. @branch@'s stories and bugs whill be removed from the plan. Do you want to save?";
$lang->productplan->featureBar['browse']['all'] = 'Alle';
$lang->productplan->featureBar['browse']['undone'] = 'Undone';
+4 -4
View File
@@ -75,9 +75,9 @@ $lang->productplan->projectNotEmpty = 'Project cannot be empty.';
$lang->productplan->nextStep = "Next step";
$lang->productplan->summary = "Total: <strong>%s</strong>, Parents: <strong>%s</strong>, Children: <strong>%s</strong>,Independent: <strong>%s</strong>.";
$lang->productplan->checkedSummary = "Seleted: <strong>%total%</strong>, Parents: <strong>%parent%</strong>, Children: <strong>%child%</strong>, Independent: <strong>%independent%</strong>.";
$lang->productplan->confirmChangePlan = "After the branch is unlinked, %s {$lang->SRCommon} and %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveStory = "After the branch is unlinked, %s {$lang->SRCommon} under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveBug = "After the branch is unlinked, %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmChangePlan = "After the branch of『%s』is unlinked, %s {$lang->SRCommon} and %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveStory = "After the branch of『%s』is unlinked, %s {$lang->SRCommon} under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveBug = "After the branch of『%s』is unlinked, %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->id = 'ID';
$lang->productplan->product = $lang->productCommon;
@@ -139,7 +139,7 @@ $lang->productplan->beginGreaterChildTip = "The start date of the parent plan[%s
$lang->productplan->endLetterChildTip = "The completion date of the parent plan[%s]: %s, cannot be less than the completion date of the child plan: %s.";
$lang->productplan->beginLetterParentTip = "The start date of the child plan[%s]: %s, cannot be less than the start date of the parent plan: %s.";
$lang->productplan->endGreaterParentTip = "The completion date of the child plan[%s]: %s, cannot be greater than the completion date of the parent plan: %s.";
$lang->productplan->diffBranchesTip = "The @branch@ %s of parent plan is not linked with the child plan. @branch@'s stories and bugs whill be removed from the plan. Do you want to save?";
$lang->productplan->diffBranchesTip = "The @branch@『%s』of parent plan is not linked with the child plan. @branch@'s stories and bugs whill be removed from the plan. Do you want to save?";
$lang->productplan->featureBar['browse']['all'] = 'All';
$lang->productplan->featureBar['browse']['undone'] = 'Undone';
+4 -4
View File
@@ -75,9 +75,9 @@ $lang->productplan->projectNotEmpty = 'Project cannot be empty.';
$lang->productplan->nextStep = "Next step";
$lang->productplan->summary = "Total: <strong>%s</strong>, Parents: <strong>%s</strong>, Children: <strong>%s</strong>,Independent: <strong>%s</strong>.";
$lang->productplan->checkedSummary = "Seleted: <strong>%total%</strong>, Parents: <strong>%parent%</strong>, Children: <strong>%child%</strong>, Independent: <strong>%independent%</strong>.";
$lang->productplan->confirmChangePlan = "After the branch is unlinked, %s {$lang->SRCommon} and %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveStory = "After the branch is unlinked, %s {$lang->SRCommon} under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveBug = "After the branch is unlinked, %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmChangePlan = "After the branch of『%s』is unlinked, %s {$lang->SRCommon} and %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveStory = "After the branch of『%s』is unlinked, %s {$lang->SRCommon} under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->confirmRemoveBug = "After the branch of『%s』is unlinked, %s bugs under the branch will be removed from the plan at the same time, so still want to unassociate?";
$lang->productplan->id = 'ID';
$lang->productplan->product = $lang->productCommon;
@@ -139,7 +139,7 @@ $lang->productplan->beginGreaterChildTip = "The start date of the parent plan[%s
$lang->productplan->endLetterChildTip = "The completion date of the parent plan[%s]: %s, cannot be less than the completion date of the child plan: %s.";
$lang->productplan->beginLetterParentTip = "The start date of the child plan[%s]: %s, cannot be less than the start date of the parent plan: %s.";
$lang->productplan->endGreaterParentTip = "The completion date of the child plan[%s]: %s, cannot be greater than the completion date of the parent plan: %s.";
$lang->productplan->diffBranchesTip = "The @branch@ %s of parent plan is not linked with the child plan. @branch@'s stories and bugs whill be removed from the plan. Do you want to save?";
$lang->productplan->diffBranchesTip = "The @branch@『%s』of parent plan is not linked with the child plan. @branch@'s stories and bugs whill be removed from the plan. Do you want to save?";
$lang->productplan->featureBar['browse']['all'] = 'Tous';
$lang->productplan->featureBar['browse']['undone'] = 'Undone';
+4 -4
View File
@@ -75,9 +75,9 @@ $lang->productplan->projectNotEmpty = '所属项目不能为空。';
$lang->productplan->nextStep = "下一步";
$lang->productplan->summary = "本页共 <strong>%s</strong> 个计划,父计划 <strong>%s</strong>,子计划 <strong>%s</strong>,独立计划 <strong>%s</strong>。";
$lang->productplan->checkedSummary = "共选中 <strong>%total%</strong> 个计划,父计划 <strong>%parent%</strong>,子计划 <strong>%child%</strong>,独立计划 <strong>%independent%</strong>。";
$lang->productplan->confirmChangePlan = "分支解除关联后,分支下的%s个{$lang->SRCommon}和%s个Bug将同步从计划中移除,是否解除?";
$lang->productplan->confirmRemoveStory = "分支解除关联后,分支下的%s个{$lang->SRCommon}将同步从计划中移除,是否解除?";
$lang->productplan->confirmRemoveBug = "分支解除关联后,分支下的%s个Bug将同步从计划中移除,是否解除?";
$lang->productplan->confirmChangePlan = "分支『%s』解除关联后,分支下的%s个{$lang->SRCommon}和%s个Bug将同步从计划中移除,是否解除?";
$lang->productplan->confirmRemoveStory = "分支『%s』解除关联后,分支下的%s个{$lang->SRCommon}将同步从计划中移除,是否解除?";
$lang->productplan->confirmRemoveBug = "分支『%s』解除关联后,分支下的%s个Bug将同步从计划中移除,是否解除?";
$lang->productplan->id = '编号';
$lang->productplan->product = $lang->productCommon;
@@ -139,7 +139,7 @@ $lang->productplan->beginGreaterChildTip = "父计划[%s]的开始日期:%s,
$lang->productplan->endLetterChildTip = "父计划[%s]的完成日期:%s,不能小于子计划的完成日期: %s";
$lang->productplan->beginLetterParentTip = "子计划[%s]的开始日期:%s,不能小于父计划的开始日期: %s";
$lang->productplan->endGreaterParentTip = "子计划[%s]的完成日期:%s,不能大于父计划的完成日期: %s";
$lang->productplan->diffBranchesTip = "父计划的@branch@ %s 未被子计划关联,对应@branch@的需求和bug将自动从计划中移除,是否保存?";
$lang->productplan->diffBranchesTip = "父计划的@branch@『%s』未被子计划关联,对应@branch@的需求和bug将自动从计划中移除,是否保存?";
$lang->productplan->featureBar['browse']['all'] = '全部';
$lang->productplan->featureBar['browse']['undone'] = '未完成';
+1 -16
View File
@@ -222,29 +222,14 @@ class productplanModel extends model
* Get top plan pairs.
*
* @param int $productID
* @param int $branch
* @param int $exclude
* @access public
* @return array
*/
public function getTopPlanPairs($productID, $branch = '', $exclude = '')
public function getTopPlanPairs($productID, $exclude = '')
{
$branchQuery = '';
if($branch !== '')
{
$branchQuery .= '(';
$branchCount = count(explode(',', $branch));
foreach(explode(',', $branch) as $index => $branchID)
{
$branchQuery .= "CONCAT(',', branch, ',') LIKE '%,$branchID,%'";
if($index < $branchCount - 1) $branchQuery .= ' AND ';
}
$branchQuery .= ')';
}
$planPairs = $this->dao->select("id,title")->from(TABLE_PRODUCTPLAN)
->where('product')->eq($productID)
->beginIF($branch !== '' and !empty($branchQuery))->andWhere($branchQuery)->fi()
->andWhere('parent')->le(0)
->andWhere('deleted')->eq(0)
->beginIF($exclude)->andWhere('status')->notin($exclude)
+6 -6
View File
@@ -37,6 +37,12 @@
<td class='muted'><?php echo $product->name;?></td><td></td><td></td>
</tr>
<?php endif;?>
<?php if(!$parent):?>
<tr>
<th><?php echo $lang->productplan->parent;?></th>
<td><?php echo html::select('parent', array(0 => '') + $parentPlanPairs, 0, "class='form-control chosen'");?>
</tr>
<?php endif;?>
<?php if($product->type != 'normal'):?>
<tr>
<th><?php echo $lang->product->branch;?></th>
@@ -57,12 +63,6 @@
<td><?php echo html::input('title', '', "class='form-control' required");?></td>
<td colspan='2' class='muted'><?php if($lastPlan) echo '(' . $lang->productplan->last . ': ' . $lastPlan->title . ')';?></td>
</tr>
<?php if(!$parent):?>
<tr>
<th><?php echo $lang->productplan->parent;?></th>
<td><?php echo html::select('parent', array(0 => '') + $parentPlanPairs, 0, "class='form-control chosen'");?>
</tr>
<?php endif;?>
<tr>
<th><?php echo $lang->productplan->begin;?></th>
<td><?php echo html::input('begin', formatTime($begin), "class='form-control form-date'");?></td>
+11 -10
View File
@@ -17,6 +17,7 @@
<?php js::set('today', helper::today());?>
<?php js::set('productID', $productID);?>
<?php js::set('oldBranch', $oldBranch);?>
<?php js::set('planID', $plan->id);?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
@@ -30,17 +31,7 @@
<th><?php echo $lang->productplan->product;?></th>
<td class='muted'><?php echo $product->name;?></td><td></td><td></td>
</tr>
<?php if($product->type != 'normal' and $plan->parent != '-1'):?>
<tr>
<th><?php echo $lang->product->branch;?></th>
<td><?php echo html::select('branch[]', $branchTagOption, $plan->branch, "onchange='getConflictStories($plan->id);' class='form-control chosen' multiple");?></td><td></td><td></td>
</tr>
<?php endif;?>
<?php endif;?>
<tr>
<th><?php echo $lang->productplan->title;?></th>
<td><?php echo html::input('title', $plan->title, "class='form-control' required");?></td><td></td><td></td>
</tr>
<?php if($plan->parent == '-1'):?>
<?php echo html::hidden('parent', $plan->parent);?>
<?php else:?>
@@ -49,6 +40,16 @@
<td><?php echo html::select('parent', array(0 => '') + $parentPlanPairs, $plan->parent, "class='form-control chosen'");?>
</tr>
<?php endif;?>
<?php if(!$product->shadow and $product->type != 'normal' and $plan->parent != '-1'):?>
<tr>
<th><?php echo $lang->product->branch;?></th>
<td><?php echo html::select('branch[]', $branchTagOption, $plan->branch, "class='form-control chosen' multiple");?></td><td></td><td></td>
</tr>
<?php endif;?>
<tr>
<th><?php echo $lang->productplan->title;?></th>
<td><?php echo html::input('title', $plan->title, "class='form-control' required");?></td><td></td><td></td>
</tr>
<tr>
<th><?php echo $lang->productplan->status;?></th>
<?php $disabled = $plan->parent == -1 ? "disabled='disabled'" : '' ;?>