Pictograms updates
authorThierry Florac <thierry.florac@onf.fr>
Thu, 05 Apr 2018 15:30:06 +0200
changeset 516 a3f26cfd3094
parent 515 a1d5eb955e54
child 517 542aebe1bb4a
Pictograms updates
src/pyams_content/component/paragraph/interfaces/pictogram.py
src/pyams_content/component/paragraph/zmi/pictogram.py
src/pyams_content/reference/pictograms/__init__.py
src/pyams_content/reference/pictograms/interfaces/__init__.py
src/pyams_content/reference/pictograms/zmi/__init__.py
src/pyams_content/reference/pictograms/zmi/templates/manager-selection.pt
--- a/src/pyams_content/component/paragraph/interfaces/pictogram.py	Wed Apr 04 15:35:44 2018 +0200
+++ b/src/pyams_content/component/paragraph/interfaces/pictogram.py	Thu Apr 05 15:30:06 2018 +0200
@@ -51,8 +51,8 @@
 
     pictogram = Attribute("Select pictogram object")
 
-    label = I18nTextLineField(title=_("Alternate label"),
-                              description=_("Alternate pictogram label; if not specified, the pictogram title "
+    label = I18nTextLineField(title=_("Alternate header"),
+                              description=_("Alternate pictogram label; if not specified, the pictogram header "
                                             "will be used"),
                               required=False)
 
--- a/src/pyams_content/component/paragraph/zmi/pictogram.py	Wed Apr 04 15:35:44 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/pictogram.py	Thu Apr 05 15:30:06 2018 +0200
@@ -35,6 +35,7 @@
 from z3c.table.interfaces import IValues, IColumn
 
 # import packages
+from pyams_content.component.paragraph import BaseParagraph
 from pyams_content.component.paragraph.pictogram import PictogramParagraph, PictogramItem
 from pyams_content.component.paragraph.zmi import BaseParagraphAddMenu, BaseParagraphAJAXAddForm, \
     BaseParagraphPropertiesEditForm, BaseParagraphAJAXEditForm
@@ -269,7 +270,7 @@
         if pictogram is not None:
             image = II18n(pictogram).query_attribute('image', request=self.request)
             if image:
-                return '<img src="{0}" />'.format(absolute_url(image, self.request, '++thumb++32x32'))
+                return '<img src="{0}" />'.format(absolute_url(image, self.request, '++thumb++48x48'))
         return '--'
 
 
@@ -318,29 +319,29 @@
 class PictogramsTableNameColumn(I18nColumn, I18nAttrColumn):
     """Pictograms table name column"""
 
-    _header = _("Label")
+    _header = _("pictogram-item-header", default="Header")
     attrName = 'label'
     weight = 10
 
     def getValue(self, obj):
         value = super(PictogramsTableNameColumn, self).getValue(obj)
         if not value:
-            value = II18n(obj.pictogram).query_attribute('title', request=self.request)
-        return value
+            value = II18n(obj.pictogram).query_attribute('header', request=self.request)
+        return value or BaseParagraph.empty_title
 
 
 @adapter_config(name='body', context=(IPictogramContainerTarget, IPyAMSLayer, PictogramsTable), provides=IColumn)
 class PictogramsTableBodyColumn(I18nColumn, I18nAttrColumn):
     """Pictograms table body column"""
 
-    _header = _("Body")
+    _header = _("Associated text")
     attrName = 'body'
     weight = 20
 
     def getValue(self, obj):
         value = super(PictogramsTableBodyColumn, self).getValue(obj)
         if not value:
-            return '--'
+            return BaseParagraph.empty_title
         return get_text_start(value, 40, 10)
 
 
--- a/src/pyams_content/reference/pictograms/__init__.py	Wed Apr 04 15:35:44 2018 +0200
+++ b/src/pyams_content/reference/pictograms/__init__.py	Thu Apr 05 15:30:06 2018 +0200
@@ -30,6 +30,7 @@
 from pyams_utils.vocabulary import vocabulary_config
 from pyramid.events import subscriber
 from zope.interface import implementer
+from zope.schema.fieldproperty import FieldProperty
 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 
@@ -52,6 +53,8 @@
     """Pictogram persistent class"""
 
     image = I18nFileProperty(IPictogram['image'])
+    alt_title = FieldProperty(IPictogram['alt_title'])
+    header = FieldProperty(IPictogram['header'])
 
 
 @vocabulary_config(name=PICTOGRAM_VOCABULARY)
--- a/src/pyams_content/reference/pictograms/interfaces/__init__.py	Wed Apr 04 15:35:44 2018 +0200
+++ b/src/pyams_content/reference/pictograms/interfaces/__init__.py	Thu Apr 05 15:30:06 2018 +0200
@@ -20,7 +20,7 @@
 from zope.annotation.interfaces import IAttributeAnnotatable
 
 # import packages
-from pyams_i18n.schema import I18nImageField
+from pyams_i18n.schema import I18nImageField, I18nTextLineField
 from zope.container.constraints import containers, contains
 from zope.interface import Interface
 from zope.schema import List, Choice
@@ -45,6 +45,14 @@
                            description=_("Pictogram content"),
                            required=True)
 
+    alt_title = I18nTextLineField(title=_("Accessibility title"),
+                                  description=_("Alternate title used to describe image content"),
+                                  required=False)
+
+    header = I18nTextLineField(title=_('pictogram-header', default="Header"),
+                               description=_("Default header associated with this pictogram"),
+                               required=False)
+
 
 class IPictogramTable(IReferenceTable):
     """Pictograms table interface"""
--- a/src/pyams_content/reference/pictograms/zmi/__init__.py	Wed Apr 04 15:35:44 2018 +0200
+++ b/src/pyams_content/reference/pictograms/zmi/__init__.py	Thu Apr 05 15:30:06 2018 +0200
@@ -65,6 +65,7 @@
     """Pictogram add form"""
 
     legend = _("Add new pictogram")
+    dialog_class = 'modal-large'
 
     fields = field.Fields(IPictogram).omit('__parent__', '__name__')
     ajax_handler = 'add-pictogram.json'
--- a/src/pyams_content/reference/pictograms/zmi/templates/manager-selection.pt	Wed Apr 04 15:35:44 2018 +0200
+++ b/src/pyams_content/reference/pictograms/zmi/templates/manager-selection.pt	Thu Apr 05 15:30:06 2018 +0200
@@ -13,10 +13,18 @@
 				 tal:repeat="pictogram view.available_pictograms">
 				<input type="hidden" name="form.widgets.selected_pictograms:list"
 					   tal:attributes="value pictogram.__name__" />
-				<div class="width-50 text-center pull-left">
+				<div class="pull-right margin-right-5">
+					<a data-toggle="modal"
+					   tal:attributes="data-ams-url extension:absolute_url(pictogram, 'properties.html')">
+						<i class="fa fa-fw fa-search hint opaque baseline"
+						   data-ams-hint-gravity="se" data-ams-hint-offset="3"
+						   title="Display pictogram properties" i18n:attributes="title"></i>
+					</a>
+				</div>
+				<div class="width-50 text-center pull-left margin-right-10">
 					<img tal:define="img i18n:pictogram.image"
 						 tal:condition="img"
-						 tal:attributes="src extension:absolute_url(img, '++thumb++32x32')" />
+						 tal:attributes="src extension:absolute_url(img, '++thumb++48x48')" />
 				</div>
 				<span tal:content="i18n:pictogram.title">Title</span>
 			</div>
@@ -32,10 +40,18 @@
 				 tal:repeat="pictogram view.selected_pictograms">
 				<input type="hidden" name="form.widgets.selected_pictograms:list"
 					   tal:attributes="value pictogram.__name__" />
-				<div class="width-50 text-center pull-left">
+				<div class="pull-right margin-right-5">
+					<a data-toggle="modal"
+					   tal:attributes="data-ams-url extension:absolute_url(pictogram, 'properties.html')">
+						<i class="fa fa-fw fa-search hint opaque baseline"
+						   data-ams-hint-gravity="se" data-ams-hint-offset="3"
+						   title="Display pictogram properties" i18n:attributes="title"></i>
+					</a>
+				</div>
+				<div class="width-50 text-center pull-left margin-right-10">
 					<img tal:define="img i18n:pictogram.image"
 						 tal:condition="img"
-						 tal:attributes="src extension:absolute_url(img, '++thumb++32x32')" />
+						 tal:attributes="src extension:absolute_url(img, '++thumb++48x48')" />
 				</div>
 				<span tal:content="i18n:pictogram.title">Title</span>
 			</div>