header.html.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <?php include '../../common/view/header.html.php';?>
  2. <?php include '../../common/view/kindeditor.html.php';?>
  3. <?php js::set('rawMethod', $this->app->rawMethod);?>
  4. <?php js::set('hiddenProduct', isset($hiddenProduct) ? $hiddenProduct : false);?>
  5. <script>
  6. /**
  7. * Load product.
  8. *
  9. * @param int $productID
  10. * @access public
  11. * @return void
  12. */
  13. function loadProduct(productID)
  14. {
  15. if(page == 'edit' && twins && productID != oldProductID)
  16. {
  17. confirmRelievedTwins = confirm(relievedTwinsTip);
  18. if(!confirmRelievedTwins)
  19. {
  20. $('#product').val(oldProductID);
  21. $('#product').trigger("chosen:updated");
  22. return false;
  23. }
  24. }
  25. if(typeof parentStory != 'undefined' && parentStory)
  26. {
  27. confirmLoadProduct = confirm(moveChildrenTips);
  28. if(!confirmLoadProduct)
  29. {
  30. $('#product').val(oldProductID);
  31. $('#product').trigger("chosen:updated");
  32. return false;
  33. }
  34. }
  35. if(typeof hasSR != 'undefined' && hasSR)
  36. {
  37. confirmLoadProduct = confirm(moveSRTips);//Set hasSR variable in pro and biz.
  38. if(!confirmLoadProduct)
  39. {
  40. $('#product').val(oldProductID);
  41. $('#product').trigger("chosen:updated");
  42. return false;
  43. }
  44. }
  45. oldProductID = $('#product').val();
  46. loadProductBranches(productID);
  47. loadProductReviewers(productID);
  48. loadURS();
  49. if(typeof(storyType) == 'string' && storyType == 'story')
  50. {
  51. var storyLink = createLink('story', 'ajaxGetParentStory', 'productID=' + productID + '&labelName=parent');
  52. $.get(storyLink, function(data)
  53. {
  54. $('#parent').replaceWith(data);
  55. $('#parent' + "_chosen").remove();
  56. $('#parent').next('.picker').remove();
  57. $('#parent').chosen();
  58. });
  59. }
  60. }
  61. /**
  62. * Load branch.
  63. *
  64. * @access public
  65. * @return void
  66. */
  67. function loadBranch()
  68. {
  69. var branch = $('#branch').val();
  70. var productID = $('#product').val();
  71. if(typeof(branch) == 'undefined') branch = 0;
  72. if(typeof(productID) == 'undefined' && config.currentMethod == 'edit') productID = oldProductID;
  73. loadProductModules(productID, branch);
  74. loadProductPlans(productID, branch);
  75. }
  76. /**
  77. * Load branches when change product.
  78. *
  79. * @param int $productID
  80. * @access public
  81. * @return void
  82. */
  83. function loadProductBranches(productID)
  84. {
  85. var param = 'all';
  86. if(page == 'create') param = 'active';
  87. $('#branch').remove();
  88. $('#branch_chosen').remove();
  89. var isTwins = storyType == 'story' && page == 'create' ? 'yes' : 'no';
  90. $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID + "&oldBranch=0&param=" + param + "&projectID=" + executionID + "&withMainBranch=1&isTwins=" + isTwins), function(data)
  91. {
  92. if(storyType == 'story' && page == 'create')
  93. {
  94. var newProductType = data ? 'normal' : 'branch';
  95. if(originProductType != newProductType)
  96. {
  97. $('.switchBranch').toggleClass('hidden');
  98. $('.switchBranch').toggleClass('disable');
  99. }
  100. $('#storyNoticeBranch').closest('tr').addClass('hidden');
  101. originProductType = newProductType;
  102. $('tr[class^="addBranchesBox"]').remove();
  103. if(data)
  104. {
  105. $.ajaxSettings.async = false;
  106. $.get(createLink('product', 'ajaxGetProductById', "productID=" + productID), function(data)
  107. {
  108. $.cookie('branchSourceName', data.branchSourceName)
  109. $.cookie('branchName', data.branchName)
  110. }, 'json')
  111. $.ajaxSettings.async = true;
  112. gap = $('#product').closest('td').next().width();
  113. $('#planIdBox').css('flex', '0 0 ' + gap + 'px')
  114. $('.switchBranch #branchBox .input-group .input-group-addon').html($.cookie('branchSourceName'))
  115. $('.switchBranch #branchBox').closest('td').prev().html($.cookie('branchName'))
  116. /* reload branch */
  117. $('#branches0').replaceWith(data);
  118. $('#branches0' + "_chosen").remove();
  119. $('#branches0').next('.picker').remove();
  120. $('#branches0').chosen();
  121. loadModuleForTwins(productID, 0, 0)
  122. loadPlanForTwins(productID, 0, 0)
  123. /* Init multi branch icon-plus. */
  124. if($(".table-form select[id^='branches']").length == $('.switchBranch #branchBox option').length)
  125. {
  126. $('.table-col .icon-plus').parent().css('pointer-events', 'none')
  127. $('.table-col .icon-plus').parent().addClass('disabled')
  128. }
  129. else
  130. {
  131. $('.table-col .icon-plus').parent().css('pointer-events', 'auto')
  132. $('.table-col .icon-plus').parent().removeClass('disabled')
  133. }
  134. }
  135. else
  136. {
  137. loadProductModules(productID, 0);
  138. loadProductPlans(productID, 0);
  139. }
  140. }
  141. else
  142. {
  143. var $product = $('#product');
  144. var $inputGroup = $product.closest('.input-group');
  145. $inputGroup.find('.input-group-addon').toggleClass('hidden', !data);
  146. if(data)
  147. {
  148. $inputGroup.append(data);
  149. $('#branch').css('width', config.currentMethod == 'create' ? '120px' : '65px').chosen();
  150. }
  151. $inputGroup.fixInputGroup();
  152. loadProductModules(productID, $('#branch').val());
  153. loadProductPlans(productID, $('#branch').val());
  154. }
  155. })
  156. }
  157. /**
  158. * Load modules when change product.
  159. *
  160. * @param int $productID
  161. * @param int $branch
  162. * @access public
  163. * @return void
  164. */
  165. function loadProductModules(productID, branch)
  166. {
  167. if(typeof(branch) == 'undefined') branch = $('#branch').val();
  168. if(!branch) branch = 0;
  169. var currentModule = 0;
  170. if(rawMethod == 'edit')
  171. {
  172. currentModule = $('#module').val();
  173. }
  174. var moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=story&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=&needManage=true&extra=nodeleted&currentModuleID=' + currentModule);
  175. var $moduleIDBox = $('#moduleIdBox');
  176. $moduleIDBox.load(moduleLink, function()
  177. {
  178. $moduleIDBox.find('#module').chosen();
  179. if(typeof(storyModule) == 'string' && config.currentMethod != 'edit' && !hiddenProduct) $moduleIDBox.prepend("<span class='input-group-addon'>" + storyModule + "</span>");
  180. $moduleIDBox.fixInputGroup();
  181. });
  182. }
  183. /**
  184. * Load plans when change product.
  185. *
  186. * @param int $productID
  187. * @param int $branch
  188. * @access public
  189. * @return void
  190. */
  191. function loadProductPlans(productID, branch)
  192. {
  193. if(typeof(branch) == 'undefined') branch = 0;
  194. if(!branch) branch = 0;
  195. var param = rawMethod == 'edit' ? 'skipParent|forStory' : 'skipParent';
  196. var expired = config.currentMethod == 'create' ? 'unexpired' : '';
  197. var planLink = createLink('product', 'ajaxGetPlans', 'productID=' + productID + '&branch=' + branch + '&planID=' + $('#plan').val() + '&fieldID=&needCreate=true&expired='+ expired +'&param=skipParent,forStory,' + config.currentMethod);
  198. var $planIdBox = rawMethod == 'create' ? $('.switchBranch #planIdBox') : $('#planIdBox');
  199. $planIdBox.load(planLink, function()
  200. {
  201. $planIdBox.find('#plan').chosen();
  202. $planIdBox.fixInputGroup();
  203. });
  204. }
  205. /**
  206. * Load reviewers when change product.
  207. *
  208. * @param int $productID
  209. * @access public
  210. * @return void
  211. */
  212. function loadProductReviewers(productID)
  213. {
  214. var storyID = <?php echo isset($story->id) ? $story->id : 0;?>;
  215. var reviewerLink = createLink('product', 'ajaxGetReviewers', 'productID=' + productID + '&storyID=' + storyID);
  216. var needNotReview = $('#needNotReview').attr('checked');
  217. $.get(reviewerLink, function(data)
  218. {
  219. if(data)
  220. {
  221. var $reviewer = $('#reviewer');
  222. var chosen = $reviewer.data('chosen');
  223. if(chosen)
  224. {
  225. chosen.destroy();
  226. }
  227. else
  228. {
  229. var picker = $reviewer.data('zui.picker');
  230. if(picker) picker.destroy();
  231. }
  232. $reviewer.replaceWith(data);
  233. $reviewer = $('#reviewer');
  234. if($reviewer.data('pickertype')) $reviewer.picker({chosenMode: true});
  235. else $reviewer.chosen();
  236. if(needNotReview == 'checked') $('#reviewer').attr('disabled', 'disabled').trigger('chosen:updated');
  237. }
  238. });
  239. }
  240. </script>