v1.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. namespace zin;
  3. class twinsStory extends wg
  4. {
  5. /**
  6. * Define widget properties.
  7. *
  8. * @var array
  9. * @access protected
  10. */
  11. protected static $defineProps = array(
  12. 'productType?: string="normal"', // 产品类型。
  13. 'branchItems?: array', // 分支列表。
  14. 'defaultBranch?: int=0', // 默认分支。
  15. 'moduleItems?: array', // 模块列表。
  16. 'defaultModule?: int=0', // 默认模块。
  17. 'planItems?: array', // 计划列表。
  18. 'defaultPlan?: int=0', // 默认计划。
  19. );
  20. public static function getPageCSS()
  21. {
  22. return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
  23. }
  24. public static function getPageJS()
  25. {
  26. return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
  27. }
  28. protected function build()
  29. {
  30. global $lang, $config;
  31. list($productType, $branchItems, $defaultBranch, $moduleItems, $defaultModule, $planItems, $defaultPlan) = $this->prop(array('productType', 'branchItems', 'defaultBranch', 'moduleItems', 'defaultModule', 'planItems', 'defaultPlan'));
  32. return div
  33. (
  34. setClass('twinsStoryBox'),
  35. div
  36. (
  37. setClass('switchBranch'),
  38. formGroup
  39. (
  40. set::style(array('padding' => '0', 'padding-right' => "var(--form-grid-gap-x-half);")),
  41. set::width('1/2'),
  42. set::label(sprintf($lang->product->branch, $lang->product->branchName[$productType]) . '&' . $lang->story->module),
  43. row
  44. (
  45. cell
  46. (
  47. set::width('1/2'),
  48. setClass('w-1/2'),
  49. setID('branchBox'),
  50. picker
  51. (
  52. setID('branches_0'),
  53. set::name('branches[0]'),
  54. set::items($branchItems),
  55. set::value($defaultBranch),
  56. setData(array('index' => 0, 'on' => 'change', 'call' => 'loadBranchRelation', 'params' => 'event'))
  57. )
  58. ),
  59. cell
  60. (
  61. set::width('1/2'),
  62. setClass('w-1/2'),
  63. setID('moduleIdBox'),
  64. picker(setID('modules_0'), set::name('modules[0]'), set::items($moduleItems), set::value($defaultModule), set::required(true))
  65. )
  66. )
  67. ),
  68. formGroup
  69. (
  70. set::style(array('padding' => '0', 'padding-left' => "var(--form-grid-gap-x-half);")),
  71. set::width('1/2'),
  72. set::label($lang->story->plan),
  73. set::required(strpos(",{$config->story->create->requiredFields},", ",plan,") !== false),
  74. inputGroup
  75. (
  76. setID('planIdBox'),
  77. picker(setID('plans_0'), set::name('plans[0]'), set::items($planItems), set::value($defaultPlan))
  78. )
  79. ),
  80. !empty($branchItems) && count($branchItems) > 1 ? formGroup
  81. (
  82. setClass('c-actions'),
  83. btn(setClass('btn-link addNewLine'), setData(array('on' => 'click', 'call' => 'addBranchesBox', 'params' => 'event')), set::title(sprintf($lang->story->addBranch, $lang->product->branchName[$productType])), icon('plus'))
  84. ) : null
  85. ),
  86. div
  87. (
  88. setID('storyNoticeBranch'),
  89. setClass('hidden'),
  90. set::width('full'),
  91. div(setClass('text-gray'), icon(setClass('text-warning'), 'help'), set::style(array('font-size' => '12px')), $lang->story->notice->branch)
  92. ),
  93. div
  94. (
  95. setID('addBranchesBox'),
  96. setClass('hidden'),
  97. formGroup
  98. (
  99. set::style(array('padding' => '0', 'padding-right' => "var(--form-grid-gap-x-half);")),
  100. set::width('1/2'),
  101. row
  102. (
  103. cell
  104. (
  105. set::width('1/2'),
  106. setClass('w-1/2'),
  107. setID('branchBox'),
  108. div(setID('branches'), setClass('form-group-wrapper'))
  109. ),
  110. cell
  111. (
  112. set::width('1/2'),
  113. setClass('w-1/2'),
  114. setID('moduleIdBox'),
  115. div(setID('modules'), setClass('form-group-wrapper'))
  116. )
  117. )
  118. ),
  119. formGroup
  120. (
  121. set::style(array('padding' => '0', 'padding-left' => "var(--form-grid-gap-x-half);")),
  122. set::width('1/2'),
  123. inputGroup
  124. (
  125. setID('planIdBox'),
  126. div(setID('plans'), setClass('form-group-wrapper'))
  127. )
  128. ),
  129. formGroup
  130. (
  131. setClass('c-actions'),
  132. btn(setClass('btn-link addNewLine'), set::title(sprintf($lang->story->addBranch, $lang->product->branchName[$productType])), icon('plus')),
  133. btn(setClass('btn-link removeNewLine'), set::title(sprintf($lang->story->deleteBranch, $lang->product->branchName[$productType])), icon('trash'))
  134. )
  135. )
  136. );
  137. }
  138. }