diff --git a/module/tree/view/edit.html.php b/module/tree/view/edit.html.php index 1b45b20748..e34672e2bc 100644 --- a/module/tree/view/edit.html.php +++ b/module/tree/view/edit.html.php @@ -41,7 +41,7 @@ if(isset($pageCSS)) css::internal($pageCSS); root, "class='form-control chosen' onchange='loadBranches(this)'");?> type != 'normal'):?> - branch, "class='form-control chosen control-branch'");?> + branch, "class='form-control chosen control-branch' onchange='loadModules(this)'");?> @@ -166,8 +166,34 @@ function loadBranches(obj) { $inputGroup.append(data); $inputGroup.find('#branch').removeAttr('onchange'); + $inputGroup.find('#branch').attr('onchange', 'loadModules(this)'); $inputGroup.find('#branch').chosen(); } }) } + +/** + * Load modules by product and branch. + * + * @param obj $branch + * @access public + * @return void + */ +function loadModules(branch) +{ + var productID = $('#root').val(); + var branchID = $(branch).val(); + var moduleID = $('#parent').val(); + var moduleBox = $('#parent').closest('tr').children('td'); + + if(typeof(branchID) == 'undefined') branchID = 0; + if(typeof(moduleID) == 'undefined') moduleID = 0; + + link = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=story&branch=' + branchID + '&rootModuleID=0&returnType=html&fieldID=&needManage=true&extra=¤tModuleID=' + moduleID); + $(moduleBox).load(link, function() + { + $(this).children('select').attr('id', 'parent').attr('name', 'parent'); + $(this).find('select').chosen() + }); +}