Ticket.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { User } from 'src/models/User.js'
  2. import { Collection, Model } from 'js-abstract-model'
  3. import { TicketReplyList } from 'src/models/TicketReply.js'
  4. import { TicketCategory } from 'src/models/TicketCategory.js'
  5. class Ticket extends Model {
  6. constructor (data) {
  7. super(data, [
  8. { key: 'id' },
  9. { key: 'title' },
  10. { key: 'body' }, //
  11. { key: 'priority' }, // HIGH - ...
  12. { key: 'status' }, // ADMIN_REPLIED - ...
  13. { key: 'source_type' }, // INVOICE - CLASSROOM
  14. { key: 'source_id' },
  15. { key: 'source' },
  16. { key: 'category' },
  17. {
  18. key: 'category_info',
  19. relatedModel: TicketCategory
  20. },
  21. {
  22. key: 'replies_info',
  23. relatedModel: TicketReplyList
  24. },
  25. { key: 'creator' },
  26. {
  27. key: 'creator_info',
  28. relatedModel: User
  29. },
  30. { key: 'owner' },
  31. {
  32. key: 'owner_info',
  33. relatedModel: User
  34. }
  35. ])
  36. this.priorityEnums = [
  37. {
  38. label: 'بالا',
  39. value: 'HIGH'
  40. }
  41. ]
  42. this.statusEnums = [
  43. {
  44. label: 'در انتظار پاسخ',
  45. value: 'OPENED',
  46. color: '#2FA84A'
  47. },
  48. {
  49. label: 'ادمین پاسخ داده',
  50. value: 'ADMIN_REPLIED',
  51. color: '#0B6AB1'
  52. },
  53. {
  54. label: 'کاربر پاسخ داده',
  55. value: 'USER_REPLIED',
  56. color: '#0B6AB1'
  57. },
  58. // {
  59. // label: 'در حال انتظار',
  60. // value: 'PENDING',
  61. // color: '#2FA84A'
  62. // },
  63. // {
  64. // label: 'خوانده نشده',
  65. // value: 'UNREAD',
  66. // color: '#2FA84A'
  67. // },
  68. // {
  69. // label: 'خوانده شده',
  70. // value: 'READ',
  71. // color: '#2FA84A'
  72. // },
  73. {
  74. label: 'بسته شده',
  75. value: 'CLOSED',
  76. color: '#989898'
  77. }
  78. ]
  79. this.loadStatusInfo()
  80. this.loadPriorityInfo()
  81. }
  82. loadPriorityInfo () {
  83. const target = this.priorityEnums.find(type => type.value === this.priority)
  84. if (!target) {
  85. this.priority_info = null
  86. } else {
  87. this.priority_info = target
  88. }
  89. }
  90. loadStatusInfo () {
  91. const target = this.statusEnums.find(type => type.value === this.status)
  92. if (!target) {
  93. this.status_info = {
  94. label: null,
  95. value: null,
  96. color: ''
  97. }
  98. } else {
  99. this.status_info = target
  100. }
  101. }
  102. }
  103. class TicketList extends Collection {
  104. model () {
  105. return Ticket
  106. }
  107. }
  108. export { Ticket, TicketList }