Report.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <div class='modal is-active'>
  3. <div class='modal-background'></div>
  4. <div class='modal-card'>
  5. <header class='modal-card-head'>
  6. <p class='modal-card-title'>Report</p>
  7. <button class='delete' @click='$parent.modals.report = !$parent.modals.report'></button>
  8. </header>
  9. <section class='modal-card-body'>
  10. <div class='columns song-types'>
  11. <div class='column song-type' v-if='$parent.previousSong !== null'>
  12. <div class='card is-fullwidth' :class="{ 'is-highlight-active': isPreviousSongActive }" @click="highlight('previousSong')">
  13. <header class='card-header'>
  14. <p class='card-header-title'>
  15. Previous Song
  16. </p>
  17. </header>
  18. <div class='card-content'>
  19. <article class='media'>
  20. <figure class='media-left'>
  21. <p class='image is-64x64'>
  22. <img :src='$parent.previousSong.thumbnail' onerror='this.src="/assets/notes.png"'>
  23. </p>
  24. </figure>
  25. <div class='media-content'>
  26. <div class='content'>
  27. <p>
  28. <strong>{{ $parent.previousSong.title }}</strong>
  29. <br>
  30. <small>{{ $parent.previousSong.artists.split(' ,') }}</small>
  31. </p>
  32. </div>
  33. </div>
  34. </article>
  35. </div>
  36. </div>
  37. </div>
  38. <div class='column song-type' v-if='$parent.currentSong !== null'>
  39. <div class='card is-fullwidth' :class="{ 'is-highlight-active': isCurrentSongActive }" @click="highlight('currentSong')">
  40. <header class='card-header'>
  41. <p class='card-header-title'>
  42. Current Song
  43. </p>
  44. </header>
  45. <div class='card-content'>
  46. <article class='media'>
  47. <figure class='media-left'>
  48. <p class='image is-64x64'>
  49. <img :src='$parent.currentSong.thumbnail' onerror='this.src="/assets/notes.png"'>
  50. </p>
  51. </figure>
  52. <div class='media-content'>
  53. <div class='content'>
  54. <p>
  55. <strong>{{ $parent.currentSong.title }}</strong>
  56. <br>
  57. <small>{{ $parent.currentSong.artists.split(' ,') }}</small>
  58. </p>
  59. </div>
  60. </div>
  61. </article>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. <div class='edit-report-wrapper'>
  67. <div class='columns is-multiline'>
  68. <div class='column is-half' v-for='issue in issues'>
  69. <label class='label'>{{ issue.name }}</label>
  70. <p class='control' v-for='reason in issue.reasons' track-by='$index'>
  71. <label class='checkbox'>
  72. <input type='checkbox' @click='toggleIssue(issue.name, reason)'>
  73. {{ reason }}
  74. </label>
  75. </p>
  76. </div>
  77. <div class='column'>
  78. <label class='label'>Other</label>
  79. <textarea class='textarea' maxlength='400' placeholder='Any other details...' @keyup='updateCharactersRemaining()' v-model='report.description'></textarea>
  80. <div class='textarea-counter'>{{ charactersRemaining }}</div>
  81. </div>
  82. </div>
  83. </div>
  84. </section>
  85. <footer class='modal-card-foot'>
  86. <a class='button is-success' @click='create()'>
  87. <i class='material-icons save-changes'>done</i>
  88. <span>&nbsp;Create</span>
  89. </a>
  90. <a class='button is-danger' @click='$parent.modals.report = !$parent.modals.report'>
  91. <span>&nbsp;Cancel</span>
  92. </a>
  93. </footer>
  94. </div>
  95. </div>
  96. </template>
  97. <script>
  98. import { Toast } from 'vue-roaster';
  99. import io from '../../io';
  100. export default {
  101. data() {
  102. return {
  103. charactersRemaining: 400,
  104. isPreviousSongActive: false,
  105. isCurrentSongActive: true,
  106. report: {
  107. songId: this.$parent.currentSong._id,
  108. description: '',
  109. issues: [
  110. { name: 'Video', reasons: [] },
  111. { name: 'Title', reasons: [] },
  112. { name: 'Duration', reasons: [] },
  113. { name: 'Artists', reasons: [] },
  114. { name: 'Thumbnail', reasons: [] }
  115. ],
  116. createdBy: this.$parent.$parent.userId,
  117. createdAt: Date.now()
  118. },
  119. issues: [
  120. {
  121. name: 'Video',
  122. reasons: [
  123. 'Doesn\'t exist',
  124. 'It\'s private',
  125. 'It\'s not available in my country'
  126. ]
  127. },
  128. {
  129. name: 'Title',
  130. reasons: [
  131. 'Incorrect',
  132. 'Inappropriate'
  133. ]
  134. },
  135. {
  136. name: 'Duration',
  137. reasons: [
  138. 'Skips too soon',
  139. 'Skips too late',
  140. 'Starts too soon',
  141. 'Skips too late'
  142. ]
  143. },
  144. {
  145. name: 'Artists',
  146. reasons: [
  147. 'Incorrect',
  148. 'Inappropriate'
  149. ]
  150. },
  151. {
  152. name: 'Thumbnail',
  153. reasons: [
  154. 'Incorrect',
  155. 'Inappropriate',
  156. 'Doesn\'t exist'
  157. ]
  158. }
  159. ]
  160. }
  161. },
  162. methods: {
  163. create: function () {
  164. this.socket.emit('reports.create', this.report, res => {
  165. Toast.methods.addToast(res.message, 4000);
  166. });
  167. },
  168. updateCharactersRemaining: function () {
  169. this.charactersRemaining = 400 - $('.textarea').val().length;
  170. },
  171. highlight: function (type) {
  172. if (type == 'currentSong') {
  173. this.report.songId = this.$parent.currentSong._id;
  174. this.isPreviousSongActive = false;
  175. this.isCurrentSongActive = true;
  176. } else if (type == 'previousSong') {
  177. this.report.songId = this.$parent.previousSong._id;
  178. this.isCurrentSongActive = false;
  179. this.isPreviousSongActive = true;
  180. }
  181. },
  182. toggleIssue: function (name, reason) {
  183. for (let z = 0; z < this.report.issues.length; z++) {
  184. if (this.report.issues[z].name == name) {
  185. if (this.report.issues[z].reasons.indexOf(reason) > -1) {
  186. this.report.issues[z].reasons.splice(
  187. this.report.issues[z].reasons.indexOf(reason), 1
  188. );
  189. } else this.report.issues[z].reasons.push(reason);
  190. }
  191. }
  192. }
  193. },
  194. events: {
  195. closeModal: function () {
  196. this.$parent.toggleModal('report');
  197. }
  198. },
  199. ready: function () {
  200. let _this = this;
  201. io.getSocket((socket) => {
  202. _this.socket = socket;
  203. });
  204. },
  205. }
  206. </script>
  207. <style type='scss' scoped>
  208. h6 { margin-bottom: 15px; }
  209. .song-types {
  210. margin-right: 0;
  211. }
  212. .song-type:first-of-type {
  213. padding-left: 0;
  214. }
  215. .media-content {
  216. display: flex;
  217. align-items: center;
  218. height: 64px;
  219. }
  220. .radio-controls .control {
  221. display: flex;
  222. align-items: center;
  223. }
  224. .textarea-counter {
  225. text-align: right;
  226. }
  227. @media screen and (min-width: 769px) {
  228. .radio-controls .control-label { padding-top: 0 !important; }
  229. }
  230. .edit-report-wrapper {
  231. padding: 20px;
  232. }
  233. .is-highlight-active {
  234. border: 3px #03a9f4 solid;
  235. }
  236. </style>