Create.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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' autofocus @keyup.enter='createPlaylist()'>
  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. import io from '../../../io';
  23. export default {
  24. data() {
  25. return {
  26. playlist: {
  27. displayName: null,
  28. songs: [],
  29. createdBy: this.$parent.$parent.username,
  30. createdAt: Date.now()
  31. }
  32. }
  33. },
  34. methods: {
  35. createPlaylist: function () {
  36. let _this = this;
  37. _this.socket.emit('playlists.create', _this.playlist, res => {
  38. Toast.methods.addToast(res.message, 3000);
  39. });
  40. this.$parent.toggleModal('createPlaylist');
  41. }
  42. },
  43. ready: function () {
  44. let _this = this;
  45. io.getSocket((socket) => {
  46. _this.socket = socket;
  47. });
  48. },
  49. events: {
  50. closeModal: function() {
  51. this.$parent.toggleModal("createPlaylist");
  52. }
  53. }
  54. }
  55. </script>
  56. <style type='scss' scoped>
  57. .menu { padding: 0 20px; }
  58. .menu-list li {
  59. display: flex;
  60. justify-content: space-between;
  61. }
  62. .menu-list a:hover { color: #000 !important; }
  63. li a {
  64. display: flex;
  65. align-items: center;
  66. }
  67. .controls {
  68. display: flex;
  69. a {
  70. display: flex;
  71. align-items: center;
  72. }
  73. }
  74. .table {
  75. margin-bottom: 0;
  76. }
  77. h5 { padding: 20px 0; }
  78. </style>