Added prompt to content datatype widget
authorThierry Florac <thierry.florac@onf.fr>
Thu, 06 Sep 2018 08:54:37 +0200
changeset 925 9c8e01516f97
parent 924 e33b18ba971b
child 926 9f9ffb0be25d
Added prompt to content datatype widget
src/pyams_content/shared/common/zmi/types.py
--- a/src/pyams_content/shared/common/zmi/types.py	Wed Sep 05 16:23:00 2018 +0200
+++ b/src/pyams_content/shared/common/zmi/types.py	Thu Sep 06 08:54:37 2018 +0200
@@ -16,32 +16,36 @@
 # import standard library
 import json
 
+from pyramid.decorator import reify
+from pyramid.events import subscriber
+from pyramid.exceptions import NotFound
+from pyramid.view import view_config
+from z3c.form import field
+from z3c.form.interfaces import DISPLAY_MODE, IDataExtractedEvent
+from z3c.table.interfaces import IValues, IColumn
+from zope.interface import Invalid
+
+from pyams_content import _
 # import interfaces
 from pyams_content.interfaces import MANAGE_TOOL_PERMISSION, MANAGE_CONTENT_PERMISSION
+# import packages
+from pyams_content.reference.pictograms.zmi.widget import PictogramSelectFieldWidget
 from pyams_content.shared.common.interfaces.types import ITypedSharedTool, ITypedDataManager, \
     IBaseDataType, IDataType, ISubType, IWfTypedSharedContent
-from pyams_content.skin import pyams_content
-from pyams_i18n.interfaces import II18n
-from pyams_skin.interfaces.container import ITableElementName
-from pyams_skin.interfaces.viewlet import IWidgetTitleViewletManager
-from pyams_skin.layer import IPyAMSLayer
-from pyams_viewlet.interfaces import IViewletManager
-from pyams_zmi.interfaces.menu import IPropertiesMenu
-from pyams_zmi.layer import IAdminLayer
-from z3c.form.interfaces import DISPLAY_MODE, IDataExtractedEvent
-from z3c.table.interfaces import IValues, IColumn
-
-# import packages
-from pyams_content.reference.pictograms.zmi.widget import PictogramSelectFieldWidget
 from pyams_content.shared.common.types import DataType, SubType
 from pyams_content.shared.common.zmi import SharedContentAddForm
 from pyams_content.shared.common.zmi.properties import SharedContentPropertiesEditForm
+from pyams_content.skin import pyams_content
 from pyams_form.form import AJAXAddForm, ajax_config
 from pyams_form.security import ProtectedFormObjectMixin
+from pyams_i18n.interfaces import II18n
 from pyams_i18n.widget import I18nSEOTextLineFieldWidget
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.container import delete_container_element
 from pyams_skin.event import get_json_table_refresh_event
+from pyams_skin.interfaces.container import ITableElementName
+from pyams_skin.interfaces.viewlet import IWidgetTitleViewletManager
+from pyams_skin.layer import IPyAMSLayer
 from pyams_skin.table import BaseTable, SorterColumn, TrashColumn, NameColumn, ActionColumn
 from pyams_skin.viewlet.menu import MenuItem
 from pyams_skin.viewlet.toolbar import ToolbarAction
@@ -50,17 +54,12 @@
 from pyams_utils.traversing import get_parent
 from pyams_utils.unicode import translate_string
 from pyams_utils.url import absolute_url
+from pyams_viewlet.interfaces import IViewletManager
 from pyams_viewlet.viewlet import viewlet_config
 from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
+from pyams_zmi.interfaces.menu import IPropertiesMenu
+from pyams_zmi.layer import IAdminLayer
 from pyams_zmi.view import ContainerAdminView
-from pyramid.decorator import reify
-from pyramid.events import subscriber
-from pyramid.exceptions import NotFound
-from pyramid.view import view_config
-from z3c.form import field
-from zope.interface import Invalid
-
-from pyams_content import _
 
 
 @viewlet_config(name='data-types.menu', context=ITypedSharedTool, layer=IAdminLayer,
@@ -567,6 +566,12 @@
 
     fields = field.Fields(IWfTypedSharedContent).select('title', 'data_type', 'notepad')
 
+    def updateWidgets(self, prefix=None):
+        super(TypedSharedContentAddForm, self).updateWidgets(prefix)
+        if 'data_type' in self.widgets:
+            self.widgets['data_type'].prompt = True
+            self.widgets['data_type'].promptMessage = _("Select content type...")
+
 
 @pagelet_config(name='properties.html', context=IWfTypedSharedContent, layer=IPyAMSLayer,
                 permission=MANAGE_CONTENT_PERMISSION)