Report.vue 6.4 KB

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