Skip to content
This repository was archived by the owner on Apr 23, 2026. It is now read-only.

Commit bd2db1b

Browse files
authored
Merge pull request #214 from eea/develop
Community: Add custom CSS to a widget
2 parents 2ca7c5f + e51ebf3 commit bd2db1b

12 files changed

Lines changed: 55 additions & 6 deletions

File tree

docs/HISTORY.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
14.4 - (2021-02-11)
5+
---------------------------
6+
* Feature: Add custom CSS class to a widget css classes
7+
[balavec]
8+
49
14.3 (2020-10-16)
510
---------------------------
611
* Change: Trigger FacetedSettingsWillBeChangedEvent before faceted settings change

eea/facetednavigation/browser/template/default.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<property name="position">right</property>
88
<property name="section">default</property>
99
<property name="hidden">True</property>
10+
<property name="custom_css"></property>
1011
<property name="start">0</property>
1112
<property name="end">20</property>
1213
<property name="step">5</property>
@@ -18,6 +19,7 @@
1819
<property name="position">right</property>
1920
<property name="section">default</property>
2021
<property name="hidden">False</property>
22+
<property name="custom_css"></property>
2123
<property name="index">portal_type</property>
2224
<property
2325
name="vocabulary">eea.faceted.vocabularies.FacetedPortalTypes</property>
@@ -36,6 +38,7 @@
3638
<property name="position">right</property>
3739
<property name="section">default</property>
3840
<property name="hidden">True</property>
41+
<property name="custom_css"></property>
3942
<property name="vocabulary"></property>
4043
<property name="default">effective(reverse)</property>
4144
</criterion>
@@ -45,6 +48,7 @@
4548
<property name="position">center</property>
4649
<property name="section">default</property>
4750
<property name="hidden">False</property>
51+
<property name="custom_css"></property>
4852
</criterion>
4953
</criteria>
5054
</object>

eea/facetednavigation/docs/browser.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ Edit (no AJAX)
211211
<property name="position">top</property>
212212
<property name="section">default</property>
213213
<property name="hidden">False</property>
214+
<property name="custom_css"></property>
214215
<property name="count">False</property>
215216
<property name="cloud">sphere</property>
216217
</criterion>
@@ -226,6 +227,7 @@ Edit (no AJAX)
226227
<property name="position">left</property>
227228
<property name="section">default</property>
228229
<property name="hidden">True</property>
230+
<property name="custom_css"></property>
229231
<property name="count">True</property>
230232
</criterion>
231233
</criteria>

eea/facetednavigation/docs/exportimport.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Checkboxes
8686
<property name="position">left</property>
8787
<property name="section">default</property>
8888
<property name="hidden">False</property>
89+
<property name="custom_css"></property>
8990
<property name="count">True</property>
9091
</criterion>
9192
<criterion name="c1">
@@ -96,6 +97,7 @@ Checkboxes
9697
<property name="position">right</property>
9798
<property name="section">default</property>
9899
<property name="hidden">False</property>
100+
<property name="custom_css"></property>
99101
<property name="count">False</property>
100102
<property name="cloud">sphere</property>
101103
<property name="sizemin">15</property>
@@ -144,6 +146,7 @@ Let's check exported
144146
<property name="position">left</property>
145147
<property name="section">default</property>
146148
<property name="hidden">False</property>
149+
<property name="custom_css"></property>
147150
<property name="count">True</property>
148151
</criterion>
149152
<criterion name="c1">
@@ -154,6 +157,7 @@ Let's check exported
154157
<property name="position">right</property>
155158
<property name="section">default</property>
156159
<property name="hidden">False</property>
160+
<property name="custom_css"></property>
157161
<property name="count">False</property>
158162
<property name="cloud">sphere</property>
159163
<property name="sizemin">15</property>
@@ -198,6 +202,7 @@ Check configuration
198202
<property name="position">right</property>
199203
<property name="section">default</property>
200204
<property name="hidden">False</property>
205+
<property name="custom_css"></property>
201206
<property name="count">False</property>
202207
<property name="cloud">sphere</property>
203208
<property name="sizemin">15</property>
@@ -226,6 +231,7 @@ Now update it
226231
<property name="position">left</property>
227232
<property name="section">default</property>
228233
<property name="hidden">False</property>
234+
<property name="custom_css"></property>
229235
<property name="count">True</property>
230236
</criterion>
231237
<criterion name="c1">
@@ -236,6 +242,7 @@ Now update it
236242
<property name="position">right</property>
237243
<property name="section">default</property>
238244
<property name="hidden">False</property>
245+
<property name="custom_css"></property>
239246
<property name="count">False</property>
240247
<property name="cloud">sphere</property>
241248
<property name="sizemin">15</property>
@@ -294,6 +301,7 @@ Let's see our new configuration
294301
<property name="position">top</property>
295302
<property name="section">default</property>
296303
<property name="hidden">False</property>
304+
<property name="custom_css"></property>
297305
<property name="count">False</property>
298306
<property name="cloud">sphere</property>
299307
</criterion>
@@ -309,6 +317,7 @@ Let's see our new configuration
309317
<property name="position">left</property>
310318
<property name="section">default</property>
311319
<property name="hidden">True</property>
320+
<property name="custom_css"></property>
312321
<property name="count">True</property>
313322
</criterion>
314323
</criteria>
@@ -345,6 +354,7 @@ Import a xml file with purge set to False, new criteria will be added to existin
345354
<property name="position">top</property>
346355
<property name="section">default</property>
347356
<property name="hidden">False</property>
357+
<property name="custom_css"></property>
348358
<property name="count">False</property>
349359
<property name="cloud">sphere</property>
350360
</criterion>
@@ -356,6 +366,7 @@ Import a xml file with purge set to False, new criteria will be added to existin
356366
<property name="position">top</property>
357367
<property name="section">advanced</property>
358368
<property name="hidden">False</property>
369+
<property name="custom_css"></property>
359370
<property name="calYearRange">c-10:c+10</property>
360371
</criterion>
361372
<criterion name="c7">
@@ -370,6 +381,7 @@ Import a xml file with purge set to False, new criteria will be added to existin
370381
<property name="position">left</property>
371382
<property name="section">default</property>
372383
<property name="hidden">True</property>
384+
<property name="custom_css"></property>
373385
<property name="count">True</property>
374386
</criterion>
375387
</criteria>
@@ -402,6 +414,7 @@ Importing an already existing criterion will not fail, it is just ignored and a
402414
<property name="position">top</property>
403415
<property name="section">default</property>
404416
<property name="hidden">False</property>
417+
<property name="custom_css"></property>
405418
<property name="count">False</property>
406419
<property name="cloud">sphere</property>
407420
</criterion>
@@ -413,6 +426,7 @@ Importing an already existing criterion will not fail, it is just ignored and a
413426
<property name="position">top</property>
414427
<property name="section">advanced</property>
415428
<property name="hidden">False</property>
429+
<property name="custom_css"></property>
416430
<property name="calYearRange">c-10:c+10</property>
417431
</criterion>
418432
<criterion name="c7">
@@ -427,6 +441,7 @@ Importing an already existing criterion will not fail, it is just ignored and a
427441
<property name="position">left</property>
428442
<property name="section">default</property>
429443
<property name="hidden">True</property>
444+
<property name="custom_css"></property>
430445
<property name="count">True</property>
431446
</criterion>
432447
</criteria>
@@ -458,6 +473,7 @@ Import a xml file with purge set to True (default), existing criteria are remove
458473
<property name="position">top</property>
459474
<property name="section">advanced</property>
460475
<property name="hidden">False</property>
476+
<property name="custom_css"></property>
461477
<property name="calYearRange">c-10:c+10</property>
462478
</criterion>
463479
</criteria>
@@ -489,6 +505,7 @@ Import a xml file with criterion purge set to False, existing criterion is left
489505
<property name="position">top</property>
490506
<property name="section">advanced</property>
491507
<property name="hidden">False</property>
508+
<property name="custom_css"></property>
492509
<property name="calYearRange">c-10:c+10</property>
493510
</criterion>
494511
</criteria>
@@ -520,6 +537,7 @@ Import a xml file with criterion purge set to True, existing criterion is remove
520537
<property name="position">top</property>
521538
<property name="section">advanced</property>
522539
<property name="hidden">False</property>
540+
<property name="custom_css"></property>
523541
<property name="calYearRange">c-20:c+20</property>
524542
</criterion>
525543
</criteria>

eea/facetednavigation/tests/data/exportimport.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<property name="widget">checkbox</property>
66
<property name="position">left</property>
77
<property name="hidden">True</property>
8+
<property name="custom_css"></property>
89
<property name="title">Type d'element</property>
910
<property name="index">portal_type</property>
1011
<property name="vocabulary"></property>
@@ -18,6 +19,7 @@
1819
<property name="widget">tagscloud</property>
1920
<property name="position">top</property>
2021
<property name="hidden">False</property>
22+
<property name="custom_css"></property>
2123
<property name="title">Meta-type d'element</property>
2224
<property name="index">meta_type</property>
2325
<property name="vocabulary"></property>

eea/facetednavigation/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14.2
1+
14.4

eea/facetednavigation/widgets/boolean/widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def css_class(self):
3030
css_type = self.widget_type
3131
css_title = normalizer.normalize(self.data.title)
3232
return ('faceted-checkboxes-widget '
33-
'faceted-{0}-widget section-{1}').format(css_type, css_title)
33+
'faceted-{0}-widget section-{1}{2}').format(css_type, css_title, self.custom_css)
3434

3535
def selected(self):
3636
""" Return True if True by default

eea/facetednavigation/widgets/checkbox/widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def css_class(self):
3737
css_type = self.widget_type
3838
css_title = normalizer.normalize(self.data.title)
3939
return ('faceted-checkboxes-widget '
40-
'faceted-{0}-widget section-{1}').format(css_type, css_title)
40+
'faceted-{0}-widget section-{1}{2}').format(css_type, css_title, self.custom_css)
4141

4242
@property
4343
def default(self):

eea/facetednavigation/widgets/interfaces.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,20 @@ class ISchema(Interface):
131131
required=False
132132
)
133133

134+
custom_css = schema.TextLine(
135+
title=_(u"Custom CSS"),
136+
description=_(u"Custom CSS class for widget to display in view page"),
137+
required=False
138+
)
139+
custom_css._type = (six.text_type, str)
140+
141+
134142
class FacetedSchemata(group.Group):
135143
""" Faceted Schemata
136144
"""
137145
prefix = 'faceted'
138146

147+
139148
class DefaultSchemata(FacetedSchemata):
140149
""" Schemata default
141150
"""
@@ -154,7 +163,8 @@ class LayoutSchemata(FacetedSchemata):
154163
fields = field.Fields(ISchema).select(
155164
u'position',
156165
u'section',
157-
u'hidden'
166+
u'hidden',
167+
u'custom_css'
158168
)
159169

160170

eea/facetednavigation/widgets/multiselect/widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def css_class(self):
3737
css_type = self.widget_type
3838
css_title = normalizer.normalize(self.data.title)
3939
return ('faceted-multiselect-widget '
40-
'faceted-{0}-widget section-{1}').format(css_type, css_title)
40+
'faceted-{0}-widget section-{1}{2}').format(css_type, css_title, self.custom_css)
4141

4242
@property
4343
def default(self):

0 commit comments

Comments
 (0)