showimport.html.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. namespace zin;
  3. $fields = array();
  4. $fields['idIndex'] = array('name' => 'id', 'label' => $lang->transfer->id, 'control' => 'index', 'required' => false, 'width' => '64px');
  5. $fields['lib'] = array('name' => 'lib', 'label' => $lang->transfer->id, 'control' => 'input', 'required' => false, 'width' => '64px', 'hidden' => true);
  6. $fields += $datas->fields;
  7. $fields['steps']['width'] = '300px';
  8. $fields['stage']['multiple'] = true;
  9. unset($fields['stepDesc'], $fields['stepExpect'], $fields['pri']['items'][0]);
  10. $requiredFields = $datas->requiredFields;
  11. $allCount = $datas->allCount;
  12. $allPager = $datas->allPager;
  13. $pagerID = $datas->pagerID;
  14. $isEndPage = $datas->isEndPage;
  15. $maxImport = $datas->maxImport;
  16. $dataInsert = $datas->dataInsert;
  17. $suhosinInfo = $datas->suhosinInfo;
  18. $module = $datas->module;
  19. $datas = $datas->datas;
  20. if(!empty($suhosinInfo))
  21. {
  22. div(setClass('alert secondary'), html($suhosinInfo));
  23. }
  24. elseif(empty($maxImport) and $allCount > $this->config->file->maxImport)
  25. {
  26. panel
  27. (
  28. on::keyup('[name=maxImport]', 'recomputeTimes'),
  29. set::title($lang->transfer->import),
  30. html(sprintf($lang->file->importSummary, $allCount, html::input('maxImport', $config->file->maxImport, "style='width:50px'"), ceil($allCount / $config->file->maxImport))),
  31. btn(setID('import'), setClass('primary'), on::click('setMaxImport'), $lang->import)
  32. );
  33. pageJS(<<<JAVASCRIPT
  34. window.recomputeTimes = function()
  35. {
  36. if(parseInt(\$('#maxImport').val())) \$('#times').html(Math.ceil(parseInt({$allCount}) / parseInt(\$('#maxImport').val())));
  37. };
  38. window.setMaxImport = function()
  39. {
  40. \$.cookie.set('maxImport', \$('#maxImport').val(), {expires:config.cookieLife, path:config.webRoot});
  41. loadCurrentPage();
  42. };
  43. JAVASCRIPT
  44. );
  45. }
  46. else
  47. {
  48. $submitText = $isEndPage ? $lang->save : $lang->file->saveAndNext;
  49. $isStartPage = $pagerID == 1;
  50. $items['id'] = array
  51. (
  52. 'name' => 'id',
  53. 'control' => 'hidden',
  54. );
  55. $items['idIndex'] = array
  56. (
  57. 'name' => 'index',
  58. 'label' => $lang->idAB,
  59. 'control' => 'index',
  60. 'width' => '32px'
  61. );
  62. $items['lib'] = array
  63. (
  64. 'name' => 'lib',
  65. 'label' => '',
  66. 'hidden' => true,
  67. 'control' => 'hidden',
  68. 'width' => '32px'
  69. );
  70. $items['module'] = array
  71. (
  72. 'name' => 'module',
  73. 'label' => $lang->testcase->module,
  74. 'control' => 'picker',
  75. 'items' => $fields['module']['items'],
  76. 'width' => '136px',
  77. 'required' => strpos(",$requiredFields,", ',module,') !== false
  78. );
  79. $items['title'] = array
  80. (
  81. 'name' => 'title',
  82. 'label' => $lang->testcase->title,
  83. 'width' => '240px',
  84. 'required' => strpos(",$requiredFields,", ',title,') !== false
  85. );
  86. $items['precondition'] = array
  87. (
  88. 'name' => 'precondition',
  89. 'label' => $lang->testcase->precondition,
  90. 'control' => 'textarea',
  91. 'width' => '240px',
  92. 'required' => strpos(",$requiredFields,", ',precondition,') !== false
  93. );
  94. $items['keywords'] = array
  95. (
  96. 'name' => 'keywords',
  97. 'label' => $lang->testcase->keywords,
  98. 'width' => '240px',
  99. 'required' => strpos(",$requiredFields,", ',keywords,') !== false
  100. );
  101. $items['pri'] = array
  102. (
  103. 'name' => 'pri',
  104. 'label' => $lang->testcase->pri,
  105. 'control' => 'pripicker',
  106. 'items' => $fields['pri']['items'],
  107. 'width' => '80px',
  108. 'required' => strpos(",$requiredFields,", ',pri,') !== false
  109. );
  110. $items['type'] = array
  111. (
  112. 'name' => 'type',
  113. 'label' => $lang->testcase->type,
  114. 'control' => 'picker',
  115. 'items' => $lang->testcase->typeList,
  116. 'width' => '160px',
  117. 'required' => strpos(",$requiredFields,", ',type,') !== false
  118. );
  119. $items[] = array
  120. (
  121. 'name' => 'stage',
  122. 'label' => $lang->testcase->stage,
  123. 'control' => 'picker',
  124. 'multiple' => true,
  125. 'items' => $lang->testcase->stageList,
  126. 'width' => '240px',
  127. 'required' => strpos(",$requiredFields,", ',stage,') !== false
  128. );
  129. /* Field of steps. */
  130. $items[] = array
  131. (
  132. 'name' => 'steps',
  133. 'control' => array('control' => 'textarea', 'class' => 'form-control form-batch-input text-3-row', 'placeholder' => $lang->testcase->stepsPlaceholder),
  134. 'label' => $lang->testcase->steps,
  135. 'width' => '256px',
  136. 'required' => isset($requiredFields['steps'])
  137. );
  138. /* Field of expects. */
  139. $items[] = array
  140. (
  141. 'name' => 'expects',
  142. 'control' => array('control' => 'textarea', 'class' => 'form-control form-batch-input text-3-row'),
  143. 'label' => $lang->testcase->expect,
  144. 'width' => '256px',
  145. 'required' => isset($requiredFields['expects'])
  146. );
  147. formBatchPanel
  148. (
  149. set::title($lang->transfer->import),
  150. set::mode('edit'),
  151. set::items($items),
  152. set::data(array_values($datas)),
  153. set::actions(array()),
  154. div
  155. (
  156. setClass('toolbar form-actions form-group no-label'),
  157. $this->session->insert ? btn(set::btnType('submit'), setClass('primary btn-wide'), $submitText) : btn(set('data-toggle', 'modal'), set('data-target', '#importNoticeModal'), setClass('primary btn-wide'), $submitText),
  158. btn(set::url($backLink), setClass('btn-back btn-wide'), $lang->goback),
  159. $this->session->insert && $dataInsert != '' ? formHidden('insert', $dataInsert) : null,
  160. formHidden('isEndPage', $isEndPage ? 1 : 0),
  161. formHidden('pagerID', $pagerID),
  162. html(sprintf($lang->file->importPager, $allCount, $pagerID, $allPager))
  163. ),
  164. $this->session->insert ? null : modal
  165. (
  166. set::size('sm'),
  167. setID('importNoticeModal'),
  168. set::title($lang->importConfirm),
  169. formHidden('insert', 0),
  170. div
  171. (
  172. setClass('alert flex items-center'),
  173. icon(setClass('icon-2x alert-icon'), 'exclamation-sign'),
  174. div($lang->noticeImport)
  175. ),
  176. to::footer
  177. (
  178. btn(setClass('danger btn-wide'), set('onclick', 'submitForm("cover")'), $lang->importAndCover),
  179. btn(setClass('primary btn-wide'), set('onclick', 'submitForm("insert")'), $lang->importAndInsert)
  180. )
  181. )
  182. );
  183. pageJS(<<<JAVASCRIPT
  184. window.submitForm = function(type)
  185. {
  186. \$('[name=insert]').val(type == 'insert' ? 1 : 0);
  187. \$('#importNoticeModal .modal-footer .btn').addClass('disabled');
  188. const formUrl = \$("button[data-target='#importNoticeModal']").closest('form').attr('action');
  189. const formData = new FormData(\$("button[data-target='#importNoticeModal']").closest('form')[0]);
  190. \$.ajaxSubmit({url: formUrl, data: formData});
  191. };
  192. JAVASCRIPT
  193. );
  194. }