ajaxgetdropmenu.html.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php js::set('productID', $productID);?>
  2. <?php js::set('module', $module);?>
  3. <?php js::set('method', $method);?>
  4. <?php js::set('extra', $extra);?>
  5. <style>
  6. #navTabs {position: sticky; top: 0; background: #fff; z-index: 950;}
  7. #navTabs > li {padding: 0px 10px; display: inline-block}
  8. #navTabs > li > span {display: inline-block;}
  9. #navTabs > li > a {margin: 0!important; padding: 8px 0px; display: inline-block}
  10. #tabContent {margin-top: 5px; z-index: 900; max-width: 220px}
  11. .productTree ul {list-style: none; margin: 0}
  12. .productTree .products>ul {padding-left: 7px;}
  13. .productTree .products>ul > li > div {display: flex; flex-flow: row nowrap; justify-content: flex-start; align-items: center;}
  14. .productTree .products>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;}
  15. .productTree li a i.icon {font-size: 15px !important;}
  16. .productTree li a i.icon:before {min-width: 16px !important;}
  17. .productTree li .label {position: unset; margin-bottom: 0;}
  18. .productTree 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;}
  19. .productTree .tree li > .list-toggle {line-height: 24px;}
  20. .productTree .tree li.has-list.open:before {content: unset;}
  21. .tree.noProgram li {padding-left: 0;}
  22. #swapper li > div.hide-in-search>a:focus, #swapper li > div.hide-in-search>a:hover {color: #838a9d; cursor: default;}
  23. #swapper li > a {margin-top: 4px; margin-bottom: 4px;}
  24. #swapper li {padding-top: 0; padding-bottom: 0;}
  25. #swapper .tree li > .list-toggle {top: -1px;}
  26. #subHeader .tree ul {display: block;}
  27. div#closed {width: 90px; height: 25px; line-height: 25px; background-color: #ddd; color: #3c495c; text-align: center; margin-left: 15px; border-radius: 2px;}
  28. #gray-line {width: 230px; height: 1px; margin-left: 10px; margin-bottom:2px; background-color: #ddd;}
  29. #swapper li >.selected {color: #0c64eb!important;background: #e9f2fb!important;}
  30. #dropMenu .col-footer .selected{color: #2e7fff!important;background: #e6f0ff!important; padding: 1px 10px;border-radius: 4px;}
  31. </style>
  32. <?php
  33. $productCounts = array();
  34. $productNames = array();
  35. $tabActive = '';
  36. $myProducts = 0;
  37. $others = 0;
  38. $closeds = 0;
  39. $currentProduct = '';
  40. foreach($products as $programID => $programProducts)
  41. {
  42. $productCounts[$programID]['myProduct'] = 0;
  43. $productCounts[$programID]['others'] = 0;
  44. $productCounts[$programID]['closed'] = 0;
  45. foreach($programProducts as $product)
  46. {
  47. $responsibles = explode(',', $product->PMT . ',' . $product->reviewer);
  48. if($product->status == 'normal' and in_array($this->app->user->account, $responsibles)) $productCounts[$programID]['myProduct'] ++;
  49. if($product->status == 'normal' and !in_array($this->app->user->account, $responsibles)) $productCounts[$programID]['others'] ++;
  50. if($product->status == 'closed') $productCounts[$programID]['closed'] ++;
  51. $productNames[] = $product->name;
  52. }
  53. }
  54. $productsPinYin = common::convert2Pinyin($productNames);
  55. $myProductsHtml = '<ul class="tree tree-angles" data-ride="tree">';
  56. $normalProductsHtml = '<ul class="tree tree-angles" data-ride="tree">';
  57. $closedProductsHtml = '<ul class="tree tree-angles" data-ride="tree">';
  58. foreach($products as $programID => $programProducts)
  59. {
  60. /* Add the program name before project. */
  61. if($programID)
  62. {
  63. $programName = zget($programs, $programID);
  64. if($productCounts[$programID]['myProduct']) $myProductsHtml .= '<li><div class="hide-in-search"><a class="text-muted not-list-item" title="' . $programName . '">' . $programName . '</a> <label class="label">' . $lang->program->common . '</label></div><ul>';
  65. if($productCounts[$programID]['others']) $normalProductsHtml .= '<li><div class="hide-in-search"><a class="text-muted not-list-item" title="' . $programName . '">' . $programName . '</a> <label class="label">' . $lang->program->common . '</label></div><ul>';
  66. if($productCounts[$programID]['closed']) $closedProductsHtml .= '<li><div class="hide-in-search"><a class="text-muted not-list-item" title="' . $programName . '">' . $programName . '</a> <label class="label">' . $lang->program->common . '</label></div><ul>';
  67. }
  68. foreach($programProducts as $index => $product)
  69. {
  70. if($product->id == $productID) $currentProduct = $product;
  71. $selected = $product->id == $productID ? 'selected' : '';
  72. $productName = $product->line ? zget($lines, $product->line, '') . ' / ' . $product->name : $product->name;
  73. $linkHtml = $this->product->setParamsForLink($module, $link, $projectID, $product->id);
  74. $locateTab = ($module == 'testtask' and $method == 'browseUnits' and $app->tab == 'project') ? '' : "data-app='$app->tab'";
  75. $responsibles = explode(',', $product->PMT . ',' . $product->reviewer);
  76. if(strpos('normal,wait', $product->status) !== false and in_array($this->app->user->account, $responsibles))
  77. {
  78. $myProductsHtml .= '<li>' . html::a($linkHtml, $productName, '', "class='$selected clickable' title='{$productName}' data-key='" . zget($productsPinYin, $product->name, '') . "' data-app='$app->tab'") . '</li>';
  79. if($selected == 'selected') $tabActive = 'myProduct';
  80. $myProducts ++;
  81. }
  82. else if(strpos('normal,wait', $product->status) !== false and !in_array($this->app->user->account, $responsibles))
  83. {
  84. $normalProductsHtml .= '<li>' . html::a($linkHtml, $productName, '', "class='$selected clickable' title='{$productName}' data-key='" . zget($productsPinYin, $product->name, '') . "' data-app='$app->tab'") . '</li>';
  85. if($selected == 'selected') $tabActive = 'other';
  86. $others ++;
  87. }
  88. else if($product->status == 'closed')
  89. {
  90. $closedProductsHtml .= '<li>' . html::a($linkHtml, $productName, '', "class='$selected clickable' title='$productName' class='closed' data-key='" . zget($productsPinYin, $product->name, '') . "' data-app='$app->tab'") . '</li>';
  91. if($selected == 'selected') $tabActive = 'closed';
  92. }
  93. /* If the programID is greater than 0, the product is the last one in the program, print the closed label. */
  94. if($programID and !isset($programProducts[$index + 1]))
  95. {
  96. if($productCounts[$programID]['myProduct']) $myProductsHtml .= '</ul></li>';
  97. if($productCounts[$programID]['others']) $normalProductsHtml .= '</ul></li>';
  98. if($productCounts[$programID]['closed']) $closedProductsHtml .= '</ul></li>';
  99. }
  100. }
  101. }
  102. $myProductsHtml .= '</ul>';
  103. $normalProductsHtml .= '</ul>';
  104. $closedProductsHtml .= '</ul>';
  105. ?>
  106. <div class="table-row">
  107. <div class="table-col col-left">
  108. <div class='list-group'>
  109. <?php $tabActive = ($myProducts and ($tabActive == 'closed' or $tabActive == 'myProduct')) ? 'myProduct' : 'other';?>
  110. <?php if($myProducts): ?>
  111. <ul class="nav nav-tabs nav-tabs-primary" id="navTabs">
  112. <li class="<?php if($tabActive == 'myProduct') echo 'active';?>"><?php echo html::a('#myProduct', $lang->product->mine, '', "data-toggle='tab' class='not-list-item not-clear-menu'");?><span class="label label-light label-badge"><?php echo $myProducts;?></span><li>
  113. <li class="<?php if($tabActive == 'other') echo 'active';?>"><?php echo html::a('#other', $lang->product->other, '', "data-toggle='tab' class='not-list-item not-clear-menu'")?><span class="label label-light label-badge"><?php echo $others;?></span><li>
  114. </ul>
  115. <?php endif;?>
  116. <div class="tab-content productTree" id="tabContent">
  117. <div class="tab-pane products <?php if($tabActive == 'myProduct') echo 'active';?>" id="myProduct">
  118. <?php echo $myProductsHtml;?>
  119. </div>
  120. <div class="tab-pane products <?php if($tabActive == 'other') echo 'active';?>" id="other">
  121. <?php echo $normalProductsHtml;?>
  122. </div>
  123. </div>
  124. </div>
  125. <div class="col-footer">
  126. <?php //echo html::a(helper::createLink('product', 'all'), '<i class="icon icon-cards-view muted"></i> ' . $lang->product->all, '', 'class="not-list-item"'); ?>
  127. <?php //echo html::a(helper::createLink('project', 'browse', 'programID=0&browseType=all'), '<i class="icon icon-cards-view muted"></i> ' . $lang->project->all, '', 'class="not-list-item"'); ?>
  128. <a class='pull-right toggle-right-col not-list-item'><?php echo $lang->product->closed?><i class='icon icon-angle-right'></i></a>
  129. <?php if($this->app->tab == 'feedback'):?>
  130. <?php $selected = $productID == 'all' ? 'selected' : '';?>
  131. <?php if($module == 'feedback'):?>
  132. <?php echo html::a(helper::createLink('feedback', 'admin', 'browseType=byProduct&param=all'), $lang->product->all, '', "class='not-list-item pull-left toggle-left-col $selected'"); ?>
  133. <?php endif;?>
  134. <?php if($module == 'ticket'):?>
  135. <?php echo html::a(helper::createLink('ticket', 'browse', 'browseType=byProduct&param=all'), $lang->product->all, '', "class='not-list-item pull-left toggle-left-col $selected'"); ?>
  136. <?php endif;?>
  137. <?php endif;?>
  138. </div>
  139. </div>
  140. <div id="gray-line" hidden></div>
  141. <div id="closed" hidden><?php echo $lang->product->closedProduct?></div>
  142. <div class="table-col col-right productTree">
  143. <div class='list-group products'><?php echo $closedProductsHtml;?></div>
  144. </div>
  145. </div>
  146. <script>
  147. $(function()
  148. {
  149. <?php if($currentProduct and $currentProduct->status == 'closed'):?>
  150. $('.col-footer .toggle-right-col').click(function(){ scrollToSelected(); })
  151. <?php else:?>
  152. scrollToSelected();
  153. <?php endif;?>
  154. $('.nav-tabs li span').hide();
  155. $('.nav-tabs li.active').find('span').show();
  156. $('.nav-tabs > li a').click(function()
  157. {
  158. if($('#swapper input[type="search"]').val() == '')
  159. {
  160. $(this).siblings().show();
  161. $(this).parent().siblings('li').find('span').hide();
  162. }
  163. })
  164. $('#swapper [data-ride="tree"]').tree('expand');
  165. $('#swapper #dropMenu .search-box').on('onSearchChange', function(event, value)
  166. {
  167. if(value != '')
  168. {
  169. $('div.hide-in-search').siblings('i').addClass('hide-in-search');
  170. $('.nav-tabs li span').hide();
  171. }
  172. else
  173. {
  174. $('div.hide-in-search').siblings('i').removeClass('hide-in-search');
  175. $('li.has-list div.hide-in-search').removeClass('hidden');
  176. $('.nav-tabs li.active').find('span').show();
  177. }
  178. if($('.form-control.search-input').val().length > 0)
  179. {
  180. $('#closed').attr("hidden", false);
  181. $('#gray-line').attr("hidden", false);
  182. }
  183. else
  184. {
  185. $('#closed').attr("hidden", true);
  186. $('#gray-line').attr("hidden", true);
  187. }
  188. });
  189. $('#swapper #dropMenu').on('onSearchComplete', function(event, value)
  190. {
  191. if(!value) return;
  192. if($("#myProduct .clickable.search-list-item").not(".hidden").length > 0)
  193. {
  194. $("#navTabs a[href='#myProduct']").tab('show');
  195. }
  196. else if($("#other .clickable.search-list-item").not(".hidden").length > 0)
  197. {
  198. $("#navTabs a[href='#other']").tab('show');
  199. }
  200. if($('ul.tree-angles').height() == 0)
  201. {
  202. $('#closed').attr("hidden", true);
  203. $('#gray-line').attr("hidden", true);
  204. }
  205. });
  206. })
  207. </script>