bugform.html.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. <?php
  2. /**
  3. * The create bug view of issue module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2015 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Congzhi Chen <congzhi@cnezsoft.com>
  8. * @package issue
  9. * @version $Id$
  10. * @link http://www.zentao.net
  11. */
  12. ?>
  13. <tr>
  14. <th><?php echo $lang->issue->resolution;?></th>
  15. <td>
  16. <?php echo html::select('resolution', $lang->issue->resolveMethods, $resolution, 'class="form-control chosen" onchange="getSolutions()"');?>
  17. </td>
  18. </tr>
  19. <tr>
  20. <th class='w-110px'><?php echo $lang->bug->product;?></th>
  21. <td>
  22. <div class='input-group'>
  23. <?php echo html::select('product', $products, $productID, "onchange='loadAll(this.value);' class='form-control chosen control-product'");?>
  24. <?php if($this->session->currentProductType != 'normal' and isset($products[$productID])):?>
  25. <?php echo html::select('branch', $branches, $branch, "onchange='loadBranch()' class='form-control chosen control-branch'");?>
  26. <?php endif;?>
  27. </div>
  28. </td>
  29. <td>
  30. <div class='input-group' id='moduleIdBox'>
  31. <span class="input-group-addon"><?php echo $lang->bug->module?></span>
  32. <?php
  33. echo html::select('module', $moduleOptionMenu, $moduleID, "onchange='loadModuleRelated()' class='form-control chosen'");
  34. if(count($moduleOptionMenu) == 1)
  35. {
  36. echo "<span class='input-group-addon'>";
  37. echo html::a($this->createLink('tree', 'browse', "rootID=$productID&view=bug&currentModuleID=0&branch=$branch", '', true), $lang->tree->manage, '', "class='text-primary' data-toggle='modal' data-type='iframe' data-width='95%'");
  38. echo '&nbsp; ';
  39. echo html::a("javascript:void(0)", $lang->refresh, '', "class='refresh' onclick='loadProductModules($productID)'");
  40. echo '</span>';
  41. }
  42. ?>
  43. </div>
  44. </td>
  45. </tr>
  46. <tr>
  47. <th><?php echo $lang->bug->type;?></th>
  48. <?php $showOS = strpos(",$showFields,", ',os,') !== false;?>
  49. <?php $showBrowser = strpos(",$showFields,", ',browser,') !== false;?>
  50. <td>
  51. <div class='input-group' id='bugTypeInputGroup'>
  52. <?php echo html::select('type', $lang->bug->typeList, '', "class='form-control'");?>
  53. </div>
  54. <td>
  55. <div class='input-group'>
  56. <?php if($showOS):?>
  57. <span class='input-group-addon fix-border'><?php echo $lang->bug->os?></span>
  58. <?php echo html::select('os', $lang->bug->osList, '', "class='form-control'");?>
  59. <?php endif;?>
  60. <?php if($showBrowser):?>
  61. <span class='input-group-addon fix-border'><?php echo $lang->bug->browser?></span>
  62. <?php echo html::select('browser', $lang->bug->browserList, '', "class='form-control'");?>
  63. <?php endif;?>
  64. </div>
  65. </td>
  66. </tr>
  67. <tr>
  68. <th><?php echo $lang->bug->project;?></th>
  69. <td>
  70. <div class='input-group' id='bugProjectInputGroup'>
  71. <?php echo html::select('project', $projects, $projectID, "class='form-control chosen' onchange='loadProductExecutions($productID, this.value)' style='width: 125px!important'");?>
  72. <span class='input-group-addon fix-border'><?php echo $lang->bug->execution;?></span>
  73. <?php echo html::select('execution', $executions, '', "class='form-control chosen' onchange='loadExecutionRelated(this.value)' style='width: 120px!important'");?>
  74. </div>
  75. </td>
  76. <td>
  77. <div class='input-group required' id='buildBox'>
  78. <span class="input-group-addon"><?php echo $lang->bug->openedBuild?></span>
  79. <?php echo html::select('openedBuild[]', $builds, $buildID, "size=4 multiple=multiple class='chosen form-control'");?>
  80. <span class='input-group-addon fix-border' id='buildBoxActions'></span>
  81. <div class='input-group-btn'><?php echo html::commonButton($lang->bug->allBuilds, "class='btn' id='all' data-toggle='tooltip' onclick='loadAllBuilds()'")?></div>
  82. </div>
  83. </td>
  84. </tr>
  85. <tr>
  86. <th><nobr><?php echo $lang->bug->lblAssignedTo;?></nobr></th>
  87. <td>
  88. <div class='input-group'>
  89. <?php echo html::select('assignedTo', $users, '', "class='form-control chosen'");?>
  90. <span class='input-group-btn'><?php echo html::commonButton($lang->bug->allUsers, "class='btn btn-default' onclick='loadAllUsers()' data-toggle='tooltip'");?></span>
  91. </div>
  92. </td>
  93. <?php $showDeadline = strpos(",$showFields,", ',deadline,') !== false;?>
  94. <?php if($showDeadline):?>
  95. <td id='deadlineTd'>
  96. <div class='input-group'>
  97. <span class='input-group-addon'><?php echo $lang->bug->deadline?></span>
  98. <span><?php echo html::input('deadline', $issue->deadline, "class='form-control form-date'");?></span>
  99. </div>
  100. </td>
  101. </tr>
  102. <?php endif;?>
  103. <tr>
  104. <th><?php echo $lang->bug->title;?></th>
  105. <td colspan='2'>
  106. <div class="input-group title-group required">
  107. <div class="input-control has-icon-right">
  108. <?php echo html::input('title', $issue->title, "class='form-control'");?>
  109. </div>
  110. <span class="input-group-addon fix-border br-0"><?php echo $lang->bug->pri;?></span>
  111. <div class="input-group-btn pri-selector" data-type="pri">
  112. <?php echo html::select('pri', $lang->bug->priList, $issue->pri, "class='form-control'");?>
  113. </div>
  114. </div>
  115. </td>
  116. </tr>
  117. <tr>
  118. <th><?php echo $lang->bug->steps;?></th>
  119. <td colspan='2'>
  120. <?php echo html::textarea('steps', $issue->desc, "rows='10' class='form-control'");?>
  121. </td>
  122. </tr>
  123. <tr>
  124. <th><?php echo $lang->issue->resolvedBy;?></th>
  125. <td>
  126. <?php echo html::select('resolvedBy', $users, $this->app->user->account, "class='form-control chosen'");?>
  127. </td>
  128. </tr>
  129. <tr>
  130. <th><?php echo $lang->issue->resolvedDate;?></th>
  131. <td>
  132. <div class='input-group has-icon-right'>
  133. <?php echo html::input('resolvedDate', date('Y-m-d'), "class='form-control form-date'");?>
  134. <label for="date" class="input-control-icon-right"><i class="icon icon-delay"></i></label>
  135. </div>
  136. </td>
  137. </tr>
  138. <tr>
  139. <td></td>
  140. <td>
  141. <div class='form-action'><?php echo html::submitButton();?></div>
  142. </td>
  143. </tr>
  144. <?php
  145. js::set('holders', $lang->bug->placeholder);
  146. js::set('page', 'create');
  147. js::set('createRelease', $lang->release->create);
  148. js::set('createBuild', $lang->build->create);
  149. js::set('refresh', $lang->refresh);
  150. ?>
  151. <script>
  152. $(function()
  153. {
  154. var page = window.page || '';
  155. var flow = window.flow;
  156. $('#subNavbar a[data-toggle=dropdown]').parent().addClass('dropdown dropdown-hover');
  157. if(page == 'create')
  158. {
  159. var productID = $('#product').val();
  160. var moduleID = $('#module').val();
  161. var assignedto = $('#assignedTo').val();
  162. changeProductConfirmed = true;
  163. oldStoryID = $('#story').val() || 0;
  164. oldProjectID = 0;
  165. oldOpenedBuild = '';
  166. oldTaskID = $('#oldTaskID').val() || 0;
  167. notice();
  168. }
  169. if(page == 'create' || page == 'edit' || page == 'assignedto' || page == 'confirmbug')
  170. {
  171. oldProductID = $('#product').val();
  172. $("#story, #task, #mailto").chosen();
  173. }
  174. if(window.flow != 'full')
  175. {
  176. $('.querybox-toggle').click(function()
  177. {
  178. $(this).parent().toggleClass('active');
  179. });
  180. }
  181. });
  182. /**
  183. * Load all fields.
  184. *
  185. * @param int $productID
  186. * @access public
  187. * @return void
  188. */
  189. function loadAll(productID)
  190. {
  191. if(page == 'create')
  192. {
  193. loadProjectTeamMembers(productID);
  194. }
  195. if(!changeProductConfirmed)
  196. {
  197. firstChoice = confirm(confirmChangeProduct);
  198. changeProductConfirmed = true; // Only notice the user one time.
  199. if(!firstChoice)
  200. {
  201. $('#product').val(oldProductID);//Revert old product id if confirm is no.
  202. $('#product').trigger("chosen:updated");
  203. $('#product').chosen();
  204. return true;
  205. }
  206. loadAll(productID);
  207. }
  208. else
  209. {
  210. loadProductBranches(productID);
  211. loadProductModules(productID);
  212. loadProductProjects(productID);
  213. loadProductBuilds(productID);
  214. loadProductplans(productID);
  215. }
  216. }
  217. /**
  218. * Load by branch.
  219. *
  220. * @access public
  221. * @return void
  222. */
  223. function loadBranch()
  224. {
  225. productID = $('#product').val();
  226. loadProductModules(productID);
  227. loadProductProjects(productID);
  228. loadProductBuilds(productID);
  229. loadProductplans(productID);
  230. }
  231. /**
  232. *Load all builds of one project or product.
  233. *
  234. * @access public
  235. * @return void
  236. */
  237. function loadAllBuilds(that)
  238. {
  239. if(page == 'resolve')
  240. {
  241. oldResolvedBuild = $('#resolvedBuild').val() ? $('#resolvedBuild').val() : 0;
  242. link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=0&index=0&type=all');
  243. $('#resolvedBuildBox').load(link, function(){$(this).find('select').chosen()});
  244. }
  245. else
  246. {
  247. productID = $('#product').val();
  248. projectID = $('#project').val();
  249. if(page == 'edit') buildBox = $(that).closest('.input-group').attr('id');
  250. if(projectID)
  251. {
  252. loadAllProjectBuilds(projectID, productID);
  253. }
  254. else
  255. {
  256. loadAllProductBuilds(productID);
  257. }
  258. }
  259. }
  260. /**
  261. * Load all builds of the project.
  262. *
  263. * @param int $projectID
  264. * @param int $productID
  265. * @access public
  266. * @return void
  267. */
  268. function loadAllProjectBuilds(projectID, productID)
  269. {
  270. branch = $('#branch').val();
  271. if(typeof(branch) == 'undefined') branch = 0;
  272. if(page == 'create')
  273. {
  274. oldOpenedBuild = $('#openedBuild').val() ? $('#openedBuild').val() : 0;
  275. link = createLink('build', 'ajaxGetExecutionBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&needCreate=true&type=all');
  276. $.get(link, function(data)
  277. {
  278. if(!data) data = '<select id="openedBuild" name="openedBuild" class="form-control" multiple=multiple></select>';
  279. $('#openedBuild').replaceWith(data);
  280. $('#openedBuild_chosen').remove();
  281. $("#openedBuild").chosen();
  282. notice();
  283. })
  284. }
  285. if(page == 'edit')
  286. {
  287. if(buildBox == 'openedBuildBox')
  288. {
  289. link = createLink('build', 'ajaxGetExecutionBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&needCreate=true&type=all');
  290. $('#openedBuildBox').load(link, function(){$(this).find('select').chosen()});
  291. }
  292. if(buildBox == 'resolvedBuildBox')
  293. {
  294. link = createLink('build', 'ajaxGetExecutionBuilds', 'projectID=' + projectID + '&productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=0&index=0&needCreate=true&type=all');
  295. $('#resolvedBuildBox').load(link, function(){$(this).find('select').chosen()});
  296. }
  297. }
  298. }
  299. /**
  300. * Load all builds of the product.
  301. *
  302. * @param int $productID
  303. * @access public
  304. * @return void
  305. */
  306. function loadAllProductBuilds(productID)
  307. {
  308. branch = $('#branch').val();
  309. if(typeof(branch) == 'undefined') branch = 0;
  310. if(page == 'create')
  311. {
  312. link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&type=all');
  313. $.get(link, function(data)
  314. {
  315. if(!data) data = '<select id="openedBuild" name="openedBuild" class="form-control" multiple=multiple></select>';
  316. $('#openedBuild').replaceWith(data);
  317. $('#openedBuild_chosen').remove();
  318. $("#openedBuild").chosen();
  319. notice();
  320. })
  321. }
  322. if(page == 'edit')
  323. {
  324. if(buildBox == 'openedBuildBox')
  325. {
  326. link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch + '&index=0&type=all');
  327. $('#openedBuildBox').load(link, function(){$(this).find('select').chosen()});
  328. }
  329. if(buildBox == 'resolvedBuildBox')
  330. {
  331. link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=0&index=0&type=all');
  332. $('#resolvedBuildBox').load(link, function(){$(this).find('select').chosen()});
  333. }
  334. }
  335. }
  336. /**
  337. * Load product's modules.
  338. *
  339. * @param int $productID
  340. * @access public
  341. * @return void
  342. */
  343. function loadProductModules(productID)
  344. {
  345. branch = $('#branch').val();
  346. if(typeof(branch) == 'undefined') branch = 0;
  347. link = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=bug&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=&needManage=true');
  348. $('#moduleIdBox').load(link, function()
  349. {
  350. $(this).find('select').chosen()
  351. if(typeof(bugModule) == 'string') $('#moduleIdBox').prepend("<span class='input-group-addon' style='border-left-width: 1px;'>" + bugModule + "</span>");
  352. });
  353. }
  354. /**
  355. * Load projects of product.
  356. *
  357. * @param int $productID
  358. * @access public
  359. * @return void
  360. */
  361. function loadProductProjects(productID)
  362. {
  363. branch = $('#branch').val();
  364. if(typeof(branch) == 'undefined') branch = 0;
  365. link = createLink('product', 'ajaxGetProjects', 'productID=' + productID + '&branch=' + branch + '&projectID=' + $('#project').val());
  366. $('#project').load(link, function(){$(this).chosen(); $(this).trigger('chosen:updated');});
  367. }
  368. /**
  369. * Load executions of product.
  370. *
  371. * @param int $productID
  372. * @param int $projectID
  373. * @access public
  374. * @return void
  375. */
  376. function loadProductExecutions(productID, projectID = 0)
  377. {
  378. branch = $('#branch').val();
  379. if(typeof(branch) == 'undefined') branch = 0;
  380. link = createLink('product', 'ajaxGetExecutions', 'productID=' + productID + '&projectID=' + projectID + '&branch=' + branch);
  381. $('#execution').load(link, function()
  382. {
  383. $(this).chosen();
  384. $(this).trigger('chosen:updated');
  385. });
  386. }
  387. /**
  388. * Load product plans.
  389. *
  390. * @param productID $productID
  391. * @access public
  392. * @return void
  393. */
  394. function loadProductplans(productID)
  395. {
  396. branch = $('#branch').val();
  397. if(typeof(branch) == 'undefined') branch = 0;
  398. link = createLink('productplan', 'ajaxGetProductplans', 'productID=' + productID + '&branch=' + branch);
  399. $('#planIdBox').load(link, function(){$(this).find('select').chosen()});
  400. }
  401. /**
  402. * Load product builds.
  403. *
  404. * @param productID $productID
  405. * @access public
  406. * @return void
  407. */
  408. function loadProductBuilds(productID)
  409. {
  410. branch = $('#branch').val();
  411. if(typeof(branch) == 'undefined') branch = 0;
  412. link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch);
  413. if(page == 'create')
  414. {
  415. $.get(link, function(data)
  416. {
  417. if(!data) data = '<select id="openedBuild" name="openedBuild" class="form-control" multiple=multiple></select>';
  418. $('#openedBuild').replaceWith(data);
  419. $('#openedBuild_chosen').remove();
  420. $("#openedBuild").chosen();
  421. notice();
  422. })
  423. }
  424. else
  425. {
  426. $('#openedBuildBox').load(link, function(){$(this).find('select').chosen()});
  427. link = createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=' + branch);
  428. $('#resolvedBuildBox').load(link, function(){$(this).find('select').chosen()});
  429. }
  430. }
  431. /**
  432. * Load execution related bugs.
  433. *
  434. * @param int $executionID
  435. * @access public
  436. * @return void
  437. */
  438. function loadExecutionRelated(executionID)
  439. {
  440. if(executionID)
  441. {
  442. loadExecutionBuilds(executionID);
  443. loadAssignedTo(executionID);
  444. }
  445. else
  446. {
  447. loadProductBuilds($('#product').val());
  448. }
  449. }
  450. /**
  451. * Load builds of an execution.
  452. *
  453. * @param int $executionID
  454. * @access public
  455. * @return void
  456. */
  457. function loadExecutionBuilds(executionID)
  458. {
  459. branch = $('#branch').val();
  460. if(typeof(branch) == 'undefined') branch = 0;
  461. productID = $('#product').val();
  462. oldOpenedBuild = $('#openedBuild').val() ? $('#openedBuild').val() : 0;
  463. if(page == 'create')
  464. {
  465. link = createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + "&branch=" + branch + "&index=0&needCreate=true");
  466. $.get(link, function(data)
  467. {
  468. if(!data) data = '<select id="openedBuild" name="openedBuild" class="form-control" multiple=multiple></select>';
  469. $('#openedBuild').replaceWith(data);
  470. $('#openedBuild_chosen').remove();
  471. $("#openedBuild").chosen();
  472. notice();
  473. })
  474. }
  475. else
  476. {
  477. link = createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + '&varName=openedBuild&build=' + oldOpenedBuild + '&branch=' + branch);
  478. $('#openedBuildBox').load(link, function(){$(this).find('select').chosen()});
  479. oldResolvedBuild = $('#resolvedBuild').val() ? $('#resolvedBuild').val() : 0;
  480. link = createLink('build', 'ajaxGetExecutionBuilds', 'executionID=' + executionID + '&productID=' + productID + '&varName=resolvedBuild&build=' + oldResolvedBuild + '&branch=' + branch);
  481. $('#resolvedBuildBox').load(link, function(){$(this).find('select').chosen()});
  482. }
  483. }
  484. /**
  485. * Set story field.
  486. *
  487. * @param moduleID $moduleID
  488. * @param productID $productID
  489. * @access public
  490. * @return void
  491. */
  492. function setStories(moduleID, productID)
  493. {
  494. var branch = $('#branch').val();
  495. if(typeof(branch) == 'undefined') branch = 0;
  496. link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID);
  497. $.get(link, function(stories)
  498. {
  499. if(!stories) stories = '<select id="story" name="story" class="form-control"></select>';
  500. $('#story').replaceWith(stories);
  501. $('#story_chosen').remove();
  502. $("#story").chosen();
  503. });
  504. }
  505. /**
  506. * Load product branches.
  507. *
  508. * @param int $productID
  509. * @access public
  510. * @return void
  511. */
  512. function loadProductBranches(productID)
  513. {
  514. $('#branch').remove();
  515. $('#branch_chosen').remove();
  516. $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID), function(data)
  517. {
  518. if(data)
  519. {
  520. $('#product').closest('.input-group').append(data);
  521. $('#branch').css('width', page == 'create' ? '120px' : '65px');
  522. $('#branch').chosen();
  523. }
  524. })
  525. }
  526. /**
  527. * Load team members of the project as assignedTo list.
  528. *
  529. * @param int $projectID
  530. * @access public
  531. * @return void
  532. */
  533. function loadAssignedTo(projectID)
  534. {
  535. link = createLink('bug', 'ajaxLoadAssignedTo', 'projectID=' + projectID + '&selectedUser=' + $('#assignedTo').val());
  536. $.get(link, function(data)
  537. {
  538. $('#assignedTo_chosen').remove();
  539. $('#assignedTo').replaceWith(data);
  540. $('#assignedTo').chosen();
  541. });
  542. }
  543. /**
  544. * notice for create build.
  545. *
  546. * @access public
  547. * @return void
  548. */
  549. function notice()
  550. {
  551. $('#buildBoxActions').empty().hide();
  552. if($('#openedBuild').find('option').length <= 1)
  553. {
  554. var html = '';
  555. if($('#project').length == 0 || $('#project').val() == '')
  556. {
  557. var branch = $('#branch').val();
  558. if(typeof(branch) == 'undefined') branch = 0;
  559. var link = createLink('release', 'create', 'productID=' + $('#product').val() + '&branch=' + branch);
  560. html += '<a href="' + link + '" target="_blank" style="padding-right:5px">' + createBuild + '</a> ';
  561. html += '<a href="javascript:loadProductBuilds(' + $('#product').val() + ')">' + refresh + '</a>';
  562. }
  563. else
  564. {
  565. projectID = $('#project').val();
  566. html += '<a href="' + createLink('build', 'create','projectID=' + projectID) + '" target="_blank" style="padding-right:5px">' + createBuild + '</a> ';
  567. html += '<a href="javascript:loadProjectBuilds(' + projectID + ')">' + refresh + '</a>';
  568. }
  569. var $bba = $('#buildBoxActions');
  570. if($bba.length)
  571. {
  572. $bba.html(html);
  573. $bba.show();
  574. }
  575. else
  576. {
  577. if($('#buildBox').closest('tr').find('td').size() > 1)
  578. {
  579. $('#buildBox').closest('td').next().attr('id', 'buildBoxActions');
  580. $('#buildBox').closest('td').next().html(html);
  581. }
  582. else
  583. {
  584. html = "<td id='buildBoxActions'>" + html + '</td>';
  585. $('#buildBox').closest('td').after(html);
  586. }
  587. }
  588. }
  589. }
  590. /**
  591. * Load all users as assignedTo list.
  592. *
  593. * @access public
  594. * @return void
  595. */
  596. function loadAllUsers()
  597. {
  598. var link = createLink('bug', 'ajaxLoadAllUsers', 'selectedUser=' + $('#assignedTo').val());
  599. $.get(link, function(data)
  600. {
  601. if(data)
  602. {
  603. var moduleID = $('#module').val();
  604. var productID = $('#product').val();
  605. setAssignedTo(moduleID, productID);
  606. $('#assignedTo').empty().append($(data).find('option')).trigger('chosen:updated').trigger('chosen:activate');
  607. }
  608. });
  609. }
  610. /**
  611. * Load team members of the latest project of a product as assignedTo list.
  612. *
  613. * @param $productID
  614. * @access public
  615. * @return void
  616. */
  617. function loadProjectTeamMembers(productID)
  618. {
  619. var link = createLink('bug', 'ajaxLoadProjectTeamMembers', 'productID=' + productID + '&selectedUser=' + $('#assignedTo').val());
  620. $('#assignedToBox').load(link, function(){$('#assignedTo').chosen();});
  621. }
  622. /**
  623. * load assignedTo and stories of module.
  624. *
  625. * @access public
  626. * @return void
  627. */
  628. function loadModuleRelated()
  629. {
  630. var moduleID = $('#module').val();
  631. var productID = $('#product').val();
  632. setAssignedTo(moduleID, productID);
  633. setStories(moduleID, productID);
  634. }
  635. /**
  636. * Set the assignedTo field.
  637. *
  638. * @access public
  639. * @return void
  640. */
  641. function setAssignedTo(moduleID, productID)
  642. {
  643. if(typeof(productID) == 'undefined') productID = $('#product').val();
  644. if(typeof(moduleID) == 'undefined') moduleID = $('#module').val();
  645. var link = createLink('bug', 'ajaxGetModuleOwner', 'moduleID=' + moduleID + '&productID=' + productID);
  646. $.get(link, function(owner)
  647. {
  648. $('#assignedTo').val(owner);
  649. $("#assignedTo").trigger("chosen:updated");
  650. });
  651. }
  652. $(function()
  653. {
  654. if($('#project').val()) loadExecutionRelated($('#project').val());
  655. $('[data-toggle=tooltip]').tooltip();
  656. // adjust size of bug type input group
  657. var adjustBugTypeGroup = function()
  658. {
  659. var $group = $('#bugTypeInputGroup');
  660. var width = ($group.parent().width()), addonWidth = 0;
  661. var $controls = $group.find('.chosen-single');
  662. $group.children('.input-group-addon').each(function()
  663. {
  664. addonWidth += $(this).outerWidth();
  665. });
  666. var bestWidth = Math.floor((width - addonWidth)/$controls.length);
  667. $controls.css('width', bestWidth);
  668. var lastWidth = width - addonWidth - bestWidth * ($controls.length - 1);
  669. $controls.last().css('width', lastWidth);
  670. };
  671. adjustBugTypeGroup();
  672. $(window).on('resize', adjustBugTypeGroup);
  673. // init pri and severity selector
  674. $('#severity, #pri').on('change', function()
  675. {
  676. var $select = $(this);
  677. var $selector = $select.closest('.pri-selector');
  678. var value = $select.val();
  679. $selector.find('.pri-text').html($selector.data('type') === 'severity' ? '<span class="label-severity" data-severity="' + value + '" title="' + value + '"></span>' : '<span class="label-pri label-pri-' + value + '" title="' + value + '">' + value + '</span>');
  680. });
  681. loadAll(<?php echo $productID;?>);
  682. });
  683. </script>