Skip to content

Commit 10d9f45

Browse files
committed
extra_class field for each row
1 parent 8bd7090 commit 10d9f45

File tree

5 files changed

+60
-6
lines changed

5 files changed

+60
-6
lines changed

src/cs_dynamicpages/behaviors/configure.zcml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
marker=".row_width.IRowWidthMarker"
2323
/>
2424

25+
<plone:behavior
26+
name="cs_dynamicpages.extra_class"
27+
title="ExtraClass"
28+
description="This behavior provides..."
29+
factory=".extra_class.ExtraClass"
30+
provides=".extra_class.IExtraClass"
31+
marker=".extra_class.IExtraClassMarker"
32+
/>
33+
2534

2635
<plone:behavior
2736
name="cs_dynamicpages.row_columns"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from plone import schema
2+
from plone.autoform.interfaces import IFormFieldProvider
3+
from plone.supermodel import model
4+
from Products.CMFPlone.utils import safe_hasattr
5+
from zope.component import adapter
6+
from zope.interface import implementer
7+
from zope.interface import Interface
8+
from zope.interface import provider
9+
10+
11+
class IExtraClassMarker(Interface):
12+
pass
13+
14+
15+
@provider(IFormFieldProvider)
16+
class IExtraClass(model.Schema):
17+
""" """
18+
19+
extra_class = schema.TextLine(
20+
title="Extra class for row",
21+
required=False,
22+
23+
)
24+
25+
26+
@implementer(IExtraClass)
27+
@adapter(IExtraClassMarker)
28+
class ExtraClass:
29+
def __init__(self, context):
30+
self.context = context
31+
32+
@property
33+
def extra_class(self):
34+
if safe_hasattr(self.context, "extra_class"):
35+
return self.context.extra_class
36+
return None
37+
38+
@extra_class.setter
39+
def extra_class(self, value):
40+
self.context.extra_class = value

src/cs_dynamicpages/controlpanels/dynamic_pages_control_panel/controlpanel.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class IDynamicPagesControlPanel(Interface):
5959
"IBasic.title",
6060
"IBasic.description",
6161
"IRowWidth.width",
62+
"IExtraClass.extra_class",
6263
"IRelatedImage.related_image",
6364
"IRelatedImage.image_position",
6465
"ILinkInfo.link_text",
@@ -72,6 +73,7 @@ class IDynamicPagesControlPanel(Interface):
7273
"IBasic.title",
7374
"IBasic.description",
7475
"IRowWidth.width",
76+
"IExtraClass.extra_class",
7577
"IRelatedImage.related_image",
7678
"IRelatedImage.image_position",
7779
"ILinkInfo.link_text",
@@ -81,34 +83,35 @@ class IDynamicPagesControlPanel(Interface):
8183
},
8284
{
8385
"row_type": "cs_dynamicpages-horizontal-rule-view",
84-
"each_row_type_fields": ["IBasic.title", "IRowWidth.width"],
86+
"each_row_type_fields": ["IBasic.title", "IRowWidth.width", "IExtraClass.extra_class",],
8587
"row_type_has_featured_add_button": False,
8688
},
8789
{
8890
"row_type": "cs_dynamicpages-spacer-view",
89-
"each_row_type_fields": ["IBasic.title"],
91+
"each_row_type_fields": ["IBasic.title", "IExtraClass.extra_class",],
9092
"row_type_has_featured_add_button": False,
9193
},
9294
{
9395
"row_type": "cs_dynamicpages-slider-view",
94-
"each_row_type_fields": ["IBasic.title", "IRowWidth.width"],
96+
"each_row_type_fields": ["IBasic.title", "IRowWidth.width", "IExtraClass.extra_class",],
9597
"row_type_has_featured_add_button": True,
9698
},
9799
{
98100
"row_type": "cs_dynamicpages-features-view",
99-
"each_row_type_fields": ["IBasic.title", "IRowWidth.width"],
101+
"each_row_type_fields": ["IBasic.title", "IRowWidth.width", "IExtraClass.extra_class",],
100102
"row_type_has_featured_add_button": True,
101103
},
102104
{
103105
"row_type": "cs_dynamicpages-accordion-view",
104-
"each_row_type_fields": ["IBasic.title", "IRowWidth.width"],
106+
"each_row_type_fields": ["IBasic.title", "IRowWidth.width", "IExtraClass.extra_class",],
105107
"row_type_has_featured_add_button": True,
106108
},
107109
{
108110
"row_type": "cs_dynamicpages-query-columns-view",
109111
"each_row_type_fields": [
110112
"IBasic.title",
111113
"IRowWidth.width",
114+
"IExtraClass.extra_class",
112115
"ICollection.query",
113116
"ICollection.sort_on",
114117
"ICollection.sort_order",
@@ -123,6 +126,7 @@ class IDynamicPagesControlPanel(Interface):
123126
"each_row_type_fields": [
124127
"IBasic.title",
125128
"IRowWidth.width",
129+
"IExtraClass.extra_class",
126130
"IRichTextBehavior-text",
127131
],
128132
"row_type_has_featured_add_button": False,

src/cs_dynamicpages/profiles/default/types/DynamicPageRow.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<element value="cs_dynamicpages.related_image" />
5252
<element value="cs_dynamicpages.row_columns" />
5353
<element value="cs_dynamicpages.row_width" />
54+
<element value="cs_dynamicpages.extra_class" />
5455
<element value="plone.collection" />
5556
<element value="plone.constraintypes" />
5657
<!--<element value="plone.leadimage"/>-->

src/cs_dynamicpages/views/dynamic_view.pt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
rows view/rows;
2222
">
2323
<tal:featured repeat="brain rows">
24-
<section class="dynamic-row ${row/row_template} state-${row/review_state}" id="${row/id}"
24+
<section class="dynamic-row ${row/row_template} state-${row/review_state} ${row/extra_class}" id="${row/id}"
2525
data-delete-target="true" data-elementid="${row/id}" data-elementurl="${row/absolute_url}"
2626
data-move-target="true" data-parenturl="${row/aq_parent/absolute_url}" tal:define="
2727
row brain/getObject;

0 commit comments

Comments
 (0)