overviews.rb 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. overview_role = Role.find_by(name: 'Agent')
  3. Overview.create_if_not_exists(
  4. name: __('My Assigned Tickets'),
  5. link: 'my_assigned',
  6. prio: 1000,
  7. role_ids: [overview_role.id],
  8. condition: {
  9. 'ticket.state_id' => {
  10. operator: 'is',
  11. value: Ticket::State.by_category(:open).pluck(:id),
  12. },
  13. 'ticket.owner_id' => {
  14. operator: 'is',
  15. pre_condition: 'current_user.id',
  16. },
  17. },
  18. order: {
  19. by: 'created_at',
  20. direction: 'ASC',
  21. },
  22. view: {
  23. d: %w[title customer group created_at],
  24. s: %w[title customer group created_at],
  25. m: %w[number title customer group created_at],
  26. view_mode_default: 's',
  27. },
  28. )
  29. Overview.create_if_not_exists(
  30. name: __('Unassigned & Open Tickets'),
  31. link: 'all_unassigned',
  32. prio: 1010,
  33. role_ids: [overview_role.id],
  34. condition: {
  35. 'ticket.state_id' => {
  36. operator: 'is',
  37. value: Ticket::State.by_category(:work_on_all).pluck(:id),
  38. },
  39. 'ticket.owner_id' => {
  40. operator: 'is',
  41. pre_condition: 'not_set',
  42. },
  43. },
  44. order: {
  45. by: 'created_at',
  46. direction: 'ASC',
  47. },
  48. view: {
  49. d: %w[title customer group created_at],
  50. s: %w[title customer group created_at],
  51. m: %w[number title customer group created_at],
  52. view_mode_default: 's',
  53. },
  54. )
  55. Overview.create_if_not_exists(
  56. name: __('My Pending Reached Tickets'),
  57. link: 'my_pending_reached',
  58. prio: 1020,
  59. role_ids: [overview_role.id],
  60. condition: {
  61. 'ticket.state_id' => {
  62. operator: 'is',
  63. value: Ticket::State.by_category(:pending_reminder).pluck(:id),
  64. },
  65. 'ticket.owner_id' => {
  66. operator: 'is',
  67. pre_condition: 'current_user.id',
  68. },
  69. 'ticket.pending_time' => {
  70. operator: 'before (relative)',
  71. value: 0,
  72. range: 'minute',
  73. },
  74. },
  75. order: {
  76. by: 'created_at',
  77. direction: 'ASC',
  78. },
  79. view: {
  80. d: %w[title customer group created_at],
  81. s: %w[title customer group created_at],
  82. m: %w[number title customer group created_at],
  83. view_mode_default: 's',
  84. },
  85. )
  86. Overview.create_if_not_exists(
  87. name: __('My Subscribed Tickets'),
  88. link: 'my_subscribed_tickets',
  89. prio: 1025,
  90. role_ids: [overview_role.id],
  91. condition: { 'ticket.mention_user_ids'=>{ 'operator' => 'is', 'pre_condition' => 'current_user.id', 'value' => '', 'value_completion' => '' } },
  92. order: {
  93. by: 'created_at',
  94. direction: 'ASC',
  95. },
  96. view: {
  97. d: %w[title customer group created_at],
  98. s: %w[title customer group created_at],
  99. m: %w[number title customer group created_at],
  100. view_mode_default: 's',
  101. },
  102. )
  103. Overview.create_if_not_exists(
  104. name: __('Open Tickets'),
  105. link: 'all_open',
  106. prio: 1030,
  107. role_ids: [overview_role.id],
  108. condition: {
  109. 'ticket.state_id' => {
  110. operator: 'is',
  111. value: Ticket::State.by_category(:work_on_all).pluck(:id),
  112. },
  113. },
  114. order: {
  115. by: 'created_at',
  116. direction: 'ASC',
  117. },
  118. view: {
  119. d: %w[title customer group state owner created_at],
  120. s: %w[title customer group state owner created_at],
  121. m: %w[number title customer group state owner created_at],
  122. view_mode_default: 's',
  123. },
  124. )
  125. Overview.create_if_not_exists(
  126. name: __('Pending Reached Tickets'),
  127. link: 'all_pending_reached',
  128. prio: 1040,
  129. role_ids: [overview_role.id],
  130. condition: {
  131. 'ticket.state_id' => {
  132. operator: 'is',
  133. value: Ticket::State.by_category(:pending_reminder).pluck(:id),
  134. },
  135. 'ticket.pending_time' => {
  136. operator: 'before (relative)',
  137. value: 0,
  138. range: 'minute',
  139. },
  140. },
  141. order: {
  142. by: 'created_at',
  143. direction: 'ASC',
  144. },
  145. view: {
  146. d: %w[title customer group owner created_at],
  147. s: %w[title customer group owner created_at],
  148. m: %w[number title customer group owner created_at],
  149. view_mode_default: 's',
  150. },
  151. )
  152. Overview.create_if_not_exists(
  153. name: __('Escalated Tickets'),
  154. link: 'all_escalated',
  155. prio: 1050,
  156. role_ids: [overview_role.id],
  157. condition: {
  158. 'ticket.escalation_at' => {
  159. operator: 'till (relative)',
  160. value: '10',
  161. range: 'minute',
  162. },
  163. },
  164. order: {
  165. by: 'escalation_at',
  166. direction: 'ASC',
  167. },
  168. view: {
  169. d: %w[title customer group owner escalation_at],
  170. s: %w[title customer group owner escalation_at],
  171. m: %w[number title customer group owner escalation_at],
  172. view_mode_default: 's',
  173. },
  174. )
  175. Overview.create_if_not_exists(
  176. name: __('My Replacement Tickets'),
  177. link: 'my_replacement_tickets',
  178. prio: 1080,
  179. role_ids: [overview_role.id],
  180. out_of_office: true,
  181. condition: {
  182. 'ticket.state_id' => {
  183. operator: 'is',
  184. value: Ticket::State.by_category(:open).pluck(:id),
  185. },
  186. 'ticket.out_of_office_replacement_id' => {
  187. operator: 'is',
  188. pre_condition: 'current_user.id',
  189. },
  190. },
  191. order: {
  192. by: 'created_at',
  193. direction: 'DESC',
  194. },
  195. view: {
  196. d: %w[title customer group owner escalation_at],
  197. s: %w[title customer group owner escalation_at],
  198. m: %w[number title customer group owner escalation_at],
  199. view_mode_default: 's',
  200. },
  201. )
  202. overview_role = Role.find_by(name: 'Customer')
  203. Overview.create_if_not_exists(
  204. name: __('My Tickets'),
  205. link: 'my_tickets',
  206. prio: 1100,
  207. role_ids: [overview_role.id],
  208. condition: {
  209. 'ticket.state_id' => {
  210. operator: 'is',
  211. value: Ticket::State.by_category(:viewable).pluck(:id),
  212. },
  213. 'ticket.customer_id' => {
  214. operator: 'is',
  215. pre_condition: 'current_user.id',
  216. },
  217. },
  218. order: {
  219. by: 'created_at',
  220. direction: 'DESC',
  221. },
  222. view: {
  223. d: %w[title customer state created_at],
  224. s: %w[number title state created_at],
  225. m: %w[number title state created_at],
  226. view_mode_default: 's',
  227. },
  228. )
  229. Overview.create_if_not_exists(
  230. name: __('My Organization Tickets'),
  231. link: 'my_organization_tickets',
  232. prio: 1200,
  233. role_ids: [overview_role.id],
  234. organization_shared: true,
  235. condition: {
  236. 'ticket.state_id' => {
  237. operator: 'is',
  238. value: Ticket::State.by_category(:viewable).pluck(:id),
  239. },
  240. 'ticket.organization_id' => {
  241. operator: 'is',
  242. pre_condition: 'current_user.organization_id',
  243. },
  244. },
  245. order: {
  246. by: 'created_at',
  247. direction: 'DESC',
  248. },
  249. view: {
  250. d: %w[title customer organization state created_at],
  251. s: %w[number title customer organization state created_at],
  252. m: %w[number title customer organization state created_at],
  253. view_mode_default: 's',
  254. },
  255. )