mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
parent
be30cec2ad
commit
538ff9be7b
@ -34,7 +34,8 @@ export function constructFormUrl(
|
|||||||
*/
|
*/
|
||||||
export function extractAvailableFields(
|
export function extractAvailableFields(
|
||||||
response: AxiosResponse,
|
response: AxiosResponse,
|
||||||
method?: string
|
method?: string,
|
||||||
|
hideErrors?: boolean
|
||||||
): Record<string, ApiFormFieldType> | null {
|
): Record<string, ApiFormFieldType> | null {
|
||||||
// OPTIONS request *must* return 200 status
|
// OPTIONS request *must* return 200 status
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
@ -44,21 +45,7 @@ export function extractAvailableFields(
|
|||||||
|
|
||||||
let actions: any = response.data?.actions ?? null;
|
let actions: any = response.data?.actions ?? null;
|
||||||
|
|
||||||
if (!method) {
|
if (!method || !actions) {
|
||||||
notifications.show({
|
|
||||||
title: t`Form Error`,
|
|
||||||
message: t`Form method not provided`,
|
|
||||||
color: 'red'
|
|
||||||
});
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!actions) {
|
|
||||||
notifications.show({
|
|
||||||
title: t`Form Error`,
|
|
||||||
message: t`Response did not contain action data`,
|
|
||||||
color: 'red'
|
|
||||||
});
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +58,9 @@ export function extractAvailableFields(
|
|||||||
|
|
||||||
if (!(method in actions)) {
|
if (!(method in actions)) {
|
||||||
// Missing method - this means user does not have appropriate permission
|
// Missing method - this means user does not have appropriate permission
|
||||||
permissionDenied();
|
if (!hideErrors) {
|
||||||
|
permissionDenied();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ export function InvenTreeTable<T = any>({
|
|||||||
|
|
||||||
let names: Record<string, string> = {};
|
let names: Record<string, string> = {};
|
||||||
let fields: ApiFormFieldSet =
|
let fields: ApiFormFieldSet =
|
||||||
extractAvailableFields(response, 'POST') || {};
|
extractAvailableFields(response, 'POST', true) || {};
|
||||||
|
|
||||||
// Extract flattened map of fields
|
// Extract flattened map of fields
|
||||||
mapFields(fields, (path, field) => {
|
mapFields(fields, (path, field) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user