Author: jmorliaguet
Date: Mon Dec  5 00:56:14 2005
New Revision: 1958

Modified:
   cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt
   cpsskins/branches/jmo-perspectives/browser/editing/views.py
Log:

- moved TAL code to views



Modified: cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt     
(original)
+++ cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt     Mon Dec 
 5 00:56:14 2005
@@ -18,50 +18,33 @@
     <ul class="buttons">
 
       <!-- edit element -->
-      <li>
-        <a tal:attributes="class python: info['element']['selected'] and
-                          'itemselected' or 'item'" i18n:translate=""
-           href="@@edit-menu.html?main_url=@@edit.html">
-          <img src="" tal:attributes="src context/@@getIcon" />
-          <tal:block i18n:translate="" content="context/type:contenttype" />
+      <li tal:define="element_info info/element">
+        <a i18n:translate="" tal:attributes="
+           class python: element_info['selected'] and 'itemselected' or 'item';
+           href element_info/url">
+          <img src="" tal:attributes="src element_info/icon" />
+          <tal:block i18n:translate="" content="element_info/title" />
         </a>
       </li>
 
       <!-- edit formats -->
-      <tal:block condition="python: display is not None">
-        <li tal:define="formats info/formats"
-            tal:repeat="format formats">
-          <a i18n:translate=""
-             tal:attributes="
-               class python: format['selected'] and 'itemselected' or 'item';
-               href format/url"
-             tal:content="format/title" />
-        </li>
-      </tal:block>
+      <li tal:repeat="format info/formats">
+        <a i18n:translate=""
+           tal:attributes="
+             href format/url;
+             class python: format['selected'] and 'itemselected' or 'item'"
+           tal:content="format/title" />
+      </li>
 
     </ul>
 
     <div style="clear:both"></div>
 
-    <div class="editActions"
-     tal:define="actions context/@@view_get_menu/cpsskins_editing_actions"
-     tal:condition="actions">
-      <a tal:condition="format_name"
-         tal:attributes="href 
string:@@edit-menu.html?action=create-setting.html&format=$format_name">
-         <img src="/++skin++cpsskins/@@/create-setting-16.png" />
-         Create setting
-      </a>
-      <a tal:condition="format_name"
-         tal:attributes="href 
string:@@edit-menu.html?base=display&action=use-setting.html&format=$format_name">
-         <img src="/++skin++cpsskins/@@/use-setting-16.png" />
-         Use setting
+    <div class="editActions" tal:define="actions info/actions">
+      <a href="#" tal:repeat="action actions" tal:attributes="href action/url">
+        <img src="" tal:attributes="src 
string:/++skins++cpsskins/@@${action/icon}" />
+        <tal:block content="action/title" i18n:translate="" />
       </a>
-      <a href="#"
-         tal:repeat="info actions"
-         tal:attributes="href info/action;
-                         class info/selected"
-         tal:content="info/title"
-         i18n:translate="" />
     </div>
 
   </body>

Modified: cpsskins/branches/jmo-perspectives/browser/editing/views.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/editing/views.py (original)
+++ cpsskins/branches/jmo-perspectives/browser/editing/views.py Mon Dec  5 
00:56:14 2005
@@ -55,7 +55,6 @@
 
 class Editing(BrowserView):
 
-    adapts(IElement)
     implements(IEditing)
 
     def getId(self):
@@ -104,12 +103,21 @@
         negociation = getMultiAdapter((context, request),
                                       INegociation, 'negociation')
         perspective = negociation.getPerspective()
-
         displayable = IDisplayable(context)
         display = displayable.getEffectiveDisplay(perspective)
         formattable = IFormattable(display)
 
         main = context
+
+        # Edited element
+        element_info = {
+            'title': IType(context).getContentType().__name__,
+            'url': '@@edit-menu.html?main_url=@@edit.html',
+            'selected': not format_name,
+            'icon': '',
+            }
+
+        # Formats
         formats_info = []
         for f in formattable.getFormats(resolve=False):
             is_setting = ISetting.providedBy(f)
@@ -130,15 +138,29 @@
                 'selected': selected,
                 })
 
+        # Actions
+        actions_info = []
+        if format_name :
+            actions_info.append({
+                'title': u'Create setting',
+                'url': '@@%s?action=%s&format=%s' % \
+                       ('edit-menu.html', 'create-setting.html', format_name),
+                'icon': u'create-setting-16.png',
+                })
+
+        if format_name:
+            actions_info.append({
+                'title': u'Use setting',
+                'url': '@@%s?base=display&action=%s&format=%s' % \
+                       ('edit-menu.html', 'use-setting.html', format_name),
+                'icon': u'use-setting-16.png',
+                })
+
+        # Main area
         if base == 'display':
             main = display
-
         main_url = main_url or self.getAbsoluteURL(main) + '/@@' + action
 
-        element_info = {
-            'selected': not format_name,
-            }
-
         return {
             'negociation': negociation,
             'perspective': perspective,
@@ -146,6 +168,7 @@
             'format_name': format_name,
             'element': element_info,
             'formats': formats_info,
+            'actions' : actions_info,
             'main_url': main_url,
             }
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to