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. const _this = this;
  218. io.getSocket(socket => {
  219. _this.socket = socket;
  220. });
  221. },
  222. methods: {
  223. create() {
  224. const _this = this;
  225. console.log(this.report);
  226. _this.socket.emit("reports.create", _this.report, res => {
  227. Toast.methods.addToast(res.message, 4000);
  228. if (res.status === "success")
  229. _this.closeModal({
  230. sector: "station",
  231. modal: "report"
  232. });
  233. });
  234. },
  235. updateCharactersRemaining() {
  236. this.charactersRemaining =
  237. 400 - document.getElementsByClassName("textarea").value.length;
  238. },
  239. highlight(type) {
  240. if (type === "currentSong") {
  241. this.report.songId = this.$parent.currentSong.songId;
  242. this.isPreviousSongActive = false;
  243. this.isCurrentSongActive = true;
  244. } else if (type === "previousSong") {
  245. this.report.songId = this.$parent.previousSong.songId;
  246. this.isCurrentSongActive = false;
  247. this.isPreviousSongActive = true;
  248. }
  249. },
  250. toggleIssue(name, reason) {
  251. for (let z = 0; z < this.report.issues.length; z += 1) {
  252. if (this.report.issues[z].name === name) {
  253. if (this.report.issues[z].reasons.indexOf(reason) > -1) {
  254. this.report.issues[z].reasons.splice(
  255. this.report.issues[z].reasons.indexOf(reason),
  256. 1
  257. );
  258. } else this.report.issues[z].reasons.push(reason);
  259. }
  260. }
  261. },
  262. ...mapActions("modals", ["closeModal"])
  263. }
  264. };
  265. </script>
  266. <style lang="scss" scoped>
  267. h6 {
  268. margin-bottom: 15px;
  269. }
  270. .song-type:first-of-type {
  271. padding-left: 0;
  272. }
  273. .song-type:last-of-type {
  274. padding-right: 0;
  275. }
  276. .media-content {
  277. display: flex;
  278. align-items: center;
  279. height: 64px;
  280. }
  281. .radio-controls .control {
  282. display: flex;
  283. align-items: center;
  284. }
  285. .textarea-counter {
  286. text-align: right;
  287. }
  288. @media screen and (min-width: 769px) {
  289. .radio-controls .control-label {
  290. padding-top: 0 !important;
  291. }
  292. }
  293. .edit-report-wrapper {
  294. padding: 20px;
  295. }
  296. .is-highlight-active {
  297. border: 3px #03a9f4 solid;
  298. }
  299. </style>