diff --git a/module/story/control.php b/module/story/control.php index d5b74f0ca0..ad3140bf46 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -2461,6 +2461,38 @@ class story extends control echo json_encode($storyInfo); } + /** + * AJAX: get the user requirements of the product. + * + * @param int $productID + * @param string $labelName + * @param bool $isMultiple + * @param int $defaultID + * @access public + * @return string + */ + public function ajaxGetProductURS($productID, $labelName = '', $isMultiple = false, $defaultID = '') + { + $requirements = array('0' => '') + $this->story->getRequirements($productID); + $labelName = $isMultiple ? $labelName . '[]' : $labelName; + $misc = $isMultiple ? 'class="form-control" multiple' : 'class="form-control"'; + return print(html::select($labelName, $requirements, $defaultID, $misc)); + } + + /** + * AJAX: get the parent story. + * + * @param int $productID + * @param string $labelName + * @access public + * @return string + */ + public function ajaxGetParentStory($productID, $labelName = '') + { + $stories = $this->story->getParentStoryPairs($productID); + return print(html::select($labelName, $stories, 0, 'class="form-control"')); + } + /** * The report page. * diff --git a/module/story/view/header.html.php b/module/story/view/header.html.php index 90c940028c..c7979823ea 100644 --- a/module/story/view/header.html.php +++ b/module/story/view/header.html.php @@ -36,6 +36,27 @@ function loadProduct(productID) oldProductID = $('#product').val(); loadProductBranches(productID); loadProductReviewers(productID); + + if(typeof(storyType) == 'string' && storyType == 'story') + { + var requirementLink = createLink('story', 'ajaxGetProductURS', 'productID=' + productID + '&labelName=URS' + '&isMultiple=1'); + $.get(requirementLink, function(data) + { + $('#URS').replaceWith(data); + $('#URS' + "_chosen").remove(); + $('#URS').next('.picker').remove(); + $('#URS').chosen(); + }); + + var storyLink = createLink('story', 'ajaxGetParentStory', 'productID=' + productID + '&labelName=parent'); + $.get(storyLink, function(data) + { + $('#parent').replaceWith(data); + $('#parent' + "_chosen").remove(); + $('#parent').next('.picker').remove(); + $('#parent').chosen(); + }); + } } /**