Classroom.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { User } from 'src/models/User.js'
  2. import { Unit } from 'src/models/Unit.js'
  3. import { SessionList } from 'src/models/Session.js'
  4. import { Model, Collection } from 'js-abstract-model'
  5. class Classroom extends Model {
  6. constructor (data) {
  7. super(data, [
  8. { key: 'id' },
  9. { key: 'creator' },
  10. {
  11. key: 'creator_info',
  12. relatedModel: User
  13. },
  14. { key: 'thumbnail' },
  15. { key: 'title' },
  16. { key: 'holding_type' },
  17. { key: 'audience_gender_type' },
  18. { key: 'holding_year' },
  19. { key: 'holding_month' },
  20. { key: 'sessions_frequency' },
  21. { key: 'professor' },
  22. { key: 'current_user_register_info' },
  23. {
  24. key: 'professor_info',
  25. relatedModel: User
  26. },
  27. { key: 'unit' },
  28. {
  29. key: 'unit_info',
  30. relatedModel: Unit
  31. },
  32. {
  33. key: 'sessions_info',
  34. relatedModel: SessionList
  35. },
  36. { key: 'audience_role' },
  37. { key: 'price' },
  38. { key: 'capacity' },
  39. { key: 'used_capacity' },
  40. { key: 'allowed_absence_count' },
  41. { key: 'effective_absence_coefficient' },
  42. { key: 'mandatory_assignment_count' },
  43. { key: 'minimum_passing_mark' },
  44. { key: 'minimum_conditional_passing_mark' },
  45. { key: 'minimum_clean_passing_mark' },
  46. { key: 'special_passing_mark' },
  47. { key: 'live_streaming_url' },
  48. { key: 'classroom_address' },
  49. { key: 'beginning_enrollment_period' },
  50. { key: 'ending_enrollment_period' },
  51. { key: 'beginning_registration_period' },
  52. { key: 'ending_registration_period' },
  53. { key: 'allow_dropping_on_registration_period' },
  54. { key: 'registration_period_refund_percent' },
  55. { key: 'beginning_drop_add_period' },
  56. { key: 'ending_drop_add_period' },
  57. { key: 'allow_adding_on_drop_add_period' },
  58. { key: 'allow_dropping_on_drop_add_period' },
  59. { key: 'drop_add_period_refund_percent' },
  60. { key: 'is_enabled_enrolment' },
  61. { key: 'is_enabled_adding' },
  62. { key: 'is_enabled_viewing' },
  63. { key: 'is_enabled_dropping' },
  64. { key: 'rules' },
  65. { key: 'description' },
  66. { key: 'is_current_user_registered' },
  67. { key: 'publish_time' },
  68. { key: 'creation_time' },
  69. { key: 'last_modification_time' },
  70. { key: 'is_active' },
  71. { key: 'is_deleted' },
  72. { key: 'status' }
  73. ])
  74. this.statusEnums = [
  75. {
  76. label: 'قبل از دوره حذف و اضافه',
  77. value: 'BEFORE_DROP_ADD_PERIOD'
  78. },
  79. {
  80. label: 'در دوره حذف و اضافه',
  81. value: 'IN_REGISTRATION_PERIOD'
  82. }
  83. ]
  84. this.loadStatusInfo()
  85. if (!this.thumbnail) {
  86. this.thumbnail = '/assets/images/web/sample-class-thumbnail.jpg'
  87. }
  88. }
  89. loadStatusInfo () {
  90. const target = this.statusEnums.find(type => type.value === this.status)
  91. if (!target) {
  92. this.status_info = {
  93. label: null,
  94. value: null
  95. }
  96. } else {
  97. this.status_info = target
  98. }
  99. }
  100. }
  101. class ClassroomList extends Collection {
  102. model () {
  103. return Classroom
  104. }
  105. }
  106. export { Classroom, ClassroomList }