mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 13:00:13 +02:00
adjust app default columns
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import clsx from 'clsx';
|
||||
import formatDuration from 'format-duration';
|
||||
import { AnimatePresence } from 'motion/react';
|
||||
import { Fragment, memo, ReactNode, useState } from 'react';
|
||||
import { generatePath, Link } from 'react-router';
|
||||
|
||||
import styles from './item-card.module.css';
|
||||
|
||||
import i18n from '/@/i18n/i18n';
|
||||
import { ItemCardControls } from '/@/renderer/components/item-card/item-card-controls';
|
||||
import { ItemImage } from '/@/renderer/components/item-image/item-image';
|
||||
import { getDraggedItems } from '/@/renderer/components/item-list/helpers/get-dragged-items';
|
||||
@@ -19,7 +19,15 @@ import { ItemControls } from '/@/renderer/components/item-list/types';
|
||||
import { useDragDrop } from '/@/renderer/hooks/use-drag-drop';
|
||||
import { AppRoute } from '/@/renderer/router/routes';
|
||||
import { useGeneralSettings } from '/@/renderer/store';
|
||||
import { formatDateAbsolute, formatDateRelative, formatRating } from '/@/renderer/utils/format';
|
||||
import {
|
||||
formatDateAbsolute,
|
||||
formatDateAbsoluteUTC,
|
||||
formatDateRelative,
|
||||
formatDurationString,
|
||||
formatRating,
|
||||
} from '/@/renderer/utils/format';
|
||||
import { Group } from '/@/shared/components/group/group';
|
||||
import { Icon } from '/@/shared/components/icon/icon';
|
||||
import { Separator } from '/@/shared/components/separator/separator';
|
||||
import { Skeleton } from '/@/shared/components/skeleton/skeleton';
|
||||
import { Text } from '/@/shared/components/text/text';
|
||||
@@ -991,7 +999,7 @@ export const getDataRows = (): DataRow[] => {
|
||||
{
|
||||
format: (data) => {
|
||||
if ('duration' in data && data.duration !== null) {
|
||||
return formatDuration(data.duration * 1000);
|
||||
return formatDurationString(data.duration);
|
||||
}
|
||||
return '';
|
||||
},
|
||||
@@ -1009,7 +1017,7 @@ export const getDataRows = (): DataRow[] => {
|
||||
{
|
||||
format: (data) => {
|
||||
if ('releaseDate' in data && data.releaseDate) {
|
||||
return data.releaseDate;
|
||||
return formatDateAbsoluteUTC(data.releaseDate);
|
||||
}
|
||||
return '';
|
||||
},
|
||||
@@ -1027,7 +1035,12 @@ export const getDataRows = (): DataRow[] => {
|
||||
{
|
||||
format: (data) => {
|
||||
if ('lastPlayedAt' in data && data.lastPlayedAt) {
|
||||
return formatDateRelative(data.lastPlayedAt);
|
||||
return (
|
||||
<Group align="center" gap="xs">
|
||||
<Icon icon="lastPlayed" size="sm" />
|
||||
{formatDateRelative(data.lastPlayedAt)}
|
||||
</Group>
|
||||
);
|
||||
}
|
||||
return '';
|
||||
},
|
||||
@@ -1036,7 +1049,7 @@ export const getDataRows = (): DataRow[] => {
|
||||
{
|
||||
format: (data) => {
|
||||
if ('playCount' in data && data.playCount !== null) {
|
||||
return String(data.playCount);
|
||||
return i18n.t('entity.play', { count: data.playCount });
|
||||
}
|
||||
return '';
|
||||
},
|
||||
@@ -1085,7 +1098,7 @@ export const getDataRows = (): DataRow[] => {
|
||||
{
|
||||
format: (data) => {
|
||||
if ('songCount' in data && data.songCount !== null) {
|
||||
return String(data.songCount);
|
||||
return i18n.t('entity.trackWithCount', { count: data.songCount });
|
||||
}
|
||||
return '';
|
||||
},
|
||||
|
||||
@@ -74,8 +74,8 @@ export const DefaultTitleCombinedColumn = (props: ItemTableListInnerColumn) => {
|
||||
};
|
||||
|
||||
const artists = useMemo(() => {
|
||||
if (row && 'artists' in row && Array.isArray(row.artists)) {
|
||||
return (row.artists as RelatedAlbumArtist[]).map((artist) => {
|
||||
if (row && 'artists' in item && Array.isArray(item.artists)) {
|
||||
return (item.artists as RelatedAlbumArtist[]).map((artist) => {
|
||||
const path = generatePath(AppRoute.LIBRARY_ARTISTS_DETAIL, {
|
||||
artistId: artist.id,
|
||||
});
|
||||
@@ -83,9 +83,9 @@ export const DefaultTitleCombinedColumn = (props: ItemTableListInnerColumn) => {
|
||||
});
|
||||
}
|
||||
return [];
|
||||
}, [row]);
|
||||
}, [item, row]);
|
||||
|
||||
if (row && 'name' in row && 'imageUrl' in row && 'artists' in row) {
|
||||
if (item && 'name' in item && 'imageUrl' in item && 'artists' in item) {
|
||||
const rowHeight = props.getRowHeight(props.rowIndex, props);
|
||||
const path = getTitlePath(props.itemType, (props.data[props.rowIndex] as any).id as string);
|
||||
|
||||
@@ -143,7 +143,7 @@ export const DefaultTitleCombinedColumn = (props: ItemTableListInnerColumn) => {
|
||||
})}
|
||||
>
|
||||
<Text className={styles.title} isNoSelect size="md" {...titleLinkProps}>
|
||||
{row.name as string}
|
||||
{item.name as string}
|
||||
</Text>
|
||||
<div className={styles.artists}>
|
||||
{artists.map((artist, index) => (
|
||||
|
||||
@@ -18,34 +18,34 @@ export const SONG_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
label: i18n.t('table.config.label.rowIndex', { postProcess: 'titleCase' }),
|
||||
pinned: 'left',
|
||||
pinned: null,
|
||||
value: TableColumn.ROW_INDEX,
|
||||
width: 80,
|
||||
width: 60,
|
||||
},
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.image', { postProcess: 'titleCase' }),
|
||||
pinned: 'left',
|
||||
pinned: null,
|
||||
value: TableColumn.IMAGE,
|
||||
width: 70,
|
||||
},
|
||||
{
|
||||
align: 'start',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.title', { postProcess: 'titleCase' }),
|
||||
pinned: 'left',
|
||||
pinned: null,
|
||||
value: TableColumn.TITLE,
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
align: 'start',
|
||||
autoSize: false,
|
||||
isEnabled: false,
|
||||
isEnabled: true,
|
||||
label: i18n.t('table.config.label.titleCombined', { postProcess: 'titleCase' }),
|
||||
pinned: 'left',
|
||||
pinned: null,
|
||||
value: TableColumn.TITLE_COMBINED,
|
||||
width: 300,
|
||||
},
|
||||
@@ -61,7 +61,7 @@ export const SONG_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'start',
|
||||
autoSize: false,
|
||||
isEnabled: false,
|
||||
isEnabled: true,
|
||||
label: i18n.t('table.config.label.album', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.ALBUM,
|
||||
@@ -70,7 +70,7 @@ export const SONG_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'start',
|
||||
autoSize: true,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.albumArtist', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.ALBUM_ARTIST,
|
||||
@@ -115,7 +115,7 @@ export const SONG_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.releaseDate', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.RELEASE_DATE,
|
||||
@@ -178,7 +178,7 @@ export const SONG_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.lastPlayed', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.LAST_PLAYED,
|
||||
@@ -214,7 +214,7 @@ export const SONG_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.dateAdded', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.DATE_ADDED,
|
||||
@@ -232,7 +232,7 @@ export const SONG_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.playCount', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.PLAY_COUNT,
|
||||
@@ -252,7 +252,7 @@ export const SONG_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
label: i18n.t('table.config.label.favorite', { postProcess: 'titleCase' }),
|
||||
pinned: 'right',
|
||||
pinned: null,
|
||||
value: TableColumn.USER_FAVORITE,
|
||||
width: 60,
|
||||
},
|
||||
@@ -268,9 +268,9 @@ export const SONG_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.actions', { postProcess: 'titleCase' }),
|
||||
pinned: 'right',
|
||||
pinned: null,
|
||||
value: TableColumn.ACTIONS,
|
||||
width: 60,
|
||||
},
|
||||
@@ -284,34 +284,34 @@ export const ALBUM_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
label: i18n.t('table.config.label.rowIndex', { postProcess: 'titleCase' }),
|
||||
pinned: 'left',
|
||||
pinned: null,
|
||||
value: TableColumn.ROW_INDEX,
|
||||
width: 80,
|
||||
width: 60,
|
||||
},
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.image', { postProcess: 'titleCase' }),
|
||||
pinned: 'left',
|
||||
pinned: null,
|
||||
value: TableColumn.IMAGE,
|
||||
width: 70,
|
||||
},
|
||||
{
|
||||
align: 'start',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.title', { postProcess: 'titleCase' }),
|
||||
pinned: 'left',
|
||||
pinned: null,
|
||||
value: TableColumn.TITLE,
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
align: 'start',
|
||||
autoSize: false,
|
||||
isEnabled: false,
|
||||
isEnabled: true,
|
||||
label: i18n.t('table.config.label.titleCombined', { postProcess: 'titleCase' }),
|
||||
pinned: 'left',
|
||||
pinned: null,
|
||||
value: TableColumn.TITLE_COMBINED,
|
||||
width: 300,
|
||||
},
|
||||
@@ -327,7 +327,7 @@ export const ALBUM_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'start',
|
||||
autoSize: true,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.albumArtist', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.ALBUM_ARTIST,
|
||||
@@ -381,7 +381,7 @@ export const ALBUM_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.releaseDate', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.RELEASE_DATE,
|
||||
@@ -390,7 +390,7 @@ export const ALBUM_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.lastPlayed', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.LAST_PLAYED,
|
||||
@@ -399,7 +399,7 @@ export const ALBUM_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.dateAdded', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.DATE_ADDED,
|
||||
@@ -408,7 +408,7 @@ export const ALBUM_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.playCount', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.PLAY_COUNT,
|
||||
@@ -419,7 +419,7 @@ export const ALBUM_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
label: i18n.t('table.config.label.favorite', { postProcess: 'titleCase' }),
|
||||
pinned: 'right',
|
||||
pinned: null,
|
||||
value: TableColumn.USER_FAVORITE,
|
||||
width: 60,
|
||||
},
|
||||
@@ -435,9 +435,9 @@ export const ALBUM_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.actions', { postProcess: 'titleCase' }),
|
||||
pinned: 'right',
|
||||
pinned: null,
|
||||
value: TableColumn.ACTIONS,
|
||||
width: 60,
|
||||
},
|
||||
@@ -451,7 +451,7 @@ export const ALBUM_ARTIST_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
label: i18n.t('table.config.label.rowIndex', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.ROW_INDEX,
|
||||
width: 80,
|
||||
width: 60,
|
||||
},
|
||||
{
|
||||
align: 'center',
|
||||
@@ -539,7 +539,7 @@ export const ALBUM_ARTIST_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
label: i18n.t('table.config.label.favorite', { postProcess: 'titleCase' }),
|
||||
pinned: 'right',
|
||||
pinned: null,
|
||||
value: TableColumn.USER_FAVORITE,
|
||||
width: 60,
|
||||
},
|
||||
@@ -555,9 +555,9 @@ export const ALBUM_ARTIST_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.actions', { postProcess: 'titleCase' }),
|
||||
pinned: 'right',
|
||||
pinned: null,
|
||||
value: TableColumn.ACTIONS,
|
||||
width: 60,
|
||||
},
|
||||
@@ -571,7 +571,7 @@ export const PLAYLIST_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
label: i18n.t('table.config.label.rowIndex', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.ROW_INDEX,
|
||||
width: 80,
|
||||
width: 60,
|
||||
},
|
||||
{
|
||||
align: 'center',
|
||||
@@ -630,9 +630,9 @@ export const PLAYLIST_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.actions', { postProcess: 'titleCase' }),
|
||||
pinned: 'right',
|
||||
pinned: null,
|
||||
value: TableColumn.ACTIONS,
|
||||
width: 60,
|
||||
},
|
||||
@@ -646,7 +646,7 @@ export const GENRE_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
label: i18n.t('table.config.label.rowIndex', { postProcess: 'titleCase' }),
|
||||
pinned: null,
|
||||
value: TableColumn.ROW_INDEX,
|
||||
width: 80,
|
||||
width: 60,
|
||||
},
|
||||
{
|
||||
align: 'start',
|
||||
@@ -678,9 +678,9 @@ export const GENRE_TABLE_COLUMNS: DefaultTableColumn[] = [
|
||||
{
|
||||
align: 'center',
|
||||
autoSize: false,
|
||||
isEnabled: true,
|
||||
isEnabled: false,
|
||||
label: i18n.t('table.config.label.actions', { postProcess: 'titleCase' }),
|
||||
pinned: 'right',
|
||||
pinned: null,
|
||||
value: TableColumn.ACTIONS,
|
||||
width: 60,
|
||||
},
|
||||
@@ -728,6 +728,15 @@ export const pickTableColumns = (options: {
|
||||
const enabledSet = new Set(enabledColumns);
|
||||
const remaining = columns.filter((col) => !enabledSet.has(col.value));
|
||||
columnsToProcess = [...columnsToProcess, ...remaining];
|
||||
} else {
|
||||
// When pickColumns is provided, include pickColumns that aren't in enabledColumns
|
||||
// so they can be added as disabled entries
|
||||
const enabledSet = new Set(enabledColumns);
|
||||
const pickColumnsNotEnabled = pickColumns
|
||||
.filter((col) => !enabledSet.has(col))
|
||||
.map((col) => columnMap.get(col))
|
||||
.filter((col): col is DefaultTableColumn => col !== undefined);
|
||||
columnsToProcess = [...columnsToProcess, ...pickColumnsNotEnabled];
|
||||
}
|
||||
} else {
|
||||
columnsToProcess = columns;
|
||||
|
||||
Reference in New Issue
Block a user