header.review.html.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <?php
  2. /* get last review info in this file. */
  3. $lastReview = $this->mr->getLastReviewInfo($repo->id);
  4. /* Get product pairs. */
  5. if(isset($repo->product) and $repo->product)
  6. {
  7. $products = $this->dao->select('id,name')->from(TABLE_PRODUCT)->where('`id`')->in($repo->product)->fetchPairs();
  8. }
  9. else
  10. {
  11. $products = $this->loadModel('product')->getPairs();
  12. }
  13. /* get product by cookie or last review in this file. */
  14. $repoProduct = isset($_COOKIE['repoPairs'][$repoID]) ? $_COOKIE['repoPairs'][$repoID] : '';
  15. $repoProduct = (!empty($lastReview->bug) && isset($lastReview->bug->product)) ? $lastReview->bug->product : $repoProduct;
  16. $repoProduct = isset($products[$repoProduct]) ? $repoProduct : key($products);
  17. $bugRepoModule = (!empty($lastReview->bug) && $lastReview->bug->product == $repoProduct) ? $lastReview->bug->module : '';
  18. $executions = $this->mr->getExecutionPairs($repoProduct);
  19. $modules = $this->loadModel('tree')->getOptionMenu($repoProduct, $viewType = 'bug', $startModuleID = 0);
  20. $users = $this->loadModel('user')->getPairs('devfirst|nodeleted|noclosed');
  21. $products = array('' => '') + $products;
  22. $executions = array('' => '') + $executions;
  23. $taskExecutions = $executions;
  24. if(empty($repo->product)) $taskExecutions = array('' => '') + $this->loadModel('execution')->getPairs();
  25. $repoExecution = (!empty($lastReview->task) && isset($lastReview->task->execution)) ? $lastReview->task->execution : $this->session->execution;
  26. $repoExecution = isset($taskExecutions[$repoExecution]) ? $repoExecution : key($taskExecutions);
  27. $taskModules = array('' => '');
  28. $taskRepoModule = 0;
  29. $taskMembers = array('' => '');
  30. if($repoExecution)
  31. {
  32. $taskModules = $this->loadModel('tree')->getTaskOptionMenu($repoExecution, 0, 0, '');
  33. $taskRepoModule = (!empty($lastReview->task) && $lastReview->task->execution == $repoExecution) ? $lastReview->task->module : '';
  34. $taskMembers = $this->loadModel('user')->getTeamMemberPairs($repoExecution, 'execution', 'nodeleted');
  35. }
  36. $reviews = $this->mr->getReview($repoID, $MR->id);
  37. $v1 = helper::safe64Encode($sourceBranch);
  38. $v2 = helper::safe64Encode($targetBranch);
  39. $this->loadModel('repo');
  40. $taskModuleSelect = html::select('taskModule', $taskModules, $taskRepoModule, 'class="form-control chosen"');
  41. $taskUserSelect = html::select('taskAssignedTo', $taskMembers, '', 'class="form-control chosen"');
  42. $taskExecutionSelect = html::select('taskExecution', $taskExecutions, $repoExecution, 'class="form-control chosen" onchange="changeExecution(this)"');
  43. $reviewUrl = $this->createLink('mr', 'addReview', "repoID=$repoID&mr={$MR->id}&v1=$v1&v2=$v2");
  44. $productSelect = html::select('product', $products, $repoProduct, 'class="product form-control chosen" onchange="changeProduct(this)"');
  45. $branches = $this->loadModel('branch')->getPairs($repoProduct);
  46. $moduleSelect = html::select('module', $modules, $bugRepoModule, 'class="form-control chosen"');
  47. $executionSelect = html::select('execution', $executions, '', 'class="form-control chosen"');
  48. $typeSelect = html::select('repoType', $lang->repo->typeList, '', 'class="form-control chosen"');
  49. $userSelect = html::select('assignedTo', $users, '', 'class="form-control chosen assignedTo"');
  50. $lineReviews = array();
  51. foreach($reviews as $line => $lineReview)
  52. {
  53. foreach($lineReview as $objectType => $objects)
  54. {
  55. foreach($objects as $objectID => $object)
  56. {
  57. $lineReview = array();
  58. $lineReview['id'] = $objectID;
  59. $lineReview['line'] = $line;
  60. $lineReview['title'] = $objectType == 'bug' ? $object->title : $object->name;
  61. $lineReview['content'] = $objectType == 'bug' ? $object->steps : $object->desc;
  62. $lineReview['realname'] = $object->realname;
  63. $lineReview['openedDate'] = substr($object->openedDate, 5, 11);
  64. $lineReview['lines'] = $object->lines;
  65. $lineReview['objectType'] = $objectType;
  66. $lineReview['entry'] = $object->entry;
  67. $lineReview['edit'] = common::hasPriv($objectType, 'edit');
  68. $lineReview['delete'] = common::hasPriv($objectType, 'delete');
  69. $lineReview['view'] = common::hasPriv($objectType, 'view');
  70. $lineReviews[$line][] = $lineReview;
  71. }
  72. }
  73. }
  74. js::set('reviews', $lineReviews);
  75. js::set('productError', $lang->repo->error->product);
  76. js::set('contentError', $lang->repo->error->commentText);
  77. js::set('titleError', $lang->repo->error->title);
  78. js::set('commentError', $lang->repo->error->comment);
  79. js::set('submit', $lang->repo->submit);
  80. js::set('cancel', $lang->repo->cancel);
  81. js::set('confirmDelete', $lang->repo->notice->deleteReview);
  82. js::set('repoID', $repoID);
  83. js::set('MRID', $MR->id);
  84. js::set('revision', '');
  85. ?>
  86. <?php if(common::hasPriv('mr', 'addReview')):?>
  87. <form id="reviewForm" class="reviewForm main-form hide" method="post" action="<?php echo $reviewUrl?>">
  88. <div class="reviewFormContainer">
  89. <table class='table table-form'>
  90. <tr>
  91. <th class='w-100px'><?php echo $lang->mr->reviewType;?></th>
  92. <td class='w-p45'><?php echo html::select('reviewType', $lang->mr->reviewTypeList, 'bug', "class='form-control' onchange=changeReviewType(this)")?></td>
  93. <th class='w-100px'></th>
  94. <td class='w-p45'></td>
  95. </tr>
  96. <tr>
  97. <th><?php echo $lang->repo->product?></th>
  98. <td>
  99. <div class='input-group'>
  100. <?php echo $productSelect?>
  101. <?php if($branches) echo html::select('branch', $branches, '', "class='form-control' style='width:95px' onchange='loadBranch(this)'");?>
  102. </div>
  103. </td>
  104. <th><?php echo $lang->repo->module?></th>
  105. <td><?php echo $moduleSelect?></td>
  106. </tr>
  107. <tr>
  108. <th><?php echo $lang->repo->execution?></th>
  109. <td>
  110. <div class='bugExecutionBox'><?php echo $executionSelect?></div>
  111. <div class='taskExecutionBox hide required'><?php echo $taskExecutionSelect?></div>
  112. </td>
  113. <th><?php echo $lang->repo->type?></th>
  114. <td><?php echo $typeSelect?></td>
  115. <th class='taskModuleBox hide'><?php echo $lang->repo->module?></th>
  116. <td class='taskModuleBox hide'><?php echo $taskModuleSelect?></td>
  117. </tr>
  118. <tr>
  119. <th><?php echo $lang->repo->assign?></th>
  120. <td>
  121. <div class='bugAssignedToBox'><?php echo $userSelect?></div>
  122. <div class='taskAssignedToBox hide'><?php echo $taskUserSelect?></div>
  123. </td>
  124. <th><?php echo $lang->repo->lines?></th>
  125. <td class='lines'>
  126. <div class="input-group">
  127. <input class="line form-control" type="number" min="1" name="begin">
  128. <span class="input-group-addon fix-border">-</span>
  129. <input class="line form-control" type="number" min="1" name="end">
  130. </div>
  131. </td>
  132. </tr>
  133. <tr>
  134. <th><?php echo $lang->repo->title?></th>
  135. <td colspan='3' class='required'>
  136. <?php echo html::input('title', '', "class='form-control'");?>
  137. </td>
  138. </tr>
  139. <tr>
  140. <th><?php echo $lang->repo->detile?></th>
  141. <td colspan='3'><textarea id="commentText" name="commentText" class="commentInput form-control" spellcheck="false"></textarea></td>
  142. </tr>
  143. <tr>
  144. <th></th>
  145. <td colspan="3" class='form-actions'>
  146. <?php echo html::hidden('entry');?>
  147. <?php echo html::submitButton($lang->repo->submit, '', 'btn btn-wide btn-primary reviewSubmit');?>
  148. <?php echo html::commonButton($lang->cancel, "onclick='hiddenForm()'", 'btn btn-wide');?>
  149. </td>
  150. </tr>
  151. </table>
  152. <div class="optional"></div>
  153. </div>
  154. </form>
  155. <?php else:?>
  156. <form id='reviewForm' class='reviewForm hide'>
  157. <?php printf($lang->user->errorDeny, $lang->mr->common, $lang->mr->addReview);?>
  158. </form>
  159. <?php endif;?>
  160. <div class='panel panel-sm hide panel-review' id='reviewPanel'>
  161. <div class='panel-heading'>
  162. <div class='panel-actions pull-right'>
  163. <a href='javascript:;' class='delete reviewDelete'><i class='icon-remove'></i></a>
  164. <a href="javascript:;"><i class='icon-chevron-down'></i></a>
  165. </div>
  166. <i class='text-muted'></i> <strong class='title'></strong>
  167. </div>
  168. <div class='panel-body'>
  169. <p><?php echo $lang->repo->lines?> <strong class='code-lines'></strong> &nbsp; <i class='icon-user text-muted'></i> <strong class='realname'></strong> &nbsp;<span class='text-muted bug-date'><i class='icon-time'></i> <span class='openedDate'></span></span></p>
  170. <p class='content text-content'></p>
  171. </div>
  172. </div>
  173. <div class='dropdown' id="reviewsPreview">
  174. <ul class='dropdown-menu fade'>
  175. <li class='dropdown-header'><?php echo $lang->repo->line?><strong class='code-line'></strong> &nbsp; <i class='icon-bug'></i> <strong class='bug-count'>0</strong> &nbsp; <i class='icon-comments-alt'></i> <strong class='comment-count'>0</strong></li>
  176. </ul>
  177. </div>
  178. <div id='rowTip' class='hide'><div class='row-tip'><div class='on-expand tip'><span><?php echo $lang->repo->expand?> </span><i class='icon-chevron-down'></i></div><div class='on-collapse tip'><span><?php echo $lang->repo->collapse?> </span><i class='icon-chevron-up'></i></div></div></div>
  179. <script>
  180. function changeReviewType(select)
  181. {
  182. var reviewType = $(select).val();
  183. if(reviewType == 'bug')
  184. {
  185. $('#product').closest('td').show();
  186. $('#product').closest('td').prev().show();
  187. $('#module').closest('td').show();
  188. $('#module').closest('td').prev().show();
  189. $('#repoType').closest('td').show();
  190. $('#repoType').closest('td').prev().show();
  191. $('.taskModuleBox').addClass('hide');
  192. $('.bugAssignedToBox').removeClass('hide');
  193. $('.taskAssignedToBox').addClass('hide');
  194. $('.bugExecutionBox').removeClass('hide');
  195. $('.taskExecutionBox').addClass('hide');
  196. }
  197. else
  198. {
  199. $('#product').closest('td').hide();
  200. $('#product').closest('td').prev().hide();
  201. $('#module').closest('td').hide();
  202. $('#module').closest('td').prev().hide();
  203. $('#repoType').closest('td').hide();
  204. $('#repoType').closest('td').prev().hide();
  205. $('.taskModuleBox').removeClass('hide');
  206. $('.bugAssignedToBox').addClass('hide');
  207. $('.taskAssignedToBox').removeClass('hide');
  208. $('.bugExecutionBox').addClass('hide');
  209. $('.taskExecutionBox').removeClass('hide');
  210. }
  211. }
  212. function changeProduct(select)
  213. {
  214. loadProductBranches(select);
  215. productID = $(select).children('option:selected').val();
  216. link = createLink('repo', 'ajaxGetExecutions', 'productID=' + productID);
  217. $(select).closest('.reviewFormContainer').find('select[name=execution]').parent().load(link, '', function(){$('#execution').chosen();});
  218. moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=bug&branch=0&rootModuleID=0&returnType=html');
  219. $(select).closest('.reviewFormContainer').find('select[name=module]').parent().load(moduleLink, '', function(){$('#module').chosen();});
  220. }
  221. function changeExecution(select)
  222. {
  223. if($('#reviewType').val() == 'bug') return false;
  224. var executionID = $(select).val();
  225. moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'execution=' + executionID + '&viewtype=task&branch=0&rootModuleID=0&returnType=html');
  226. $('td.taskModuleBox').load(moduleLink, '', function(){$('.taskModuleBox #module').attr('id', 'taskModule').attr('name', 'taskModule').chosen();});
  227. assignLink = createLink('execution', 'ajaxGetMembers', 'executionID=' + executionID);
  228. $('.taskAssignedToBox').load(assignLink, '', function(){$('.taskAssignedToBox #assignedTo').attr('id', 'taskAssignedTo').attr('name', 'taskAssignedTo').chosen();});
  229. }
  230. function loadProductBranches(select)
  231. {
  232. $(select).closest('.input-group').find('#branch').remove();
  233. productID = $(select).children('option:selected').val();
  234. $.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID), function(data)
  235. {
  236. if(data)
  237. {
  238. $(select).closest('.input-group').append(data);
  239. $(select).closest('.input-group').find('#branch').css('width', '95px');
  240. }
  241. });
  242. }
  243. function loadBranch(select)
  244. {
  245. branch = $(select).val();
  246. productID = $(select).closest('.input-group').find('#product').val();
  247. link = createLink('repo', 'ajaxGetExecutions', 'productID=' + productID + '&branch=' + branch);
  248. $(select).closest('.reviewFormContainer').find('select[name=execution]').parent().load(link, '', function(){$('#execution').chosen();});
  249. moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=bug&branch=' + branch + '&rootModuleID=0&returnType=html');
  250. $(select).closest('.reviewFormContainer').find('select[name=module]').parent().load(moduleLink, '', function(){$('#module').chosen();});
  251. }
  252. function hiddenForm()
  253. {
  254. $('.with-action-row').removeClass('with-action-row');
  255. }
  256. /* remove a function */
  257. function loadModuleRelated(){}
  258. </script>