Create.vue 1.9 KB

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