Updated default focus
authorThierry Florac <tflorac@ulthar.net>
Thu, 19 Nov 2020 16:10:44 +0100
changeset 1433 23b4d281e849
parent 1432 4f6eb363c72a
child 1434 13db47aeac34
Updated default focus
src/pyams_content/shared/site/zmi/container.py
--- a/src/pyams_content/shared/site/zmi/container.py	Wed Nov 18 15:15:11 2020 +0100
+++ b/src/pyams_content/shared/site/zmi/container.py	Thu Nov 19 16:10:44 2020 +0100
@@ -10,8 +10,6 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-__docformat__ = 'restructuredtext'
-
 import json
 from datetime import datetime
 
@@ -21,18 +19,20 @@
 from z3c.form import field
 from z3c.table.column import GetAttrColumn
 from z3c.table.interfaces import IColumn, IValues
-from zope.interface import implementer, Interface
+from zope.interface import Interface, alsoProvides, implementer
 from zope.intid.interfaces import IIntIds
 from zope.lifecycleevent import ObjectMovedEvent
 
 from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION, MANAGE_SITE_PERMISSION
 from pyams_content.shared.common.interfaces import ISharedContent, ISharedSite
 from pyams_content.shared.common.interfaces.zmi import IDashboardTable
-from pyams_content.shared.common.zmi.dashboard import SharedToolDashboardOwnerColumn, SharedToolDashboardSequenceColumn, \
-    SharedToolDashboardStatusColumn, SharedToolDashboardStatusDateColumn, SharedToolDashboardStatusPrincipalColumn, \
+from pyams_content.shared.common.zmi.dashboard import SharedToolDashboardOwnerColumn, \
+    SharedToolDashboardSequenceColumn, SharedToolDashboardStatusColumn, \
+    SharedToolDashboardStatusDateColumn, SharedToolDashboardStatusPrincipalColumn, \
     SharedToolDashboardVersionColumn
 from pyams_content.shared.site import WfSiteTopic
-from pyams_content.shared.site.interfaces import IBaseSiteItem, IContentLink, ISiteContainer, ISiteManager, ISiteLink
+from pyams_content.shared.site.interfaces import IBaseSiteItem, IContentLink, ISiteContainer, \
+    ISiteLink, ISiteManager
 from pyams_content.zmi import pyams_content
 from pyams_content.zmi.interfaces import ISiteTreeMenu, ISiteTreeTable, IUserAddingsMenuLabel
 from pyams_form.form import ajax_config
@@ -41,34 +41,39 @@
 from pyams_skin.container import ContainerView, delete_container_element
 from pyams_skin.event import get_json_table_cell_refresh_event
 from pyams_skin.interfaces import IInnerPage, IPageHeader
-from pyams_skin.interfaces.container import ITableElementEditor, ITableElementName, ITableWithActions
+from pyams_skin.interfaces.container import ITableElementEditor, ITableElementName, \
+    ITableWithActions
 from pyams_skin.interfaces.viewlet import IBreadcrumbItem, ITableItemColumnActionsMenu
 from pyams_skin.layer import IPyAMSLayer
 from pyams_skin.page import DefaultPageHeaderAdapter
-from pyams_skin.table import BaseTable, DefaultElementEditorAdapter, I18nColumn, JsActionColumn, NameColumn, \
-    SorterColumn, TrashColumn
+from pyams_skin.table import BaseTable, DefaultElementEditorAdapter, I18nColumn, JsActionColumn, \
+    NameColumn, SorterColumn, TrashColumn
 from pyams_skin.viewlet.breadcrumb import BreadcrumbAdminLayerItem
 from pyams_skin.viewlet.menu import MenuItem
 from pyams_skin.viewlet.toolbar import ToolbarMenuItem
 from pyams_template.template import template_config
-from pyams_utils.adapter import ContextRequestAdapter, ContextRequestViewAdapter, adapter_config, \
-    NullAdapter
+from pyams_utils.adapter import ContextRequestAdapter, ContextRequestViewAdapter, NullAdapter, \
+    adapter_config
 from pyams_utils.date import format_datetime
 from pyams_utils.fanstatic import get_resource_path
 from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+from pyams_utils.interfaces.data import IObjectData
 from pyams_utils.interfaces.traversing import IPathElements
 from pyams_utils.registry import get_utility
 from pyams_utils.timezone import tztime
 from pyams_utils.traversing import get_parent
 from pyams_utils.url import absolute_url
 from pyams_viewlet.manager import viewletmanager_config
-from pyams_viewlet.viewlet import viewlet_config, contentprovider_config
+from pyams_viewlet.viewlet import contentprovider_config, viewlet_config
 from pyams_workflow.interfaces import IWorkflowPublicationInfo, IWorkflowVersions
 from pyams_zmi.form import AdminDialogEditForm
 from pyams_zmi.interfaces.menu import IPropertiesMenu, ISiteManagementMenu
 from pyams_zmi.layer import IAdminLayer
 from pyams_zmi.view import AdminView
 
+
+__docformat__ = 'restructuredtext'
+
 from pyams_content import _
 
 
@@ -185,12 +190,20 @@
                                                            'publication_expiration_date')
     edit_permission = MANAGE_SITE_PERMISSION
 
+    def updateActions(self):
+        super(SiteContainerWorkflowPublicationEditForm, self).updateActions()
+        submit = self.actions.get('submit')
+        if submit is not None:
+            submit.object_data = {'ams-focus-target': 'true'}
+            alsoProvides(submit, IObjectData)
+
     def updateWidgets(self, prefix=None):
         super(SiteContainerWorkflowPublicationEditForm, self).updateWidgets(prefix)
         if 'publication_effective_date' in self.widgets:
             pub_info = IWorkflowPublicationInfo(self.context)
             if pub_info.publication_effective_date is None:
-                self.widgets['publication_effective_date'].value = tztime(datetime.utcnow()).strftime('%d/%m/%y %H:%M')
+                self.widgets['publication_effective_date'].value = \
+                    tztime(datetime.utcnow()).strftime('%d/%m/%y %H:%M')
 
     def get_ajax_output(self, changes):
         output = super(self.__class__, self).get_ajax_output(changes)