2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
ref="wrapper"
|
2022-10-18 14:07:41 +00:00
|
|
|
class="song-list-wrap"
|
2022-05-09 14:27:17 +00:00
|
|
|
data-testid="song-list"
|
2022-04-15 14:24:30 +00:00
|
|
|
tabindex="0"
|
|
|
|
@keydown.delete.prevent.stop="handleDelete"
|
|
|
|
@keydown.enter.prevent.stop="handleEnter"
|
|
|
|
@keydown.a.prevent="handleA"
|
|
|
|
>
|
2022-06-10 10:47:46 +00:00
|
|
|
<div :class="config.sortable ? 'sortable' : 'unsortable'" class="song-list-header">
|
2022-05-09 14:27:17 +00:00
|
|
|
<span
|
|
|
|
class="track-number"
|
|
|
|
data-testid="header-track-number"
|
2022-07-21 07:54:36 +00:00
|
|
|
role="button"
|
|
|
|
title="Sort by track number"
|
2022-06-10 10:47:46 +00:00
|
|
|
@click="sort('track')"
|
2022-05-09 14:27:17 +00:00
|
|
|
>
|
2022-04-24 18:44:48 +00:00
|
|
|
#
|
2022-11-17 16:30:38 +00:00
|
|
|
<template v-if="config.sortable">
|
2023-11-10 13:16:06 +00:00
|
|
|
<Icon v-if="sortField === 'track' && sortOrder === 'asc'" :icon="faCaretDown" class="text-highlight" />
|
|
|
|
<Icon v-if="sortField === 'track' && sortOrder === 'desc'" :icon="faCaretUp" class="text-highlight" />
|
2022-11-17 16:30:38 +00:00
|
|
|
</template>
|
2022-04-24 18:44:48 +00:00
|
|
|
</span>
|
2022-05-09 14:27:17 +00:00
|
|
|
<span
|
2022-11-12 21:38:31 +00:00
|
|
|
class="title-artist"
|
2022-05-09 14:27:17 +00:00
|
|
|
data-testid="header-title"
|
2022-07-21 07:54:36 +00:00
|
|
|
role="button"
|
|
|
|
title="Sort by title"
|
2022-06-10 10:47:46 +00:00
|
|
|
@click="sort('title')"
|
2022-05-09 14:27:17 +00:00
|
|
|
>
|
2022-04-24 18:44:48 +00:00
|
|
|
Title
|
2022-11-17 16:30:38 +00:00
|
|
|
<template v-if="config.sortable">
|
2023-11-10 13:16:06 +00:00
|
|
|
<Icon v-if="sortField === 'title' && sortOrder === 'asc'" :icon="faCaretDown" class="text-highlight" />
|
|
|
|
<Icon v-if="sortField === 'title' && sortOrder === 'desc'" :icon="faCaretUp" class="text-highlight" />
|
2022-11-17 16:30:38 +00:00
|
|
|
</template>
|
2022-04-24 18:44:48 +00:00
|
|
|
</span>
|
2022-04-15 17:00:08 +00:00
|
|
|
<span
|
2022-05-09 14:27:17 +00:00
|
|
|
class="album"
|
|
|
|
data-testid="header-album"
|
2022-07-21 07:54:36 +00:00
|
|
|
role="button"
|
|
|
|
title="Sort by album"
|
2022-06-10 10:47:46 +00:00
|
|
|
@click="sort('album_name')"
|
2022-04-15 17:00:08 +00:00
|
|
|
>
|
2022-04-24 18:44:48 +00:00
|
|
|
Album
|
2022-11-17 16:30:38 +00:00
|
|
|
<template v-if="config.sortable">
|
2023-11-10 13:16:06 +00:00
|
|
|
<Icon v-if="sortField === 'album_name' && sortOrder === 'asc'" :icon="faCaretDown" class="text-highlight" />
|
|
|
|
<Icon v-if="sortField === 'album_name' && sortOrder === 'desc'" :icon="faCaretUp" class="text-highlight" />
|
2022-11-17 16:30:38 +00:00
|
|
|
</template>
|
2022-04-24 18:44:48 +00:00
|
|
|
</span>
|
2024-01-18 11:13:05 +00:00
|
|
|
<template v-if="config.collaborative">
|
|
|
|
<span class="collaborator">User</span>
|
|
|
|
<span class="added-at">Added</span>
|
|
|
|
</template>
|
2022-05-09 14:27:17 +00:00
|
|
|
<span
|
|
|
|
class="time"
|
|
|
|
data-testid="header-length"
|
2022-07-21 07:54:36 +00:00
|
|
|
role="button"
|
|
|
|
title="Sort by song duration"
|
2022-06-10 10:47:46 +00:00
|
|
|
@click="sort('length')"
|
2022-05-09 14:27:17 +00:00
|
|
|
>
|
2022-10-25 18:25:58 +00:00
|
|
|
Time
|
2022-11-17 16:30:38 +00:00
|
|
|
<template v-if="config.sortable">
|
2023-11-10 13:16:06 +00:00
|
|
|
<Icon v-if="sortField === 'length' && sortOrder === 'asc'" :icon="faCaretDown" class="text-highlight" />
|
|
|
|
<Icon v-if="sortField === 'length' && sortOrder === 'desc'" :icon="faCaretUp" class="text-highlight" />
|
2022-11-17 16:30:38 +00:00
|
|
|
</template>
|
2022-04-24 18:44:48 +00:00
|
|
|
</span>
|
2022-11-12 21:38:31 +00:00
|
|
|
<span class="extra">
|
2022-12-02 16:17:37 +00:00
|
|
|
<SongListSorter v-if="config.sortable" :field="sortField" :order="sortOrder" @sort="sort" />
|
2022-11-12 21:38:31 +00:00
|
|
|
</span>
|
2022-04-15 17:00:08 +00:00
|
|
|
</div>
|
|
|
|
|
2022-07-16 09:52:39 +00:00
|
|
|
<VirtualScroller
|
|
|
|
v-slot="{ item }"
|
2022-10-26 12:34:32 +00:00
|
|
|
:item-height="64"
|
2022-12-17 12:09:22 +00:00
|
|
|
:items="filteredSongRows"
|
2022-07-16 09:52:39 +00:00
|
|
|
@scroll="onScroll"
|
|
|
|
@scrolled-to-end="$emit('scrolled-to-end')"
|
|
|
|
>
|
2022-04-29 08:40:34 +00:00
|
|
|
<SongListItem
|
|
|
|
:key="item.song.id"
|
|
|
|
:item="item"
|
|
|
|
draggable="true"
|
2024-01-18 11:13:05 +00:00
|
|
|
@click="onClick(item, $event)"
|
2022-10-10 07:00:02 +00:00
|
|
|
@dragleave="onDragLeave"
|
|
|
|
@dragstart="onDragStart(item, $event)"
|
|
|
|
@dragenter.prevent="onDragEnter"
|
2022-04-29 08:40:34 +00:00
|
|
|
@dragover.prevent
|
2022-10-10 07:00:02 +00:00
|
|
|
@drop.prevent="onDrop(item, $event)"
|
2022-11-17 16:30:38 +00:00
|
|
|
@dragend.prevent="onDragEnd"
|
2022-04-30 11:55:54 +00:00
|
|
|
@contextmenu.prevent="openContextMenu(item, $event)"
|
2022-04-29 08:40:34 +00:00
|
|
|
/>
|
2022-04-27 20:52:37 +00:00
|
|
|
</VirtualScroller>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-07-21 07:54:36 +00:00
|
|
|
import { findIndex } from 'lodash'
|
|
|
|
import isMobile from 'ismobilejs'
|
2022-10-25 18:25:58 +00:00
|
|
|
import { faCaretDown, faCaretUp } from '@fortawesome/free-solid-svg-icons'
|
2022-12-17 12:09:22 +00:00
|
|
|
import { computed, nextTick, onMounted, Ref, ref, watch } from 'vue'
|
2022-09-03 08:32:09 +00:00
|
|
|
import { eventBus, requireInjection } from '@/utils'
|
2022-10-10 07:00:02 +00:00
|
|
|
import { useDraggable, useDroppable } from '@/composables'
|
2022-12-29 21:05:58 +00:00
|
|
|
import {
|
|
|
|
SelectedSongsKey,
|
|
|
|
SongListConfigKey,
|
|
|
|
SongListFilterKeywordsKey,
|
|
|
|
SongListSortFieldKey,
|
|
|
|
SongListSortOrderKey,
|
|
|
|
SongsKey
|
|
|
|
} from '@/symbols'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-07 18:05:46 +00:00
|
|
|
import VirtualScroller from '@/components/ui/VirtualScroller.vue'
|
|
|
|
import SongListItem from '@/components/song/SongListItem.vue'
|
2022-11-12 21:38:31 +00:00
|
|
|
import SongListSorter from '@/components/song/SongListSorter.vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-09-03 08:32:09 +00:00
|
|
|
const { startDragging } = useDraggable('songs')
|
2022-10-10 07:00:02 +00:00
|
|
|
const { getDroppedData, acceptsDrop } = useDroppable(['songs'])
|
2022-09-03 08:32:09 +00:00
|
|
|
|
2022-11-13 15:18:24 +00:00
|
|
|
const emit = defineEmits<{
|
|
|
|
(e: 'press:enter', event: KeyboardEvent): void,
|
|
|
|
(e: 'press:delete'): void,
|
|
|
|
(e: 'reorder', song: Song): void,
|
|
|
|
(e: 'sort', field: SongListSortField, order: SortOrder): void,
|
|
|
|
(e: 'scroll-breakpoint', direction: 'up' | 'down'): void,
|
|
|
|
(e: 'scrolled-to-end'): void,
|
|
|
|
}>()
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-10-10 07:00:02 +00:00
|
|
|
const [items] = requireInjection<[Ref<Song[]>]>(SongsKey)
|
|
|
|
const [selectedSongs, setSelectedSongs] = requireInjection<[Ref<Song[]>, Closure]>(SelectedSongsKey)
|
|
|
|
const [sortField, setSortField] = requireInjection<[Ref<SongListSortField>, Closure]>(SongListSortFieldKey)
|
|
|
|
const [sortOrder, setSortOrder] = requireInjection<[Ref<SortOrder>, Closure]>(SongListSortOrderKey)
|
2022-11-12 21:38:31 +00:00
|
|
|
const [config] = requireInjection<[Partial<SongListConfig>]>(SongListConfigKey, [{}])
|
|
|
|
|
2022-12-17 12:09:22 +00:00
|
|
|
const filterKeywords = requireInjection(SongListFilterKeywordsKey, ref(''))
|
|
|
|
|
2022-11-17 16:30:38 +00:00
|
|
|
const wrapper = ref<HTMLElement>()
|
2022-04-15 17:00:08 +00:00
|
|
|
const lastSelectedRow = ref<SongRow>()
|
2022-05-09 14:27:17 +00:00
|
|
|
const sortFields = ref<SongListSortField[]>([])
|
2022-04-29 08:40:34 +00:00
|
|
|
const songRows = ref<SongRow[]>([])
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-01-24 22:39:47 +00:00
|
|
|
watch(
|
|
|
|
songRows,
|
|
|
|
() => setSelectedSongs(songRows.value.filter(({ selected }) => selected).map(({ song }) => song)),
|
|
|
|
{ deep: true }
|
|
|
|
)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-01-18 11:13:05 +00:00
|
|
|
const filteredSongRows = computed<SongRow[]>(() => {
|
2022-12-17 12:09:22 +00:00
|
|
|
const keywords = filterKeywords.value.trim().toLowerCase()
|
|
|
|
|
|
|
|
if (!keywords) {
|
|
|
|
return songRows.value
|
|
|
|
}
|
|
|
|
|
2024-01-24 22:39:47 +00:00
|
|
|
return songRows.value.filter(({ song }) => {
|
2022-12-17 12:09:22 +00:00
|
|
|
return (
|
|
|
|
song.title.toLowerCase().includes(keywords) ||
|
|
|
|
song.artist_name.toLowerCase().includes(keywords) ||
|
|
|
|
song.album_artist_name.toLowerCase().includes(keywords) ||
|
|
|
|
song.album_name.toLowerCase().includes(keywords)
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-07-16 09:52:39 +00:00
|
|
|
let lastScrollTop = 0
|
|
|
|
|
2022-12-07 00:44:42 +00:00
|
|
|
const onScroll = (e: Event) => {
|
2022-07-16 09:52:39 +00:00
|
|
|
const scroller = e.target as HTMLElement
|
|
|
|
|
|
|
|
if (scroller.scrollTop > 512 && lastScrollTop < 512) {
|
|
|
|
emit('scroll-breakpoint', 'down')
|
|
|
|
} else if (scroller.scrollTop < 512 && lastScrollTop > 512) {
|
|
|
|
emit('scroll-breakpoint', 'up')
|
|
|
|
}
|
|
|
|
|
|
|
|
lastScrollTop = scroller.scrollTop
|
|
|
|
}
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
/**
|
|
|
|
* Since song objects themselves are shared by all song lists, we can't use them directly to
|
|
|
|
* determine their selection status (selected/unselected). Therefore, for each song list, we
|
2022-04-29 08:40:34 +00:00
|
|
|
* maintain an array of "song rows," each containing the song itself and the "selected" flag.
|
2022-04-15 17:00:08 +00:00
|
|
|
*/
|
2022-04-29 08:40:34 +00:00
|
|
|
const generateSongRows = () => {
|
2022-04-15 17:00:08 +00:00
|
|
|
// Since this method re-generates the song wrappers, we need to keep track of the
|
|
|
|
// selected songs manually.
|
|
|
|
const selectedSongIds = selectedSongs.value.map(song => song.id)
|
|
|
|
|
2022-11-12 21:38:31 +00:00
|
|
|
return items.value.map<SongRow>(song => ({
|
2022-04-15 17:00:08 +00:00
|
|
|
song,
|
|
|
|
selected: selectedSongIds.includes(song.id)
|
|
|
|
}))
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const sort = (field: SongListSortField) => {
|
2022-04-15 17:00:08 +00:00
|
|
|
// there are certain circumstances where sorting is simply disallowed, e.g. in Queue
|
2022-11-12 21:38:31 +00:00
|
|
|
if (!config.sortable) {
|
2022-04-15 17:00:08 +00:00
|
|
|
return
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-20 08:00:02 +00:00
|
|
|
setSortField(field)
|
|
|
|
setSortOrder(sortOrder.value === 'asc' ? 'desc' : 'asc')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
emit('sort', field, sortOrder.value)
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const render = () => {
|
2022-11-12 21:38:31 +00:00
|
|
|
config.sortable || (sortFields.value = [])
|
2022-06-10 10:47:46 +00:00
|
|
|
songRows.value = generateSongRows()
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-28 16:04:52 +00:00
|
|
|
watch(items, () => render(), { deep: true })
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-21 18:12:11 +00:00
|
|
|
const handleDelete = () => {
|
|
|
|
emit('press:delete')
|
2022-04-15 17:00:08 +00:00
|
|
|
clearSelection()
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-21 18:12:11 +00:00
|
|
|
const handleEnter = (event: KeyboardEvent) => {
|
|
|
|
emit('press:enter', event)
|
|
|
|
clearSelection()
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
/**
|
|
|
|
* Select all (filtered) rows in the current list.
|
|
|
|
*/
|
2022-04-29 08:40:34 +00:00
|
|
|
const selectAllRows = () => songRows.value.forEach(row => (row.selected = true))
|
|
|
|
const clearSelection = () => songRows.value.forEach(row => (row.selected = false))
|
2022-04-15 17:00:08 +00:00
|
|
|
const handleA = (event: KeyboardEvent) => (event.ctrlKey || event.metaKey) && selectAllRows()
|
2022-04-29 08:40:34 +00:00
|
|
|
const getAllSongsWithSort = () => songRows.value.map(row => row.song)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-01-18 11:13:05 +00:00
|
|
|
const onClick = (row: SongRow, event: MouseEvent) => {
|
2022-04-15 17:00:08 +00:00
|
|
|
// If we're on a touch device, or if Ctrl/Cmd key is pressed, just toggle selection.
|
|
|
|
if (isMobile.any) {
|
2022-04-29 08:40:34 +00:00
|
|
|
toggleRow(row)
|
2022-04-15 17:00:08 +00:00
|
|
|
return
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
if (event.ctrlKey || event.metaKey) {
|
2022-04-29 08:40:34 +00:00
|
|
|
toggleRow(row)
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
if (event.button === 0) {
|
|
|
|
if (!(event.ctrlKey || event.metaKey || event.shiftKey)) {
|
|
|
|
clearSelection()
|
2022-04-29 08:40:34 +00:00
|
|
|
toggleRow(row)
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
if (event.shiftKey && lastSelectedRow.value) {
|
2022-04-29 08:40:34 +00:00
|
|
|
selectRowsBetween(lastSelectedRow.value, row)
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-29 08:40:34 +00:00
|
|
|
const toggleRow = (row: SongRow) => {
|
|
|
|
row.selected = !row.selected
|
|
|
|
lastSelectedRow.value = row
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-29 08:40:34 +00:00
|
|
|
const selectRowsBetween = (first: SongRow, second: SongRow) => {
|
2022-04-29 09:52:55 +00:00
|
|
|
const firstIndex = Math.max(0, findIndex(songRows.value, row => row.song.id === first.song.id))
|
|
|
|
const secondIndex = Math.max(0, findIndex(songRows.value, row => row.song.id === second.song.id))
|
|
|
|
const indexes = [firstIndex, secondIndex]
|
2022-04-15 17:00:08 +00:00
|
|
|
indexes.sort((a, b) => a - b)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
for (let i = indexes[0]; i <= indexes[1]; ++i) {
|
2022-04-29 08:40:34 +00:00
|
|
|
songRows.value[i].selected = true
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-01-18 11:13:05 +00:00
|
|
|
const onDragStart = async (row: SongRow, event: DragEvent) => {
|
2022-04-15 17:00:08 +00:00
|
|
|
// If the user is dragging an unselected row, clear the current selection.
|
2022-04-29 08:40:34 +00:00
|
|
|
if (!row.selected) {
|
2022-04-15 17:00:08 +00:00
|
|
|
clearSelection()
|
2022-04-29 08:40:34 +00:00
|
|
|
row.selected = true
|
2024-01-18 11:13:05 +00:00
|
|
|
await nextTick()
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-11-17 16:30:38 +00:00
|
|
|
// Add "dragging" class to the wrapper so that we can disable pointer events on child elements.
|
|
|
|
// This prevents dragleave events from firing when the user drags the mouse over the child elements.
|
2022-12-02 16:17:37 +00:00
|
|
|
wrapper.value?.classList.add('dragging')
|
2022-11-17 16:30:38 +00:00
|
|
|
|
2022-09-03 08:32:09 +00:00
|
|
|
startDragging(event, selectedSongs.value)
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-10-10 07:00:02 +00:00
|
|
|
const onDragEnter = (event: DragEvent) => {
|
2022-11-12 21:38:31 +00:00
|
|
|
if (!config.reorderable) return
|
2022-07-29 12:12:55 +00:00
|
|
|
|
2022-10-10 07:00:02 +00:00
|
|
|
if (acceptsDrop(event)) {
|
2022-11-17 16:30:38 +00:00
|
|
|
(event.target as HTMLElement).closest('.song-item')?.classList.add('droppable')
|
2022-10-10 07:00:02 +00:00
|
|
|
}
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-10-10 07:00:02 +00:00
|
|
|
const onDrop = (item: SongRow, event: DragEvent) => {
|
2022-11-12 21:38:31 +00:00
|
|
|
if (!config.reorderable || !getDroppedData(event) || !selectedSongs.value.length) {
|
2022-12-02 16:17:37 +00:00
|
|
|
wrapper.value?.classList.remove('dragging')
|
2022-10-10 07:00:02 +00:00
|
|
|
return onDragLeave(event)
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
wrapper.value?.classList.remove('dragging')
|
2022-11-17 16:30:38 +00:00
|
|
|
|
2022-04-29 08:40:34 +00:00
|
|
|
emit('reorder', item.song)
|
2022-10-10 07:00:02 +00:00
|
|
|
return onDragLeave(event)
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
|
|
|
|
2022-10-10 07:00:02 +00:00
|
|
|
const onDragLeave = (event: DragEvent) => {
|
2022-11-17 16:30:38 +00:00
|
|
|
(event.target as HTMLElement).closest('.song-item')?.classList.remove('droppable')
|
2022-04-15 17:00:08 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
const onDragEnd = () => wrapper.value?.classList.remove('dragging')
|
2022-11-17 16:30:38 +00:00
|
|
|
|
2022-04-29 08:40:34 +00:00
|
|
|
const openContextMenu = async (row: SongRow, event: MouseEvent) => {
|
|
|
|
if (!row.selected) {
|
2022-04-15 17:00:08 +00:00
|
|
|
clearSelection()
|
2022-04-29 08:40:34 +00:00
|
|
|
toggleRow(row)
|
2022-10-25 18:01:44 +00:00
|
|
|
|
|
|
|
// awaiting a next tick so that the selected songs are collected properly
|
|
|
|
await nextTick()
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
eventBus.emit('SONG_CONTEXT_MENU_REQUESTED', event, selectedSongs.value)
|
|
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
2022-10-10 07:00:02 +00:00
|
|
|
getAllSongsWithSort
|
2022-04-15 14:24:30 +00:00
|
|
|
})
|
2022-04-28 14:46:38 +00:00
|
|
|
|
|
|
|
onMounted(() => render())
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.song-list-wrap {
|
|
|
|
position: relative;
|
2022-04-27 20:52:37 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2022-11-27 17:39:50 +00:00
|
|
|
overflow: auto;
|
2022-12-17 12:09:22 +00:00
|
|
|
flex: 1;
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-10-13 15:18:47 +00:00
|
|
|
@media screen and (max-width: 768px) {
|
|
|
|
padding: 0 12px;
|
|
|
|
}
|
|
|
|
|
2022-04-15 14:24:30 +00:00
|
|
|
.song-list-header {
|
|
|
|
background: var(--color-bg-secondary);
|
2022-04-15 17:00:08 +00:00
|
|
|
display: flex;
|
2022-11-12 21:38:31 +00:00
|
|
|
z-index: 2; // fix stack-context related issue when e.g., footer would cover the sort context menu
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
2022-11-17 16:30:38 +00:00
|
|
|
&.dragging .song-item * {
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.droppable {
|
|
|
|
position: relative;
|
|
|
|
box-shadow: 0 3px 0 var(--color-green);
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
2022-08-01 08:58:25 +00:00
|
|
|
.song-list-header > span, .song-item > span {
|
2022-04-15 14:24:30 +00:00
|
|
|
text-align: left;
|
|
|
|
padding: 8px;
|
|
|
|
vertical-align: middle;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
|
|
&.time {
|
2022-10-26 12:34:32 +00:00
|
|
|
flex-basis: 64px;
|
|
|
|
overflow: visible;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&.track-number {
|
2022-04-15 17:00:08 +00:00
|
|
|
flex-basis: 66px;
|
2022-04-15 14:24:30 +00:00
|
|
|
padding-left: 24px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.album {
|
2022-04-15 17:00:08 +00:00
|
|
|
flex-basis: 27%;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
2024-01-18 11:13:05 +00:00
|
|
|
&.collaborator {
|
|
|
|
flex-basis: 72px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&.added-at {
|
|
|
|
flex-basis: 144px;
|
|
|
|
text-align: left;
|
|
|
|
}
|
|
|
|
|
2022-11-12 21:38:31 +00:00
|
|
|
&.extra {
|
2022-04-15 17:00:08 +00:00
|
|
|
flex-basis: 36px;
|
2024-01-18 11:13:05 +00:00
|
|
|
text-align: center;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&.play {
|
|
|
|
display: none;
|
|
|
|
|
|
|
|
@media (hover: none) {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
}
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-11-12 21:38:31 +00:00
|
|
|
&.title-artist {
|
2022-04-15 17:00:08 +00:00
|
|
|
flex: 1;
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
.song-list-header {
|
2022-04-15 14:24:30 +00:00
|
|
|
color: var(--color-text-secondary);
|
|
|
|
letter-spacing: 1px;
|
|
|
|
text-transform: uppercase;
|
|
|
|
cursor: pointer;
|
|
|
|
|
2022-11-12 21:38:31 +00:00
|
|
|
.extra {
|
|
|
|
padding-left: 0;
|
|
|
|
padding-right: 0;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
.unsortable span {
|
2022-04-15 14:24:30 +00:00
|
|
|
cursor: default;
|
|
|
|
}
|
|
|
|
|
|
|
|
.scroller {
|
|
|
|
overflow: auto;
|
|
|
|
position: absolute;
|
|
|
|
top: 35px;
|
|
|
|
left: 0;
|
|
|
|
bottom: 0;
|
|
|
|
right: 0;
|
|
|
|
overflow-y: scroll;
|
|
|
|
-webkit-overflow-scrolling: touch;
|
|
|
|
|
|
|
|
.item-container {
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
2022-07-16 09:52:39 +00:00
|
|
|
min-height: 200%;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.item {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media only screen and (max-width: 768px) {
|
|
|
|
.scroller {
|
|
|
|
top: 0;
|
|
|
|
|
|
|
|
.item-container {
|
|
|
|
left: 12px;
|
|
|
|
right: 12px;
|
2022-07-16 09:52:39 +00:00
|
|
|
width: calc(200vw - 24px);
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
.song-item {
|
2022-07-29 12:12:55 +00:00
|
|
|
padding: 8px 12px;
|
2022-04-15 14:24:30 +00:00
|
|
|
position: relative;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
2022-07-16 09:52:39 +00:00
|
|
|
width: 200%;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
2024-01-18 11:13:05 +00:00
|
|
|
.song-item :is(.track-number, .album, .time, .added-at),
|
|
|
|
.song-list-header :is(.track-number, .album, .time, .added-at) {
|
2022-04-15 14:24:30 +00:00
|
|
|
display: none;
|
2022-11-12 21:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.song-item span {
|
2022-04-15 14:24:30 +00:00
|
|
|
padding: 0;
|
|
|
|
vertical-align: bottom;
|
|
|
|
|
2022-10-26 12:34:32 +00:00
|
|
|
&.thumbnail {
|
|
|
|
display: block;
|
|
|
|
padding-right: 12px;
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
}
|
2022-12-17 12:09:22 +00:00
|
|
|
|
|
|
|
.virtual-scroller {
|
|
|
|
flex: 1;
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
</style>
|