catalog.html.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. /**
  3. * The browse view file of tree 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 tree
  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('currentModuleID', $currentModuleID);?>
  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->baseline->catalog;?></div>
  20. </div>
  21. <div class="panel-body">
  22. <ul id='modulesTree' data-name='tree-baseline'></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 $lang->baseline->manageChild;?>
  31. </div>
  32. </div>
  33. <div class="panel-body">
  34. <form id='childrenForm' method='post' target='hiddenwin' action='<?php echo $this->createLink('tree', 'manageChild', "root=0&viewType=doc");?>'>
  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('baseline', '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->baseline->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->baseline->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">
  82. <?php echo html::submitButton();?>
  83. <?php echo html::backButton();?>
  84. <?php echo html::hidden('parentModuleID', $currentModuleID);?>
  85. <?php echo html::hidden('maxOrder', $maxOrder);?>
  86. </td>
  87. </tr>
  88. </tbody>
  89. </table>
  90. </form>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. <script>
  96. $(function()
  97. {
  98. var data = $.parseJSON('<?php echo helper::jsonEncode4Parse($tree);?>');
  99. var options =
  100. {
  101. initialState: 'preserve',
  102. data: data,
  103. sortable:
  104. {
  105. lazy: true,
  106. nested: true,
  107. canMoveHere: function($ele, $target)
  108. {
  109. if($ele && $target && $ele.parent().closest('li').attr('data-id') !== $target.parent().closest('li').attr('data-id')) return false;
  110. }
  111. },
  112. itemCreator: function($li, item)
  113. {
  114. var link = (item.id !== undefined && item.type != 'line') ? ('<a href="' + createLink('baseline', 'catalog', 'moduleID={0}'.format(item.id, item.branch)) + '">' + item.name + '</a>') : ('<span class="tree-toggle">' + item.name + '</span>');
  115. var $toggle = $('<span class="module-name" data-id="' + item.id + '">' + link + '</span>');
  116. $li.append($toggle);
  117. if(item.nodeType || item.type) $li.addClass('tree-item-' + (item.nodeType || item.type));
  118. if(currentModuleID == item.id) $li.addClass('active');
  119. return true;
  120. },
  121. actions:
  122. {
  123. sort:
  124. {
  125. title: '<?php echo $lang->tree->dragAndSort ?>',
  126. template: '<a class="sort-handler"><i class="icon-move"></i></a>'
  127. },
  128. //edit:
  129. //{
  130. // linkTemplate: '<?php echo helper::createLink('tree', 'edit', "moduleID={0}&type=baseline"); ?>',
  131. // title: '<?php echo $lang->tree->edit ?>',
  132. // template: '<a><i class="icon-edit"></i></a>'
  133. //},
  134. "delete":
  135. {
  136. linkTemplate: '<?php echo helper::createLink('tree', 'delete', "rootID=0&moduleID={0}"); ?>',
  137. title: '<?php echo $lang->tree->delete ?>',
  138. template: '<a><i class="icon-trash"></i></a>'
  139. },
  140. subModules:
  141. {
  142. linkTemplate: '<?php echo helper::createLink('baseline', 'catalog', "moduleID={0}"); ?>',
  143. title: '<?php echo $title;?>',
  144. template: '<a><?php echo '<i class="icon-treemap-alt"></i>';?></a>',
  145. }
  146. },
  147. action: function(event)
  148. {
  149. var action = event.action, $target = $(event.target), item = event.item;
  150. if(action.type === 'edit')
  151. {
  152. new $.zui.ModalTrigger({
  153. type: 'ajax',
  154. url: action.linkTemplate.format(item.id),
  155. keyboard: true
  156. }).show();
  157. }
  158. else if(action.type === 'delete')
  159. {
  160. hiddenwin.location.href = action.linkTemplate.format(item.id);
  161. }
  162. else if(action.type === 'sort')
  163. {
  164. var orders = {};
  165. $('#modulesTree').find('li:not(.tree-action-item)').each(function()
  166. {
  167. var $li = $(this);
  168. if($li.hasClass('tree-item-branch')) return;
  169. var item = $li.data();
  170. orders['orders[' + item.id + ']'] = $li.attr('data-order') || item.order;
  171. });
  172. $.post('<?php echo $this->createLink('tree', 'updateOrder', "rootID=0&viewType=baseline");?>', orders).error(function()
  173. {
  174. bootbox.alert(lang.timeout);
  175. });
  176. }
  177. else if(action.type === 'subModules')
  178. {
  179. window.location.href = action.linkTemplate.format(item.id, item.branch);
  180. }
  181. }
  182. };
  183. if(<?php echo common::hasPriv('tree', 'updateorder') ? 'false' : 'true' ?>) options.actions["sort"] = false;
  184. if(<?php echo common::hasPriv('tree', 'edit') ? 'false' : 'true' ?>) options.actions["edit"] = false;
  185. if(<?php echo common::hasPriv('tree', 'delete') ? 'false' : 'true' ?>) options.actions["delete"] = false;
  186. var $tree = $('#modulesTree').tree(options);
  187. var tree = $tree.data('zui.tree');
  188. if(<?php echo $currentModuleID ?>)
  189. {
  190. var $currentLi = $tree.find('.module-name[data-id=' + <?php echo $currentModuleID ?> + ']').closest('li');
  191. if($currentLi.length) tree.show($currentLi);
  192. }
  193. $tree.on('mouseenter', 'li:not(.tree-action-item)', function(e)
  194. {
  195. $('#modulesTree').find('li.hover').removeClass('hover');
  196. $(this).addClass('hover');
  197. e.stopPropagation();
  198. });
  199. });
  200. </script>
  201. <?php include $app->getModuleRoot() . 'common/view/footer.html.php';?>