--- a/src/pyams_content/shared/imagemap/interfaces/__init__.py Tue Sep 12 11:30:45 2017 +0200
+++ b/src/pyams_content/shared/imagemap/interfaces/__init__.py Tue Sep 12 16:40:44 2017 +0200
@@ -16,12 +16,14 @@
# import standard library
# import interfaces
+from pyams_content.component.paragraph.interfaces import IBaseParagraph
from pyams_content.shared.common.interfaces import ISharedTool, IWfSharedContent, ISharedContent
from zope.annotation.interfaces import IAttributeAnnotatable
# import packages
from pyams_content.shared.imagemap.schema import MapArea
from pyams_i18n.schema import I18nTextLineField, I18nImageField
+from pyams_sequence.schema import InternalReference
from pyams_utils.schema import PersistentDict
from zope.schema import Object, Choice
@@ -68,3 +70,14 @@
class IImageMap(ISharedContent):
"""Workflow managed image map interface"""
+
+
+class IImageMapParagraph(IBaseParagraph):
+ """Image map paragraph"""
+
+ reference = InternalReference(title=_("Internal reference"),
+ description=_("Reference to image map object"),
+ content_type=IMAGEMAP_CONTENT_TYPE)
+
+ def get_target(self, state=None):
+ """Get reference target"""
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/imagemap/paragraph.py Tue Sep 12 16:40:44 2017 +0200
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_content.component.paragraph.interfaces import IParagraphFactory
+from pyams_content.shared.imagemap.interfaces import IImageMapParagraph
+
+# import packages
+from pyams_content.component.paragraph import BaseParagraph
+from pyams_sequence.utility import get_reference_target
+from pyams_utils.registry import utility_config
+from zope.interface import implementer
+from zope.schema.fieldproperty import FieldProperty
+
+from pyams_content import _
+
+
+@implementer(IImageMapParagraph)
+class ImageMapParagraph(BaseParagraph):
+ """Image map paragraph"""
+
+ icon_class = 'fa-location-arrow'
+ icon_hint = _("Image map")
+
+ reference = FieldProperty(IImageMapParagraph['reference'])
+
+ def get_target(self, state=None):
+ return get_reference_target(self.reference, state)
+
+
+@utility_config(name='ImageMap', provides=IParagraphFactory)
+class ImageMapParagraphFactory(object):
+ """Image map paragraph factory"""
+
+ name = _("Image map")
+ content_type = ImageMapParagraph
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/imagemap/zmi/paragraph.py Tue Sep 12 16:40:44 2017 +0200
@@ -0,0 +1,127 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
+from pyams_content.component.paragraph.zmi.interfaces import IParagraphInnerEditor
+from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION
+from pyams_content.shared.common.interfaces import IWfSharedContent
+from pyams_content.shared.imagemap.interfaces import IImageMapParagraph
+from pyams_form.interfaces.form import IInnerForm, IEditFormButtons
+from pyams_i18n.interfaces import II18n
+from pyams_skin.interfaces.viewlet import IToolbarAddingMenu
+from pyams_skin.layer import IPyAMSLayer
+from z3c.form.interfaces import INPUT_MODE
+
+# import packages
+from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm
+from pyams_content.component.paragraph.zmi.container import ParagraphContainerView
+from pyams_content.shared.imagemap.paragraph import ImageMapParagraph
+from pyams_form.security import ProtectedFormObjectMixin
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_skin.viewlet.toolbar import ToolbarMenuItem
+from pyams_utils.adapter import adapter_config
+from pyams_utils.traversing import get_parent
+from pyams_viewlet.viewlet import viewlet_config
+from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
+from pyramid.view import view_config
+from z3c.form import field, button
+from zope.interface import implementer
+
+from pyams_content import _
+
+
+@viewlet_config(name='add-imagemap-paragraph.menu', context=IParagraphContainerTarget, view=ParagraphContainerView,
+ layer=IPyAMSLayer, manager=IToolbarAddingMenu, weight=80)
+class ImagemapParagraphAddMenu(ProtectedFormObjectMixin, ToolbarMenuItem):
+ """Image map paragraph add menu"""
+
+ label = _("Add image map...")
+ label_css_class = 'fa fa-fw fa-location-arrow'
+ url = 'add-imagemap-paragraph.html'
+ modal_target = True
+
+
+@pagelet_config(name='add-imagemap-paragraph.html', context=IParagraphContainerTarget, layer=IPyAMSLayer,
+ permission=MANAGE_CONTENT_PERMISSION)
+class ImagemapParagraphAddForm(AdminDialogAddForm):
+ """Image map paragraph add form"""
+
+ legend = _("Add new image map")
+ icon_css_class = 'fa fa-fw fa-location-arrow'
+
+ fields = field.Fields(IImageMapParagraph).omit('__parent__', '__name__', 'visible')
+ ajax_handler = 'add-imagemap-paragraph.json'
+ edit_permission = MANAGE_CONTENT_PERMISSION
+
+ def create(self, data):
+ return ImageMapParagraph()
+
+ def add(self, object):
+ IParagraphContainer(self.context).append(object)
+
+
+@view_config(name='add-imagemap-paragraph.json', context=IParagraphContainerTarget, request_type=IPyAMSLayer,
+ permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
+class ImagemapParagraphAJAXAddForm(BaseParagraphAJAXAddForm, ImagemapParagraphAddForm):
+ """Image map paragraph add form, JSON renderer"""
+
+
+@pagelet_config(name='properties.html', context=IImageMapParagraph, layer=IPyAMSLayer,
+ permission=MANAGE_CONTENT_PERMISSION)
+class ImagemapParagraphPropertiesEditForm(AdminDialogEditForm):
+ """Image map paragraph edit form"""
+
+ @property
+ def title(self):
+ content = get_parent(self.context, IWfSharedContent)
+ return II18n(content).query_attribute('title', request=self.request)
+
+ legend = _("Edit paragraph properties")
+ icon_css_class = 'fa fa-fw fa-location-arrow'
+
+ fields = field.Fields(IImageMapParagraph).omit('__parent__', '__name__', 'visible')
+ ajax_handler = 'properties.json'
+ edit_permission = MANAGE_CONTENT_PERMISSION
+
+
+@view_config(name='properties.json', context=IImageMapParagraph, request_type=IPyAMSLayer,
+ permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
+class ImagemapParagrahPropertiesAJAXEditForm(BaseParagraphAJAXEditForm, ImagemapParagraphPropertiesEditForm):
+ """Image map properties edit form, JSON renderer"""
+
+
+@adapter_config(context=(IImageMapParagraph, IPyAMSLayer), provides=IParagraphInnerEditor)
+@implementer(IInnerForm)
+class ImagemapParagraphInnerEditForm(ImagemapParagraphPropertiesEditForm):
+ """Image map properties inner edit form"""
+
+ legend = None
+ ajax_handler = 'inner-properties.json'
+
+ @property
+ def buttons(self):
+ if self.mode == INPUT_MODE:
+ return button.Buttons(IEditFormButtons)
+ else:
+ return button.Buttons()
+
+
+@view_config(name='inner-properties.json', context=IImageMapParagraph, request_type=IPyAMSLayer,
+ permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
+class ImagemapParagraphInnerAJAXEditForm(BaseParagraphAJAXEditForm, ImagemapParagraphInnerEditForm):
+ """Image map paragraph properties inner edit form, JSON rendener"""