Create.vue 1.6 KB

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