Songs.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <script setup lang="ts">
  2. import { defineAsyncComponent, onMounted } from "vue";
  3. import { storeToRefs } from "pinia";
  4. import { useConfigStore } from "@/stores/config";
  5. import { useEditSongStore } from "@/stores/editSong";
  6. import { useSearchMusare } from "@/composables/useSearchMusare";
  7. const MediaItem = defineAsyncComponent(
  8. () => import("@/components/MediaItem.vue")
  9. );
  10. const props = defineProps({
  11. modalUuid: { type: String, required: true },
  12. modalModulePath: { type: String, default: "modals/editSong/MODAL_UUID" }
  13. });
  14. const configStore = useConfigStore();
  15. const { sitename } = storeToRefs(configStore);
  16. const { form } = useEditSongStore({ modalUuid: props.modalUuid });
  17. const {
  18. musareSearch,
  19. resultsLeftCount,
  20. nextPageResultsCount,
  21. searchForMusareSongs
  22. } = useSearchMusare();
  23. onMounted(async () => {
  24. musareSearch.value.query = form.inputs.title.value;
  25. searchForMusareSongs(1, false);
  26. });
  27. </script>
  28. <template>
  29. <div class="musare-songs-tab">
  30. <label class="label"> Search for a song on {{ sitename }} </label>
  31. <div class="control is-grouped input-with-button">
  32. <p class="control is-expanded">
  33. <input
  34. class="input"
  35. type="text"
  36. placeholder="Enter your song query here..."
  37. v-model="musareSearch.query"
  38. @keyup.enter="searchForMusareSongs(1)"
  39. />
  40. </p>
  41. <p class="control">
  42. <a class="button is-info" @click="searchForMusareSongs(1)"
  43. ><i class="material-icons icon-with-button">search</i
  44. >Search</a
  45. >
  46. </p>
  47. </div>
  48. <div v-if="musareSearch.results.length > 0">
  49. <media-item
  50. v-for="result in musareSearch.results"
  51. :key="result._id"
  52. :song="result"
  53. :disabled-actions="['addToPlaylist', 'edit']"
  54. />
  55. <button
  56. v-if="resultsLeftCount > 0"
  57. class="button is-primary load-more-button"
  58. @click="searchForMusareSongs(musareSearch.page + 1)"
  59. >
  60. Load {{ nextPageResultsCount }} more results
  61. </button>
  62. </div>
  63. </div>
  64. </template>
  65. <style lang="less" scoped>
  66. .musare-songs-tab #song-query-results {
  67. height: calc(100% - 74px);
  68. overflow: auto;
  69. .search-query-item {
  70. .icon-selected {
  71. color: var(--green) !important;
  72. }
  73. .icon-not-selected {
  74. color: var(--grey) !important;
  75. }
  76. }
  77. .search-query-item:not(:last-of-type) {
  78. margin-bottom: 10px;
  79. }
  80. .load-more-button {
  81. width: 100%;
  82. margin-top: 10px;
  83. }
  84. }
  85. </style>