Songs.vue 2.2 KB

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