mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-13 08:21:26 +00:00
Modal api forms (#5355)
* Very basic form implementation * Fetch field definition data via AP * Add cancel and submit buttons * Render basic field stack, and extract field data from API * Extract specific field definition * Handle text fields * Add some more fields * Implement boolean and number fields * Add callback for value changes * Use form state to update values * Add skeleton for a 'related field' * Framework for related field query manager * Handle date type fields * Make date input clearable * Fix error messae * Fix for optional callback function * Use LoadingOverlay component * Support url and email fields * Add icon support - Cannot hash react nodes! * Create components for different form types - Create - Edit - Delete * Split ApiFormField into separate file * Add support for pre-form and post-form content * Don't render hidden fields * Smaller spacing * More demo data * Add icon to clear text input value * Account for "read only" property * Framework for a submit data query * Return 404 on API requests other than GET - Other request methods need love too! * Starting work on dynamically opening forms * Check validity of OPTIONS response * refactor * Launch modal form with provided props * Refactor tractor: - Handle simple form submission - Handle simple error messages * Improve support for content pre and post form * Allow custom content to be inserted between fields * Pass form props down to individual fields * Update playground page with API forms functionality * Simplify form submission to handle different methods * Handle passing of initial form data values * Improve docstrings * Code cleanup and add translations * Add comment * Ignore icon for checkbox input * Add custom callback function for individual form fields * Use Switch instead of Checkbox * Add react-select * Implement very simple related field select input - No custom rendering yet - Simple pk / name combination * FIrst pass at retrieving data from API * Updates: - Implement "filters" for each form field - Prevent duplicate searches from doing weird things * Rearrange files * Load initial values for related fields from the API - Requires cleanup * Display error message for related field * Create some basic functions for construction field sets * Display non-field-errors in form * Improved error rendering * Change field definition from list to Record type - In line with current (javascript) implementation - Cleaner / simpler to work with * Correctly use default values on first form load * Improve date input * define a set of stockitem fields * Implement "Choice" field using mantine.select * Implement useForm hook for better performance * Show permission denied error * Improved callback "onChangeValue" functionality - Define proper return type - Access all form data * Cleanup * Implement components for rendering database model instance - Not fully featured yet (still a lot of work to go) - Porting code across from existing "model_renderers.js" * Update packages * Handle file input fields * Improved loading overlay for form submission * Utilize modal renderers in search results * SearchDrawer cleanup * Temporary fix for image pathing issue * Cleanup table action buttons - Now use a dropdown menu - Implement "edit part" directly from the table - This is only as an example for now * Fix playground * Generate random ID with useId hook * Fix abortController to use ref * Use AbortController for search panel * Fix TableColumn type definition * Improved generation of unique form ID values
This commit is contained in:
@ -1,13 +1,16 @@
|
||||
import { t } from '@lingui/macro';
|
||||
import { Text } from '@mantine/core';
|
||||
import { IconEdit, IconTrash } from '@tabler/icons-react';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { editPart } from '../../../functions/forms/PartForms';
|
||||
import { notYetImplemented } from '../../../functions/notifications';
|
||||
import { shortenString } from '../../../functions/tables';
|
||||
import { ThumbnailHoverCard } from '../../items/Thumbnail';
|
||||
import { TableColumn } from '../Column';
|
||||
import { TableFilter } from '../Filter';
|
||||
import { InvenTreeTable } from '../InvenTreeTable';
|
||||
import { RowActions } from '../RowActions';
|
||||
|
||||
/**
|
||||
* Construct a list of columns for the part table
|
||||
@ -17,6 +20,7 @@ function partTableColumns(): TableColumn[] {
|
||||
{
|
||||
accessor: 'name',
|
||||
sortable: true,
|
||||
noWrap: true,
|
||||
title: t`Part`,
|
||||
render: function (record: any) {
|
||||
// TODO - Link to the part detail page
|
||||
@ -78,6 +82,38 @@ function partTableColumns(): TableColumn[] {
|
||||
accessor: 'link',
|
||||
title: t`Link`,
|
||||
switchable: true
|
||||
},
|
||||
{
|
||||
accessor: 'actions',
|
||||
title: '',
|
||||
switchable: false,
|
||||
render: function (record: any) {
|
||||
return (
|
||||
<RowActions
|
||||
title={`Part Actions`}
|
||||
actions={[
|
||||
{
|
||||
title: t`Edit`,
|
||||
icon: <IconEdit color="blue" />,
|
||||
onClick: () =>
|
||||
editPart({
|
||||
part_id: record.pk,
|
||||
callback: () => {
|
||||
// TODO: Reload the table, somehow?
|
||||
// TODO: Insert / update a single row in the table?
|
||||
// TODO: We need to have a hook back into the table
|
||||
}
|
||||
})
|
||||
},
|
||||
{
|
||||
title: t`Delete`,
|
||||
onClick: notYetImplemented,
|
||||
icon: <IconTrash color="red" />
|
||||
}
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user