-
-
Notifications
You must be signed in to change notification settings - Fork 74
Add the ability to specify forms for buttons #173
Conversation
I'll have a deeper look into this when I have the time, but I will definitely accept this PR! =) About 3. I added a JQuery plugin that adds serializeJSON. There is also a plugin there that adds populate to populate the form from JSON. Squashing would be nice, but its up to you. I see you changed the CHANGELOG.md a bit. But perhaps you saw that its auto generated from GIT. |
I will fix up to use the JSON plugin as well as cleanup a few other things including the changelog. Hopefully will have an updated PR tomorrow with these changes. |
This change adds the ability to specify a JSON-based form for a given button, which will get automatically rendered when the button is pressed. The submitted data is available as serialized JSON in the ${BUTTON_FORM_DATA} variable. For the specification of what a form looks like and it's serialized result, look at README.md in the change.
8eae8f7
to
2a5c793
Compare
OK - should be much improved - a single commit with a reasonable commit message, I took out CHANGELOG.md, as well as cleaned up a few small bugs. It also adds documentation to the README. |
Thanks! |
* Adding fmt-maven-plugin to format code on Google Java Format. * Correcting warnings from Grunt / JSHint. * Adding, and using, enum, RENDER_FOR, in PrnfbRenderer.
I browsed the code a bit and I have some thoughts. Perhaps its better to have DTO:s that represent the buttonForm. Perhaps ButtonFormDTO and it can have a list of ButtonFormOptionDTO. That would enable us to do better checks on the JSON provided here. So that we could have errors like No name supplier or Type not recognized... We would also just need to render the defaultValue here. We would have JSON already so we dont need to parse here. I added ENCODE_FOR where JSON would be removed and we can use NONE instead. And let the framework encode the defaultValue string to JSON correctly. Let me know your opinion or if you start working on that. I will try to do it when I find the time. |
I'm looking into this now =) |
* Triggering without showing dialog, if no form supplied. * Adding DTO:s to properly validate JSON in form. * Adjusting textarea size in GUI. * Supplying form as JSON to GUI, instead of escaped JSON string.
* Triggering without showing dialog, if no form supplied. * Adding DTO:s to properly validate JSON in form. * Adjusting textarea size in GUI. * Supplying form as JSON to GUI, instead of escaped JSON string.
* Triggering without showing dialog, if no form supplied. * Adding DTO:s to properly validate JSON in form. * Storing the button form in objects, not a String. * Adjusting textarea size in GUI. * Supplying form as JSON to GUI, instead of escaped JSON string.
* Triggering without showing dialog, if no form supplied. * Adding DTO:s to properly validate JSON in form. * Storing the button form in objects, not a String. * Adjusting textarea size in GUI. * Supplying form as JSON to GUI, instead of escaped JSON string.
* Triggering without showing dialog, if no form supplied. * Adding DTO:s to properly validate JSON in form. * Storing the button form in objects, not a String. * Adjusting textarea size in GUI. * Supplying form as JSON to GUI, instead of escaped JSON string.
* Triggering without showing dialog, if no form supplied. * Adding DTO:s to properly validate JSON in form. * Storing the button form in objects, not a String. * Adjusting textarea size in GUI. * Supplying form as JSON to GUI, instead of escaped JSON string.
* Triggering without showing dialog, if no form supplied. * Adding DTO:s to properly validate JSON in form. * Storing the button form in objects, not a String. * Adjusting textarea size in GUI. * Supplying form as JSON to GUI, instead of escaped JSON string.
I think I'm happy with the implementation now. Will do some more testing before release. |
This is now added to 2.44. |
* Quotes were escaped with slashes.
We had a dire need to be able to get some interactivity from forms when pressing buttons, so that we could, for example, decide what kind of unit tests to run or builds to create.
At first I was thinking that it would be nice to have a form builder in the UI itself, but I'm way too lazy and not that talented, so instead I opted to allow you to specify a JSON representation of a form and then we'd just render it properly.
For example, this form:
Ends up looking like this:
And you can edit it like this:
In the form you can also use the normal variables (modulo
BUTTON_FORM_DATA
of course) so that they will be rendered as well. The form will then be sent to the server usingjQuery
'sserializeArray
format. For the above form, it looks like this:I specified it in the URL as such, but you can also put it as POST data of course:
?form_data=${BUTTON_FORM_DATA}
I fixed up the units so they're all passing, and I also handled HTML escaping of the content to make sure nothing terrible happens. In terms of improvements that are possible:
Hope this makes sense and happy holidays 🎄