src/pyams_default_theme/component/paragraph/zmi/map.py
changeset 102 9821ede236b1
child 147 5a23b395ccef
equal deleted inserted replaced
101:9c1189405f90 102:9821ede236b1
       
     1 #
       
     2 # Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 from pyams_content.component.paragraph.interfaces.map import have_gis
       
    17 if have_gis:
       
    18 
       
    19     # import standard library
       
    20 
       
    21     # import interfaces
       
    22     from pyams_default_theme.component.paragraph.interfaces.map import IMapParagraphDefaultRendererSettings
       
    23     from pyams_form.interfaces.form import IFormManager
       
    24     from pyams_skin.layer import IPyAMSLayer
       
    25 
       
    26     # import packages
       
    27     from pyams_content.features.renderer.zmi import RendererPropertiesEditForm
       
    28     from pyams_form.group import NamedWidgetsGroup
       
    29     from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
       
    30     from pyams_zmi.form import AdminDialogEditForm
       
    31     from z3c.form import field
       
    32     from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget
       
    33 
       
    34     from pyams_default_theme import _
       
    35 
       
    36 
       
    37     @adapter_config(context=(IMapParagraphDefaultRendererSettings, IPyAMSLayer, RendererPropertiesEditForm),
       
    38                     provides=IFormManager)
       
    39     class MapParagraphDefaultRendererSettingsFormManager(ContextRequestViewAdapter):
       
    40         """Map paragraph default renderer settings form manager"""
       
    41 
       
    42         def getFields(self):
       
    43             fields = field.Fields(IMapParagraphDefaultRendererSettings).omit('use_default_map_configuration')
       
    44             fields['no_use_default_map_configuration'].widgetFactory = SingleCheckBoxFieldWidget
       
    45             return fields
       
    46 
       
    47         def update(self):
       
    48             view = self.view
       
    49             view.dialog_class = 'modal-large'
       
    50             AdminDialogEditForm.update(view)
       
    51 
       
    52         def updateWidgets(self, prefix=None):
       
    53             AdminDialogEditForm.updateWidgets(self.view, prefix)
       
    54 
       
    55         def updateActions(self):
       
    56             AdminDialogEditForm.updateActions(self.view)
       
    57 
       
    58         def updateGroups(self):
       
    59             view = self.view
       
    60             view.add_group(NamedWidgetsGroup(view, 'configuration', view.widgets,
       
    61                                              view.fields.keys(),
       
    62                                              legend=_("Don't use default map configuration"),
       
    63                                              css_class='inner',
       
    64                                              switch=True,
       
    65                                              checkbox_switch=True,
       
    66                                              checkbox_field=IMapParagraphDefaultRendererSettings['no_use_default_map_configuration']))
       
    67             AdminDialogEditForm.updateGroups(view)