| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- <?php include '../../common/view/header.html.php';?>
- <?php include '../../common/view/kindeditor.html.php';?>
- <?php js::set('rawMethod', $this->app->rawMethod);?>
- <?php js::set('hiddenProduct', isset($hiddenProduct) ? $hiddenProduct : false);?>
- <script>
- /**
- * Load product.
- *
- * @param int $productID
- * @access public
- * @return void
- */
- function loadProduct(productID)
- {
- if(page == 'edit' && twins && productID != oldProductID)
- {
- confirmRelievedTwins = confirm(relievedTwinsTip);
- if(!confirmRelievedTwins)
- {
- $('#product').val(oldProductID);
- $('#product').trigger("chosen:updated");
- return false;
- }
- }
- if(typeof parentStory != 'undefined' && parentStory)
- {
- confirmLoadProduct = confirm(moveChildrenTips);
- if(!confirmLoadProduct)
- {
- $('#product').val(oldProductID);
- $('#product').trigger("chosen:updated");
- return false;
- }
- }
- if(typeof hasSR != 'undefined' && hasSR)
- {
- confirmLoadProduct = confirm(moveSRTips);//Set hasSR variable in pro and biz.
- if(!confirmLoadProduct)
- {
- $('#product').val(oldProductID);
- $('#product').trigger("chosen:updated");
- return false;
- }
- }
- oldProductID = $('#product').val();
- loadProductBranches(productID);
- loadProductReviewers(productID);
- loadURS();
- if(typeof(storyType) == 'string' && storyType == 'story')
- {
- 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();
- });
- }
- }
- /**
- * Load branch.
- *
- * @access public
- * @return void
- */
- function loadBranch()
- {
- var branch = $('#branch').val();
- var productID = $('#product').val();
- if(typeof(branch) == 'undefined') branch = 0;
- if(typeof(productID) == 'undefined' && config.currentMethod == 'edit') productID = oldProductID;
- loadProductModules(productID, branch);
- loadProductPlans(productID, branch);
- }
- /**
- * Load branches when change product.
- *
- * @param int $productID
- * @access public
- * @return void
- */
- function loadProductBranches(productID)
- {
- var param = 'all';
- if(page == 'create') param = 'active';
- $('#branch').remove();
- $('#branch_chosen').remove();
- var isTwins = storyType == 'story' && page == 'create' ? 'yes' : 'no';
- $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID + "&oldBranch=0¶m=" + param + "&projectID=" + executionID + "&withMainBranch=1&isTwins=" + isTwins), function(data)
- {
- if(storyType == 'story' && page == 'create')
- {
- var newProductType = data ? 'normal' : 'branch';
- if(originProductType != newProductType)
- {
- $('.switchBranch').toggleClass('hidden');
- $('.switchBranch').toggleClass('disable');
- }
- $('#storyNoticeBranch').closest('tr').addClass('hidden');
- originProductType = newProductType;
- $('tr[class^="addBranchesBox"]').remove();
- if(data)
- {
- $.ajaxSettings.async = false;
- $.get(createLink('product', 'ajaxGetProductById', "productID=" + productID), function(data)
- {
- $.cookie('branchSourceName', data.branchSourceName)
- $.cookie('branchName', data.branchName)
- }, 'json')
- $.ajaxSettings.async = true;
- gap = $('#product').closest('td').next().width();
- $('#planIdBox').css('flex', '0 0 ' + gap + 'px')
- $('.switchBranch #branchBox .input-group .input-group-addon').html($.cookie('branchSourceName'))
- $('.switchBranch #branchBox').closest('td').prev().html($.cookie('branchName'))
- /* reload branch */
- $('#branches0').replaceWith(data);
- $('#branches0' + "_chosen").remove();
- $('#branches0').next('.picker').remove();
- $('#branches0').chosen();
- loadModuleForTwins(productID, 0, 0)
- loadPlanForTwins(productID, 0, 0)
- /* Init multi branch icon-plus. */
- if($(".table-form select[id^='branches']").length == $('.switchBranch #branchBox option').length)
- {
- $('.table-col .icon-plus').parent().css('pointer-events', 'none')
- $('.table-col .icon-plus').parent().addClass('disabled')
- }
- else
- {
- $('.table-col .icon-plus').parent().css('pointer-events', 'auto')
- $('.table-col .icon-plus').parent().removeClass('disabled')
- }
- }
- else
- {
- loadProductModules(productID, 0);
- loadProductPlans(productID, 0);
- }
- }
- else
- {
- var $product = $('#product');
- var $inputGroup = $product.closest('.input-group');
- $inputGroup.find('.input-group-addon').toggleClass('hidden', !data);
- if(data)
- {
- $inputGroup.append(data);
- $('#branch').css('width', config.currentMethod == 'create' ? '120px' : '65px').chosen();
- }
- $inputGroup.fixInputGroup();
- loadProductModules(productID, $('#branch').val());
- loadProductPlans(productID, $('#branch').val());
- }
- })
- }
- /**
- * Load modules when change product.
- *
- * @param int $productID
- * @param int $branch
- * @access public
- * @return void
- */
- function loadProductModules(productID, branch)
- {
- if(typeof(branch) == 'undefined') branch = $('#branch').val();
- if(!branch) branch = 0;
- var currentModule = 0;
- if(rawMethod == 'edit')
- {
- currentModule = $('#module').val();
- }
- var moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=story&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=&needManage=true&extra=nodeleted¤tModuleID=' + currentModule);
- var $moduleIDBox = $('#moduleIdBox');
- $moduleIDBox.load(moduleLink, function()
- {
- $moduleIDBox.find('#module').chosen();
- if(typeof(storyModule) == 'string' && config.currentMethod != 'edit' && !hiddenProduct) $moduleIDBox.prepend("<span class='input-group-addon'>" + storyModule + "</span>");
- $moduleIDBox.fixInputGroup();
- });
- }
- /**
- * Load plans when change product.
- *
- * @param int $productID
- * @param int $branch
- * @access public
- * @return void
- */
- function loadProductPlans(productID, branch)
- {
- if(typeof(branch) == 'undefined') branch = 0;
- if(!branch) branch = 0;
- var param = rawMethod == 'edit' ? 'skipParent|forStory' : 'skipParent';
- var expired = config.currentMethod == 'create' ? 'unexpired' : '';
- var planLink = createLink('product', 'ajaxGetPlans', 'productID=' + productID + '&branch=' + branch + '&planID=' + $('#plan').val() + '&fieldID=&needCreate=true&expired='+ expired +'¶m=skipParent,forStory,' + config.currentMethod);
- var $planIdBox = rawMethod == 'create' ? $('.switchBranch #planIdBox') : $('#planIdBox');
- $planIdBox.load(planLink, function()
- {
- $planIdBox.find('#plan').chosen();
- $planIdBox.fixInputGroup();
- });
- }
- /**
- * Load reviewers when change product.
- *
- * @param int $productID
- * @access public
- * @return void
- */
- function loadProductReviewers(productID)
- {
- var storyID = <?php echo isset($story->id) ? $story->id : 0;?>;
- var reviewerLink = createLink('product', 'ajaxGetReviewers', 'productID=' + productID + '&storyID=' + storyID);
- var needNotReview = $('#needNotReview').attr('checked');
- $.get(reviewerLink, function(data)
- {
- if(data)
- {
- var $reviewer = $('#reviewer');
- var chosen = $reviewer.data('chosen');
- if(chosen)
- {
- chosen.destroy();
- }
- else
- {
- var picker = $reviewer.data('zui.picker');
- if(picker) picker.destroy();
- }
- $reviewer.replaceWith(data);
- $reviewer = $('#reviewer');
- if($reviewer.data('pickertype')) $reviewer.picker({chosenMode: true});
- else $reviewer.chosen();
- if(needNotReview == 'checked') $('#reviewer').attr('disabled', 'disabled').trigger('chosen:updated');
- }
- });
- }
- </script>
|