Report.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <template>
  2. <div>
  3. <modal class="report-modal" title="Report">
  4. <template #body>
  5. <div class="report-modal-inner-container">
  6. <div id="left-part">
  7. <song-item
  8. :song="song"
  9. :duration="false"
  10. :disabled-actions="['report']"
  11. header="Selected Song.."
  12. />
  13. <div class="columns is-multiline">
  14. <div
  15. v-for="category in predefinedCategories"
  16. class="column is-half"
  17. :key="category.category"
  18. >
  19. <label class="label">{{
  20. category.category
  21. }}</label>
  22. <p
  23. v-for="issue in category.issues"
  24. class="control checkbox-control"
  25. :key="issue.title"
  26. >
  27. <span class="align-horizontally">
  28. <span>
  29. <label class="switch">
  30. <input
  31. type="checkbox"
  32. :id="issue.title"
  33. v-model="issue.enabled"
  34. />
  35. <span
  36. class="slider round"
  37. ></span>
  38. </label>
  39. <label :for="issue.title">
  40. <span></span>
  41. <p>{{ issue.title }}</p>
  42. </label>
  43. </span>
  44. <i
  45. class="material-icons"
  46. content="Provide More info"
  47. v-tippy
  48. @click="
  49. issue.showDescription = !issue.showDescription
  50. "
  51. >
  52. info
  53. </i>
  54. </span>
  55. <input
  56. type="text"
  57. class="input"
  58. v-model="issue.description"
  59. v-if="issue.showDescription"
  60. placeholder="Provide more information..."
  61. @keyup="issue.enabled = true"
  62. />
  63. </p>
  64. </div>
  65. <!-- allow for multiple custom issues with plus/add button and then a input textbox -->
  66. <!-- do away with textbox -->
  67. <div class="column is-half">
  68. <div id="custom-issues">
  69. <div id="custom-issues-title">
  70. <label class="label"
  71. >Issues not listed</label
  72. >
  73. <button
  74. class="button tab-actionable-button "
  75. content="Add an issue that isn't listed"
  76. v-tippy
  77. @click="customIssues.push('')"
  78. >
  79. <i
  80. class="material-icons icon-with-button"
  81. >add</i
  82. >
  83. <span>
  84. Add Custom Issue
  85. </span>
  86. </button>
  87. </div>
  88. <div
  89. class="custom-issue control is-grouped input-with-button"
  90. v-for="(issue, index) in customIssues"
  91. :key="index"
  92. >
  93. <p class="control is-expanded">
  94. <input
  95. type="text"
  96. class="input"
  97. v-model="customIssues[index]"
  98. placeholder="Provide information..."
  99. />
  100. </p>
  101. <p class="control">
  102. <button
  103. class="button is-danger"
  104. content="Remove custom issue"
  105. v-tippy
  106. @click="
  107. customIssues.splice(
  108. index,
  109. 1
  110. )
  111. "
  112. >
  113. <i class="material-icons">
  114. delete
  115. </i>
  116. </button>
  117. </p>
  118. </div>
  119. <p
  120. id="no-issues-listed"
  121. v-if="customIssues.length <= 0"
  122. >
  123. <em>
  124. Add any issues that aren't listed
  125. above.
  126. </em>
  127. </p>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <div id="right-part" v-if="existingReports.length > 0">
  133. <h4 class="section-title">Previous Reports</h4>
  134. <p class="section-description">
  135. You have made
  136. {{
  137. existingReports.length > 1
  138. ? "multiple reports"
  139. : "a report"
  140. }}
  141. about this song already.
  142. </p>
  143. <hr class="section-horizontal-rule" />
  144. <div class="report-items">
  145. <div
  146. class="report-item"
  147. v-for="report in existingReports"
  148. :key="report._id"
  149. >
  150. <report-info-item
  151. :created-at="report.createdAt"
  152. :created-by="report.createdBy"
  153. >
  154. <template #actions>
  155. <i
  156. class="material-icons"
  157. content="View Report"
  158. v-tippy
  159. @click="view(report._id)"
  160. >
  161. open_in_full
  162. </i>
  163. </template>
  164. </report-info-item>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. </template>
  170. <template #footer>
  171. <a class="button is-success" @click="create()" href="#">
  172. <i class="material-icons save-changes">done</i>
  173. <span>&nbsp;Create</span>
  174. </a>
  175. <a
  176. class="button is-danger"
  177. href="#"
  178. @click="closeModal('report')"
  179. >
  180. <span>&nbsp;Cancel</span>
  181. </a>
  182. </template>
  183. </modal>
  184. <view-report v-if="modals.viewReport" :report-id="viewingReportId" />
  185. </div>
  186. </template>
  187. <script>
  188. import { mapState, mapGetters, mapActions } from "vuex";
  189. import Toast from "toasters";
  190. import ViewReport from "@/components/modals/ViewReport.vue";
  191. import SongItem from "@/components/SongItem.vue";
  192. import ReportInfoItem from "@/components/ReportInfoItem.vue";
  193. import Modal from "../Modal.vue";
  194. export default {
  195. components: { Modal, ViewReport, SongItem, ReportInfoItem },
  196. data() {
  197. return {
  198. viewingReportId: "",
  199. icons: {
  200. duration: "timer",
  201. video: "tv",
  202. thumbnail: "image",
  203. artists: "record_voice_over",
  204. title: "title",
  205. custom: "lightbulb"
  206. },
  207. existingReports: [],
  208. customIssues: [],
  209. predefinedCategories: [
  210. {
  211. category: "video",
  212. issues: [
  213. {
  214. enabled: false,
  215. title: "Doesn't exist",
  216. description: "",
  217. showDescription: false
  218. },
  219. {
  220. enabled: false,
  221. title: "It's private",
  222. description: "",
  223. showDescription: false
  224. },
  225. {
  226. enabled: false,
  227. title: "It's not available in my country",
  228. description: "",
  229. showDescription: false
  230. },
  231. {
  232. enabled: false,
  233. title: "Unofficial",
  234. description: "",
  235. showDescription: false
  236. }
  237. ]
  238. },
  239. {
  240. category: "title",
  241. issues: [
  242. {
  243. enabled: false,
  244. title: "Incorrect",
  245. description: "",
  246. showDescription: false
  247. },
  248. {
  249. enabled: false,
  250. title: "Inappropriate",
  251. description: "",
  252. showDescription: false
  253. }
  254. ]
  255. },
  256. {
  257. category: "duration",
  258. issues: [
  259. {
  260. enabled: false,
  261. title: "Skips too soon",
  262. description: "",
  263. showDescription: false
  264. },
  265. {
  266. enabled: false,
  267. title: "Skips too late",
  268. description: "",
  269. showDescription: false
  270. },
  271. {
  272. enabled: false,
  273. title: "Starts too soon",
  274. description: "",
  275. showDescription: false
  276. },
  277. {
  278. enabled: false,
  279. title: "Starts too late",
  280. description: "",
  281. showDescription: false
  282. }
  283. ]
  284. },
  285. {
  286. category: "artists",
  287. issues: [
  288. {
  289. enabled: false,
  290. title: "Incorrect",
  291. description: "",
  292. showDescription: false
  293. },
  294. {
  295. enabled: false,
  296. title: "Inappropriate",
  297. description: "",
  298. showDescription: false
  299. }
  300. ]
  301. },
  302. {
  303. category: "thumbnail",
  304. issues: [
  305. {
  306. enabled: false,
  307. title: "Incorrect",
  308. description: "",
  309. showDescription: false
  310. },
  311. {
  312. enabled: false,
  313. title: "Inappropriate",
  314. description: "",
  315. showDescription: false
  316. },
  317. {
  318. enabled: false,
  319. title: "Doesn't exist",
  320. description: "",
  321. showDescription: false
  322. }
  323. ]
  324. }
  325. ]
  326. };
  327. },
  328. computed: {
  329. ...mapState({
  330. song: state => state.modals.report.song
  331. }),
  332. ...mapState("modalVisibility", {
  333. modals: state => state.modals
  334. }),
  335. ...mapGetters({
  336. socket: "websockets/getSocket"
  337. })
  338. },
  339. mounted() {
  340. this.socket.dispatch("reports.myReportsForSong", this.song._id, res => {
  341. if (res.status === "success")
  342. this.existingReports = res.data.reports;
  343. });
  344. },
  345. methods: {
  346. view(reportId) {
  347. this.viewingReportId = reportId;
  348. this.openModal("viewReport");
  349. },
  350. create() {
  351. const issues = [];
  352. // any predefined issues that are enabled
  353. this.predefinedCategories.forEach(category =>
  354. category.issues.forEach(issue => {
  355. if (issue.enabled)
  356. issues.push({
  357. category: category.category,
  358. title: issue.title,
  359. description: issue.description
  360. });
  361. })
  362. );
  363. // any custom issues
  364. this.customIssues.forEach(issue =>
  365. issues.push({ category: "custom", title: issue })
  366. );
  367. if (issues.length === 0)
  368. return new Toast("Reports must have at least one issue");
  369. return this.socket.dispatch(
  370. "reports.create",
  371. {
  372. issues,
  373. youtubeId: this.song.youtubeId
  374. },
  375. res => {
  376. new Toast(res.message);
  377. if (res.status === "success") this.closeModal("report");
  378. }
  379. );
  380. },
  381. ...mapActions("modals/report", ["reportSong"]),
  382. ...mapActions("modalVisibility", ["openModal", "closeModal"])
  383. }
  384. };
  385. </script>
  386. <style lang="scss">
  387. .report-modal {
  388. .modal-card {
  389. width: 1050px;
  390. }
  391. .song-item {
  392. .thumbnail {
  393. min-width: 130px;
  394. width: 130px;
  395. height: 130px;
  396. }
  397. }
  398. }
  399. </style>
  400. <style lang="scss" scoped>
  401. .report-modal-inner-container {
  402. display: flex;
  403. #right-part {
  404. border-left: 1px solid var(--light-grey-3);
  405. padding-left: 20px;
  406. margin-left: 20px;
  407. min-width: 325px;
  408. @media screen and (max-width: 900px) {
  409. display: none;
  410. }
  411. .report-items {
  412. max-height: 485px;
  413. overflow: auto;
  414. .report-item:not(:first-of-type) {
  415. margin-top: 10px;
  416. }
  417. }
  418. }
  419. }
  420. .label {
  421. text-transform: capitalize;
  422. }
  423. .columns {
  424. margin-left: unset;
  425. margin-right: unset;
  426. margin-top: 20px;
  427. .control {
  428. display: flex;
  429. flex-direction: column;
  430. span.align-horizontally {
  431. width: 100%;
  432. display: flex;
  433. align-items: center;
  434. justify-content: space-between;
  435. span {
  436. display: flex;
  437. }
  438. }
  439. i {
  440. cursor: pointer;
  441. }
  442. input[type="text"] {
  443. height: initial;
  444. margin: 10px 0;
  445. }
  446. }
  447. }
  448. #custom-issues {
  449. height: 100%;
  450. #custom-issues-title {
  451. display: flex;
  452. align-items: center;
  453. justify-content: space-between;
  454. margin-bottom: 15px;
  455. button {
  456. padding: 3px 5px;
  457. height: initial;
  458. }
  459. label {
  460. margin: 0;
  461. }
  462. }
  463. #no-issues-listed {
  464. display: flex;
  465. height: calc(100% - 32px - 15px);
  466. align-items: center;
  467. justify-content: center;
  468. }
  469. .custom-issue {
  470. flex-direction: row;
  471. input {
  472. height: 36px;
  473. margin: 0;
  474. }
  475. }
  476. }
  477. </style>