Media.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { Collection, Model } from 'js-abstract-model'
  2. import { CelebrityList } from 'src/models/Celebrity.js'
  3. import { MediaHashtagList } from 'src/models/MediaHashtag.js'
  4. import { MediaCategory } from 'src/models/MediaCategory.js'
  5. class Media extends Model {
  6. constructor (data) {
  7. super(data, [
  8. { key: 'id' },
  9. { key: 'title' },
  10. { key: 'type' }, // VIDEO - TEXT - SOUND - IMAGE
  11. { key: 'source_type' }, // CONTENT - SETTING
  12. { key: 'url' },
  13. { key: 'iframe_code' },
  14. { key: 'script_code' },
  15. { key: 'is_live_streaming' },
  16. { key: 'category' },
  17. {
  18. key: 'category_info',
  19. relatedModel: MediaCategory
  20. },
  21. { key: 'description' },
  22. {
  23. key: 'celebrities',
  24. relatedModel: CelebrityList
  25. },
  26. { key: 'hashtags' },
  27. {
  28. key: 'hashtags_info',
  29. relatedModel: MediaHashtagList
  30. }
  31. ])
  32. this.typeEnums = [
  33. {
  34. label: 'ویدیو',
  35. value: 'VIDEO'
  36. },
  37. {
  38. label: 'متن',
  39. value: 'TEXT'
  40. },
  41. {
  42. label: 'صوت',
  43. value: 'SOUND'
  44. },
  45. {
  46. label: 'تصویر',
  47. value: 'IMAGE'
  48. }
  49. ]
  50. this.loadTypeInfo()
  51. }
  52. loadTypeInfo () {
  53. const target = this.typeEnums.find(type => type.value === this.type)
  54. if (!target) {
  55. this.type_info = null
  56. } else {
  57. this.type_info = target
  58. }
  59. }
  60. }
  61. class MediaList extends Collection {
  62. model () {
  63. return Media
  64. }
  65. }
  66. export { Media, MediaList }