mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-27 19:16:44 +00:00
[PUI] fix Table Context Menu Links (#8623)
* Add switch to disable context menu Fixes #8553 * make attachment links right-clickable
This commit is contained in:
parent
4f3e8cb0a0
commit
a20fd9d231
@ -18,6 +18,7 @@ export type TableColumnProps<T = any> = {
|
||||
textAlign?: 'left' | 'center' | 'right'; // The text alignment of the column
|
||||
cellsStyle?: any; // The style of the cells in the column
|
||||
extra?: any; // Extra data to pass to the render function
|
||||
noContext?: boolean; // Disable context menu for this column
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ export type InvenTreeTableProps<T = any> = {
|
||||
modelType?: ModelType;
|
||||
rowStyle?: (record: T, index: number) => any;
|
||||
modelField?: string;
|
||||
onRowContextMenu?: (record: T, event: any) => void;
|
||||
onCellContextMenu?: (record: T, event: any) => void;
|
||||
minHeight?: number;
|
||||
noHeader?: boolean;
|
||||
};
|
||||
@ -568,16 +568,21 @@ export function InvenTreeTable<T extends Record<string, any>>({
|
||||
[props.onRowClick, props.onCellClick]
|
||||
);
|
||||
|
||||
// Callback when a row is right-clicked
|
||||
const handleRowContextMenu = ({
|
||||
// Callback when a cell is right-clicked
|
||||
const handleCellContextMenu = ({
|
||||
record,
|
||||
column,
|
||||
event
|
||||
}: {
|
||||
record: any;
|
||||
column: any;
|
||||
event: any;
|
||||
}) => {
|
||||
if (props.onRowContextMenu) {
|
||||
return props.onRowContextMenu(record, event);
|
||||
if (column?.noContext === true) {
|
||||
return;
|
||||
}
|
||||
if (props.onCellContextMenu) {
|
||||
return props.onCellContextMenu(record, event);
|
||||
} else if (props.rowActions) {
|
||||
const empty = () => {};
|
||||
const items = props.rowActions(record).map((action) => ({
|
||||
@ -693,7 +698,7 @@ export function InvenTreeTable<T extends Record<string, any>>({
|
||||
overflow: 'hidden'
|
||||
})
|
||||
}}
|
||||
onRowContextMenu={handleRowContextMenu}
|
||||
onCellContextMenu={handleCellContextMenu}
|
||||
{...optionalParams}
|
||||
/>
|
||||
</Box>
|
||||
|
@ -48,7 +48,8 @@ function attachmentTableColumns(): TableColumn[] {
|
||||
} else {
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
},
|
||||
noContext: true
|
||||
},
|
||||
{
|
||||
accessor: 'comment',
|
||||
|
@ -61,7 +61,8 @@ export default function ImportSesssionTable() {
|
||||
render: (record: any) => (
|
||||
<AttachmentLink attachment={record.data_file} />
|
||||
),
|
||||
sortable: false
|
||||
sortable: false,
|
||||
noContext: true
|
||||
},
|
||||
DateColumn({
|
||||
accessor: 'timestamp',
|
||||
|
@ -28,7 +28,8 @@ export default function StocktakeReportTable() {
|
||||
title: t`Report`,
|
||||
sortable: false,
|
||||
switchable: false,
|
||||
render: (record: any) => <AttachmentLink attachment={record.report} />
|
||||
render: (record: any) => <AttachmentLink attachment={record.report} />,
|
||||
noContext: true
|
||||
},
|
||||
{
|
||||
accessor: 'part_count',
|
||||
|
@ -219,7 +219,8 @@ export function TemplateTable({
|
||||
}
|
||||
|
||||
return <AttachmentLink attachment={record.template} />;
|
||||
}
|
||||
},
|
||||
noContext: true
|
||||
},
|
||||
{
|
||||
accessor: 'model_type',
|
||||
|
@ -195,7 +195,10 @@ export default function StockItemTestResultTable({
|
||||
accessor: 'attachment',
|
||||
title: t`Attachment`,
|
||||
render: (record: any) =>
|
||||
record.attachment && <AttachmentLink attachment={record.attachment} />
|
||||
record.attachment && (
|
||||
<AttachmentLink attachment={record.attachment} />
|
||||
),
|
||||
noContext: true
|
||||
},
|
||||
NoteColumn({}),
|
||||
DateColumn({}),
|
||||
|
Loading…
x
Reference in New Issue
Block a user