Added custom label to contact card link button
authorThierry Florac <thierry.florac@onf.fr>
Tue, 20 Nov 2018 15:40:17 +0100
changeset 239 a6429e91f091
parent 236 829f481fe2a6 (current diff)
parent 238 df8da54d790a (diff)
child 240 00334308efd4
Added custom label to contact card link button
docs/HISTORY.txt
src/pyams_default_theme/component/paragraph/interfaces/contact.py
src/pyams_default_theme/component/paragraph/templates/contact-default.pt
--- a/docs/HISTORY.txt	Tue Nov 20 09:13:12 2018 +0100
+++ b/docs/HISTORY.txt	Tue Nov 20 15:40:17 2018 +0100
@@ -1,6 +1,10 @@
 History
 =======
 
+0.1.17
+------
+ - added customizable label to contact button
+
 0.1.16
 ------
  - added results internal OID into view's preview
--- a/src/pyams_default_theme/component/paragraph/contact.py	Tue Nov 20 09:13:12 2018 +0100
+++ b/src/pyams_default_theme/component/paragraph/contact.py	Tue Nov 20 15:40:17 2018 +0100
@@ -43,6 +43,7 @@
     photo_position = FieldProperty(IContactParagraphDefaultRendererSettings['photo_position'])
     display_map = FieldProperty(IContactParagraphDefaultRendererSettings['display_map'])
     map_position = FieldProperty(IContactParagraphDefaultRendererSettings['map_position'])
+    button_label = FieldProperty(IContactParagraphDefaultRendererSettings['button_label'])
 
     @property
     def can_display_photo(self):
--- a/src/pyams_default_theme/component/paragraph/interfaces/contact.py	Tue Nov 20 09:13:12 2018 +0100
+++ b/src/pyams_default_theme/component/paragraph/interfaces/contact.py	Tue Nov 20 15:40:17 2018 +0100
@@ -12,15 +12,11 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
-
-# import interfaces
+from zope.interface import Attribute, Interface
+from zope.schema import Bool, Choice
+from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
 
-# import packages
-from zope.interface import Interface, Attribute
-from zope.schema import Bool, Choice
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
+from pyams_i18n.schema import I18nTextLineField
 
 from pyams_default_theme import _
 
@@ -60,3 +56,8 @@
                           default='right')
 
     can_display_map = Attribute("Check if location map can be displayed")
+
+    button_label = I18nTextLineField(title=_("Contact button label"),
+                                     description=_("Custom label of the contact button displayed by "
+                                                   "front-office template"),
+                                     required=False)
--- a/src/pyams_default_theme/component/paragraph/templates/contact-default.pt	Tue Nov 20 09:13:12 2018 +0100
+++ b/src/pyams_default_theme/component/paragraph/templates/contact-default.pt	Tue Nov 20 15:40:17 2018 +0100
@@ -23,8 +23,9 @@
 		</div>
 		<tal:if condition="view.contact_email">
 			<span i18n:translate="">Contact email:</span>
-			<a href="mailto:${view.contact_email}">
-				${view.contact_email}
+			<a tal:define="buttom_label i18n:settings.button_label"
+			   href="mailto:${view.contact_email}?subject=${view.title}">
+				${button_label or view.contact_email}
 			</a><br />
 		</tal:if>
 		<tal:if condition="view.phone_number">