diff --git a/module/productplan/control.php b/module/productplan/control.php index 91e31a77e2..3d34f90760 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -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")); } /** diff --git a/module/productplan/js/create.js b/module/productplan/js/create.js index 4c4be3f040..dc43f76277 100644 --- a/module/productplan/js/create.js +++ b/module/productplan/js/create.js @@ -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 + "¤tBranches=" + 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() diff --git a/module/productplan/js/edit.js b/module/productplan/js/edit.js index 402f42c589..9d3733f176 100644 --- a/module/productplan/js/edit.js +++ b/module/productplan/js/edit.js @@ -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 + "¤tBranches=" + currentBranches), function(data) + { + $('#branch').replaceWith(data); + $('#branch_chosen').remove(); + $('#branch').chosen(); + }) +}) + $('#future').on('change', function() { if($(this).prop('checked')) diff --git a/module/productplan/lang/de.php b/module/productplan/lang/de.php index c402dd43ff..ac56c0aeec 100644 --- a/module/productplan/lang/de.php +++ b/module/productplan/lang/de.php @@ -75,9 +75,9 @@ $lang->productplan->projectNotEmpty = 'Project cannot be empty.'; $lang->productplan->nextStep = "Next step"; $lang->productplan->summary = "Total: %s, Parents: %s, Children: %s,Independent: %s."; $lang->productplan->checkedSummary = "Seleted: %total%, Parents: %parent%, Children: %child%, Independent: %independent%."; -$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'; diff --git a/module/productplan/lang/en.php b/module/productplan/lang/en.php index 3306bc5bdb..49a6bf5bd1 100644 --- a/module/productplan/lang/en.php +++ b/module/productplan/lang/en.php @@ -75,9 +75,9 @@ $lang->productplan->projectNotEmpty = 'Project cannot be empty.'; $lang->productplan->nextStep = "Next step"; $lang->productplan->summary = "Total: %s, Parents: %s, Children: %s,Independent: %s."; $lang->productplan->checkedSummary = "Seleted: %total%, Parents: %parent%, Children: %child%, Independent: %independent%."; -$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'; diff --git a/module/productplan/lang/fr.php b/module/productplan/lang/fr.php index 46bfcaf196..5fd88247f3 100644 --- a/module/productplan/lang/fr.php +++ b/module/productplan/lang/fr.php @@ -75,9 +75,9 @@ $lang->productplan->projectNotEmpty = 'Project cannot be empty.'; $lang->productplan->nextStep = "Next step"; $lang->productplan->summary = "Total: %s, Parents: %s, Children: %s,Independent: %s."; $lang->productplan->checkedSummary = "Seleted: %total%, Parents: %parent%, Children: %child%, Independent: %independent%."; -$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'; diff --git a/module/productplan/lang/zh-cn.php b/module/productplan/lang/zh-cn.php index b1765303ea..f756060d8e 100644 --- a/module/productplan/lang/zh-cn.php +++ b/module/productplan/lang/zh-cn.php @@ -75,9 +75,9 @@ $lang->productplan->projectNotEmpty = '所属项目不能为空。'; $lang->productplan->nextStep = "下一步"; $lang->productplan->summary = "本页共 %s 个计划,父计划 %s,子计划 %s,独立计划 %s。"; $lang->productplan->checkedSummary = "共选中 %total% 个计划,父计划 %parent%,子计划 %child%,独立计划 %independent%。"; -$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'] = '未完成'; diff --git a/module/productplan/model.php b/module/productplan/model.php index d378d62382..a5604badb9 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -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) diff --git a/module/productplan/view/create.html.php b/module/productplan/view/create.html.php index 01a0a00b82..c0534d69fc 100644 --- a/module/productplan/view/create.html.php +++ b/module/productplan/view/create.html.php @@ -37,6 +37,12 @@