--- a/src/pyams_content/shared/imagemap/__init__.py Wed Sep 13 11:39:37 2017 +0200
+++ b/src/pyams_content/shared/imagemap/__init__.py Wed Sep 13 12:28:47 2017 +0200
@@ -9,6 +9,7 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
+from pyams_content.component.association.interfaces import IAssociationContainer
__docformat__ = 'restructuredtext'
@@ -87,6 +88,10 @@
del self.areas[key]
get_current_registry().notify(ObjectModifiedEvent(self))
+ def get_association(self, area):
+ return IAssociationContainer(self).get(area.link)
+
+
register_content_type(WfImageMap)
--- a/src/pyams_content/shared/imagemap/interfaces/__init__.py Wed Sep 13 11:39:37 2017 +0200
+++ b/src/pyams_content/shared/imagemap/interfaces/__init__.py Wed Sep 13 12:28:47 2017 +0200
@@ -67,6 +67,9 @@
value_type=Object(schema=IImageMapArea),
required=False)
+ def get_association(self, area):
+ """Get asociation for given area"""
+
class IImageMap(ISharedContent):
"""Workflow managed image map interface"""
--- a/src/pyams_content/shared/imagemap/zmi/paragraph.py Wed Sep 13 11:39:37 2017 +0200
+++ b/src/pyams_content/shared/imagemap/zmi/paragraph.py Wed Sep 13 12:28:47 2017 +0200
@@ -16,7 +16,9 @@
# import standard library
# import interfaces
-from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
+from pyams_content.component.association.interfaces import IAssociationContainer, IAssociationInfo
+from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer, \
+ IParagraphSummary
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
@@ -34,9 +36,10 @@
from pyams_form.security import ProtectedFormObjectMixin
from pyams_pagelet.pagelet import pagelet_config
from pyams_skin.viewlet.toolbar import ToolbarMenuItem
+from pyams_template.template import template_config, get_view_template
from pyams_utils.adapter import adapter_config
from pyams_utils.traversing import get_parent
-from pyams_viewlet.viewlet import viewlet_config
+from pyams_viewlet.viewlet import viewlet_config, BaseContentProvider
from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
from pyramid.view import view_config
from z3c.form import field, button
@@ -125,3 +128,18 @@
permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
class ImagemapParagraphInnerAJAXEditForm(BaseParagraphAJAXEditForm, ImagemapParagraphInnerEditForm):
"""Image map paragraph properties inner edit form, JSON rendener"""
+
+
+#
+# Image map paragraph summary
+#
+
+@adapter_config(context=(IImageMapParagraph, IPyAMSLayer), provides=IParagraphSummary)
+@template_config(template='templates/paragraph-summary.pt', layer=IPyAMSLayer)
+class ImagemapParagraphSummary(BaseContentProvider):
+ """Image map paragraph summary"""
+
+ language = None
+
+ def get_item_info(self, item):
+ return IAssociationInfo(item, None)
--- a/src/pyams_content/shared/imagemap/zmi/summary.py Wed Sep 13 11:39:37 2017 +0200
+++ b/src/pyams_content/shared/imagemap/zmi/summary.py Wed Sep 13 12:28:47 2017 +0200
@@ -52,10 +52,5 @@
class ImagemapSummaryView(object):
"""Image map summary view"""
- def get_item(self, area):
- """Get URL of given link"""
- item = IAssociationContainer(self.context).get(area.link)
- return item if (item is not None and item.visible) else None
-
def get_item_info(self, item):
return IAssociationInfo(item, None)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/imagemap/zmi/templates/paragraph-summary.pt Wed Sep 13 12:28:47 2017 +0200
@@ -0,0 +1,26 @@
+<div class="no-padding" i18n:domain="pyams_content"
+ data-ams-plugins="pyams_content"
+ tal:define="imagemap context.get_target()"
+ tal:attributes="data-ams-plugin-pyams_content-src extension:resource_path('pyams_content.skin:pyams_content')">
+ <img usemap="#imagemap_summary"
+ tal:define="image i18n:imagemap.image"
+ tal:attributes="src extension:absolute_url(image);
+ usemap string:#imagemap_summary_${context.__name__}"
+ data-ams-callback="PyAMS_content.imgmap.initSummary" />
+ <map name="imagemap_summary"
+ tal:attributes="name string:imagemap_summary_${context.__name__}">
+ <tal:loop repeat="area imagemap.areas.values()">
+ <tal:var define="item imagemap.get_association(area)"
+ condition="item and item.visible">
+ <area shape="poly"
+ tal:define="info view.get_item_info(item);
+ area_title i18n:area.title;
+ item_title i18n:info.user_title;
+ title area_title or item_title;"
+ tal:attributes="coords area.area;
+ href item.get_url(request);
+ title title;" />
+ </tal:var>
+ </tal:loop>
+ </map>
+</div>
--- a/src/pyams_content/shared/imagemap/zmi/templates/summary.pt Wed Sep 13 11:39:37 2017 +0200
+++ b/src/pyams_content/shared/imagemap/zmi/templates/summary.pt Wed Sep 13 12:28:47 2017 +0200
@@ -10,8 +10,8 @@
data-ams-callback="PyAMS_content.imgmap.initSummary" />
<map name="imagemap_preview">
<tal:loop repeat="area context.areas.values()">
- <tal:var define="item view.get_item(area)"
- condition="item">
+ <tal:var define="item context.get_association(area)"
+ condition="item and item.visible">
<area shape="poly"
tal:define="info view.get_item_info(item);
area_title i18n:area.title;