ajaxgetdropmenu.html.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <?php js::set('module', $module);?>
  2. <?php js::set('method', $method);?>
  3. <?php js::set('extra', $extra);?>
  4. <style>
  5. #navTabs {position: sticky; top: 0; background: #fff; z-index: 950;}
  6. #navTabs>li {padding: 0px 10px; display: inline-block}
  7. #navTabs>li>span {display: inline-block;}
  8. #navTabs>li>a {margin: 0!important; padding: 8px 0px; display: inline-block}
  9. #tabContent {margin-top: 5px; z-index: 900; max-width: 220px}
  10. .executionTree ul {list-style: none; margin: 0}
  11. .executionTree .executions>ul>li>div {display: flex; flex-flow: row nowrap; justify-content: flex-start; align-items: center;}
  12. .executionTree .executions>ul>li label {background: rgba(255,255,255,0.5); line-height: unset; color: #838a9d; border: 1px solid #d8d8d8; border-radius: 2px; padding: 1px 4px;}
  13. .executionTree li a i.icon {font-size: 15px !important;}
  14. .executionTree li a i.icon:before {min-width: 16px !important;}
  15. .executionTree li .label {position: unset; margin-bottom: 0;}
  16. .executionTree li>a, div.hide-in-search>a {display: block; padding: 2px 10px 2px 5px; overflow: hidden; line-height: 20px; text-overflow: ellipsis; white-space: nowrap; border-radius: 4px;}
  17. .executionTree .tree li>.list-toggle {line-height: 24px;}
  18. .executionTree .tree li.has-list.open:before {content: unset;}
  19. #swapper li>div.hide-in-search>a:focus, #swapper li>div.hide-in-search>a:hover {color: #838a9d; cursor: default;}
  20. #swapper li > a {margin-top: 4px; margin-bottom: 4px;}
  21. #swapper li {padding-top: 0; padding-bottom: 0;}
  22. #swapper .tree li>.list-toggle {top: -1px;}
  23. #closed {width: 90px; height: 25px; line-height: 25px; background-color: #ddd; color: #3c495c; text-align: center; margin-left: 15px; border-radius: 2px;}
  24. #gray-line {width: 230px;height: 1px; margin-left: 10px; margin-bottom:2px; background-color: #ddd;}
  25. #dropMenu.has-search-text .hide-in-search {display: flex;}
  26. #swapper li>.selected {color: #0c64eb!important; background: #e9f2fb!important;}
  27. </style>
  28. <?php
  29. $executionCounts = array();
  30. $executionNames = array();
  31. $currentExecution = '';
  32. $tabActive = '';
  33. $myExecutions = 0;
  34. $others = 0;
  35. $dones = 0;
  36. foreach($projectExecutions as $projectID => $executions)
  37. {
  38. $executionCounts[$projectID]['myExecution'] = 0;
  39. $executionCounts[$projectID]['others'] = 0;
  40. $executionCounts[$projectID]['closed'] = 0;
  41. foreach($executions as $execution)
  42. {
  43. if($execution->status != 'done' and $execution->status != 'closed' and ($execution->PM == $this->app->user->account or isset($execution->teams[$this->app->user->account]))) $executionCounts[$projectID]['myExecution'] ++;
  44. if($execution->status != 'done' and $execution->status != 'closed' and $execution->PM != $this->app->user->account and !isset($execution->teams[$this->app->user->account])) $executionCounts[$projectID]['others'] ++;
  45. if($execution->status == 'done' or $execution->status == 'closed') $executionCounts[$projectID]['closed'] ++;
  46. $onlyChildStage = $execution->grade == 2 and $execution->project != $execution->parent;
  47. $executionNames[$execution->id] = $execution->name;
  48. if($onlyChildStage and isset($parents[$execution->parent]))
  49. {
  50. $executionNames[$execution->id] = $parents[$execution->parent]->name . '/' . $execution->name;
  51. }
  52. }
  53. }
  54. $executionsPinYin = common::convert2Pinyin($executionNames);
  55. $myExecutionsHtml = '<ul class="tree tree-angles" data-ride="tree">';
  56. $normalExecutionsHtml = '<ul class="tree tree-angles" data-ride="tree">';
  57. $closedExecutionsHtml = '<ul class="tree tree-angles" data-ride="tree">';
  58. $kanbanLink = $this->createLink('execution', 'kanban', "executionID=%s");
  59. $taskLink = $this->createLink('execution', 'task', "executionID=%s");
  60. foreach($projectExecutions as $projectID => $executions)
  61. {
  62. /* Adapt to the old version. */
  63. if($projectID)
  64. {
  65. $projectName = zget($projects, $projectID);
  66. if($executionCounts[$projectID]['myExecution']) $myExecutionsHtml .= '<li><div class="hide-in-search"><a class="text-muted not-list-item" title="' . $projectName . '">' . $projectName . '</a> <label class="label">' . $lang->project->common . '</label></div><ul>';
  67. if($executionCounts[$projectID]['others']) $normalExecutionsHtml .= '<li><div class="hide-in-search"><a class="text-muted not-list-item" title="' . $projectName . '">' . $projectName . '</a> <label class="label">' . $lang->project->common . '</label></div><ul>';
  68. if($executionCounts[$projectID]['closed']) $closedExecutionsHtml .= '<li><div class="hide-in-search"><a class="text-muted not-list-item" title="' . $projectName . '">' . $projectName . '</a> <label class="label">' . $lang->project->common . '</label></div><ul>';
  69. }
  70. foreach($executions as $index => $execution)
  71. {
  72. $executionLink = $link;
  73. $isKanbanMethod = ((in_array($method, $config->execution->kanbanMethod) and $module == 'execution') or (strpos(',create,edit,', ",$method,") !== false and $module == 'build'));
  74. if(isset($execution->type) and $execution->type == 'kanban' and !$isKanbanMethod) $executionLink = $kanbanLink;
  75. if(isset($execution->type) and $execution->type != 'kanban' and strpos(',kanban,cfd,', ",$method,") !== false) $executionLink = $taskLink;
  76. if(isset($execution->type) and $execution->type == 'stage' and in_array($module, array('issue', 'risk', 'opportunity', 'pssp', 'auditplan', 'meeting'))) $executionLink = $taskLink;
  77. if(isset($execution->attribute) and in_array($execution->attribute, array('request', 'review')))
  78. {
  79. $changeLink = false;
  80. if(in_array($module, array('repo', 'issue', 'risk', 'opportunity', 'pssp', 'auditplan', 'meeting'))) $changeLink = true;
  81. if($module == 'execution' and in_array($method, array('story', 'bug', 'testcase', 'testtask', 'build', 'grouptask', 'tree', 'manageproducts'))) $changeLink = true;
  82. if($changeLink) $executionLink = (isset($execution->type) and $execution->type == 'kanban') ? $kanbanLink : $taskLink;
  83. }
  84. if($execution->id == $executionID) $currentExecution = $execution;
  85. $selected = $execution->id == $executionID ? 'selected' : '';
  86. if($execution->status != 'done' and $execution->status != 'closed' and ($execution->PM == $this->app->user->account or isset($execution->teams[$this->app->user->account])))
  87. {
  88. $myExecutionsHtml .= '<li>' . html::a(sprintf($executionLink, $execution->id), $executionNames[$execution->id], '', "class='$selected clickable' title='{$executionNames[$execution->id]}' data-key='" . zget($executionsPinYin, $execution->name, '') . "' data-app='{$this->app->tab}'") . '</li>';
  89. if($selected == 'selected') $tabActive = 'myExecution';
  90. $myExecutions ++;
  91. }
  92. else if($execution->status != 'done' and $execution->status != 'closed' and $execution->PM != $this->app->user->account and !isset($execution->teams[$this->app->user->account]))
  93. {
  94. $normalExecutionsHtml .= '<li>' . html::a(sprintf($executionLink, $execution->id), $executionNames[$execution->id], '', "class='$selected clickable' title='{$executionNames[$execution->id]}' data-key='" . zget($executionsPinYin, $execution->name, '') . "' data-app='{$this->app->tab}'") . '</li>';
  95. if($selected == 'selected') $tabActive = 'other';
  96. $others ++;
  97. }
  98. else if($execution->status == 'done' or $execution->status == 'closed')
  99. {
  100. $closedExecutionsHtml .= '<li>' . html::a(sprintf($executionLink, $execution->id), $executionNames[$execution->id], '', "class='$selected clickable' title='{$executionNames[$execution->id]}' data-key='" . zget($executionsPinYin, $execution->name, '') . "' data-app='{$this->app->tab}'") . '</li>';
  101. if($selected == 'selected') $tabActive = 'closed';
  102. }
  103. /* If the execution is the last one in the project, print the closed label. */
  104. if(!isset($executions[$index + 1]))
  105. {
  106. if($executionCounts[$projectID]['myExecution']) $myExecutionsHtml .= '</ul></li>';
  107. if($executionCounts[$projectID]['others']) $normalExecutionsHtml .= '</ul></li>';
  108. if($executionCounts[$projectID]['closed']) $closedExecutionsHtml .= '</ul></li>';
  109. }
  110. }
  111. }
  112. $myExecutionsHtml .= '</ul>';
  113. $normalExecutionsHtml .= '</ul>';
  114. $closedExecutionsHtml .= '</ul>';
  115. ?>
  116. <div class="table-row">
  117. <div class="table-col col-left">
  118. <div class='list-group'>
  119. <?php $tabActive = ($myExecutions and ($tabActive == 'closed' or $tabActive == 'myExecution')) ? 'myExecution' : 'other';?>
  120. <?php if($myExecutions): ?>
  121. <ul class="nav nav-tabs nav-tabs-primary" id="navTabs">
  122. <li class="<?php if($tabActive == 'myExecution') echo 'active';?>"><?php echo html::a('#myExecution', $lang->execution->involved, '', "data-toggle='tab' class='not-list-item not-clear-menu'");?><span class="label label-light label-badge"><?php echo $myExecutions;?></span><li>
  123. <li class="<?php if($tabActive == 'other') echo 'active';?>"><?php echo html::a('#other', $lang->project->other, '', "data-toggle='tab' class='not-list-item not-clear-menu'")?><span class="label label-light label-badge"><?php echo $others;?></span><li>
  124. </ul>
  125. <?php endif;?>
  126. <div class="tab-content executionTree" id="tabContent">
  127. <div class="tab-pane executions <?php if($tabActive == 'myExecution') echo 'active';?>" id="myExecution">
  128. <?php echo $myExecutionsHtml;?>
  129. </div>
  130. <div class="tab-pane executions <?php if($tabActive == 'other') echo 'active';?>" id="other">
  131. <?php echo $normalExecutionsHtml;?>
  132. </div>
  133. </div>
  134. </div>
  135. <div class="col-footer">
  136. <a class='pull-right toggle-right-col not-list-item'><?php echo $lang->execution->doneExecutions;?><i class='icon icon-angle-right'></i></a>
  137. </div>
  138. </div>
  139. <div id="gray-line" hidden></div>
  140. <div id="closed" hidden><?php echo $lang->execution->closedExecution?></div>
  141. <div class="table-col col-right executionTree">
  142. <div class='list-group executions'><?php echo $closedExecutionsHtml;?></div>
  143. </div>
  144. </div>
  145. <script>
  146. $(function()
  147. {
  148. <?php if($currentExecution and ($currentExecution->status == 'done' or $currentExecution->status == 'closed')):?>
  149. $('.col-footer .toggle-right-col').click(function(){ scrollToSelected(); })
  150. <?php else:?>
  151. scrollToSelected();
  152. <?php endif;?>
  153. $('.nav-tabs li span').hide();
  154. $('.nav-tabs li.active').find('span').show();
  155. $('.nav-tabs>li a').click(function()
  156. {
  157. if($('#swapper input[type="search"]').val() == '')
  158. {
  159. $(this).siblings().show();
  160. $(this).parent().siblings('li').find('span').hide();
  161. }
  162. })
  163. $('#swapper [data-ride="tree"]').tree('expand');
  164. $('#swapper #dropMenu .search-box').on('onSearchChange', function(event, value)
  165. {
  166. if(value != '')
  167. {
  168. $('div.hide-in-search').siblings('i').addClass('hide-in-search');
  169. $('.nav-tabs li span').hide();
  170. }
  171. else
  172. {
  173. $('div.hide-in-search').siblings('i').removeClass('hide-in-search');
  174. $('li.has-list div.hide-in-search').removeClass('hidden');
  175. $('.nav-tabs li.active').find('span').show();
  176. }
  177. if($('.form-control.search-input').val().length > 0)
  178. {
  179. $('#closed').attr("hidden", false);
  180. $('#gray-line').attr("hidden", false);
  181. }
  182. else
  183. {
  184. $('#closed').attr("hidden", true);
  185. $('#gray-line').attr("hidden", true);
  186. }
  187. });
  188. $('#swapper #dropMenu').on('onSearchComplete', function()
  189. {
  190. var listItem = $(this).find('.has-list');
  191. listItem.each(function()
  192. {
  193. $(this).css('display','')
  194. var $hidden = $(this).find('.hidden');
  195. var $item = $(this).find('.search-list-item');
  196. if($hidden.length == $item.length) $(this).css('display','none');
  197. });
  198. if($('.list-group.executions').height() == 0)
  199. {
  200. $('#closed').attr("hidden", true);
  201. $('#gray-line').attr("hidden", true);
  202. }
  203. });
  204. })
  205. </script>