browse.html.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. /**
  3. * The browse view file of subject 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 Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package subject
  9. * @version $Id: browse.html.php 4796 2013-06-06 02:21:59Z zhujinyonging@gmail.com $
  10. * @link http://www.zentao.net
  11. */
  12. ?>
  13. <?php include $app->getModuleRoot() . 'common/view/header.html.php';?>
  14. <?php js::set('confirmDeleteTip', $lang->tree->confirmDelete);?>
  15. <div id="mainContent" class="main-row">
  16. <div class="side-col col-4">
  17. <div class="panel">
  18. <div class="panel-heading">
  19. <div class="panel-title"><?php echo $lang->subject->common;?></div>
  20. </div>
  21. <div class="panel-body">
  22. <ul id='modulesTree' data-name='tree-subject'></ul>
  23. </div>
  24. </div>
  25. </div>
  26. <div class="main-col col-8">
  27. <div class="panel">
  28. <div class="panel-heading">
  29. <div class="panel-title">
  30. <?php echo empty($currentModuleID) ? $lang->subject->manage : $lang->subject->manageChild;?>
  31. </div>
  32. </div>
  33. <div class="panel-body">
  34. <form class='form-ajax' id='childrenForm' method='post' action='<?php echo $this->createLink('tree', 'manageChild', "root=0&viewType=subject&oldPage=yes");?>'>
  35. <table class='table table-form table-auto'>
  36. <tr>
  37. <td class="text-middle text-right with-padding">
  38. <?php
  39. foreach($parentModules as $module)
  40. {
  41. echo "<span>" . html::a($this->createLink('subject', 'browse', "moduleID=$module->id"), $module->name) . " <i class='icon icon-angle-right muted'></i></span>";
  42. }
  43. ?>
  44. </td>
  45. <td>
  46. <div id='sonModule'>
  47. <?php $maxOrder = 0;?>
  48. <?php foreach($sons as $sonModule):?>
  49. <?php if($sonModule->order > $maxOrder) $maxOrder = $sonModule->order;?>
  50. <div class="table-row row-module">
  51. <div class="table-col col-module"><?php echo html::input("modules[id$sonModule->id]", $sonModule->name, 'class="form-control"');?></div>
  52. <div class="table-col col-shorts"><?php echo html::input("shorts[id$sonModule->id]", $sonModule->short, "class='form-control' placeholder='{$lang->tree->short}'") . html::hidden("order[id$sonModule->id]", $sonModule->order);?></div>
  53. <div class="table-col col-actions"> </div>
  54. </div>
  55. <?php endforeach;?>
  56. <?php for($i = 0; $i < 5; $i ++):?>
  57. <div class="table-row row-module row-module-new">
  58. <div class="table-col col-module"><?php echo html::input("modules[]", '', "class='form-control' placeholder='{$lang->subject->name}'");?></div>
  59. <div class="table-col col-shorts"><?php echo html::input("shorts[]", '', "class='form-control' placeholder='{$lang->tree->short}'");?></div>
  60. <div class="table-col col-actions">
  61. <button type="button" class="btn btn-link btn-icon btn-add" onclick="addItem(this)"><i class="icon icon-plus"></i></button>
  62. <button type="button" class="btn btn-link btn-icon btn-delete" onclick="deleteItem(this)"><i class="icon icon-close"></i></button>
  63. </div>
  64. </div>
  65. <?php endfor;?>
  66. </div>
  67. <div id="insertItemBox" class="template">
  68. <div class="table-row row-module row-module-new">
  69. <div class="table-col col-module"><?php echo html::input("modules[]", '', "class='form-control' placeholder='{$lang->subject->name}'");?></div>
  70. <div class="table-col col-shorts"><?php echo html::input("shorts[]", '', "class='form-control' placeholder='{$lang->tree->short}'");?></div>
  71. <div class="table-col col-actions">
  72. <button type="button" class="btn btn-link btn-icon btn-add" onclick="addItem(this)"><i class="icon icon-plus"></i></button>
  73. <button type="button" class="btn btn-link btn-icon btn-delete" onclick="deleteItem(this)"><i class="icon icon-close"></i></button>
  74. </div>
  75. </div>
  76. </div>
  77. </td>
  78. </tr>
  79. <tr>
  80. <td></td>
  81. <td colspan="2" class="form-actions text-center">
  82. <?php echo html::submitButton();?>
  83. <?php echo html::hidden('parentModuleID', $currentModuleID);?>
  84. <?php echo html::hidden('maxOrder', $maxOrder);?>
  85. </td>
  86. </tr>
  87. </tbody>
  88. </table>
  89. </form>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. <script>
  95. $(function()
  96. {
  97. var data = $.parseJSON('<?php echo helper::jsonEncode4Parse($tree);?>');
  98. var options =
  99. {
  100. initialState: 'preserve',
  101. data: data,
  102. sortable:
  103. {
  104. lazy: true,
  105. nested: true,
  106. canMoveHere: function($ele, $target)
  107. {
  108. if($ele && $target && $ele.parent().closest('li').attr('data-id') !== $target.parent().closest('li').attr('data-id')) return false;
  109. }
  110. },
  111. itemCreator: function($li, item)
  112. {
  113. var link = (item.id !== undefined && item.type != 'line') ? ('<a href="' + createLink('subject', 'browse', 'moduleID={0}'.format(item.id, item.branch)) + '">' + item.name + '</a>') : ('<span class="tree-toggle">' + item.name + '</span>');
  114. var $toggle = $('<span class="module-name" data-id="' + item.id + '">' + link + '</span>');
  115. if(item.type === 'bug') $toggle.append('&nbsp; <span class="text-muted">[B]</span>');
  116. if(item.type === 'case') $toggle.append('&nbsp; <span class="text-muted">[C]</span>');
  117. $li.append($toggle);
  118. if(item.nodeType || item.type) $li.addClass('tree-item-' + (item.nodeType || item.type));
  119. $li.toggleClass('active', <?php echo $currentModuleID ?> === item.id);
  120. return true;
  121. },
  122. actions:
  123. {
  124. sort:
  125. {
  126. title: '<?php echo $lang->tree->dragAndSort ?>',
  127. template: '<a class="sort-handler"><i class="icon-move"></i></a>'
  128. },
  129. //edit:
  130. //{
  131. // linkTemplate: '<?php echo helper::createLink('tree', 'edit', "moduleID={0}&type=subject"); ?>',
  132. // title: '<?php echo $lang->tree->edit ?>',
  133. // template: '<a><i class="icon-edit"></i></a>'
  134. //},
  135. "delete":
  136. {
  137. linkTemplate: '<?php echo helper::createLink('tree', 'delete', "moduleID={0}&confirm=yes"); ?>',
  138. title: '<?php echo $lang->delete . $lang->subject->common;?>',
  139. template: '<a><i class="icon-trash"></i></a>'
  140. },
  141. subModules:
  142. {
  143. linkTemplate: '<?php echo helper::createLink('subject', 'browse', "moduleID={0}"); ?>',
  144. title: '<?php echo $title;?>',
  145. template: '<a><?php echo '<i class="icon-split"></i>';?></a>',
  146. }
  147. },
  148. action: function(event)
  149. {
  150. var action = event.action, $target = $(event.target), item = event.item;
  151. if(action.type === 'edit')
  152. {
  153. new $.zui.ModalTrigger({
  154. type: 'ajax',
  155. url: action.linkTemplate.format(item.id),
  156. keyboard: true
  157. }).show();
  158. }
  159. else if(action.type === 'delete')
  160. {
  161. if(confirm(confirmDeleteTip))
  162. {
  163. $.get(action.linkTemplate.format(item.id), function(response)
  164. {
  165. if(JSON.parse(response).result === 'success') location.reload();
  166. })
  167. }
  168. }
  169. else if(action.type === 'sort')
  170. {
  171. var orders = {};
  172. $('#modulesTree').find('li:not(.tree-action-item)').each(function()
  173. {
  174. var $li = $(this);
  175. if($li.hasClass('tree-item-branch')) return;
  176. var item = $li.data();
  177. orders['orders[' + item.id + ']'] = $li.attr('data-order') || item.order;
  178. });
  179. $.post('<?php echo $this->createLink('tree', 'updateOrder', "rootID=0&viewType=subject");?>', orders).error(function()
  180. {
  181. bootbox.alert(lang.timeout);
  182. });
  183. }
  184. else if(action.type === 'subModules')
  185. {
  186. window.location.href = action.linkTemplate.format(item.id, item.branch);
  187. }
  188. }
  189. };
  190. if(<?php echo common::hasPriv('tree', 'updateorder') ? 'false' : 'true' ?>) options.actions["sort"] = false;
  191. if(<?php echo common::hasPriv('tree', 'edit') ? 'false' : 'true' ?>) options.actions["edit"] = false;
  192. if(<?php echo common::hasPriv('tree', 'delete') ? 'false' : 'true' ?>) options.actions["delete"] = false;
  193. var $tree = $('#modulesTree').tree(options);
  194. var tree = $tree.data('zui.tree');
  195. if(<?php echo $currentModuleID ?>)
  196. {
  197. var $currentLi = $tree.find('.module-name[data-id=' + <?php echo $currentModuleID ?> + ']').closest('li');
  198. if($currentLi.length) tree.show($currentLi);
  199. }
  200. $tree.on('mouseenter', 'li:not(.tree-action-item)', function(e)
  201. {
  202. $('#modulesTree').find('li.hover').removeClass('hover');
  203. $(this).addClass('hover');
  204. e.stopPropagation();
  205. });
  206. $('#subNavbar > ul > li > a[href*=tree][href*=browse]').not('[href*=subject]').parent().removeClass('active');
  207. if(window.config.viewType == 'line') $('#modulemenu > .nav > li > a[href*=product][href*=all]').parent('li[data-id=all]').addClass('active');
  208. });
  209. </script>
  210. <?php include $app->getModuleRoot() . 'common/view/footer.html.php';?>