mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 18:33:33 +00:00
Fix album detail table customizations
This commit is contained in:
parent
49b6478b72
commit
277669c413
3 changed files with 51 additions and 8 deletions
|
|
@ -87,6 +87,7 @@ export const GENRE_TABLE_COLUMNS = [
|
||||||
];
|
];
|
||||||
|
|
||||||
interface TableConfigDropdownProps {
|
interface TableConfigDropdownProps {
|
||||||
|
// tableRef?: MutableRefObject<AgGridReactType<any> | null>;
|
||||||
type: TableType;
|
type: TableType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ import { AlbumListSort, LibraryItem, QueueSong, SortOrder } from '/@/renderer/ap
|
||||||
import { Button, Popover } from '/@/renderer/components';
|
import { Button, Popover } from '/@/renderer/components';
|
||||||
import { MemoizedSwiperGridCarousel } from '/@/renderer/components/grid-carousel';
|
import { MemoizedSwiperGridCarousel } from '/@/renderer/components/grid-carousel';
|
||||||
import {
|
import {
|
||||||
getColumnDefs,
|
|
||||||
TableConfigDropdown,
|
TableConfigDropdown,
|
||||||
VirtualTable,
|
VirtualTable,
|
||||||
|
getColumnDefs,
|
||||||
} from '/@/renderer/components/virtual-table';
|
} from '/@/renderer/components/virtual-table';
|
||||||
import { FullWidthDiscCell } from '/@/renderer/components/virtual-table/cells/full-width-disc-cell';
|
import { FullWidthDiscCell } from '/@/renderer/components/virtual-table/cells/full-width-disc-cell';
|
||||||
import { useCurrentSongRowStyles } from '/@/renderer/components/virtual-table/hooks/use-current-song-row-styles';
|
import { useCurrentSongRowStyles } from '/@/renderer/components/virtual-table/hooks/use-current-song-row-styles';
|
||||||
|
|
@ -34,7 +34,11 @@ import { LibraryBackgroundOverlay } from '/@/renderer/features/shared/components
|
||||||
import { useContainerQuery } from '/@/renderer/hooks';
|
import { useContainerQuery } from '/@/renderer/hooks';
|
||||||
import { AppRoute } from '/@/renderer/router/routes';
|
import { AppRoute } from '/@/renderer/router/routes';
|
||||||
import { useCurrentServer } from '/@/renderer/store';
|
import { useCurrentServer } from '/@/renderer/store';
|
||||||
import { usePlayButtonBehavior, useTableSettings } from '/@/renderer/store/settings.store';
|
import {
|
||||||
|
usePlayButtonBehavior,
|
||||||
|
useSettingsStoreActions,
|
||||||
|
useTableSettings,
|
||||||
|
} from '/@/renderer/store/settings.store';
|
||||||
import { Play } from '/@/renderer/types';
|
import { Play } from '/@/renderer/types';
|
||||||
|
|
||||||
const isFullWidthRow = (node: RowNode) => {
|
const isFullWidthRow = (node: RowNode) => {
|
||||||
|
|
@ -65,16 +69,20 @@ export const AlbumDetailContent = ({ tableRef, background }: AlbumDetailContentP
|
||||||
const cq = useContainerQuery();
|
const cq = useContainerQuery();
|
||||||
const handlePlayQueueAdd = usePlayQueueAdd();
|
const handlePlayQueueAdd = usePlayQueueAdd();
|
||||||
const tableConfig = useTableSettings('albumDetail');
|
const tableConfig = useTableSettings('albumDetail');
|
||||||
|
const { setTable } = useSettingsStoreActions();
|
||||||
|
|
||||||
const columnDefs = useMemo(() => getColumnDefs(tableConfig.columns), [tableConfig.columns]);
|
const columnDefs = useMemo(() => getColumnDefs(tableConfig.columns), [tableConfig.columns]);
|
||||||
|
|
||||||
const getRowHeight = useCallback((params: RowHeightParams) => {
|
const getRowHeight = useCallback(
|
||||||
if (isFullWidthRow(params.node)) {
|
(params: RowHeightParams) => {
|
||||||
return 45;
|
if (isFullWidthRow(params.node)) {
|
||||||
}
|
return 45;
|
||||||
|
}
|
||||||
|
|
||||||
return 60;
|
return tableConfig.rowHeight;
|
||||||
}, []);
|
},
|
||||||
|
[tableConfig.rowHeight],
|
||||||
|
);
|
||||||
|
|
||||||
const songsRowData = useMemo(() => {
|
const songsRowData = useMemo(() => {
|
||||||
if (!detailQuery.data?.songs) {
|
if (!detailQuery.data?.songs) {
|
||||||
|
|
@ -266,6 +274,32 @@ export const AlbumDetailContent = ({ tableRef, background }: AlbumDetailContentP
|
||||||
ALBUM_CONTEXT_MENU_ITEMS,
|
ALBUM_CONTEXT_MENU_ITEMS,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onColumnMoved = useCallback(() => {
|
||||||
|
const { columnApi } = tableRef?.current || {};
|
||||||
|
const columnsOrder = columnApi?.getAllGridColumns();
|
||||||
|
|
||||||
|
if (!columnsOrder) return;
|
||||||
|
|
||||||
|
const columnsInSettings = tableConfig.columns;
|
||||||
|
const updatedColumns = [];
|
||||||
|
for (const column of columnsOrder) {
|
||||||
|
const columnInSettings = columnsInSettings.find(
|
||||||
|
(c) => c.column === column.getColDef().colId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (columnInSettings) {
|
||||||
|
updatedColumns.push({
|
||||||
|
...columnInSettings,
|
||||||
|
...(!tableConfig.autoFit && {
|
||||||
|
width: column.getActualWidth(),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setTable('albumDetail', { ...tableConfig, columns: updatedColumns });
|
||||||
|
}, [setTable, tableConfig, tableRef]);
|
||||||
|
|
||||||
const { rowClassRules } = useCurrentSongRowStyles({ tableRef });
|
const { rowClassRules } = useCurrentSongRowStyles({ tableRef });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -352,6 +386,7 @@ export const AlbumDetailContent = ({ tableRef, background }: AlbumDetailContentP
|
||||||
)}
|
)}
|
||||||
<Box style={{ minHeight: '300px' }}>
|
<Box style={{ minHeight: '300px' }}>
|
||||||
<VirtualTable
|
<VirtualTable
|
||||||
|
key={`table-${tableConfig.rowHeight}`}
|
||||||
ref={tableRef}
|
ref={tableRef}
|
||||||
autoHeight
|
autoHeight
|
||||||
stickyHeader
|
stickyHeader
|
||||||
|
|
@ -378,6 +413,7 @@ export const AlbumDetailContent = ({ tableRef, background }: AlbumDetailContentP
|
||||||
rowData={songsRowData}
|
rowData={songsRowData}
|
||||||
rowSelection="multiple"
|
rowSelection="multiple"
|
||||||
onCellContextMenu={onCellContextMenu}
|
onCellContextMenu={onCellContextMenu}
|
||||||
|
onColumnMoved={onColumnMoved}
|
||||||
onRowDoubleClicked={handleRowDoubleClick}
|
onRowDoubleClicked={handleRowDoubleClick}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,7 @@ export interface SettingsSlice extends SettingsState {
|
||||||
reset: () => void;
|
reset: () => void;
|
||||||
setSettings: (data: Partial<SettingsState>) => void;
|
setSettings: (data: Partial<SettingsState>) => void;
|
||||||
setSidebarItems: (items: SidebarItemType[]) => void;
|
setSidebarItems: (items: SidebarItemType[]) => void;
|
||||||
|
setTable: (type: TableType, data: DataTableProps) => void;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -493,6 +494,11 @@ export const useSettingsStore = create<SettingsSlice>()(
|
||||||
state.general.sidebarItems = items;
|
state.general.sidebarItems = items;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
setTable: (type: TableType, data: DataTableProps) => {
|
||||||
|
set((state) => {
|
||||||
|
state.tables[type] = data;
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
...initialState,
|
...initialState,
|
||||||
})),
|
})),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue