Report.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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-transparent.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 !== {}'>
  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-transparent.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. resolved: false,
  108. songId: this.$parent.currentSong._id,
  109. description: '',
  110. issues: [
  111. { name: 'Video', reasons: [] },
  112. { name: 'Title', reasons: [] },
  113. { name: 'Duration', reasons: [] },
  114. { name: 'Artists', reasons: [] },
  115. { name: 'Thumbnail', reasons: [] }
  116. ]
  117. },
  118. issues: [
  119. {
  120. name: 'Video',
  121. reasons: [
  122. 'Doesn\'t exist',
  123. 'It\'s private',
  124. 'It\'s not available in my country'
  125. ]
  126. },
  127. {
  128. name: 'Title',
  129. reasons: [
  130. 'Incorrect',
  131. 'Inappropriate'
  132. ]
  133. },
  134. {
  135. name: 'Duration',
  136. reasons: [
  137. 'Skips too soon',
  138. 'Skips too late',
  139. 'Starts too soon',
  140. 'Skips too late'
  141. ]
  142. },
  143. {
  144. name: 'Artists',
  145. reasons: [
  146. 'Incorrect',
  147. 'Inappropriate'
  148. ]
  149. },
  150. {
  151. name: 'Thumbnail',
  152. reasons: [
  153. 'Incorrect',
  154. 'Inappropriate',
  155. 'Doesn\'t exist'
  156. ]
  157. }
  158. ]
  159. }
  160. },
  161. methods: {
  162. create: function () {
  163. let _this = this;
  164. _this.socket.emit('reports.create', _this.report, res => {
  165. Toast.methods.addToast(res.message, 4000);
  166. if (res.status == 'success') _this.$parent.modals.report = !_this.$parent.modals.report;
  167. });
  168. },
  169. updateCharactersRemaining: function () {
  170. this.charactersRemaining = 400 - $('.textarea').val().length;
  171. },
  172. highlight: function (type) {
  173. if (type == 'currentSong') {
  174. this.report.songId = this.$parent.currentSong._id;
  175. this.isPreviousSongActive = false;
  176. this.isCurrentSongActive = true;
  177. } else if (type == 'previousSong') {
  178. this.report.songId = this.$parent.previousSong._id;
  179. this.isCurrentSongActive = false;
  180. this.isPreviousSongActive = true;
  181. }
  182. },
  183. toggleIssue: function (name, reason) {
  184. for (let z = 0; z < this.report.issues.length; z++) {
  185. if (this.report.issues[z].name == name) {
  186. if (this.report.issues[z].reasons.indexOf(reason) > -1) {
  187. this.report.issues[z].reasons.splice(
  188. this.report.issues[z].reasons.indexOf(reason), 1
  189. );
  190. } else this.report.issues[z].reasons.push(reason);
  191. }
  192. }
  193. }
  194. },
  195. events: {
  196. closeModal: function () {
  197. this.$parent.toggleModal('report');
  198. }
  199. },
  200. ready: function () {
  201. let _this = this;
  202. io.getSocket((socket) => {
  203. _this.socket = socket;
  204. });
  205. },
  206. }
  207. </script>
  208. <style type='scss' scoped>
  209. h6 { margin-bottom: 15px; }
  210. .song-types {
  211. margin-right: 0;
  212. }
  213. .song-type:first-of-type {
  214. padding-left: 0;
  215. }
  216. .media-content {
  217. display: flex;
  218. align-items: center;
  219. height: 64px;
  220. }
  221. .radio-controls .control {
  222. display: flex;
  223. align-items: center;
  224. }
  225. .textarea-counter {
  226. text-align: right;
  227. }
  228. @media screen and (min-width: 769px) {
  229. .radio-controls .control-label { padding-top: 0 !important; }
  230. }
  231. .edit-report-wrapper {
  232. padding: 20px;
  233. }
  234. .is-highlight-active {
  235. border: 3px #03a9f4 solid;
  236. }
  237. </style>