src/pyams_content/component/paragraph/zmi/keypoint.py
changeset 588 fafb10af74b3
parent 555 8e8a14452567
child 591 b694d5667d17
equal deleted inserted replaced
587:978dc30214ce 588:fafb10af74b3
    46                 layer=IPyAMSLayer, manager=IToolbarAddingMenu, weight=600)
    46                 layer=IPyAMSLayer, manager=IToolbarAddingMenu, weight=600)
    47 class KeypointsParagraphAddMenu(BaseParagraphAddMenu):
    47 class KeypointsParagraphAddMenu(BaseParagraphAddMenu):
    48     """Key points paragraph add menu"""
    48     """Key points paragraph add menu"""
    49 
    49 
    50     label = _("Key points...")
    50     label = _("Key points...")
    51     label_css_class = 'fa fa-fw fa-key'
    51     label_css_class = 'fa fa-fw fa-list-ol'
    52     url = 'add-keypoints-paragraph.html'
    52     url = 'add-keypoints-paragraph.html'
    53     paragraph_type = KEYPOINTS_PARAGRAPH_TYPE
    53     paragraph_type = KEYPOINTS_PARAGRAPH_TYPE
    54 
    54 
    55 
    55 
    56 @pagelet_config(name='add-keypoints-paragraph.html', context=IParagraphContainerTarget, layer=IPyAMSLayer,
    56 @pagelet_config(name='add-keypoints-paragraph.html', context=IParagraphContainerTarget, layer=IPyAMSLayer,
    57                 permission=MANAGE_CONTENT_PERMISSION)
    57                 permission=MANAGE_CONTENT_PERMISSION)
    58 class KeypointsParagraphAddForm(AdminDialogAddForm):
    58 class KeypointsParagraphAddForm(AdminDialogAddForm):
    59     """Key points paragraph add form"""
    59     """Key points paragraph add form"""
    60 
    60 
    61     legend = _("Add new key points paragraph")
    61     legend = _("Add new key points paragraph")
    62     icon_css_class = 'fa fa-fw fa-key'
    62     icon_css_class = 'fa fa-fw fa-list-ol'
    63 
    63 
    64     fields = field.Fields(IKeypointsParagraph).select('body', 'renderer')
    64     fields = field.Fields(IKeypointsParagraph).omit('__parent__', '__name__', 'visible')
    65     ajax_handler = 'add-keypoints-paragraph.json'
    65     ajax_handler = 'add-keypoints-paragraph.json'
    66     edit_permission = MANAGE_CONTENT_PERMISSION
    66     edit_permission = MANAGE_CONTENT_PERMISSION
    67 
    67 
    68     def updateWidgets(self, prefix=None):
    68     def updateWidgets(self, prefix=None):
    69         super(KeypointsParagraphAddForm, self).updateWidgets(prefix)
    69         super(KeypointsParagraphAddForm, self).updateWidgets(prefix)
    89     """Key points paragraph properties edit form"""
    89     """Key points paragraph properties edit form"""
    90 
    90 
    91     prefix = 'keypoints_properties.'
    91     prefix = 'keypoints_properties.'
    92 
    92 
    93     legend = _("Edit key points paragraph properties")
    93     legend = _("Edit key points paragraph properties")
    94     icon_css_class = 'fa fa-fw fa-key'
    94     icon_css_class = 'fa fa-fw fa-list-ol'
    95 
    95 
    96     fields = field.Fields(IKeypointsParagraph).select('body', 'renderer')
    96     fields = field.Fields(IKeypointsParagraph).omit('__parent__', '__name__', 'visible')
    97     fields['renderer'].widgetFactory = RendererFieldWidget
    97     fields['renderer'].widgetFactory = RendererFieldWidget
    98 
    98 
    99     ajax_handler = 'properties.json'
    99     ajax_handler = 'properties.json'
   100     edit_permission = MANAGE_CONTENT_PERMISSION
   100     edit_permission = MANAGE_CONTENT_PERMISSION
   101 
   101 
   107 
   107 
   108 @view_config(name='properties.json', context=IKeypointsParagraph, request_type=IPyAMSLayer,
   108 @view_config(name='properties.json', context=IKeypointsParagraph, request_type=IPyAMSLayer,
   109              permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
   109              permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
   110 class KeypointsParagraphPropertiesAJAXEditForm(BaseParagraphAJAXEditForm, KeypointsParagraphPropertiesEditForm):
   110 class KeypointsParagraphPropertiesAJAXEditForm(BaseParagraphAJAXEditForm, KeypointsParagraphPropertiesEditForm):
   111     """Key points paragraph properties edit form, JSON renderer"""
   111     """Key points paragraph properties edit form, JSON renderer"""
   112 
       
   113     def get_ajax_output(self, changes):
       
   114         output = super(KeypointsParagraphPropertiesAJAXEditForm, self).get_ajax_output(changes)
       
   115         if 'body' in changes.get(IKeypointsParagraph, ()):
       
   116             output.setdefault('events', []).append(
       
   117                 get_json_paragraph_refresh_event(self.context, self.request))
       
   118         return output
       
   119 
   112 
   120 
   113 
   121 @adapter_config(context=(IKeypointsParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)
   114 @adapter_config(context=(IKeypointsParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)
   122 @implementer(IInnerForm)
   115 @implementer(IInnerForm)
   123 class KeypointsParagraphInnerEditForm(KeypointsParagraphPropertiesEditForm):
   116 class KeypointsParagraphInnerEditForm(KeypointsParagraphPropertiesEditForm):