IssuesModal.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <modal title="Report">
  3. <div slot="body">
  4. <router-link
  5. v-if="$route.query.returnToSong"
  6. class="button is-dark back-to-song"
  7. :to="{
  8. path: '/admin/songs',
  9. query: { id: report.songId }
  10. }"
  11. >
  12. <i class="material-icons">keyboard_return</i> &nbsp; Edit Song
  13. </router-link>
  14. <article class="message">
  15. <div class="message-body">
  16. <strong>Song ID:</strong>
  17. {{ report.song.songId }} / {{ report.song._id }}
  18. <br />
  19. <strong>Author:</strong>
  20. <user-id-to-username
  21. :userId="report.createdBy"
  22. :alt="report.createdBy"
  23. />
  24. <br />
  25. <strong>Time of report:</strong>
  26. <span :title="report.createdAt">
  27. {{
  28. formatDistance(
  29. new Date(report.createdAt),
  30. new Date(),
  31. {
  32. addSuffix: true
  33. }
  34. )
  35. }}
  36. </span>
  37. <br />
  38. <span v-if="report.description">
  39. <strong>Description:</strong>
  40. {{ report.description }}
  41. </span>
  42. </div>
  43. </article>
  44. <table v-if="report.issues.length > 0" class="table is-narrow">
  45. <thead>
  46. <tr>
  47. <td>Issue</td>
  48. <td>Reasons</td>
  49. </tr>
  50. </thead>
  51. <tbody>
  52. <tr v-for="(issue, index) in report.issues" :key="index">
  53. <td>
  54. <span>{{ issue.name }}</span>
  55. </td>
  56. <td>
  57. <span>{{ issue.reasons }}</span>
  58. </td>
  59. </tr>
  60. </tbody>
  61. </table>
  62. </div>
  63. <div slot="footer">
  64. <a
  65. class="button is-primary"
  66. href="#"
  67. @click="$parent.resolve(report._id)"
  68. >
  69. <span>Resolve</span>
  70. </a>
  71. <a
  72. class="button is-primary"
  73. :href="`/admin/songs?songId=${report.song.songId}`"
  74. target="_blank"
  75. >
  76. <span>Go to song</span>
  77. </a>
  78. <a
  79. class="button is-danger"
  80. @click="
  81. closeModal({
  82. sector: 'admin',
  83. modal: 'viewReport'
  84. })
  85. "
  86. href="#"
  87. >
  88. <span>Cancel</span>
  89. </a>
  90. </div>
  91. </modal>
  92. </template>
  93. <script>
  94. import { mapActions, mapState } from "vuex";
  95. import { formatDistance } from "date-fns";
  96. import UserIdToUsername from "../UserIdToUsername.vue";
  97. import Modal from "./Modal.vue";
  98. export default {
  99. computed: {
  100. ...mapState("admin/reports", {
  101. report: state => state.report
  102. })
  103. },
  104. mounted() {
  105. if (this.$route.query.returnToSong) {
  106. this.closeModal({ sector: "admin", modal: "editSong" });
  107. }
  108. },
  109. methods: {
  110. formatDistance,
  111. ...mapActions("modals", ["closeModal"])
  112. },
  113. components: { Modal, UserIdToUsername }
  114. };
  115. </script>
  116. <style lang="scss">
  117. @import "styles/global.scss";
  118. .back-to-song {
  119. display: flex;
  120. margin-bottom: 20px;
  121. }
  122. </style>