object_manager_attribute.rb 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. FactoryBot.define do
  2. factory :object_manager_attribute, class: ObjectManager::Attribute do
  3. transient do
  4. object_name { 'Ticket' }
  5. additional_data_options { nil }
  6. end
  7. object_lookup_id { ObjectLookup.by_name(object_name) }
  8. sequence(:name) { |n| "internal_name#{n}" }
  9. sequence(:display) { |n| "Display Name #{n}" }
  10. data_option_new { {} }
  11. editable { true }
  12. active { true }
  13. add_attribute(:to_create) { true }
  14. to_migrate { true }
  15. to_delete { false }
  16. to_config { false }
  17. position { 15 }
  18. updated_by_id { 1 }
  19. created_by_id { 1 }
  20. screens do
  21. {
  22. 'create_top' => {
  23. '-all-' => {
  24. 'null' => false
  25. }
  26. },
  27. 'edit' => {}
  28. }
  29. end
  30. callback(:after_stub, :before_create) do |object, context|
  31. next if context.additional_data_options.blank?
  32. object.data_option ||= {}
  33. object.data_option.merge! context.additional_data_options
  34. end
  35. end
  36. factory :object_manager_attribute_text, parent: :object_manager_attribute do
  37. data_type { 'input' }
  38. data_option do
  39. {
  40. 'type' => 'text',
  41. 'maxlength' => 200,
  42. 'null' => true,
  43. 'translate' => false,
  44. 'default' => '',
  45. 'options' => {},
  46. 'relation' => '',
  47. }
  48. end
  49. end
  50. factory :object_manager_attribute_integer, parent: :object_manager_attribute do
  51. data_type { 'integer' }
  52. data_option do
  53. {
  54. 'default' => 0,
  55. 'min' => 0,
  56. 'max' => 9999,
  57. }
  58. end
  59. end
  60. factory :object_manager_attribute_date, parent: :object_manager_attribute do
  61. name { 'date_attribute' }
  62. data_type { 'date' }
  63. data_option do
  64. {
  65. 'diff' => 24,
  66. 'null' => true,
  67. }
  68. end
  69. end
  70. factory :object_manager_attribute_datetime, parent: :object_manager_attribute do
  71. name { 'datetime_attribute' }
  72. data_type { 'datetime' }
  73. data_option do
  74. {
  75. 'future' => true,
  76. 'past' => true,
  77. 'diff' => 24,
  78. 'null' => true,
  79. }
  80. end
  81. end
  82. factory :object_manager_attribute_select, parent: :object_manager_attribute do
  83. data_type { 'select' }
  84. data_option do
  85. {
  86. 'default' => '',
  87. 'options' => {
  88. 'key_1' => 'value_1',
  89. 'key_2' => 'value_2',
  90. 'key_3' => 'value_3',
  91. },
  92. 'relation' => '',
  93. 'nulloption' => true,
  94. 'multiple' => false,
  95. 'null' => true,
  96. 'translate' => true,
  97. 'maxlength' => 255
  98. }
  99. end
  100. end
  101. factory :object_manager_attribute_tree_select, parent: :object_manager_attribute do
  102. data_type { 'tree_select' }
  103. data_option do
  104. {
  105. 'options' => [
  106. {
  107. 'name' => 'Incident',
  108. 'value' => 'Incident',
  109. 'children' => [
  110. {
  111. 'name' => 'Hardware',
  112. 'value' => 'Incident::Hardware',
  113. 'children' => [
  114. {
  115. 'name' => 'Monitor',
  116. 'value' => 'Incident::Hardware::Monitor'
  117. },
  118. {
  119. 'name' => 'Mouse',
  120. 'value' => 'Incident::Hardware::Mouse'
  121. },
  122. {
  123. 'name' => 'Keyboard',
  124. 'value' => 'Incident::Hardware::Keyboard'
  125. }
  126. ]
  127. },
  128. {
  129. 'name' => 'Softwareproblem',
  130. 'value' => 'Incident::Softwareproblem',
  131. 'children' => [
  132. {
  133. 'name' => 'CRM',
  134. 'value' => 'Incident::Softwareproblem::CRM'
  135. },
  136. {
  137. 'name' => 'EDI',
  138. 'value' => 'Incident::Softwareproblem::EDI'
  139. },
  140. {
  141. 'name' => 'SAP',
  142. 'value' => 'Incident::Softwareproblem::SAP',
  143. 'children' => [
  144. {
  145. 'name' => 'Authentication',
  146. 'value' => 'Incident::Softwareproblem::SAP::Authentication'
  147. },
  148. {
  149. 'name' => 'Not reachable',
  150. 'value' => 'Incident::Softwareproblem::SAP::Not reachable'
  151. }
  152. ]
  153. },
  154. {
  155. 'name' => 'MS Office',
  156. 'value' => 'Incident::Softwareproblem::MS Office',
  157. 'children' => [
  158. {
  159. 'name' => 'Excel',
  160. 'value' => 'Incident::Softwareproblem::MS Office::Excel'
  161. },
  162. {
  163. 'name' => 'PowerPoint',
  164. 'value' => 'Incident::Softwareproblem::MS Office::PowerPoint'
  165. },
  166. {
  167. 'name' => 'Word',
  168. 'value' => 'Incident::Softwareproblem::MS Office::Word'
  169. },
  170. {
  171. 'name' => 'Outlook',
  172. 'value' => 'Incident::Softwareproblem::MS Office::Outlook'
  173. }
  174. ]
  175. }
  176. ]
  177. }
  178. ]
  179. },
  180. {
  181. 'name' => 'Service request',
  182. 'value' => 'Service request',
  183. 'children' => [
  184. {
  185. 'name' => 'New software requirement',
  186. 'value' => 'Service request::New software requirement'
  187. },
  188. {
  189. 'name' => 'New hardware',
  190. 'value' => 'Service request::New hardware'
  191. },
  192. {
  193. 'name' => 'Consulting',
  194. 'value' => 'Service request::Consulting'
  195. }
  196. ]
  197. },
  198. {
  199. 'name' => 'Change request',
  200. 'value' => 'Change request'
  201. }
  202. ],
  203. 'default' => '',
  204. 'null' => true,
  205. 'relation' => '',
  206. 'maxlength' => 255,
  207. 'nulloption' => true,
  208. }
  209. end
  210. end
  211. factory :required_screen, class: Hash do
  212. create_middle do
  213. {
  214. 'ticket.customer' => {
  215. shown: true,
  216. required: true,
  217. item_class: 'column'
  218. },
  219. 'ticket.agent' => {
  220. shown: true,
  221. required: true,
  222. item_class: 'column'
  223. },
  224. 'admin.organization' => {
  225. shown: true,
  226. required: true,
  227. },
  228. 'admin.group' => {
  229. shown: true,
  230. required: true,
  231. item_class: 'column'
  232. },
  233. }
  234. end
  235. edit do
  236. {
  237. 'ticket.customer' => {
  238. shown: true,
  239. required: true
  240. },
  241. 'ticket.agent' => {
  242. shown: true,
  243. required: true
  244. },
  245. 'admin.organization' => {
  246. shown: true,
  247. required: true,
  248. },
  249. 'admin.group' => {
  250. shown: true,
  251. required: true,
  252. item_class: 'column'
  253. },
  254. }
  255. end
  256. end
  257. end