ajaxgetolddropmenu.html.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. if($product->status == 'normal' and $product->PO == $this->app->user->account) $productCounts[$programID]['myProduct'] ++;
  48. if($product->status == 'normal' and !($product->PO == $this->app->user->account)) $productCounts[$programID]['others'] ++;
  49. if($product->status == 'closed') $productCounts[$programID]['closed'] ++;
  50. $productNames[] = $product->name;
  51. }
  52. }
  53. $productsPinYin = common::convert2Pinyin($productNames);
  54. $myProductsHtml = in_array($this->config->systemMode, array('ALM', 'PLM')) ? '<ul class="tree tree-angles" data-ride="tree">' : '<ul class="tree noProgram">';
  55. $normalProductsHtml = in_array($this->config->systemMode, array('ALM', 'PLM')) ? '<ul class="tree tree-angles" data-ride="tree">' : '<ul class="tree noProgram">';
  56. $closedProductsHtml = in_array($this->config->systemMode, array('ALM', 'PLM')) ? '<ul class="tree tree-angles" data-ride="tree">' : '<ul class="tree noProgram">';
  57. foreach($products as $programID => $programProducts)
  58. {
  59. /* Add the program name before project. */
  60. if($programID and in_array($this->config->systemMode, array('ALM', 'PLM')))
  61. {
  62. $programName = zget($programs, $programID);
  63. 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>';
  64. 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>';
  65. 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>';
  66. }
  67. foreach($programProducts as $index => $product)
  68. {
  69. if($product->id == $productID) $currentProduct = $product;
  70. $selected = $product->id == $productID ? 'selected' : '';
  71. $productName = (in_array($this->config->systemMode, array('ALM', 'PLM')) and $product->line) ? zget($lines, $product->line, '') . ' / ' . $product->name : $product->name;
  72. $linkHtml = $this->product->setParamsForLink($module, $link, $projectID, $product->id);
  73. $locateTab = ($module == 'testtask' and $method == 'browseUnits' and $app->tab == 'project') ? '' : "data-app='$app->tab'";
  74. if($product->status == 'normal' and $product->PO == $this->app->user->account)
  75. {
  76. $myProductsHtml .= '<li>' . html::a($linkHtml, $productName, '', "class='$selected clickable' title='{$productName}' data-key='" . zget($productsPinYin, $product->name, '') . "' data-app='$app->tab'") . '</li>';
  77. if($selected == 'selected') $tabActive = 'myProduct';
  78. $myProducts ++;
  79. }
  80. else if($product->status == 'closed')
  81. {
  82. $closedProductsHtml .= '<li>' . html::a($linkHtml, $productName, '', "class='$selected clickable' title='$productName' class='closed' data-key='" . zget($productsPinYin, $product->name, '') . "' data-app='$app->tab'") . '</li>';
  83. if($selected == 'selected') $tabActive = 'closed';
  84. }
  85. else
  86. {
  87. $normalProductsHtml .= '<li>' . html::a($linkHtml, $productName, '', "class='$selected clickable' title='{$productName}' data-key='" . zget($productsPinYin, $product->name, '') . "' data-app='$app->tab'") . '</li>';
  88. if($selected == 'selected') $tabActive = 'other';
  89. $others ++;
  90. }
  91. /* If the programID is greater than 0, the product is the last one in the program, print the closed label. */
  92. if($programID and !isset($programProducts[$index + 1]))
  93. {
  94. if($productCounts[$programID]['myProduct']) $myProductsHtml .= '</ul></li>';
  95. if($productCounts[$programID]['others']) $normalProductsHtml .= '</ul></li>';
  96. if($productCounts[$programID]['closed']) $closedProductsHtml .= '</ul></li>';
  97. }
  98. }
  99. }
  100. $myProductsHtml .= '</ul>';
  101. $normalProductsHtml .= '</ul>';
  102. $closedProductsHtml .= '</ul>';
  103. ?>
  104. <div class="table-row">
  105. <div class="table-col col-left">
  106. <div class='list-group'>
  107. <?php $tabActive = ($myProducts and ($tabActive == 'closed' or $tabActive == 'myProduct')) ? 'myProduct' : 'other';?>
  108. <?php if($myProducts): ?>
  109. <ul class="nav nav-tabs nav-tabs-primary" id="navTabs">
  110. <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>
  111. <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>
  112. </ul>
  113. <?php endif;?>
  114. <div class="tab-content productTree" id="tabContent">
  115. <div class="tab-pane products <?php if($tabActive == 'myProduct') echo 'active';?>" id="myProduct">
  116. <?php echo $myProductsHtml;?>
  117. </div>
  118. <div class="tab-pane products <?php if($tabActive == 'other') echo 'active';?>" id="other">
  119. <?php echo $normalProductsHtml;?>
  120. </div>
  121. </div>
  122. </div>
  123. <div class="col-footer">
  124. <?php //echo html::a(helper::createLink('product', 'all'), '<i class="icon icon-cards-view muted"></i> ' . $lang->product->all, '', 'class="not-list-item"'); ?>
  125. <?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"'); ?>
  126. <a class='pull-right toggle-right-col not-list-item'><?php echo $lang->product->closed?><i class='icon icon-angle-right'></i></a>
  127. <?php if($this->app->tab == 'feedback'):?>
  128. <?php $selected = $productID == 'all' ? 'selected' : '';?>
  129. <?php if($module == 'feedback'):?>
  130. <?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'"); ?>
  131. <?php endif;?>
  132. <?php if($module == 'ticket'):?>
  133. <?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'"); ?>
  134. <?php endif;?>
  135. <?php endif;?>
  136. </div>
  137. </div>
  138. <div id="gray-line" hidden></div>
  139. <div id="closed" hidden><?php echo $lang->product->closedProducts; ?></div>
  140. <div class="table-col col-right productTree">
  141. <div class='list-group products'><?php echo $closedProductsHtml;?></div>
  142. </div>
  143. </div>
  144. <script>
  145. $(function()
  146. {
  147. <?php if($currentProduct and $currentProduct->status == 'closed'):?>
  148. $('.col-footer .toggle-right-col').click(function(){ scrollToSelected(); })
  149. <?php else:?>
  150. scrollToSelected();
  151. <?php endif;?>
  152. $('.nav-tabs li span').hide();
  153. $('.nav-tabs li.active').find('span').show();
  154. $('.nav-tabs > li a').click(function()
  155. {
  156. if($('#swapper input[type="search"]').val() == '')
  157. {
  158. $(this).siblings().show();
  159. $(this).parent().siblings('li').find('span').hide();
  160. }
  161. })
  162. $('#swapper [data-ride="tree"]').tree('expand');
  163. $('#swapper #dropMenu .search-box').on('onSearchChange', function(event, value)
  164. {
  165. if(value != '')
  166. {
  167. $('div.hide-in-search').siblings('i').addClass('hide-in-search');
  168. $('.nav-tabs li span').hide();
  169. }
  170. else
  171. {
  172. $('div.hide-in-search').siblings('i').removeClass('hide-in-search');
  173. $('li.has-list div.hide-in-search').removeClass('hidden');
  174. $('.nav-tabs li.active').find('span').show();
  175. }
  176. if($('.form-control.search-input').val().length > 0)
  177. {
  178. $('#closed').attr("hidden", false);
  179. $('#gray-line').attr("hidden", false);
  180. }
  181. else
  182. {
  183. $('#closed').attr("hidden", true);
  184. $('#gray-line').attr("hidden", true);
  185. }
  186. });
  187. $('#swapper #dropMenu').on('onSearchComplete', function(event, value)
  188. {
  189. if(!value) return;
  190. if($("#myProduct .clickable.search-list-item").not(".hidden").length > 0)
  191. {
  192. $("#navTabs a[href='#myProduct']").tab('show');
  193. }
  194. else if($("#other .clickable.search-list-item").not(".hidden").length > 0)
  195. {
  196. $("#navTabs a[href='#other']").tab('show');
  197. }
  198. if($('ul.tree-angles').height() == 0)
  199. {
  200. $('#closed').attr("hidden", true);
  201. $('#gray-line').attr("hidden", true);
  202. }
  203. });
  204. })
  205. </script>