Update misc on detail pages
This commit is contained in:
parent
01371d0227
commit
4d0620c5df
3 changed files with 37 additions and 9 deletions
|
@ -8,7 +8,7 @@ import {
|
||||||
useFixedTableHeader,
|
useFixedTableHeader,
|
||||||
VirtualTable,
|
VirtualTable,
|
||||||
} from '/@/renderer/components';
|
} from '/@/renderer/components';
|
||||||
import { CellContextMenuEvent, ColDef } from '@ag-grid-community/core';
|
import { CellContextMenuEvent, ColDef, RowDoubleClickedEvent } from '@ag-grid-community/core';
|
||||||
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
|
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
|
||||||
import { Box, Group, Stack } from '@mantine/core';
|
import { Box, Group, Stack } from '@mantine/core';
|
||||||
import { useSetState } from '@mantine/hooks';
|
import { useSetState } from '@mantine/hooks';
|
||||||
|
@ -26,7 +26,7 @@ import { Play } from '/@/renderer/types';
|
||||||
import { SONG_CONTEXT_MENU_ITEMS } from '/@/renderer/features/context-menu/context-menu-items';
|
import { SONG_CONTEXT_MENU_ITEMS } from '/@/renderer/features/context-menu/context-menu-items';
|
||||||
import { PlayButton, PLAY_TYPES } from '/@/renderer/features/shared';
|
import { PlayButton, PLAY_TYPES } from '/@/renderer/features/shared';
|
||||||
import { useAlbumList } from '/@/renderer/features/albums/queries/album-list-query';
|
import { useAlbumList } from '/@/renderer/features/albums/queries/album-list-query';
|
||||||
import { AlbumListSort, LibraryItem, SortOrder } from '/@/renderer/api/types';
|
import { AlbumListSort, LibraryItem, QueueSong, SortOrder } from '/@/renderer/api/types';
|
||||||
import { usePlayQueueAdd } from '/@/renderer/features/player';
|
import { usePlayQueueAdd } from '/@/renderer/features/player';
|
||||||
|
|
||||||
const ContentContainer = styled.div`
|
const ContentContainer = styled.div`
|
||||||
|
@ -168,6 +168,14 @@ export const AlbumDetailContent = ({ tableRef }: AlbumDetailContentProps) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleRowDoubleClick = (e: RowDoubleClickedEvent<QueueSong>) => {
|
||||||
|
if (!e.data) return;
|
||||||
|
handlePlayQueueAdd?.({
|
||||||
|
byData: [e.data],
|
||||||
|
play: playButtonBehavior,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const { intersectRef, tableContainerRef } = useFixedTableHeader();
|
const { intersectRef, tableContainerRef } = useFixedTableHeader();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -216,10 +224,12 @@ export const AlbumDetailContent = ({ tableRef }: AlbumDetailContentProps) => {
|
||||||
<VirtualTable
|
<VirtualTable
|
||||||
ref={tableRef}
|
ref={tableRef}
|
||||||
animateRows
|
animateRows
|
||||||
|
deselectOnClickOutside
|
||||||
detailRowAutoHeight
|
detailRowAutoHeight
|
||||||
maintainColumnOrder
|
maintainColumnOrder
|
||||||
suppressCellFocus
|
suppressCellFocus
|
||||||
suppressCopyRowsToClipboard
|
suppressCopyRowsToClipboard
|
||||||
|
suppressHorizontalScroll
|
||||||
suppressLoadingOverlay
|
suppressLoadingOverlay
|
||||||
suppressMoveWhenRowDragging
|
suppressMoveWhenRowDragging
|
||||||
suppressPaginationPanel
|
suppressPaginationPanel
|
||||||
|
@ -240,6 +250,7 @@ export const AlbumDetailContent = ({ tableRef }: AlbumDetailContentProps) => {
|
||||||
onGridSizeChanged={(params) => {
|
onGridSizeChanged={(params) => {
|
||||||
params.api.sizeColumnsToFit();
|
params.api.sizeColumnsToFit();
|
||||||
}}
|
}}
|
||||||
|
onRowDoubleClicked={handleRowDoubleClick}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack
|
<Stack
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { CellContextMenuEvent, ColDef } from '@ag-grid-community/core';
|
import { CellContextMenuEvent, ColDef, RowDoubleClickedEvent } from '@ag-grid-community/core';
|
||||||
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
|
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
|
||||||
import { Box, Group } from '@mantine/core';
|
import { Box, Group } from '@mantine/core';
|
||||||
import { closeAllModals, openModal } from '@mantine/modals';
|
import { closeAllModals, openModal } from '@mantine/modals';
|
||||||
|
@ -11,7 +11,13 @@ import { Link } from 'react-router-dom';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { api } from '/@/renderer/api';
|
import { api } from '/@/renderer/api';
|
||||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||||
import { LibraryItem, SortOrder, UserListQuery, UserListSort } from '/@/renderer/api/types';
|
import {
|
||||||
|
LibraryItem,
|
||||||
|
QueueSong,
|
||||||
|
SortOrder,
|
||||||
|
UserListQuery,
|
||||||
|
UserListSort,
|
||||||
|
} from '/@/renderer/api/types';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
ConfirmModal,
|
ConfirmModal,
|
||||||
|
@ -36,6 +42,7 @@ import { usePlayButtonBehavior } from '/@/renderer/store/settings.store';
|
||||||
import { Play } from '/@/renderer/types';
|
import { Play } from '/@/renderer/types';
|
||||||
|
|
||||||
const ContentContainer = styled.div`
|
const ContentContainer = styled.div`
|
||||||
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
max-width: 1920px;
|
max-width: 1920px;
|
||||||
|
@ -117,8 +124,6 @@ export const PlaylistDetailContent = ({ tableRef }: PlaylistDetailContentProps)
|
||||||
[playlistSongsQueryInfinite.data?.pages],
|
[playlistSongsQueryInfinite.data?.pages],
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('playlistSongData', playlistSongData);
|
|
||||||
|
|
||||||
const { intersectRef, tableContainerRef } = useFixedTableHeader();
|
const { intersectRef, tableContainerRef } = useFixedTableHeader();
|
||||||
|
|
||||||
const deletePlaylistMutation = useDeletePlaylist();
|
const deletePlaylistMutation = useDeletePlaylist();
|
||||||
|
@ -207,6 +212,14 @@ export const PlaylistDetailContent = ({ tableRef }: PlaylistDetailContentProps)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleRowDoubleClick = (e: RowDoubleClickedEvent<QueueSong>) => {
|
||||||
|
if (!e.data) return;
|
||||||
|
handlePlayQueueAdd?.({
|
||||||
|
byData: [e.data],
|
||||||
|
play: playButtonBehavior,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const loadMoreRef = useRef<HTMLButtonElement | null>(null);
|
const loadMoreRef = useRef<HTMLButtonElement | null>(null);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -256,10 +269,12 @@ export const PlaylistDetailContent = ({ tableRef }: PlaylistDetailContentProps)
|
||||||
<VirtualTable
|
<VirtualTable
|
||||||
ref={tableRef}
|
ref={tableRef}
|
||||||
animateRows
|
animateRows
|
||||||
|
deselectOnClickOutside
|
||||||
detailRowAutoHeight
|
detailRowAutoHeight
|
||||||
maintainColumnOrder
|
maintainColumnOrder
|
||||||
suppressCellFocus
|
suppressCellFocus
|
||||||
suppressCopyRowsToClipboard
|
suppressCopyRowsToClipboard
|
||||||
|
suppressHorizontalScroll
|
||||||
suppressLoadingOverlay
|
suppressLoadingOverlay
|
||||||
suppressMoveWhenRowDragging
|
suppressMoveWhenRowDragging
|
||||||
suppressPaginationPanel
|
suppressPaginationPanel
|
||||||
|
@ -268,7 +283,10 @@ export const PlaylistDetailContent = ({ tableRef }: PlaylistDetailContentProps)
|
||||||
columnDefs={columnDefs}
|
columnDefs={columnDefs}
|
||||||
defaultColDef={defaultColumnDefs}
|
defaultColDef={defaultColumnDefs}
|
||||||
enableCellChangeFlash={false}
|
enableCellChangeFlash={false}
|
||||||
getRowId={(data) => data.data.id}
|
getRowId={(data) => {
|
||||||
|
// It's possible that there are duplicate song ids in a playlist
|
||||||
|
return `${data.data.id}-${data.data.pageIndex}`;
|
||||||
|
}}
|
||||||
rowData={playlistSongData}
|
rowData={playlistSongData}
|
||||||
rowHeight={60}
|
rowHeight={60}
|
||||||
rowSelection="multiple"
|
rowSelection="multiple"
|
||||||
|
@ -280,6 +298,7 @@ export const PlaylistDetailContent = ({ tableRef }: PlaylistDetailContentProps)
|
||||||
onGridSizeChanged={(params) => {
|
onGridSizeChanged={(params) => {
|
||||||
params.api.sizeColumnsToFit();
|
params.api.sizeColumnsToFit();
|
||||||
}}
|
}}
|
||||||
|
onRowDoubleClicked={handleRowDoubleClick}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<MotionGroup
|
<MotionGroup
|
||||||
|
|
|
@ -135,8 +135,6 @@ const PlaylistDetailSongListRoute = () => {
|
||||||
setIsQueryBuilderExpanded(true);
|
setIsQueryBuilderExpanded(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('detailQuery?.data?.rules', detailQuery?.data?.rules);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AnimatedPage key={`playlist-detail-songList-${playlistId}`}>
|
<AnimatedPage key={`playlist-detail-songList-${playlistId}`}>
|
||||||
<Stack
|
<Stack
|
||||||
|
|
Reference in a new issue