mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix for AttachmentTable (#6481)
* Fix for AttachmentTable - Rebuild actions when permissions are recalculated * Update examples.md
This commit is contained in:
parent
d86f964fb1
commit
aed7754bc2
@ -253,4 +253,4 @@ BomItem.create(api, data={'part':sofa_id, 'sub_part':armrest_id, 'quantity':2, '
|
|||||||
```
|
```
|
||||||
|
|
||||||
Now you have three BOM items that make the BOM for the sofa. The `id` values are the primary keys of the
|
Now you have three BOM items that make the BOM for the sofa. The `id` values are the primary keys of the
|
||||||
specified parts. The reference can be any string that names the instances.
|
specified parts. The reference can be any string that names the instances.
|
||||||
|
@ -4,7 +4,7 @@ import { ActionIcon } from '@mantine/core';
|
|||||||
import { Dropzone } from '@mantine/dropzone';
|
import { Dropzone } from '@mantine/dropzone';
|
||||||
import { notifications } from '@mantine/notifications';
|
import { notifications } from '@mantine/notifications';
|
||||||
import { IconExternalLink, IconFileUpload } from '@tabler/icons-react';
|
import { IconExternalLink, IconFileUpload } from '@tabler/icons-react';
|
||||||
import { ReactNode, useEffect, useMemo, useState } from 'react';
|
import { ReactNode, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { api } from '../../App';
|
import { api } from '../../App';
|
||||||
import { AttachmentLink } from '../../components/items/AttachmentLink';
|
import { AttachmentLink } from '../../components/items/AttachmentLink';
|
||||||
@ -99,6 +99,7 @@ export function AttachmentTable({
|
|||||||
|
|
||||||
setAllowEdit('POST' in actions);
|
setAllowEdit('POST' in actions);
|
||||||
setAllowDelete('DELETE' in actions);
|
setAllowDelete('DELETE' in actions);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@ -107,41 +108,44 @@ export function AttachmentTable({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Construct row actions for the attachment table
|
// Construct row actions for the attachment table
|
||||||
function rowActions(record: any): RowAction[] {
|
const rowActions = useCallback(
|
||||||
let actions: RowAction[] = [];
|
(record: any) => {
|
||||||
|
let actions: RowAction[] = [];
|
||||||
|
|
||||||
if (allowEdit) {
|
if (allowEdit) {
|
||||||
actions.push(
|
actions.push(
|
||||||
RowEditAction({
|
RowEditAction({
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
editAttachment({
|
editAttachment({
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
model: model,
|
model: model,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
attachmentType: record.attachment ? 'file' : 'link',
|
attachmentType: record.attachment ? 'file' : 'link',
|
||||||
callback: table.refreshTable
|
callback: table.refreshTable
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowDelete) {
|
if (allowDelete) {
|
||||||
actions.push(
|
actions.push(
|
||||||
RowDeleteAction({
|
RowDeleteAction({
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
deleteAttachment({
|
deleteAttachment({
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
pk: record.pk,
|
pk: record.pk,
|
||||||
callback: table.refreshTable
|
callback: table.refreshTable
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
},
|
||||||
|
[allowEdit, allowDelete]
|
||||||
|
);
|
||||||
|
|
||||||
// Callback to upload file attachment(s)
|
// Callback to upload file attachment(s)
|
||||||
function uploadFiles(files: File[]) {
|
function uploadFiles(files: File[]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user