PostShow.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div class="post">
  3. <q-banner v-if="!post.post"
  4. class="banner post-banner">
  5. {{post.title}}
  6. </q-banner>
  7. <q-card v-if="!post.post"
  8. flat>
  9. <q-card-section>
  10. <div class="row q-col-gutter-md">
  11. <div class="col-md-2 col-sm-4 col-12 post-thumbnail">
  12. <q-img :src="post.thumbnail" />
  13. </div>
  14. <div class="col-md-10 col-sm-8 col-12 post-summary"
  15. v-html="post.summary" />
  16. </div>
  17. </q-card-section>
  18. <q-separator />
  19. <q-card-section>
  20. <div class="post-text"
  21. v-html="post.text" />
  22. </q-card-section>
  23. </q-card>
  24. <q-skeleton v-if="post.post"
  25. type="circle"
  26. size="100px"
  27. class="q-mt-md" />
  28. <q-skeleton v-if="post.post"
  29. width="150px"
  30. class="q-mt-md" />
  31. <q-skeleton v-if="post.post"
  32. height="150px"
  33. class="q-mt-md" />
  34. </div>
  35. </template>
  36. <script>
  37. import { Post } from 'src/models/Post.js'
  38. import ShamsiDate from 'src/assets/ShamsiDate.js'
  39. import { APIGateway } from 'src/api/APIGateway.js'
  40. import { mixinPrefetchServerData, mixinWidget } from 'src/mixin/Mixins.js'
  41. export default {
  42. name: 'ShowClassroomInfo',
  43. mixins: [mixinWidget, mixinPrefetchServerData],
  44. emits: ['onloadn'],
  45. data: () => ({
  46. defaultOptions: {
  47. profileMode: false
  48. },
  49. post: new Post()
  50. }),
  51. methods: {
  52. prefetchServerDataPromise () {
  53. return this.getPost()
  54. },
  55. prefetchServerDataPromiseThen (post) {
  56. this.post = new Post(post)
  57. this.post.post = false
  58. this.$emit('onloadn', this.post)
  59. },
  60. prefetchServerDataPromiseCatch () {
  61. this.post.post = false
  62. },
  63. getTitledDateTime (dateTime) {
  64. return ShamsiDate.getTitledDateTime(dateTime)
  65. },
  66. getTime (time) {
  67. return ShamsiDate.getDateTime(time)
  68. },
  69. getPost () {
  70. this.post.post = true
  71. return APIGateway.post.get(this.$route.params.id)
  72. }
  73. }
  74. }
  75. </script>
  76. <style scoped lang="scss">
  77. .post {
  78. .post-banner {
  79. margin-top: 52px;
  80. margin-bottom: 42px;
  81. }
  82. }
  83. </style>