2023-05-20 19:21:23 -07:00
|
|
|
import { ICellRendererParams } from '@ag-grid-community/core';
|
2025-05-18 14:03:18 -07:00
|
|
|
import { useState } from 'react';
|
|
|
|
|
|
2025-06-24 00:04:36 -07:00
|
|
|
import styles from './full-width-disc-cell.module.css';
|
2023-05-20 19:21:23 -07:00
|
|
|
|
2025-06-24 00:04:36 -07:00
|
|
|
import { getNodesByDiscNumber, setNodeSelection } from '/@/renderer/components/virtual-table/utils';
|
|
|
|
|
import { Button } from '/@/shared/components/button/button';
|
|
|
|
|
import { Group } from '/@/shared/components/group/group';
|
|
|
|
|
import { Icon } from '/@/shared/components/icon/icon';
|
2023-05-20 19:21:23 -07:00
|
|
|
|
2025-05-18 14:03:18 -07:00
|
|
|
export const FullWidthDiscCell = ({ api, data, node }: ICellRendererParams) => {
|
2023-07-01 19:10:05 -07:00
|
|
|
const [isSelected, setIsSelected] = useState(false);
|
2023-05-20 19:21:23 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const handleToggleDiscNodes = () => {
|
|
|
|
|
if (!data) return;
|
2024-08-25 21:34:43 -07:00
|
|
|
const split: string[] = node.data.id.split('-');
|
|
|
|
|
const discNumber = Number(split[1]);
|
|
|
|
|
// the subtitle could have '-' in it; make sure to have all remaining items
|
|
|
|
|
const subtitle = split.length === 3 ? split.slice(2).join('-') : null;
|
|
|
|
|
const nodes = getNodesByDiscNumber({ api, discNumber, subtitle });
|
2023-05-20 19:21:23 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
setNodeSelection({ isSelected: !isSelected, nodes });
|
|
|
|
|
setIsSelected((prev) => !prev);
|
|
|
|
|
};
|
2023-05-20 19:21:23 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return (
|
2025-06-24 00:04:36 -07:00
|
|
|
<div className={styles.container}>
|
2023-07-01 19:10:05 -07:00
|
|
|
<Group
|
2025-06-24 00:04:36 -07:00
|
|
|
justify="space-between"
|
2023-07-01 19:10:05 -07:00
|
|
|
w="100%"
|
|
|
|
|
>
|
|
|
|
|
<Button
|
2025-06-24 00:04:36 -07:00
|
|
|
leftSection={isSelected ? <Icon icon="squareCheck" /> : <Icon icon="square" />}
|
2025-05-18 14:03:18 -07:00
|
|
|
onClick={handleToggleDiscNodes}
|
2025-06-24 00:04:36 -07:00
|
|
|
size="compact-md"
|
2023-07-01 19:10:05 -07:00
|
|
|
variant="subtle"
|
|
|
|
|
>
|
|
|
|
|
{data.name}
|
|
|
|
|
</Button>
|
|
|
|
|
</Group>
|
2025-06-24 00:04:36 -07:00
|
|
|
</div>
|
2023-07-01 19:10:05 -07:00
|
|
|
);
|
2023-05-20 19:21:23 -07:00
|
|
|
};
|