v1.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * The stepsEditor widget class file of zin module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author sunhao<sunhao@easycorp.ltd>
  8. * @package zin
  9. * @link http://www.zentao.net
  10. */
  11. namespace zin;
  12. require_once dirname(__DIR__) . DS . 'input' . DS . 'v1.php';
  13. /**
  14. * 步骤编辑(stepsEditor)部件类
  15. * The stepsEditor widget class
  16. */
  17. class stepsEditor extends wg
  18. {
  19. /**
  20. * Define widget properties.
  21. *
  22. * @var array
  23. * @access protected
  24. */
  25. protected static $defineProps = array
  26. (
  27. 'id?: string="$GID"', // 组件根元素的 ID。
  28. 'name?: string="steps"', // 步骤输入框作为表单项的名称。
  29. 'expectsName?: string="expects"', // 预期输入框作为表单项的名称。
  30. 'data?: array', // 默认值。
  31. 'stepText?: string', // 步骤文本。
  32. 'expectText?: string', // 预期文本。
  33. 'sameLevelText?: string', // 同级文本。
  34. 'subLevelText?: string', // 子级文本。
  35. 'expectDisabledTip?: string', // 预期输入框禁用提示。
  36. 'deleteStepTip?: string', // 有子层级禁用删除提示。
  37. 'dragNestedTip?: string', // 拖拽超出提示。
  38. 'expectDisabled: bool=true', // 是否禁用预期输入框。
  39. 'postDataID: bool=false' // 是否提交表单时附加 ID。
  40. );
  41. public static function getPageJS()
  42. {
  43. return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
  44. }
  45. public static function getPageCSS()
  46. {
  47. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  48. }
  49. /**
  50. * Build the widget.
  51. *
  52. * @access protected
  53. * @return mixed
  54. */
  55. protected function build()
  56. {
  57. $stepText = $this->prop('stepText', data('lang.testcase.stepDesc'));
  58. $expectText = $this->prop('expectText', data('lang.testcase.stepExpect'));
  59. $sameLevelText = $this->prop('sameLevelText', data('lang.testcase.stepSameLevel'));
  60. $subLevelText = $this->prop('subLevelText', data('lang.testcase.stepSubLevel'));
  61. $id = $this->prop('id') ? $this->prop('id') : $this->gid;
  62. $options = $this->props->pick(array('name', 'expectsName', 'data', 'postDataID', 'expectDisabled'));
  63. $options['expectDisabledTip'] = $this->prop('expectDisabledTip', data('lang.testcase.expectDisabledTip'));
  64. $options['deleteStepTip'] = $this->prop('deleteStepTip', data('lang.testcase.deleteStepTip'));
  65. $options['dragNestedTip'] = $this->prop('dragNestedTip', data('lang.testcase.dragNestedTip'));
  66. return div
  67. (
  68. setID($id),
  69. setClass('steps-editor w-full'),
  70. div
  71. (
  72. setClass('steps-editor-header'),
  73. row
  74. (
  75. setClass('steps-editor-row'),
  76. cell
  77. (
  78. set::className('steps-editor-col steps-editor-col-step'),
  79. $stepText
  80. ),
  81. cell
  82. (
  83. set::className('steps-editor-col steps-editor-col-add'),
  84. div($sameLevelText),
  85. div($subLevelText)
  86. ),
  87. cell
  88. (
  89. set::className('steps-editor-col steps-editor-col-expect'),
  90. $expectText
  91. )
  92. )
  93. ),
  94. div
  95. (
  96. set::className('steps-editor-body')
  97. ),
  98. zui::create('stepsEditor', $options)
  99. );
  100. }
  101. }