diff --git a/module/story/js/batchcreate.ui.js b/module/story/js/batchcreate.ui.js index 588ab676ad..b17d12c5e3 100644 --- a/module/story/js/batchcreate.ui.js +++ b/module/story/js/batchcreate.ui.js @@ -1,4 +1,4 @@ -window.setModuleByBranch = function(e) +window.setModuleAndPlanByBranch = function(e) { const $branch = $(e.target); const branchID = $branch.val(); @@ -19,4 +19,20 @@ window.setModuleByBranch = function(e) $row = $row.next('tr'); if(!$row.find('td[data-name="module"][data-ditto="on"]').length) break; } + + var planLink = $.createLink('productPlan', 'ajaxGetProductPlans', 'productID=' + productID + '&branch=' + branchID); + let $rows = $branch.closest('tr'); + while($rows.length) + { + const $planPicker = $rows.find('[name^=plan]').zui('picker'); + const planID = $rows.find('[name^=plan]').val(); + $.getJSON(planLink, function(data) + { + $planPicker.render({items: data}) + $planPicker.$.setValue(planID); + }); + + $rows = $rows.next('tr'); + if(!$rows.find('td[data-name="plan"][data-ditto="on"]').length) break; + } } diff --git a/module/story/ui/batchcreate.html.php b/module/story/ui/batchcreate.html.php index b1ea94ae95..07fa4d8d8e 100644 --- a/module/story/ui/batchcreate.html.php +++ b/module/story/ui/batchcreate.html.php @@ -59,7 +59,7 @@ $fnGenerateFields = function() use ($lang, $fields, $stories, $customFields, $sh formBatchPanel ( setID('dataform'), - on::change('[data-name="branch"]', 'setModuleByBranch'), + on::change('[data-name="branch"]', 'setModuleAndPlanByBranch'), $stories ? set::data($stories) : null, set::ajax(array('beforeSubmit' => jsRaw('clickSubmit'))), set::title($storyID ? $storyTitle . $lang->colon . $this->lang->story->subdivide : $this->lang->story->batchCreate),