diff --git a/module/story/control.php b/module/story/control.php index 335c3bdb20..b60d7195b0 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -150,22 +150,6 @@ class story extends control return $this->send($response); } - /* bind siblings story id */ - $storyIDs = $storyResult['ids']; - if(count($storyIDs) > 1) - { - foreach($storyIDs as $siblingsStoryID) - { - $siblingsArr = array(); - foreach($storyIDs as $idItem) - { - if($idItem != $siblingsStoryID) $siblingsArr[] = $idItem; - $siblings = ',' . implode(',', $siblingsArr) . ','; - $this->dao->update(TABLE_STORY)->set('siblings')->eq($siblings)->where('id')->eq($siblingsStoryID)->exec(); - } - } - } - $action = $bugID == 0 ? 'Opened' : 'Frombug'; $extra = $bugID == 0 ? '' : $bugID; /* Record related action, for example FromFeedback. */ @@ -175,9 +159,8 @@ class story extends control $extra = $fromObjectID; } /* Create actions. */ - foreach($storyIDs as $idItem) $actionID = $this->action->create('task', $idItem, $action, '', $extra); - - + $storyIds = $storyResult['ids']; + foreach($storyIds as $idItem) $actionID = $this->action->create('story', $idItem, $action, '', $extra); if($objectID != 0) { diff --git a/module/story/js/create.js b/module/story/js/create.js index 3266d66af2..23b7231072 100644 --- a/module/story/js/create.js +++ b/module/story/js/create.js @@ -147,3 +147,112 @@ $(window).unload(function(){ { $(obj).closest('tr').remove(); } + + /** + * Load branch for multi branch or multi platform. + * + * @param int $branch + * @param int $branchIndex + * @access public + * @return void + */ +function loadBranchRelation(branch, branchIndex) +{ + var productID = $('#product').val(); + if(typeof(branch) == 'undefined') branch = 0; + + loadModuleForSiblings(productID, branch, branchIndex) + loadPlanForSiblings(productID, branch, branchIndex) +} + +/** + * Load branch for siblings. + * + * @paran int $procutID + * @param int $branch + * @param int $branchIndex + * @access public + * @return void + */ +function loadBranchForSiblings(productID, branch, branchIndex) +{ + var isSiblings = storyType == 'story' ? 'yes' : 'no'; + $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID + "&oldBranch=0¶m=active&projectID=" + executionID + "&withMainBranch=1&isSiblings=" + isSiblings + "&fieldID=" + branchIndex), function(data) + { + if(data) + { + /* reload branch */ + $('#branches' + branchIndex).replaceWith(data); + $('#branches' + branchIndex + "_chosen").remove(); + $('#branches' + branchIndex).next('.picker').remove(); + $('#branches' + branchIndex).chosen(); + } + }) +} + +/** + * Load module for siblings. + * + * @paran int $procutID + * @param int $branch + * @param int $branchIndex + * @access public + * @return void + */ +function loadModuleForSiblings(productID, branch, branchIndex) +{ + /* Load module */ + var currentModule = 0; + var moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=story&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=' + branchIndex + '&needManage=true&extra=¤tModuleID=' + currentModule); + if(branchIndex > 0) + { + var $moduleIDBox = $('.addBranchesBox'+ branchIndex +' #moduleIdBox'); + } + else + { + var $moduleIDBox = $('.switchBranch #moduleIdBox'); + } + $moduleIDBox.load(moduleLink, function() + { + $moduleIDBox.find('#modules' + branchIndex).chosen(); + if(branchIndex == 0) + { + $('.switchBranch #moduleIdBox span:first-child').remove() + } + $moduleIDBox.prepend("" + storyModule + "" ); + + $moduleIDBox.fixInputGroup(); + }); +} + +/** + * Load plan for siblings. + * + * @paran int $procutID + * @param int $branch + * @param int $branchIndex + * @access public + * @return void + */ +function loadPlanForSiblings(productID, branch, branchIndex) +{ + /* Load plan */ + if(typeof(branch) == 'undefined') branch = 0; + if(!branch) branch = 0; + var expired = config.currentMethod == 'create' ? 'unexpired' : ''; + planLink = createLink('product', 'ajaxGetPlans', 'productID=' + productID + '&branch=' + branch + '&planID=' + $('#plan').val() + '&fieldID=' + branchIndex + '&needCreate=true&expired='+ expired +'¶m=skipParent,' + config.currentMethod); + if(branchIndex > 0) + { + var $planIdBox = $('.addBranchesBox'+ branchIndex +' #planIdBox'); + } + else + { + var $planIdBox = $('#planIdBox'); + } + $planIdBox.load(planLink, function() + { + $planIdBox.find('#plans' + branchIndex).chosen(); + $planIdBox.prepend("" + storyPlan + ""); + $planIdBox.fixInputGroup(); + }); +} diff --git a/module/story/lang/de.php b/module/story/lang/de.php index 576042dfe2..a2d333d5aa 100644 --- a/module/story/lang/de.php +++ b/module/story/lang/de.php @@ -491,6 +491,6 @@ $lang->requirement->batchChangeModule = "Batch Change Modules"; $lang->requirement->submitReview = $lang->story->submitReview; $lang->requirement->linkStory = 'Link Story'; -$lang->story->addBranch = 'Add branch'; -$lang->story->deleteBranch = 'Delete branch'; +$lang->story->addBranch = 'Add %s'; +$lang->story->deleteBranch = 'Delete %s'; $lang->story->notice->branch = 'Each branch will establish a requirement, and the requirements are twins. The twins requirements are synchronized except for the product, branch, module, plan, and stage fields. You can manually remove the twins relationship later'; \ No newline at end of file diff --git a/module/story/lang/en.php b/module/story/lang/en.php index 729b78bdfb..6e8db724fb 100644 --- a/module/story/lang/en.php +++ b/module/story/lang/en.php @@ -491,6 +491,6 @@ $lang->requirement->batchChangeModule = "Batch Change Modules"; $lang->requirement->submitReview = $lang->story->submitReview; $lang->requirement->linkStory = 'Link Story'; -$lang->story->addBranch = 'Add branch'; -$lang->story->deleteBranch = 'Delete branch'; +$lang->story->addBranch = 'Add %s'; +$lang->story->deleteBranch = 'Delete %s'; $lang->story->notice->branch = 'Each branch will establish a requirement, and the requirements are twins. The twins requirements are synchronized except for the product, branch, module, plan, and stage fields. You can manually remove the twins relationship later'; \ No newline at end of file diff --git a/module/story/lang/fr.php b/module/story/lang/fr.php index 36c0b82cc9..a89f7dc2f9 100644 --- a/module/story/lang/fr.php +++ b/module/story/lang/fr.php @@ -491,6 +491,6 @@ $lang->requirement->batchChangeModule = "Batch Change Modules"; $lang->requirement->submitReview = $lang->story->submitReview; $lang->requirement->linkStory = 'Lier Story'; -$lang->story->addBranch = 'Add branch'; -$lang->story->deleteBranch = 'Delete branch'; +$lang->story->addBranch = 'Add %s'; +$lang->story->deleteBranch = 'Delete %s'; $lang->story->notice->branch = 'Each branch will establish a requirement, and the requirements are twins. The twins requirements are synchronized except for the product, branch, module, plan, and stage fields. You can manually remove the twins relationship later'; \ No newline at end of file diff --git a/module/story/lang/zh-cn.php b/module/story/lang/zh-cn.php index 2774b6189a..36bb908ec0 100644 --- a/module/story/lang/zh-cn.php +++ b/module/story/lang/zh-cn.php @@ -491,6 +491,6 @@ $lang->requirement->batchChangeModule = "批量修改模块"; $lang->requirement->submitReview = $lang->story->submitReview; $lang->requirement->linkStory = "关联{$lang->SRCommon}"; -$lang->story->addBranch = '添加分支'; -$lang->story->deleteBranch = '删除分支'; +$lang->story->addBranch = '添加%s'; +$lang->story->deleteBranch = '删除%s'; $lang->story->notice->branch = '每个分支会建立一个需求,需求间互为孪生关系,孪生需求间除产品、分支、模块、计划、阶段字段外均同步,后期您可以手动解除孪生关系'; \ No newline at end of file diff --git a/module/story/model.php b/module/story/model.php index 3d78dad7a1..fdc5365fd9 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -238,16 +238,16 @@ class storyModel extends model $product = $this->loadModel('product')->getById($story->product); if($product->type == 'normal' or $story->type == 'requirement') { - $this->post->branches = array(isset($story->branch) ? $story->branch : 0); - $this->post->modules = array(isset($story->module) ? $story->module : 0); - $this->post->plans = array(isset($story->plan) ? $story->plan : 0); + $this->post->branches = isset($story->branch) ? array($story->branch) : array(0 => 0); + $this->post->modules = isset($story->module) ? array($story->module) : array(0 => 0); + $this->post->plans = isset($story->plan) ? array($story->plan) : array(0 => 0); } $storyIds = array(); $mainStoryID = 0; - foreach($this->post->branches as $key => $postBranch) + foreach($this->post->branches as $key => $branch) { - $story->branch = $postBranch; + $story->branch = $branch; $story->module = $this->post->modules[$key]; $story->plan = $this->post->plans[$key]; @@ -412,6 +412,22 @@ class storyModel extends model if(empty($mainStoryID)) $mainStoryID = $storyID; } } + + /* bind siblings story id */ + if(count($storyIds) > 1) + { + foreach($storyIds as $siblingsStoryID) + { + $siblingsArr = array(); + foreach($storyIds as $idItem) + { + if($idItem != $siblingsStoryID) $siblingsArr[] = $idItem; + $siblings = ',' . implode(',', $siblingsArr) . ','; + $this->dao->update(TABLE_STORY)->set('siblings')->eq($siblings)->where('id')->eq($siblingsStoryID)->exec(); + } + } + } + return array('status' => 'created', 'id' => $mainStoryID, 'ids' => $storyIds); } diff --git a/module/story/view/create.html.php b/module/story/view/create.html.php index b6fb90e379..b04c50041e 100644 --- a/module/story/view/create.html.php +++ b/module/story/view/create.html.php @@ -108,7 +108,7 @@ foreach(explode(',', $config->story->create->requiredFields) as $field)
- +
@@ -373,8 +373,8 @@ foreach(explode(',', $config->story->create->requiredFields) as $field)
- - + +
diff --git a/module/story/view/header.html.php b/module/story/view/header.html.php index 2077a66ed2..31b5bd2cfd 100644 --- a/module/story/view/header.html.php +++ b/module/story/view/header.html.php @@ -68,118 +68,6 @@ function loadBranch() loadProductPlans(productID, branch); } -/** - * Load branch for multi branch or multi platform. - * - * @param int $branch - * @param int $branchIndex - * @access public - * @return void - */ -function loadBranchRelation(branch, branchIndex) -{ - var productID = $('#product').val(); - if(typeof(branch) == 'undefined') branch = 0; - - loadModuleForSiblings(productID, branch, branchIndex) - loadPlanForSiblings(productID, branch, branchIndex) -} - -/** - * Load branch for siblings. - * - * @paran int $procutID - * @param int $branch - * @param int $branchIndex - * @access public - * @return void - */ -function loadBranchForSiblings(productID, branch, branchIndex) -{ - var param = 'all'; - if(page == 'create') param = 'active'; - - var isSiblings = storyType == 'story' ? 'yes' : 'no'; - $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID + "&oldBranch=0¶m=" + param + "&projectID=" + executionID + "&withMainBranch=1&isSiblings=" + isSiblings + "&fieldID=" + branchIndex), function(data) - { - if(data) - { - /* reload branch */ - $('#branches' + branchIndex).replaceWith(data); - $('#branches' + branchIndex + "_chosen").remove(); - $('#branches' + branchIndex).next('.picker').remove(); - $('#branches' + branchIndex).chosen(); - } - }) -} - -/** - * Load module for siblings. - * - * @paran int $procutID - * @param int $branch - * @param int $branchIndex - * @access public - * @return void - */ -function loadModuleForSiblings(productID, branch, branchIndex) -{ - /* Load module */ - var currentModule = 0; - var moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=story&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=' + branchIndex + '&needManage=true&extra=¤tModuleID=' + currentModule); - if(branchIndex > 0) - { - var $moduleIDBox = $('.addBranchesBox'+ branchIndex +' #moduleIdBox'); - } - else - { - var $moduleIDBox = $('.switchBranch #moduleIdBox'); - } - $moduleIDBox.load(moduleLink, function() - { - $moduleIDBox.find('#modules' + branchIndex).chosen(); - if(branchIndex == 0) - { - $('.switchBranch #moduleIdBox span:first-child').remove() - } - $moduleIDBox.prepend("" + storyModule + "" ); - - $moduleIDBox.fixInputGroup(); - }); -} - -/** - * Load plan for siblings. - * - * @paran int $procutID - * @param int $branch - * @param int $branchIndex - * @access public - * @return void - */ -function loadPlanForSiblings(productID, branch, branchIndex) -{ - /* Load plan */ - if(typeof(branch) == 'undefined') branch = 0; - if(!branch) branch = 0; - var expired = config.currentMethod == 'create' ? 'unexpired' : ''; - planLink = createLink('product', 'ajaxGetPlans', 'productID=' + productID + '&branch=' + branch + '&planID=' + $('#plan').val() + '&fieldID=' + branchIndex + '&needCreate=true&expired='+ expired +'¶m=skipParent,' + config.currentMethod); - if(branchIndex > 0) - { - var $planIdBox = $('.addBranchesBox'+ branchIndex +' #planIdBox'); - } - else - { - var $planIdBox = $('#planIdBox'); - } - $planIdBox.load(planLink, function() - { - $planIdBox.find('#plans' + branchIndex).chosen(); - $planIdBox.prepend("" + storyPlan + ""); - $planIdBox.fixInputGroup(); - }); -} - /** * Load branches when change product. * @@ -212,7 +100,6 @@ function loadProductBranches(productID) $.cookie('branchSourceName', data.branchSourceName) }, 'json') - /* reload branch */ $('#branches0').replaceWith(data); $('#branches0' + "_chosen").remove(); @@ -348,4 +235,4 @@ function loadProductReviewers(productID) } }); } - + \ No newline at end of file