Create.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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'>Create Playlist</p>
  7. <button class='delete' @click='$parent.toggleModal("createPlaylist")'></button>
  8. </header>
  9. <section class='modal-card-body'>
  10. <p class='control is-expanded'>
  11. <input class='input' type='text' placeholder='Playlist Display Name' v-model='playlist.displayName'>
  12. </p>
  13. </section>
  14. <footer class='modal-card-foot'>
  15. <a class='button is-info' @click='createPlaylist()'>Create Playlist</a>
  16. </footer>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. import { Toast } from 'vue-roaster';
  22. export default {
  23. data() {
  24. return {
  25. playlist: {
  26. displayName: null,
  27. songs: [],
  28. createdBy: this.$parent.$parent.username,
  29. createdAt: Date.now()
  30. }
  31. }
  32. },
  33. methods: {
  34. createPlaylist: function () {
  35. let _this = this;
  36. _this.socket.emit('playlists.create', _this.playlist, res => {
  37. Toast.methods.addToast(res.message, 3000);
  38. });
  39. this.$parent.toggleModal('createPlaylist');
  40. }
  41. },
  42. ready: function () {
  43. let _this = this;
  44. let socketInterval = setInterval(() => {
  45. if (!!_this.$parent.$parent.socket) {
  46. _this.socket = _this.$parent.$parent.socket;
  47. clearInterval(socketInterval);
  48. }
  49. }, 100);
  50. },
  51. events: {
  52. closeModal: function() {
  53. this.$parent.toggleModal("createPlaylist");
  54. }
  55. }
  56. }
  57. </script>
  58. <style type='scss' scoped>
  59. .menu { padding: 0 20px; }
  60. .menu-list li {
  61. display: flex;
  62. justify-content: space-between;
  63. }
  64. .menu-list a:hover { color: #000 !important; }
  65. li a {
  66. display: flex;
  67. align-items: center;
  68. }
  69. .controls {
  70. display: flex;
  71. a {
  72. display: flex;
  73. align-items: center;
  74. }
  75. }
  76. .table {
  77. margin-bottom: 0;
  78. }
  79. h5 { padding: 20px 0; }
  80. </style>