Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forms initial data #6365

Merged
merged 45 commits into from
Jan 31, 2024
Merged

Conversation

SchrodingersGat
Copy link
Member

@SchrodingersGat SchrodingersGat commented Jan 30, 2024

Replaces #6332

This PR is working towards a complete refactoring of how we handle modal forms. The intent is to remove the duplicate pathways for creating forms, and settle on a single, consistent framework (as implemented by @wolflu05 )

So, in this PR we refactor / rework a number of existing forms, add some new features, add some new forms, and fix some bugs along the way.

Important Notes

  • DateInput has been fixed, and works correctly now
  • Initial data can be easily passed into a form
  • The adjustFilters callback is now passed the complete form valueset, so it can make decisions without extra hooks

- Allows user to specify an initial dataset to override default values
- Allows lower elements to access all form data without rebuild
- Pass all form data through to adjustFilters routine
- Ensure that the saved data are cleared when filters change
- Use new "hook" form structure
- Only fetch when the drop-down is actually opened
- Significantly reduces the number of API calls
- Display label / description / placeholder text
- Correct conversion of datatype
- Uses modal form hook
- Supply initial data
- Adjust filters according to selected company
- StockLocation
- PartCategory
- PartParameter table
- PartParameterTemplate table
- Cleanup unused imports
@SchrodingersGat SchrodingersGat added enhancement This is an suggested enhancement or new feature Platform UI Related to the React based User Interface labels Jan 30, 2024
Copy link

netlify bot commented Jan 30, 2024

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 1055361
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/65ba477d942a7100087df785
😎 Deploy Preview https://deploy-preview-6365--inventree-web-pui-preview.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 86 (no change from production)
Best Practices: 92 (no change from production)
SEO: 70 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

- Move fields which are only used in one location
- Also consolidate translated strings
- Also improve consistency of inline rendering (with missing image)
- Use apiUrl wrapper around ApiEndpoint
src/frontend/src/components/forms/ApiForm.tsx Show resolved Hide resolved
src/frontend/src/components/forms/ApiForm.tsx Show resolved Hide resolved
src/frontend/src/main.tsx Outdated Show resolved Hide resolved
@@ -32,6 +36,8 @@ export function RelatedModelField({
fieldState: { error }
} = controller;

const form = useFormContext();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have any drawback on performance? Eg does this component now gets rerendered more often as without that hook?

@wolflu05
Copy link
Contributor

As you asked on the other, now closed pr, if there is any reason to keep two ways, no absolutely fine to refactor to the more reactive one. Thank you that you did that now.

The only thing which I sometimes experienced and not sure about yet how to fix it are some performance problems. Mostly in react dev mode with safari on macOS. If I open a large form with lots of fields and type in something it lags a bit behind to how fast I'm typing. Have you seen this too?

- Only show localhost:8000 if in dev mode
@matmair
Copy link
Member

matmair commented Jan 30, 2024

Looks fine; regarding performance Lukas is probably a better discussion partner, I am not knowledgable in that area.

@SchrodingersGat SchrodingersGat merged commit 7fe8207 into inventree:master Jan 31, 2024
24 checks passed
@SchrodingersGat SchrodingersGat deleted the forms-initial-data branch January 31, 2024 13:39
@wolflu05
Copy link
Contributor

wolflu05 commented Feb 2, 2024

@SchrodingersGat seems like, that this PR broke the RelatedModelField. If you try to scroll all the way to the bottom it always resets to the top and there are no more items loaded after one time.

Before (working):

Bildschirmaufnahme.2024-02-02.um.17.30.05.mov

After (not working):

Bildschirmaufnahme.2024-02-02.um.17.29.27.mov

@SchrodingersGat
Copy link
Member Author

SchrodingersGat commented Feb 3, 2024

@wolflu05 thanks for reporting - I will look into it

Edit: Fixed in #6396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an suggested enhancement or new feature Platform UI Related to the React based User Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants