-
-
Notifications
You must be signed in to change notification settings - Fork 672
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
PUI Template editor #6541
PUI Template editor #6541
Conversation
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
This is very impressive @wolflu05! I was not aware of code mirror - is this editor able to provide code completion similar to IntelliSense? |
From what I read, it should be possible, but haven't taken a deep look yet, will do that tomorrow when trying to add a language parser for Django templates. But adding the available template context is a big task that I probably don't do in this PR. For that it would be good to have the the new API inplace. Maybe we then also have a way of exporting a report without overriding a template on disk, but provide the template in the body. We could then use the debug tag to get all available variables in context and somehow convert that to the codemirror code recommendations.
Actually I was asking me if we should go with monaco or codemirror (you actually already suggested codemirror here 😃 #2777 (comment) ). The issue with Monaco is that it's pretty complex to setup and the bundle size also is huge, at least where I tried it about 1,5 years ago. And I read about codemirror a while ago and wanted to try it out, I'll see how it can be configured regarding language parsing tomorrow. But the way I setup the interface it will be really easy to swap codemirror out with Monaco or even provide both. |
Sounds reasonable, this PR is already a very very good. Maybe we need to ship a few hints to get ppl to try PUI in 0.14.0 to use these great additions. The Admin Center is really shaping to be a great experience.
That should probably be part of the refactor of labels/reports, should be simple.
That must have been suggested by a former colleague who did UX design. He helped out with designing the PUI prototype and suggested a lot of things in that timeframe. |
The first draft of this is now finished, and I think it would make sense to deliver this already.
The only thing that doesn't work great is that templates get moved to the user custom folder when editing an inventree provided template, and on restart they are not present in the inventree folder, so they get copied again and we end up with duplicate templates, our modified ones and the newly initialized ones. @inventree/maintainer what should we do here for now? So please let me know what you think about this, this would be ready for review now. |
Seems like a bug in file handling; the whole template copy code is very manual and duplicated; I will try to address this in 0.15.0 |
You want to trackl the label/report app refactor? I would really appreciate that. That would add so much possibilities for the template editor. |
I am already doing the storages refactor and adding S3 so this is just a logical continuance |
src/frontend/src/components/editors/TemplateEditor/PdfPreview.tsx
Outdated
Show resolved
Hide resolved
src/frontend/src/pages/Index/Settings/AdminCenter/TemplateManagementPanel.tsx
Outdated
Show resolved
Hide resolved
@wolflu05 INCREDIBLE! I have long dreamed of this (the linked issue was created way back in 2022) - but this was never going to be possible until we built out PUI to this point. I really like the layout and flow from your video (still have to test it myself). But it is pretty much exactly what I imagined. This is going to be a huge improvement to the whole label / report process. Very well done :) |
Even though there are large similarities between labels and reports, I think that it might be a good idea to separate them into separate panels, e.g. |
@wolflu05 it would be great to add some documentation around using this new editor - and a good chance to start demonstrating the new interface in the docs too. Before this is merged in (after |
On what page should we put that? |
You could just make a new sub-page here: https://docs.inventree.org/en/latest/report/report/ Probably worth waiting until this is "feature complete" so you don't have to rework the docs |
@SchrodingersGat I merged in master and added some basic documentation. Please let me know if that's sufficient for now to explain the basic working of the template editor until we add more features to it. |
@wolflu05 looks like a great start, thanks :) I'm happy to proceed with that, and improve as we go where necessary! |
So this can be merged into main? |
Yes 👍 |
@wolflu05 this is a significant and exciting new feature - would you like to write a short blog post about it? No pressure :) |
Thanks for this amazing contribution 🙂 |
A blog post is a good idea, but not sure on how to write one. I never did this before. And secondly, this is now only in latest. Does this make sense yet? |
Blog posts are just markdown files here - if you create a PR you get a preview |
I think it is a good idea to get people interested in the new feature and PUI in general |
This is a first draft for a label editor. I tried to keep it generic so that it can be easily adapted when the API changes (ref #5841).
My goal in sometime also is to provide a visual label designer and maybe also a report designer so that people can easily setup their templates.
Here is a little sneak peak of what its looking like currently:
out.mp4
Warning
If you want to try the netlify preview, be aware that it won't work with the demo server due to cors issues with the
/media
path (ref #5948)This PR now also contains a few minor fixes in other components:
SplitButton
componentActionDropdown
disabled
was renamed tohidden
and a realdisabled
state was added (was using that before, but now refactored that so I'm using the newSplitButton
component now, but I think it makes sense to still keep that rename even that I'm not using it anymore)DetailDrawerLink
component was added to link between modals and keep track if there was a modal opened before to only then show the modal back buttonRelatedModelField
dont make an API request if the pk is an empty stringStandaloneField
component to use API form fields without a form around, but just as a react controlled componentTODO
use a library for pdf previewing instead of iframe=> seems like an iframe nevertheless provides the best controlFuture ideas