var newRowID = 0; /** * Load modules and stories of a product. * * @param int $productID * @access public * @return void */ function loadAll(productID) { loadProductBranches(productID) loadProductModules(productID); setStories(); } /** * Load by branch. * * @access public * @return void */ function loadBranch() { var branch = $('#branch').val(); if(typeof(branch) == 'undefined') branch = 0; loadProductModules($('#product').val(), branch); setStories(); } /** * Load product branches. * * @param int $productID * @access public * @return void */ function loadProductBranches(productID) { $('#branch').remove(); $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID), function(data) { if(data) { $('#product').closest('.input-group').append(data); $('#branch').css('width', config.currentMethod == 'create' ? '120px' : '65px'); } }) } /** * Load stories of module. * * @access public * @return void */ function loadModuleRelated() { setStories(); } /** * Load module. * * @param int $productID * @access public * @return void */ function loadProductModules(productID, branch) { if(typeof(branch) == 'undefined') branch = 0; if(!branch) branch = 0; link = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=case&branch=' + branch + '&rootModuleID=0&returnType=html&needManage=true'); $('#moduleIdBox').load(link, function() { $(this).find('select').chosen(defaultChosenOptions) if(typeof(caseModule) == 'string') $('#moduleIdBox').prepend("" + caseModule + "") }); setStories(); } /** * Set story field. * * @access public * @return void */ function setStories() { moduleID = $('#module').val(); productID = $('#product').val(); branch = $('#branch').val(); if(typeof(branch) == 'undefined') branch = 0; link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=50'); $.get(link, function(stories) { var value = $('#story').val(); if(!stories) stories = ''; $('#story').replaceWith(stories); $('#story').val(value); $('#story_chosen').remove(); $("#story").chosen(defaultChosenOptions); }); } /** * Delete a step row. * * @param int $rowID * @access public * @return void */ function deleteRow(rowID) { if($('.stepID').size() == 1) return; $('#row' + rowID).remove(); updateStepID(); } /** * Insert before the step. * * @param int $rowID * @access public * @return void */ function preInsert(rowID) { $('#row' + rowID).before(createRow()); updateStepID(); } /** * Insert after the step. * * @param int $rowID * @access public * @return void */ function postInsert(rowID) { $('#row' + rowID).after(createRow()); updateStepID(); } /** * Create a step row. * * @access public * @return void */ function createRow() { if(newRowID == 0) newRowID = $('.stepID').size(); newRowID ++; var newRow = "