1
0

PlaylistTabBase.vue 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. <script setup lang="ts">
  2. import { defineAsyncComponent, ref, reactive, computed, onMounted } from "vue";
  3. import Toast from "toasters";
  4. import { storeToRefs } from "pinia";
  5. import { useWebsocketsStore } from "@/stores/websockets";
  6. import { useStationStore } from "@/stores/station";
  7. import { useUserPlaylistsStore } from "@/stores/userPlaylists";
  8. import { useModalsStore } from "@/stores/modals";
  9. import { useManageStationStore } from "@/stores/manageStation";
  10. import { useSortablePlaylists } from "@/composables/useSortablePlaylists";
  11. const PlaylistItem = defineAsyncComponent(
  12. () => import("@/components/PlaylistItem.vue")
  13. );
  14. const QuickConfirm = defineAsyncComponent(
  15. () => import("@/components/QuickConfirm.vue")
  16. );
  17. const props = defineProps({
  18. modalUuid: { type: String, default: "" },
  19. type: {
  20. type: String,
  21. default: ""
  22. },
  23. sector: {
  24. type: String,
  25. default: "manageStation"
  26. }
  27. });
  28. const emit = defineEmits(["selected"]);
  29. const { socket } = useWebsocketsStore();
  30. const stationStore = useStationStore();
  31. const tab = ref("current");
  32. const search = reactive({
  33. query: "",
  34. searchedQuery: "",
  35. page: 0,
  36. count: 0,
  37. resultsLeft: 0,
  38. pageSize: 0,
  39. results: []
  40. });
  41. const featuredPlaylists = ref([]);
  42. const tabs = ref({});
  43. const {
  44. DraggableList,
  45. drag,
  46. playlists,
  47. savePlaylistOrder,
  48. orderOfPlaylists,
  49. myUserId,
  50. calculatePlaylistOrder
  51. } = useSortablePlaylists();
  52. const { autoRequest } = storeToRefs(stationStore);
  53. const manageStationStore = useManageStationStore(props);
  54. const { autofill } = storeToRefs(manageStationStore);
  55. const station = computed({
  56. get() {
  57. if (props.sector === "manageStation") return manageStationStore.station;
  58. return stationStore.station;
  59. },
  60. set(value) {
  61. if (props.sector === "manageStation")
  62. manageStationStore.updateStation(value);
  63. else stationStore.updateStation(value);
  64. }
  65. });
  66. const blacklist = computed({
  67. get() {
  68. if (props.sector === "manageStation")
  69. return manageStationStore.blacklist;
  70. return stationStore.blacklist;
  71. },
  72. set(value) {
  73. if (props.sector === "manageStation")
  74. manageStationStore.setBlacklist(value);
  75. else stationStore.setBlacklist(value);
  76. }
  77. });
  78. const resultsLeftCount = computed(() => search.count - search.results.length);
  79. const nextPageResultsCount = computed(() =>
  80. Math.min(search.pageSize, resultsLeftCount.value)
  81. );
  82. const hasPermission = permission =>
  83. props.sector === "manageStation"
  84. ? manageStationStore.hasPermission(permission)
  85. : stationStore.hasPermission(permission);
  86. const { openModal } = useModalsStore();
  87. const { setPlaylists } = useUserPlaylistsStore();
  88. const { addPlaylistToAutoRequest, removePlaylistFromAutoRequest } =
  89. stationStore;
  90. const showTab = _tab => {
  91. tabs.value[`${_tab}-tab`].scrollIntoView({ block: "nearest" });
  92. tab.value = _tab;
  93. };
  94. const label = (tense = "future", typeOverwrite = null, capitalize = false) => {
  95. let label = typeOverwrite || props.type;
  96. if (tense === "past") label = `${label}ed`;
  97. if (tense === "present") label = `${label}ing`;
  98. if (capitalize) label = `${label.charAt(0).toUpperCase()}${label.slice(1)}`;
  99. return label;
  100. };
  101. const selectedPlaylists = (typeOverwrite?: string) => {
  102. const type = typeOverwrite || props.type;
  103. if (type === "autofill") return autofill.value;
  104. if (type === "blacklist") return blacklist.value;
  105. if (type === "autorequest") return autoRequest.value;
  106. return [];
  107. };
  108. const isSelected = (playlistId, typeOverwrite?: string) => {
  109. const type = typeOverwrite || props.type;
  110. let selected = false;
  111. selectedPlaylists(type).forEach(playlist => {
  112. if (playlist._id === playlistId) selected = true;
  113. });
  114. return selected;
  115. };
  116. const deselectPlaylist = (playlistId, typeOverwrite?: string) => {
  117. const type = typeOverwrite || props.type;
  118. if (type === "autofill")
  119. return new Promise(resolve => {
  120. socket.dispatch(
  121. "stations.removeAutofillPlaylist",
  122. station.value._id,
  123. playlistId,
  124. res => {
  125. new Toast(res.message);
  126. resolve(true);
  127. }
  128. );
  129. });
  130. if (type === "blacklist")
  131. return new Promise(resolve => {
  132. socket.dispatch(
  133. "stations.removeBlacklistedPlaylist",
  134. station.value._id,
  135. playlistId,
  136. res => {
  137. new Toast(res.message);
  138. resolve(true);
  139. }
  140. );
  141. });
  142. if (type === "autorequest")
  143. return new Promise(resolve => {
  144. removePlaylistFromAutoRequest(playlistId);
  145. new Toast("Successfully deselected playlist.");
  146. resolve(true);
  147. });
  148. return false;
  149. };
  150. const selectPlaylist = async (playlist, typeOverwrite?: string) => {
  151. const type = typeOverwrite || props.type;
  152. if (isSelected(playlist._id, type))
  153. return new Toast(`Error: Playlist already ${label("past", type)}.`);
  154. if (type === "autofill")
  155. return new Promise(resolve => {
  156. socket.dispatch(
  157. "stations.autofillPlaylist",
  158. station.value._id,
  159. playlist._id,
  160. res => {
  161. new Toast(res.message);
  162. emit("selected");
  163. resolve(true);
  164. }
  165. );
  166. });
  167. if (type === "blacklist") {
  168. if (props.type !== "blacklist" && isSelected(playlist._id))
  169. await deselectPlaylist(playlist._id);
  170. return new Promise(resolve => {
  171. socket.dispatch(
  172. "stations.blacklistPlaylist",
  173. station.value._id,
  174. playlist._id,
  175. res => {
  176. new Toast(res.message);
  177. emit("selected");
  178. resolve(true);
  179. }
  180. );
  181. });
  182. }
  183. if (type === "autorequest")
  184. return new Promise(resolve => {
  185. addPlaylistToAutoRequest(playlist);
  186. new Toast("Successfully selected playlist to auto request songs.");
  187. emit("selected");
  188. resolve(true);
  189. });
  190. return false;
  191. };
  192. const searchForPlaylists = page => {
  193. if (search.page >= page || search.searchedQuery !== search.query) {
  194. search.results = [];
  195. search.page = 0;
  196. search.count = 0;
  197. search.resultsLeft = 0;
  198. search.pageSize = 0;
  199. }
  200. const { query } = search;
  201. const action =
  202. station.value.type === "official" && props.type !== "autorequest"
  203. ? "playlists.searchOfficial"
  204. : "playlists.searchCommunity";
  205. search.searchedQuery = search.query;
  206. socket.dispatch(action, query, page, res => {
  207. const { data } = res;
  208. if (res.status === "success") {
  209. const { count, pageSize, playlists } = data;
  210. search.results = [...search.results, ...playlists];
  211. search.page = page;
  212. search.count = count;
  213. search.resultsLeft = count - search.results.length;
  214. search.pageSize = pageSize;
  215. } else if (res.status === "error") {
  216. search.results = [];
  217. search.page = 0;
  218. search.count = 0;
  219. search.resultsLeft = 0;
  220. search.pageSize = 0;
  221. new Toast(res.message);
  222. }
  223. });
  224. };
  225. onMounted(() => {
  226. showTab("search");
  227. socket.onConnect(() => {
  228. socket.dispatch("playlists.indexMyPlaylists", res => {
  229. if (res.status === "success") setPlaylists(res.data.playlists);
  230. orderOfPlaylists.value = calculatePlaylistOrder(); // order in regards to the database
  231. });
  232. socket.dispatch("playlists.indexFeaturedPlaylists", res => {
  233. if (res.status === "success")
  234. featuredPlaylists.value = res.data.playlists;
  235. });
  236. if (props.type === "autofill")
  237. socket.dispatch(
  238. `stations.getStationAutofillPlaylistsById`,
  239. station.value._id,
  240. res => {
  241. if (res.status === "success") {
  242. station.value.autofill.playlists = res.data.playlists;
  243. }
  244. }
  245. );
  246. socket.dispatch(
  247. `stations.getStationBlacklistById`,
  248. station.value._id,
  249. res => {
  250. if (res.status === "success") {
  251. station.value.blacklist = res.data.playlists;
  252. }
  253. }
  254. );
  255. });
  256. });
  257. </script>
  258. <template>
  259. <div class="playlist-tab-base">
  260. <div v-if="$slots.info" class="top-info has-text-centered">
  261. <slot name="info" />
  262. </div>
  263. <div class="tabs-container">
  264. <div class="tab-selection">
  265. <button
  266. class="button is-default"
  267. :ref="el => (tabs['search-tab'] = el)"
  268. :class="{ selected: tab === 'search' }"
  269. @click="showTab('search')"
  270. >
  271. Search
  272. </button>
  273. <button
  274. class="button is-default"
  275. :ref="el => (tabs['current-tab'] = el)"
  276. :class="{ selected: tab === 'current' }"
  277. @click="showTab('current')"
  278. >
  279. Current
  280. </button>
  281. <button
  282. v-if="
  283. type === 'autorequest' || station.type === 'community'
  284. "
  285. class="button is-default"
  286. :ref="el => (tabs['my-playlists-tab'] = el)"
  287. :class="{ selected: tab === 'my-playlists' }"
  288. @click="showTab('my-playlists')"
  289. >
  290. My Playlists
  291. </button>
  292. </div>
  293. <div class="tab" v-show="tab === 'search'">
  294. <div v-if="featuredPlaylists.length > 0">
  295. <label class="label"> Featured playlists </label>
  296. <playlist-item
  297. v-for="featuredPlaylist in featuredPlaylists"
  298. :key="`featuredKey-${featuredPlaylist._id}`"
  299. :playlist="featuredPlaylist"
  300. :show-owner="true"
  301. >
  302. <template #item-icon>
  303. <i
  304. class="material-icons blacklisted-icon"
  305. v-if="
  306. isSelected(
  307. featuredPlaylist._id,
  308. 'blacklist'
  309. )
  310. "
  311. :content="`This playlist is currently ${label(
  312. 'past',
  313. 'blacklist'
  314. )}`"
  315. v-tippy
  316. >
  317. block
  318. </i>
  319. <i
  320. class="material-icons"
  321. v-else-if="isSelected(featuredPlaylist._id)"
  322. :content="`This playlist is currently ${label(
  323. 'past'
  324. )}`"
  325. v-tippy
  326. >
  327. play_arrow
  328. </i>
  329. <i
  330. class="material-icons"
  331. v-else
  332. :content="`This playlist is currently not ${label(
  333. 'past'
  334. )}`"
  335. v-tippy
  336. >
  337. {{
  338. type === "blacklist"
  339. ? "block"
  340. : "play_disabled"
  341. }}
  342. </i>
  343. </template>
  344. <template #actions>
  345. <i
  346. v-if="
  347. type !== 'blacklist' &&
  348. isSelected(
  349. featuredPlaylist._id,
  350. 'blacklist'
  351. )
  352. "
  353. class="material-icons stop-icon"
  354. :content="`This playlist is ${label(
  355. 'past',
  356. 'blacklist'
  357. )} in this station`"
  358. v-tippy="{ theme: 'info' }"
  359. >play_disabled</i
  360. >
  361. <quick-confirm
  362. v-if="
  363. type !== 'blacklist' &&
  364. isSelected(featuredPlaylist._id)
  365. "
  366. @confirm="
  367. deselectPlaylist(featuredPlaylist._id)
  368. "
  369. >
  370. <i
  371. class="material-icons stop-icon"
  372. :content="`Stop ${label(
  373. 'present'
  374. )} songs from this playlist`"
  375. v-tippy
  376. >
  377. stop
  378. </i>
  379. </quick-confirm>
  380. <i
  381. v-if="
  382. type !== 'blacklist' &&
  383. !isSelected(featuredPlaylist._id) &&
  384. !isSelected(
  385. featuredPlaylist._id,
  386. 'blacklist'
  387. )
  388. "
  389. @click="selectPlaylist(featuredPlaylist)"
  390. class="material-icons play-icon"
  391. :content="`${label(
  392. 'future',
  393. null,
  394. true
  395. )} songs from this playlist`"
  396. v-tippy
  397. >play_arrow</i
  398. >
  399. <quick-confirm
  400. v-if="
  401. type === 'blacklist' &&
  402. !isSelected(
  403. featuredPlaylist._id,
  404. 'blacklist'
  405. )
  406. "
  407. @confirm="
  408. selectPlaylist(
  409. featuredPlaylist,
  410. 'blacklist'
  411. )
  412. "
  413. >
  414. <i
  415. class="material-icons stop-icon"
  416. :content="`${label(
  417. 'future',
  418. null,
  419. true
  420. )} Playlist`"
  421. v-tippy
  422. >block</i
  423. >
  424. </quick-confirm>
  425. <quick-confirm
  426. v-if="
  427. type === 'blacklist' &&
  428. isSelected(
  429. featuredPlaylist._id,
  430. 'blacklist'
  431. )
  432. "
  433. @confirm="
  434. deselectPlaylist(featuredPlaylist._id)
  435. "
  436. >
  437. <i
  438. class="material-icons stop-icon"
  439. :content="`Stop ${label(
  440. 'present'
  441. )} songs from this playlist`"
  442. v-tippy
  443. >
  444. stop
  445. </i>
  446. </quick-confirm>
  447. <i
  448. v-if="featuredPlaylist.createdBy === myUserId"
  449. @click="
  450. openModal({
  451. modal: 'editPlaylist',
  452. data: {
  453. playlistId: featuredPlaylist._id
  454. }
  455. })
  456. "
  457. class="material-icons edit-icon"
  458. content="Edit Playlist"
  459. v-tippy
  460. >edit</i
  461. >
  462. <i
  463. v-if="
  464. featuredPlaylist.createdBy !== myUserId &&
  465. (featuredPlaylist.privacy === 'public' ||
  466. hasPermission('playlists.view.others'))
  467. "
  468. @click="
  469. openModal({
  470. modal: 'editPlaylist',
  471. data: {
  472. playlistId: featuredPlaylist._id
  473. }
  474. })
  475. "
  476. class="material-icons edit-icon"
  477. content="View Playlist"
  478. v-tippy
  479. >visibility</i
  480. >
  481. </template>
  482. </playlist-item>
  483. <br />
  484. </div>
  485. <label class="label">Search for a playlist</label>
  486. <div class="control is-grouped input-with-button">
  487. <p class="control is-expanded">
  488. <input
  489. class="input"
  490. type="text"
  491. placeholder="Enter your playlist query here..."
  492. v-model="search.query"
  493. @keyup.enter="searchForPlaylists(1)"
  494. />
  495. </p>
  496. <p class="control">
  497. <a class="button is-info" @click="searchForPlaylists(1)"
  498. ><i class="material-icons icon-with-button"
  499. >search</i
  500. >Search</a
  501. >
  502. </p>
  503. </div>
  504. <div v-if="search.results.length > 0">
  505. <playlist-item
  506. v-for="playlist in search.results"
  507. :key="`searchKey-${playlist._id}`"
  508. :playlist="playlist"
  509. :show-owner="true"
  510. >
  511. <template #item-icon>
  512. <i
  513. class="material-icons blacklisted-icon"
  514. v-if="isSelected(playlist._id, 'blacklist')"
  515. :content="`This playlist is currently ${label(
  516. 'past',
  517. 'blacklist'
  518. )}`"
  519. v-tippy
  520. >
  521. block
  522. </i>
  523. <i
  524. class="material-icons"
  525. v-else-if="isSelected(playlist._id)"
  526. :content="`This playlist is currently ${label(
  527. 'past'
  528. )}`"
  529. v-tippy
  530. >
  531. play_arrow
  532. </i>
  533. <i
  534. class="material-icons"
  535. v-else
  536. :content="`This playlist is currently not ${label(
  537. 'past'
  538. )}`"
  539. v-tippy
  540. >
  541. {{
  542. type === "blacklist"
  543. ? "block"
  544. : "play_disabled"
  545. }}
  546. </i>
  547. </template>
  548. <template #actions>
  549. <i
  550. v-if="
  551. type !== 'blacklist' &&
  552. isSelected(playlist._id, 'blacklist')
  553. "
  554. class="material-icons stop-icon"
  555. :content="`This playlist is ${label(
  556. 'past',
  557. 'blacklist'
  558. )} in this station`"
  559. v-tippy="{ theme: 'info' }"
  560. >play_disabled</i
  561. >
  562. <quick-confirm
  563. v-if="
  564. type !== 'blacklist' &&
  565. isSelected(playlist._id)
  566. "
  567. @confirm="deselectPlaylist(playlist._id)"
  568. >
  569. <i
  570. class="material-icons stop-icon"
  571. :content="`Stop ${label(
  572. 'present'
  573. )} songs from this playlist`"
  574. v-tippy
  575. >
  576. stop
  577. </i>
  578. </quick-confirm>
  579. <i
  580. v-if="
  581. type !== 'blacklist' &&
  582. !isSelected(playlist._id) &&
  583. !isSelected(playlist._id, 'blacklist')
  584. "
  585. @click="selectPlaylist(playlist)"
  586. class="material-icons play-icon"
  587. :content="`${label(
  588. 'future',
  589. null,
  590. true
  591. )} songs from this playlist`"
  592. v-tippy
  593. >play_arrow</i
  594. >
  595. <quick-confirm
  596. v-if="
  597. type === 'blacklist' &&
  598. !isSelected(playlist._id, 'blacklist')
  599. "
  600. @confirm="selectPlaylist(playlist, 'blacklist')"
  601. >
  602. <i
  603. class="material-icons stop-icon"
  604. :content="`${label(
  605. 'future',
  606. null,
  607. true
  608. )} Playlist`"
  609. v-tippy
  610. >block</i
  611. >
  612. </quick-confirm>
  613. <quick-confirm
  614. v-if="
  615. type === 'blacklist' &&
  616. isSelected(playlist._id, 'blacklist')
  617. "
  618. @confirm="deselectPlaylist(playlist._id)"
  619. >
  620. <i
  621. class="material-icons stop-icon"
  622. :content="`Stop ${label(
  623. 'present'
  624. )} songs from this playlist`"
  625. v-tippy
  626. >
  627. stop
  628. </i>
  629. </quick-confirm>
  630. <i
  631. v-if="playlist.createdBy === myUserId"
  632. @click="
  633. openModal({
  634. modal: 'editPlaylist',
  635. data: { playlistId: playlist._id }
  636. })
  637. "
  638. class="material-icons edit-icon"
  639. content="Edit Playlist"
  640. v-tippy
  641. >edit</i
  642. >
  643. <i
  644. v-if="
  645. playlist.createdBy !== myUserId &&
  646. (playlist.privacy === 'public' ||
  647. hasPermission('playlists.view.others'))
  648. "
  649. @click="
  650. openModal({
  651. modal: 'editPlaylist',
  652. data: { playlistId: playlist._id }
  653. })
  654. "
  655. class="material-icons edit-icon"
  656. content="View Playlist"
  657. v-tippy
  658. >visibility</i
  659. >
  660. </template>
  661. </playlist-item>
  662. <button
  663. v-if="resultsLeftCount > 0"
  664. class="button is-primary load-more-button"
  665. @click="searchForPlaylists(search.page + 1)"
  666. >
  667. Load {{ nextPageResultsCount }} more results
  668. </button>
  669. </div>
  670. </div>
  671. <div class="tab" v-show="tab === 'current'">
  672. <div v-if="selectedPlaylists().length > 0">
  673. <playlist-item
  674. v-for="playlist in selectedPlaylists()"
  675. :key="`key-${playlist._id}`"
  676. :playlist="playlist"
  677. :show-owner="true"
  678. >
  679. <template #item-icon>
  680. <i
  681. class="material-icons"
  682. :class="{
  683. 'blacklisted-icon': type === 'blacklist'
  684. }"
  685. :content="`This playlist is currently ${label(
  686. 'past'
  687. )}`"
  688. v-tippy
  689. >
  690. {{
  691. type === "blacklist"
  692. ? "block"
  693. : "play_arrow"
  694. }}
  695. </i>
  696. </template>
  697. <template #actions>
  698. <quick-confirm
  699. @confirm="deselectPlaylist(playlist._id)"
  700. >
  701. <i
  702. class="material-icons stop-icon"
  703. :content="`Stop ${label(
  704. 'present'
  705. )} songs from this playlist`"
  706. v-tippy
  707. >
  708. stop
  709. </i>
  710. </quick-confirm>
  711. <i
  712. v-if="playlist.createdBy === myUserId"
  713. @click="
  714. openModal({
  715. modal: 'editPlaylist',
  716. data: { playlistId: playlist._id }
  717. })
  718. "
  719. class="material-icons edit-icon"
  720. content="Edit Playlist"
  721. v-tippy
  722. >edit</i
  723. >
  724. <i
  725. v-if="
  726. playlist.createdBy !== myUserId &&
  727. (playlist.privacy === 'public' ||
  728. hasPermission('playlists.view.others'))
  729. "
  730. @click="
  731. openModal({
  732. modal: 'editPlaylist',
  733. data: { playlistId: playlist._id }
  734. })
  735. "
  736. class="material-icons edit-icon"
  737. content="View Playlist"
  738. v-tippy
  739. >visibility</i
  740. >
  741. </template>
  742. </playlist-item>
  743. </div>
  744. <p v-else class="has-text-centered scrollable-list">
  745. No playlists currently {{ label("present") }}.
  746. </p>
  747. </div>
  748. <div
  749. v-if="type === 'autorequest' || station.type === 'community'"
  750. class="tab"
  751. v-show="tab === 'my-playlists'"
  752. >
  753. <button
  754. class="button is-primary"
  755. id="create-new-playlist-button"
  756. @click="openModal('createPlaylist')"
  757. >
  758. Create new playlist
  759. </button>
  760. <div
  761. class="menu-list scrollable-list"
  762. v-if="playlists.length > 0"
  763. >
  764. <draggable-list
  765. v-model:list="playlists"
  766. item-key="_id"
  767. @start="drag = true"
  768. @end="drag = false"
  769. @update="savePlaylistOrder"
  770. >
  771. <template #item="{ element }">
  772. <playlist-item :playlist="element">
  773. <template #item-icon>
  774. <i
  775. class="material-icons blacklisted-icon"
  776. v-if="
  777. isSelected(element._id, 'blacklist')
  778. "
  779. :content="`This playlist is currently ${label(
  780. 'past',
  781. 'blacklist'
  782. )}`"
  783. v-tippy
  784. >
  785. block
  786. </i>
  787. <i
  788. class="material-icons"
  789. v-else-if="isSelected(element._id)"
  790. :content="`This playlist is currently ${label(
  791. 'past'
  792. )}`"
  793. v-tippy
  794. >
  795. play_arrow
  796. </i>
  797. <i
  798. class="material-icons"
  799. v-else
  800. :content="`This playlist is currently not ${label(
  801. 'past'
  802. )}`"
  803. v-tippy
  804. >
  805. {{
  806. type === "blacklist"
  807. ? "block"
  808. : "play_disabled"
  809. }}
  810. </i>
  811. </template>
  812. <template #actions>
  813. <i
  814. v-if="
  815. type !== 'blacklist' &&
  816. isSelected(element._id, 'blacklist')
  817. "
  818. class="material-icons stop-icon"
  819. :content="`This playlist is ${label(
  820. 'past',
  821. 'blacklist'
  822. )} in this station`"
  823. v-tippy="{ theme: 'info' }"
  824. >play_disabled</i
  825. >
  826. <quick-confirm
  827. v-if="
  828. type !== 'blacklist' &&
  829. isSelected(element._id)
  830. "
  831. @confirm="deselectPlaylist(element._id)"
  832. >
  833. <i
  834. class="material-icons stop-icon"
  835. :content="`Stop ${label(
  836. 'present'
  837. )} songs from this playlist`"
  838. v-tippy
  839. >
  840. stop
  841. </i>
  842. </quick-confirm>
  843. <i
  844. v-if="
  845. type !== 'blacklist' &&
  846. !isSelected(element._id) &&
  847. !isSelected(
  848. element._id,
  849. 'blacklist'
  850. )
  851. "
  852. @click="selectPlaylist(element)"
  853. class="material-icons play-icon"
  854. :content="`${label(
  855. 'future',
  856. null,
  857. true
  858. )} songs from this playlist`"
  859. v-tippy
  860. >play_arrow</i
  861. >
  862. <quick-confirm
  863. v-if="
  864. type === 'blacklist' &&
  865. !isSelected(
  866. element._id,
  867. 'blacklist'
  868. )
  869. "
  870. @confirm="
  871. selectPlaylist(element, 'blacklist')
  872. "
  873. >
  874. <i
  875. class="material-icons stop-icon"
  876. :content="`${label(
  877. 'future',
  878. null,
  879. true
  880. )} Playlist`"
  881. v-tippy
  882. >block</i
  883. >
  884. </quick-confirm>
  885. <quick-confirm
  886. v-if="
  887. type === 'blacklist' &&
  888. isSelected(element._id, 'blacklist')
  889. "
  890. @confirm="deselectPlaylist(element._id)"
  891. >
  892. <i
  893. class="material-icons stop-icon"
  894. :content="`Stop ${label(
  895. 'present'
  896. )} songs from this playlist`"
  897. v-tippy
  898. >
  899. stop
  900. </i>
  901. </quick-confirm>
  902. <i
  903. @click="
  904. openModal({
  905. modal: 'editPlaylist',
  906. data: {
  907. playlistId: element._id
  908. }
  909. })
  910. "
  911. class="material-icons edit-icon"
  912. content="Edit Playlist"
  913. v-tippy
  914. >edit</i
  915. >
  916. </template>
  917. </playlist-item>
  918. </template>
  919. </draggable-list>
  920. </div>
  921. <p v-else class="has-text-centered scrollable-list">
  922. You don't have any playlists!
  923. </p>
  924. </div>
  925. </div>
  926. </div>
  927. </template>
  928. <style lang="less" scoped>
  929. .night-mode {
  930. .tabs-container .tab-selection .button {
  931. background: var(--dark-grey) !important;
  932. color: var(--white) !important;
  933. }
  934. }
  935. .blacklisted-icon {
  936. color: var(--dark-red);
  937. }
  938. .playlist-tab-base {
  939. .top-info {
  940. font-size: 15px;
  941. margin-bottom: 15px;
  942. }
  943. .tabs-container {
  944. .tab-selection {
  945. display: flex;
  946. overflow-x: auto;
  947. .button {
  948. border-radius: 0;
  949. border: 0;
  950. text-transform: uppercase;
  951. font-size: 14px;
  952. color: var(--dark-grey-3);
  953. background-color: var(--light-grey-2);
  954. flex-grow: 1;
  955. height: 32px;
  956. &:not(:first-of-type) {
  957. margin-left: 5px;
  958. }
  959. }
  960. .selected {
  961. background-color: var(--primary-color) !important;
  962. color: var(--white) !important;
  963. font-weight: 600;
  964. }
  965. }
  966. .tab {
  967. padding: 15px 0;
  968. border-radius: 0;
  969. .playlist-item:not(:last-of-type) {
  970. margin-bottom: 10px;
  971. }
  972. .load-more-button {
  973. width: 100%;
  974. margin-top: 10px;
  975. }
  976. }
  977. }
  978. }
  979. .draggable-list-transition-move {
  980. transition: transform 0.5s;
  981. }
  982. .draggable-list-ghost {
  983. opacity: 0.5;
  984. filter: brightness(95%);
  985. }
  986. </style>