Report.vue 6.7 KB

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