diff --git a/module/bug/js/common.js b/module/bug/js/common.js index c60f521af7..a32cc168da 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -156,7 +156,7 @@ function loadProjectTasks(projectID) */ function loadProjectStories(projectID) { - link = createLink('story', 'ajaxGetProjectStories', 'projectID=' + projectID + '&productID=' + $('#product').val() + '&storyID=' + oldStoryID); + link = createLink('story', 'ajaxGetProjectStories', 'projectID=' + projectID + '&productID=' + $('#product').val() + '&moduleID=0&storyID=' + oldStoryID); $('#storyIdBox').load(link, function(){$('#story').chosen({no_results_text:noResultsMatch});}); } diff --git a/module/story/control.php b/module/story/control.php index 8390873783..78bf042eb2 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -757,7 +757,6 @@ class story extends control $this->loadModel('task'); $this->view->tasks = $this->task->getStoryTaskPairs($storyID, $projectID); $this->display(); - exit; } /** @@ -769,10 +768,15 @@ class story extends control * @access public * @return void */ - public function ajaxGetProjectStories($projectID, $productID = 0, $storyID = 0) + public function ajaxGetProjectStories($projectID, $productID = 0, $moduleID = 0, $storyID = 0) { - $stories = $this->story->getProjectStoryPairs($projectID, $productID); - die(html::select('story', $stories, $storyID)); + if($moduleID) + { + $moduleID = $this->loadModel('tree')->getStoryModule($moduleID); + $moduleID = $this->tree->getAllChildID($moduleID); + } + $stories = $this->story->getProjectStoryPairs($projectID, $productID, $moduleID); + die(html::select('story', $stories, $storyID, 'class=select-1 onchange=setPreview();')); } /** @@ -786,7 +790,11 @@ class story extends control */ public function ajaxGetProductStories($productID, $moduleID = 0, $storyID = 0) { - if($moduleID) $moduleID = $this->loadModel('tree')->getAllChildID($moduleID); + if($moduleID) + { + $moduleID = $this->loadModel('tree')->getStoryModule($moduleID); + $moduleID = $this->tree->getAllChildID($moduleID); + } $stories = $this->story->getProductStoryPairs($productID, $moduleID); die(html::select('story', $stories, $storyID, "class=''")); } diff --git a/module/story/model.php b/module/story/model.php index 414cd4628c..a73f52a634 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1049,12 +1049,13 @@ class storyModel extends model /** * Get stories pairs of a project. * - * @param int $projectID - * @param int $productID + * @param int $projectID + * @param int $productID + * @param array|string $moduleIds * @access public * @return array */ - public function getProjectStoryPairs($projectID = 0, $productID = 0) + public function getProjectStoryPairs($projectID = 0, $productID = 0, $moduleIds = 0) { $stories = $this->dao->select('t2.id, t2.title, t2.module, t2.pri, t2.estimate, t3.name AS product') ->from(TABLE_PROJECTSTORY)->alias('t1') @@ -1065,6 +1066,7 @@ class storyModel extends model ->where('t1.project')->eq((int)$projectID) ->andWhere('t2.deleted')->eq(0) ->beginIF($productID)->andWhere('t1.product')->eq((int)$productID)->fi() + ->beginIF($moduleIds)->andWhere('t2.module')->in($moduleIds)->fi() ->fetchAll(); if(!$stories) return array(); return $this->formatStories($stories); diff --git a/module/task/js/create.js b/module/task/js/create.js index 1dc478f55f..f0fe84f665 100644 --- a/module/task/js/create.js +++ b/module/task/js/create.js @@ -69,6 +69,18 @@ function setAfter() } } +function setStories(moduleID, projectID, productID) +{ + link = createLink('story', 'ajaxGetProjectStories', 'projectID=' + projectID + '&productID=' + productID + '&moduleID=' + moduleID); + $.get(link, function(stories) + { + if(!stories) stories = ''; + $('#story').replaceWith(stories); + $('#story_chzn').remove(); + $("#story").chosen({no_results_text: ''}); + }); +} + $(document).ready(function() { setPreview(); diff --git a/module/task/js/edit.js b/module/task/js/edit.js index 61d49b53c0..141aac0ca2 100644 --- a/module/task/js/edit.js +++ b/module/task/js/edit.js @@ -49,7 +49,7 @@ function loadModuleMenu(projectID) */ function loadProjectStories(projectID) { - link = createLink('story', 'ajaxGetProjectStories', 'projectID=' + projectID + '&moduleId=0&storyID=' + oldStoryID); + link = createLink('story', 'ajaxGetProjectStories', 'projectID=' + projectID + '&productID=0&moduleID=0&storyID=' + oldStoryID); $('#storyIdBox').load(link, function(){$('#story').chosen();}); } diff --git a/module/task/view/create.html.php b/module/task/view/create.html.php index 3d4d7e4c73..b199b08b0a 100644 --- a/module/task/view/create.html.php +++ b/module/task/view/create.html.php @@ -35,8 +35,8 @@ task->module;?> - module, "class='select-3'");?> - + module, "class='select-3' onchange='setStories(this.value,$project->id,0)'");?> + task->assignedTo;?> assignedTo, 'class=select-3');?> diff --git a/module/tree/model.php b/module/tree/model.php index a79666cd27..b563bb81f6 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -803,6 +803,24 @@ class treeModel extends model return $this->dao->select('name')->from(TABLE_PRODUCT)->where('id')->eq($module->root)->fetch(); } + /** + * Get the module that its type == 'story'. + * + * @param int $moduleID + * @access public + * @return void + */ + public function getStoryModule($moduleID) + { + $module = $this->dao->select('id,type,parent')->from(TABLE_MODULE)->where('id')->eq($moduleID)->fetch(); + while($module->id and $module->type != 'story') + { + $module = $this->dao->select('id,type,parent')->from(TABLE_MODULE)->where('id')->eq($module->parent)->fetch(); + } + + return $module->id; + } + /** * Update modules' order. *