[zeam.form.silva][Sylvain Viollon] Small improvements. Silva.ico...

[email protected] Tue, 12 Nov 2013 12:41:10 +0100
Newsgroups gmane.comp.web.zope.silva.cvs
Message-ID <[email protected]>
author:    Sylvain Viollon
date:      Mon Nov 04 14:49:58 2013 +0100
revision:  429:0d3562e44548 in zeam.form.silva
branch:    2.4
details:   https://hg.infrae.com/zeam.form.silva?cmd=changeset;node=0d3562e44548
modified:  src/zeam/form/silva/actions.py src/zeam/form/silva/widgets/others.py src/zeam/form/silva/widgets/others_templates/iconeditdisplaywidget.cpt
added:     
removed:   
log:       Small improvements. Silva.icon.edit can now select a given screen.

Subject: [zeam.form.silva][Sylvain Viollon] Default 'up' link for Configuration screen is admin.


author:    Sylvain Viollon
date:      Tue Nov 12 12:41:06 2013 +0100
revision:  430:7f9b599c9850 in zeam.form.silva
branch:    2.4
details:   https://hg.infrae.com/zeam.form.silva?cmd=changeset;node=7f9b599c9850
modified:  src/zeam/form/silva/form/smi.py
added:     
removed:   
log:       Default 'up' link for Configuration screen is admin.


diffstat:

 src/zeam/form/silva/actions.py                                         |   4 +-
 src/zeam/form/silva/form/smi.py                                        |  10 ++++++++
 src/zeam/form/silva/widgets/others.py                                  |  12 +++++++--
 src/zeam/form/silva/widgets/others_templates/iconeditdisplaywidget.cpt |   2 +-
 4 files changed, 22 insertions(+), 6 deletions(-)

diffs (83 lines):

diff -r ee0922e47cb5 -r 7f9b599c9850 src/zeam/form/silva/actions.py
--- a/src/zeam/form/silva/actions.py	Fri Oct 25 18:14:06 2013 +0200
+++ b/src/zeam/form/silva/actions.py	Tue Nov 12 12:41:06 2013 +0100
@@ -7,7 +7,7 @@
 from five import grok
 from zope.interface import Interface
 
-from silva.core.interfaces import IRoot, ISilvaService
+from silva.core.interfaces import IRoot, IZMIObject
 from silva.core.interfaces.errors import ContentError
 from silva.translations import translate as _
 
@@ -133,7 +133,7 @@
 
     def getRedirectedContent(self, form):
         content = form.context
-        if ISilvaService.providedBy(content):
+        if IZMIObject.providedBy(content):
             return aq_parent(aq_inner(content))
         return content
 
diff -r ee0922e47cb5 -r 7f9b599c9850 src/zeam/form/silva/form/smi.py
--- a/src/zeam/form/silva/form/smi.py	Fri Oct 25 18:14:06 2013 +0200
+++ b/src/zeam/form/silva/form/smi.py	Tue Nov 12 12:41:06 2013 +0100
@@ -127,6 +127,11 @@
     def get_menu_title(self):
         return self.label
 
+    def get_menu_parent(self):
+        parent = super(ConfigurationForm, self).get_menu_parent()
+        parent['screen'] = 'admin'
+        return parent
+
 
 class SMITableForm(SMIForm, table.TableForm):
     """SMI table forms.
@@ -188,6 +193,11 @@
     def get_menu_title(self):
         return self.label
 
+    def get_menu_parent(self):
+        parent = super(ComposedConfigurationForm, self).get_menu_parent()
+        parent['screen'] = 'admin'
+        return parent
+
 
 class SMISubForm(SilvaFormData, composed.SubForm):
     """SMI Sub forms.
diff -r ee0922e47cb5 -r 7f9b599c9850 src/zeam/form/silva/widgets/others.py
--- a/src/zeam/form/silva/widgets/others.py	Fri Oct 25 18:14:06 2013 +0200
+++ b/src/zeam/form/silva/widgets/others.py	Tue Nov 12 12:41:06 2013 +0100
@@ -46,12 +46,18 @@
 class IconEditDisplayWidget(IconDisplayWidget):
     grok.name('silva.icon.edit')
 
+    screen = 'content'
+
+    def get_smi_form(self):
+        form = self.form
+        while form is not None and not ISMIForm.providedBy(form):
+            form = getattr(form, 'parent', None)
+        return form
+
     def update(self):
         super(IconEditDisplayWidget, self).update()
         self.path = None
-        form = self.form
-        while form is not None and not ISMIForm.providedBy(form):
-            form = getattr(form, 'parent', None)
+        form = self.get_smi_form()
         if form is not None:
             self.path = form.get_content_path(self._content)
 
diff -r ee0922e47cb5 -r 7f9b599c9850 src/zeam/form/silva/widgets/others_templates/iconeditdisplaywidget.cpt
--- a/src/zeam/form/silva/widgets/others_templates/iconeditdisplaywidget.cpt	Fri Oct 25 18:14:06 2013 +0200
+++ b/src/zeam/form/silva/widgets/others_templates/iconeditdisplaywidget.cpt	Tue Nov 12 12:41:06 2013 +0100
@@ -1,5 +1,5 @@
 <tal:icon>
   <img tal:replace="structure widget.icon" />
-  <a href="${widget.path}" rel="content" class="open-screen"
+  <a href="${widget.path}" rel="${widget.screen}" class="open-screen"
      tal:content="widget.inputValue()" />
 </tal:icon>