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

Show modal property when editing an action #3719

Merged
merged 3 commits into from
Feb 4, 2023

Conversation

petschki
Copy link
Member

@petschki petschki commented Feb 2, 2023

fixes #3709

This needs plone/plone.base#27

@mister-roboto
Copy link

@petschki thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

return json.loads(self.context.modal)

def set_modal(self, value):
self.context.modal = json.dumps(value)
Copy link
Member Author

Choose a reason for hiding this comment

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

@mauritsvanrees not sure if this loads/dumps is needed for the textinput here ... the JSON is validated in plone.base.interfaces.controlpanel.IActionSchema

Copy link
Member

Choose a reason for hiding this comment

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

No, it is not needed. With this code, I actually get a validation error when I edit the Delete action and save it without changes: "Expecting property name enclosed in double quotes."
Ah, in the ZMI the value is:

{"actionOptions": {"disableAjaxFormSubmit":true, "redirectOnResponse":true}}

With the current code in this PR, this shows up in the Plone control panel as:

{'actionOptions': {'disableAjaxFormSubmit': True, 'redirectOnResponse': True}}

And this is no json, due to the single quotes and the Python-style booleans.
Funny. :-)

So just use return self.context.modal and self.context.modal = value. Then it works for me.
I have pushed a fix.

@petschki petschki marked this pull request as ready for review February 2, 2023 09:48
@petschki petschki changed the title Fix editing modal property when editing an action Show modal property when editing an action Feb 2, 2023
Copy link
Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!
I answered your remark in a comment, and pushed a fix.

But the setter is still not completely right yet. It works when the property already exists, but not all actions have the modal property. I tried it with the Paste action in Object buttons. In the control panel I can set a modal value and save it, but it does not show up in the ZMI.

Other parts of the code here call self.context._setPropValue, but that does not do it either. An attribute modal is set on the context, with the value, but it does not show up in the ZMI. The modal is then not active when I use the paste action: having an attribute is not enough, it has to be a property.

Okay, I have fixed that too, and now the property is there in the ZMI, and the modal is used when pasting.
Can you try it out?

return json.loads(self.context.modal)

def set_modal(self, value):
self.context.modal = json.dumps(value)
Copy link
Member

Choose a reason for hiding this comment

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

No, it is not needed. With this code, I actually get a validation error when I edit the Delete action and save it without changes: "Expecting property name enclosed in double quotes."
Ah, in the ZMI the value is:

{"actionOptions": {"disableAjaxFormSubmit":true, "redirectOnResponse":true}}

With the current code in this PR, this shows up in the Plone control panel as:

{'actionOptions': {'disableAjaxFormSubmit': True, 'redirectOnResponse': True}}

And this is no json, due to the single quotes and the Python-style booleans.
Funny. :-)

So just use return self.context.modal and self.context.modal = value. Then it works for me.
I have pushed a fix.

@petschki
Copy link
Member Author

petschki commented Feb 3, 2023

works here too ... I'll start Jenkins.

@mauritsvanrees mauritsvanrees merged commit 40a56e7 into master Feb 4, 2023
@mauritsvanrees mauritsvanrees deleted the controlpanel-actions-modal-settings branch February 4, 2023 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't edit the modal property of an action in Plone UI
3 participants