datatable.fix.html.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php $currentModule = $this->app->rawModule;?>
  2. <?php $currentMethod = $this->app->rawMethod;?>
  3. <?php $datatableId = $this->moduleName . ucfirst($this->methodName);?>
  4. <style>
  5. #setShowModule {margin-left: 30px;}
  6. </style>
  7. <script>
  8. $(function()
  9. {
  10. <?php if(!empty($setModule)):?>
  11. $('#sidebar .cell .text-center:last').append("<a href='#showModuleModal' data-toggle='modal' class='btn btn-info btn-wide'><?php echo $lang->datatable->displaySetting;?></a><hr class='space-sm' />");
  12. <?php endif;?>
  13. var addSettingButton = function()
  14. {
  15. var $btnToolbar = $('#main .table-header .btn-toolbar:first');
  16. if($btnToolbar.length > 0)
  17. {
  18. <?php $mode = isset($config->datatable->$datatableId->mode) ? $config->datatable->$datatableId->mode : 'table';?>
  19. var $dropdown = $('<div class="dropdown"><button id="tableCustomBtn" type="button" class="btn btn-link" data-toggle="dropdown"><i class="icon-cog-outline"></i></button></div>');
  20. var $dropmenu = $('<ul class="dropdown-menu pull-right"></ul>');
  21. if(typeof(storyType) != 'undefined' && storyType == 'requirement')
  22. {
  23. $dropmenu.append("<li><a href='<?php echo $this->createLink('datatable', 'ajaxCustom', 'id=' . $this->moduleName . '&method=' . $this->methodName . '&extra=requirement')?>' data-toggle='modal' data-type='ajax'><?php echo $lang->datatable->custom?></a></li>");
  24. }
  25. else if(typeof(from) != 'undefined')
  26. {
  27. <?php $fromPage = isset($fromPage) ? $fromPage : '';?>
  28. <?php $fromPage = ($fromPage == 'project' and isset($isStage) and $isStage) ? 'stage' : $fromPage;?>
  29. $dropmenu.append("<li><a href='<?php echo $this->createLink('datatable', 'ajaxCustom', 'id=' . $this->moduleName . '&method=' . $this->methodName . "&extra=$fromPage")?>' data-toggle='modal' data-type='ajax'><?php echo $lang->datatable->custom?></a></li>");
  30. }
  31. else
  32. {
  33. $dropmenu.append("<li><a href='<?php echo $this->createLink('datatable', 'ajaxCustom', 'id=' . $this->moduleName . '&method=' . $this->methodName)?>' data-toggle='modal' data-type='ajax'><?php echo $lang->datatable->custom?></a></li>");
  34. }
  35. // $dropmenu.append("<li><a href='javascript:saveDatatableConfig(\"mode\", \"<?php echo $mode == 'table' ? 'datatable' : 'table';?>\", true);' id='switchToDatatable'><?php echo $mode == 'table' ? $lang->datatable->switchToDatatable : $lang->datatable->switchToTable;?></a></li>");
  36. $dropdown.append($dropmenu)
  37. .appendTo($btnToolbar)
  38. .on('shown.zui.dropdown', function(){$btnToolbar.closest('.table-header').css('z-index', 11);})
  39. .on('hidden.zui.dropdown', function(){$btnToolbar.closest('.table-header').css('z-index', 5);});
  40. }
  41. };
  42. if ($.cookie('onlyScene') == 1) {
  43. }else{
  44. $('#main .main-table').on('tableReload', addSettingButton);
  45. addSettingButton();
  46. }
  47. $('#setShowModule').click(function()
  48. {
  49. if('<?php echo $this->app->user->account?>' == 'guest') return;
  50. datatableId = '<?php echo $datatableId?>';
  51. currentModule = '<?php echo $currentModule?>';
  52. currentMethod = '<?php echo $currentMethod?>';
  53. var value = $('#showModuleModal input[name="showModule"]:checked').val();
  54. var allModule = $('#showModuleModal input[name="showAllModule"]:checked').val();
  55. var showBranch = $('#showModuleModal input[name="showBranch"]:checked').val();
  56. if(typeof allModule === 'undefined') allModule = false;
  57. $.ajax(
  58. {
  59. type: "POST",
  60. dataType: 'json',
  61. data:
  62. {
  63. target: datatableId,
  64. name: 'showModule',
  65. value: value,
  66. allModule: allModule,
  67. showBranch: showBranch,
  68. currentModule: currentModule,
  69. currentMethod: currentMethod,
  70. },
  71. success:function(){window.location.reload();},
  72. url: '<?php echo $this->createLink('datatable', 'ajaxSave')?>'
  73. });
  74. });
  75. window.saveDatatableConfig = function(name, value, reload, global)
  76. {
  77. if('<?php echo $this->app->user->account?>' == 'guest') return;
  78. var datatableId = '<?php echo $datatableId;?>';
  79. if(typeof value === 'object') value = JSON.stringify(value);
  80. if(typeof global === 'undefined') global = 0;
  81. $.ajax(
  82. {
  83. type: "POST",
  84. dataType: 'json',
  85. data: {target: datatableId, name: name, value: value, global: global},
  86. success:function(e){if(reload) window.location.reload();},
  87. url: '<?php echo $this->createLink('datatable', 'ajaxSave')?>'
  88. });
  89. $.get(createLink('score', 'ajax', "method=switchToDataTable"));
  90. };
  91. });
  92. </script>
  93. <div class="modal fade" id="showModuleModal" tabindex="-1" role="dialog">
  94. <div class="modal-dialog w-600px">
  95. <div class="modal-content">
  96. <div class="modal-header">
  97. <button type="button" class="close" data-dismiss="modal"><i class="icon icon-close"></i></button>
  98. <h4 class="modal-title"><i class="icon-cog-outline"></i> <?php echo $lang->datatable->displaySetting;?></h4>
  99. </div>
  100. <div class="modal-body">
  101. <form class="form-condensed not-watch" method='post' target='hiddenwin' action='<?php echo $this->createLink('datatable', 'ajaxSave')?>'>
  102. <table class='table table-form'>
  103. <tr>
  104. <td class='w-160px'><?php echo $lang->datatable->showModule;?></td>
  105. <td><?php echo html::radio('showModule', $lang->datatable->showModuleList, isset($config->datatable->$datatableId->showModule) ? $config->datatable->$datatableId->showModule : '');?></td>
  106. </tr>
  107. <?php if($app->moduleName == 'execution' and $app->methodName == 'task' and $this->config->vision != 'lite'):?>
  108. <tr>
  109. <td><?php echo $lang->datatable->showAllModule;?></td>
  110. <td><?php echo html::radio('showAllModule', $lang->datatable->showAllModuleList, isset($config->execution->task->allModule) ? $config->execution->task->allModule : 0);?></td>
  111. </tr>
  112. <?php endif;?>
  113. <?php if($showBranch):?>
  114. <tr>
  115. <td><?php echo $lang->datatable->showBranch;?></td>
  116. <td><?php echo html::radio('showBranch', $lang->datatable->showBranchList, isset($config->$currentModule->$currentMethod->showBranch) ? $config->$currentModule->$currentMethod->showBranch : 1);?></td>
  117. </tr>
  118. <?php endif;?>
  119. <tr>
  120. <td colspan='2' class='text-center'><button type='button' id='setShowModule' class='btn btn-primary'><?php echo $lang->save?></button></td>
  121. </tr>
  122. </table>
  123. </form>
  124. </div>
  125. </div>
  126. </div>
  127. </div>