Skip to content

Commit

Permalink
- rename variable, documenation wording, syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Apr 8, 2019
1 parent ab7fa68 commit ab94f44
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions docs/zope4/migration/code.rst
Expand Up @@ -65,12 +65,12 @@ Example to use the info icon (i in a circle)::

zmi_icon = 'fas fa-info-circle'

If your product does not need to show a form when adding an object in the ZMI
using the `Select type to add` dropdown, which only applies to a small
percentage of available Zope products, you need to add another class variable
to prevent the modal dialog from appearing::
A few Zope products provide content that can be added in the ZMI without
showing a dialog to collect data such as an id or title. These will now
default to showing the new modal dialog as well. You can prevent that by
adding another class variable::

zmi_modal = False
zmi_show_add_dialog = False

.. _`zmi.styles` : https://github.com/zopefoundation/Zope/tree/master/src/zmi/styles
.. _`available icons` : https://fontawesome.com/icons?d=gallery&m=free
Expand Down
2 changes: 1 addition & 1 deletion src/App/dtml/manage_navbar.dtml
Expand Up @@ -55,7 +55,7 @@
<dtml-if "hasattr(aq_explicit, 'filtered_meta_types')">
<dtml-in filtered_meta_types mapping sort=name>
<dtml-if action>
<option data-dialog="&dtml-zmi_modal;"
<option data-dialog="&dtml-zmi_show_add_dialog;"
value="&dtml.html_quote-action;">&dtml-name;</option>
</dtml-if>
</dtml-in>
Expand Down
5 changes: 3 additions & 2 deletions src/OFS/ObjectManager.py
Expand Up @@ -277,8 +277,9 @@ def all_meta_types(self, interfaces=None):
# Synthesize a new key into each item that decides whether to show
# the modal add dialog in the Zope 4 ZMI
for mt in meta_types:
want_modal = getattr(mt.get('instance', None), 'zmi_modal', True)
mt['zmi_modal'] = (want_modal and 'modal') or ''
want_modal = getattr(mt.get('instance', None),
'zmi_show_add_dialog', True)
mt['zmi_show_add_dialog'] = 'modal' if want_modal else ''

return meta_types

Expand Down
2 changes: 1 addition & 1 deletion src/OFS/SimpleItem.py
Expand Up @@ -117,7 +117,7 @@ class Item(
"""A common base class for simple, non-container objects."""

zmi_icon = 'far fa-file'
zmi_modal = True
zmi_show_add_dialog = True

security = ClassSecurityInfo()

Expand Down
4 changes: 2 additions & 2 deletions src/OFS/tests/testObjectManager.py
Expand Up @@ -140,11 +140,11 @@ def test_all_meta_types_adds_zmi_modal(self):
om.meta_types = ({'name': 'Foo'}, {'name': 'Bar'}, {'name': 'Baz'})
amt = om.all_meta_types()
for mt in [x for x in amt if x['name'] in ('foo', 'bar', 'baz')]:
self.assertEqual(mt['zmi_modal'], 'modal')
self.assertEqual(mt['zmi_show_add_dialog'], 'modal')

# Pick an example that will be different
for mt in [x for x in amt if x['name'] == 'Virtual Host Monster']:
self.assertEqual(mt['zmi_modal'], '')
self.assertEqual(mt['zmi_show_add_dialog'], '')

def test_setObject_set_owner_with_no_user(self):
om = self._makeOne()
Expand Down
2 changes: 1 addition & 1 deletion src/Products/SiteAccess/VirtualHostMonster.py
Expand Up @@ -24,7 +24,7 @@ class VirtualHostMonster(Persistent, Item, Implicit):

meta_type = 'Virtual Host Monster'
zmi_icon = 'fa fa-code-branch'
zmi_modal = False
zmi_show_add_dialog = False
priority = 25

id = 'virtual_hosting'
Expand Down

0 comments on commit ab94f44

Please sign in to comment.