← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-client-web/web-dashboard into lp:openobject-client-web

 

vda(Open ERP) has proposed merging lp:~openerp-dev/openobject-client-web/web-dashboard into lp:openobject-client-web.

Requested reviews:
  OpenERP SA's Web Client R&D (openerp-dev-web)


Improvements in dashboard.
-- 
https://code.launchpad.net/~openerp-dev/openobject-client-web/web-dashboard/+merge/37436
Your team OpenERP SA's Web Client R&D is requested to review the proposed merge of lp:~openerp-dev/openobject-client-web/web-dashboard into lp:openobject-client-web.
=== modified file 'addons/openerp/controllers/root.py'
--- addons/openerp/controllers/root.py	2010-10-03 11:25:14 +0000
+++ addons/openerp/controllers/root.py	2010-10-04 08:54:39 +0000
@@ -50,45 +50,20 @@
     def index(self, next=None):
         """Index page, loads the view defined by `action_id`.
         """
+        arguments = {}
         if next: arguments = {'next': next}
-        else: arguments = {'next': '/openerp/home'}
-        
-        proxy = rpc.RPCProxy("res.users")
-        act_id = proxy.read([rpc.session.uid], ['action_id', 'name'], rpc.session.context)
-        
-        if act_id[0]['action_id'] :
-            raise redirect("/openerp/menu", **arguments)
-        else:
-            raise redirect('/openerp/dashboard')
-        
-    
-    def user_action(self, id='action_id'):
-        """Perform default user action.
-
-        @param id: `action_id` or `menu_id`
-        """
-        proxy = rpc.RPCProxy("res.users")
-        act_id = proxy.read([rpc.session.uid], [id, 'name'], rpc.session.context)
-
-        if not act_id[0][id]:
-            common.warning(_('You can not log into the system!\nAsk the administrator to verify\nyou have an action defined for your user.'), _('Access Denied!'))
-            rpc.session.logout()
-            raise redirect('/openerp')
-        else:
-            act_id = act_id[0][id][0]
-            from openerp import controllers
-            return controllers.actions.execute_by_id(act_id)
-    
-    @expose(template="/openerp/controllers/templates/dashboard.mako")
-    def dashboard(self):
-        ctx = rpc.session.context.copy()
-        proxy = rpc.RPCProxy("ir.ui.menu")
-        ids = proxy.search([('parent_id', '=', False)], 0, 0, 0, ctx)
-        parents = proxy.read(ids, ['name', 'icon', 'action'], ctx)
-        return dict(parents = parents)
+        else:
+            user_action_id = rpc.RPCProxy("res.users").read([rpc.session.uid], ['action_id'], rpc.session.context)[0]['action_id']
+            if user_action_id:
+                arguments = {'next': '/openerp/home'}
+        
+        raise redirect("/openerp/menu", **arguments)
+    
     @expose()
     def home(self):
-        return self.user_action('action_id')
+        user_action_id = rpc.RPCProxy("res.users").read([rpc.session.uid], ['action_id'], rpc.session.context)[0]['action_id']
+        from openerp import controllers
+        return controllers.actions.execute_by_id(user_action_id[0])
     
     @expose(content_type='application/octet-stream')
     def report(self, report_name=None, **kw):
@@ -117,9 +92,8 @@
     </html>
     """ % (url("/openerp/static/images/loading.gif"))
 
-    @expose(template="/openerp/controllers/templates/menu.mako")
+    @expose(template="/openerp/controllers/templates/index.mako")
     def menu(self, active=None, next=None):
-        from openerp.utils import icons
         from openerp.widgets import tree_view
         
         try:
@@ -130,7 +104,7 @@
         ctx = rpc.session.context.copy()
         proxy = rpc.RPCProxy("ir.ui.menu")
         ids = proxy.search([('parent_id', '=', False)], 0, 0, 0, ctx)
-        parents = proxy.read(ids, ['name', 'icon', 'action'], ctx)
+        parents = proxy.read(ids, ['name'], ctx)
                 
         if not id and ids:
             id = ids[0]
@@ -138,25 +112,24 @@
         for parent in parents:
             if parent['id'] == id:
                 parent['active'] = 'active'
-                # explicit next takes precedence on menu item action
-                if not next and parent.get('action'):
-                    next = url('/openerp/custom_action', action=id)
-                
-        ids = proxy.search([('parent_id', '=', id)], 0, 0, 0, ctx)
-        tools = proxy.read(ids, ['name', 'icon', 'action'], ctx)
-        view = cache.fields_view_get('ir.ui.menu', 1, 'tree', {})
-        fields = cache.fields_get(view['model'], False, ctx)
+            parent['url'] = url('/openerp/menu', active=parent['id'], next=url('/openerp/custom_action', action=parent['id']))
         
-        for tool in tools:
-            tid = tool['id']
-            tool['icon'] = icons.get_icon(tool['icon'])
-            tool['tree'] = tree = tree_view.ViewTree(view, 'ir.ui.menu', tid,
-                                    domain=[('parent_id', '=', tid)],
-                                    context=ctx, action="/openerp/tree/action", fields=fields)
-            tree._name = "tree_%s" %(tid)
-            tree.tree.onselection = None
-            tree.tree.onheaderclick = None
-            tree.tree.showheaders = 0
+        tools = []
+        if next: 
+            ids = proxy.search([('parent_id', '=', id)], 0, 0, 0, ctx)
+            tools = proxy.read(ids, ['name', 'action'], ctx)
+            view = cache.fields_view_get('ir.ui.menu', 1, 'tree', {})
+            fields = cache.fields_get(view['model'], False, ctx)
+            
+            for tool in tools:
+                tid = tool['id']
+                tool['tree'] = tree = tree_view.ViewTree(view, 'ir.ui.menu', tid,
+                                        domain=[('parent_id', '=', tid)],
+                                        context=ctx, action="/openerp/tree/action", fields=fields)
+                tree._name = "tree_%s" %(tid)
+                tree.tree.onselection = None
+                tree.tree.onheaderclick = None
+                tree.tree.showheaders = 0
 
         return dict(parents=parents, tools=tools, load_content=(next and next or ''))
 

=== removed file 'addons/openerp/controllers/templates/dashboard.mako'
--- addons/openerp/controllers/templates/dashboard.mako	2010-10-01 08:16:56 +0000
+++ addons/openerp/controllers/templates/dashboard.mako	1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
-<%inherit file="/openerp/controllers/templates/base_dispatch.mako"/>
-<%def name="header()">
-    <title>OpenERP Dashboard</title>
-
-    <script type="text/javascript" src="/openerp/static/javascript/accordion.js"></script>
-    <script type="text/javascript" src="/openerp/static/javascript/treegrid.js"></script>
-    <script type="text/javascript" src="/openerp/static/javascript/notebook/notebook.js"></script>
-</%def>
-<%def name="content()">
-    <div id="root">
-        <table id="content" class="three-a" width="100%">
-            <tr>
-                <%include file="header.mako"/>
-            </tr>
-            <tr>
-                <td id="main_nav" colspan="3">
-                    <div id="applications_menu">
-                        <ul>
-                            %for parent in parents:
-                                <li>
-                                    <a href="${py.url('/openerp/menu', active=parent['id'])}"
-                                       target="_top" class="${parent.get('active', '')}">
-                                        <span>${parent['name']}</span>
-                                    </a>
-                                </li>
-                            % endfor
-                        </ul>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td id="primary" width="100%">
-                    <div class="wrap" style="padding: 10px;">
-                        <ul class="sections-a">
-                            %for parent in parents:
-                                <li id="${parent['id']}" class="${'-'.join(parent['name'].split(' ')).lower()}">
-                                    <span class="wrap">
-                                        <a href="${py.url('/openerp/menu', active=parent['id'])}">
-                                            <span>
-                                                <strong>${parent['name']}</strong>
-                                            </span>
-                                        </a>
-                                    </span>
-                                </li>
-                            % endfor
-                        </ul>
-                    </div>
-                </td>
-            </tr>
-        </table>
-    </div>
-</%def>

=== modified file 'addons/openerp/controllers/templates/header.mako'
--- addons/openerp/controllers/templates/header.mako	2010-09-30 10:04:42 +0000
+++ addons/openerp/controllers/templates/header.mako	2010-10-04 08:54:39 +0000
@@ -21,7 +21,7 @@
 %>
 <td id="top" colspan="3">
     <p id="cmp_logo">
-        <a href="/" target="_top">
+        <a href="http://www.openerp.com"; target="_blank">
             <img alt="OpenERP" id="company_logo" src="/openerp/static/images/openerp_small.png"/>
         </a>
     </p>
@@ -37,61 +37,60 @@
         <li><a href="#footer" accesskey="f">Skip to footer [f]</a></li>
     </ul>
     % if logged:
-	    <div id="corner">
-	        <ul class="tools">
-	            <li><a href="javascript: void(0)" onclick="header_actions('/openerp/home')" class="home">${_("Home")}</a>
-	                <ul>
-	                    <li class="first last"><a href="javascript: void(0)" onclick="header_actions('/openerp/home')">${_("Home")}</a></li>
-	                </ul>
-	            </li>
-	            <li>
-	                <a href="javascript: void(0)" onclick="header_actions('/openerp/requests')" class="req_messages"><small>${total_request}</small></a>
-	                <ul>
-	                    <li class="first last"><a href="javascript: void(0)" onclick="header_actions('/openerp/requests')">${_("Requests")}</a></li>
-	                </ul>
-	            </li>
-
-	            <li><a href="javascript: void(0)" onclick="header_actions('/openerp/pref/create')" class="preferences">${_("Preferences")}</a>
-	                <ul>
-	                    <li class="first last"><a href="javascript: void(0)" onclick="header_actions('/openerp/pref/create')">${_("Edit Preferences")}</a></li>
-	                </ul>
-	            </li>
-	            <li><a href="javascript: void(0)" onclick="header_actions('/openerp/about')" class="info">${_("About")}</a>
-	                <ul>
-	                    <li class="first last"><a href="javascript: void(0)" onclick="header_actions('/openerp/about')">${_("About")}</a></li>
-	                </ul>
-	            </li>
-
-	            <li><a target="_blank" href="http://doc.openerp.com/"; class="help">${_("Help")}</a>
-	                <ul>
-	                    <li class="first last"><a target="_blank" href="http://doc.openerp.com/";>${_("Help")}</a></li>
-	                </ul>
-	            </li>
-
-	            % if cp.config('server.environment') == 'production':
-	                <li id="clear_cache"><a href="javascript: void(0)" onclick="header_actions('/openerp/pref/clear_cache')" class="clear_cache">${_("Clear Cache")}</a>
-	                    <ul>
-	                        <li class="first last"><a href="javascript: void(0);">${_("Clear Cache")}</a></li>
-	                    </ul>
-	                </li>
-	            % endif
-	        </ul>
-	        <p class="logout"><a href="${py.url('/openerp/logout')}" target="_top">${_("Logout")}</a></p>
-	    </div>
-	% endif
-	
+        <div id="corner">
+            <ul class="tools">
+                <li><a href="${py.url('/openerp')}" target="_top" class="home">${_("Home")}</a>
+                    <ul>
+                        <li class="first last"><a href="${py.url('/openerp')}" target="_top">${_("Home")}</a></li>
+                    </ul>
+                </li>
+                <li>
+                    <a href="${py.url('/openerp/requests')}" class="req_messages"><small>${total_request}</small></a>
+                    <ul>
+                        <li class="first last"><a href="${py.url('/openerp/requests')}">${_("Requests")}</a></li>
+                    </ul>
+                </li>
+
+                <li><a href="${py.url('/openerp/pref/create')}" class="preferences">${_("Preferences")}</a>
+                    <ul>
+                        <li class="first last"><a href="${py.url('/openerp/pref/create')}">${_("Edit Preferences")}</a></li>
+                    </ul>
+                </li>
+                <li><a href="/openerp/about" class="info">${_("About")}</a>
+                    <ul>
+                        <li class="first last"><a href="/openerp/about">${_("About")}</a></li>
+                    </ul>
+                </li>
+
+                <li><a target="_blank" href="http://doc.openerp.com/"; class="help">${_("Help")}</a>
+                    <ul>
+                        <li class="first last"><a target="_blank" href="http://doc.openerp.com/";>${_("Help")}</a></li>
+                    </ul>
+                </li>
+
+                % if cp.config('server.environment') == 'production':
+                    <li id="clear_cache"><a href="${py.url('/openerp/pref/clear_cache')}" class="clear_cache">${_("Clear Cache")}</a>
+                        <ul>
+                            <li class="first last"><a href="javascript: void(0);">${_("Clear Cache")}</a></li>
+                        </ul>
+                    </li>
+                % endif
+            </ul>
+            <p class="logout"><a href="${py.url('/openerp/logout')}" target="_top">${_("Logout")}</a></p>
+        </div>
+    % endif
+    
     <div id="shortcuts" class="menubar">
     % if logged:
         <ul>
-	        % for i, sc in enumerate(shortcuts):
-	            <li class="${i == 0 and 'first' or ''}">
-	                <a id="shortcut_${sc['res_id']}"
-	                   href="javascript: void(0)"
-                       onclick='header_actions("/openerp/tree/open","${sc['res_id']}", "ir.ui.menu")'>
-	                   <span>${sc['name']}</span>
-	                </a>
-	            </li>
-	        % endfor
+            % for i, sc in enumerate(shortcuts):
+                <li class="${i == 0 and 'first' or ''}">
+                    <a id="shortcut_${sc['res_id']}"
+                       href="${py.url('/openerp/tree/open', id=sc['res_id'], model='ir.ui.menu')}">
+                       <span>${sc['name']}</span>
+                    </a>
+                </li>
+            % endfor
         </ul>
     % endif
     </div>

=== added file 'addons/openerp/controllers/templates/index.mako'
--- addons/openerp/controllers/templates/index.mako	1970-01-01 00:00:00 +0000
+++ addons/openerp/controllers/templates/index.mako	2010-10-04 08:54:39 +0000
@@ -0,0 +1,154 @@
+<%inherit file="/openerp/controllers/templates/base_dispatch.mako"/>
+
+<%def name="header()">
+    <title>OpenERP</title>
+
+    <script type="text/javascript" src="/openerp/static/javascript/accordion.js"></script>
+    <script type="text/javascript" src="/openerp/static/javascript/treegrid.js"></script>
+    <script type="text/javascript" src="/openerp/static/javascript/notebook/notebook.js"></script>
+
+    <script type="text/javascript">
+        var DOCUMENT_TO_LOAD = "${load_content}";
+        var CAL_INSTANCE = null;
+
+        jQuery(document).ready(function () {
+            // Don't load doc if there is a hash-url, it takes precedence
+            if(DOCUMENT_TO_LOAD && !hashUrl()) {
+                openLink(DOCUMENT_TO_LOAD);
+            }
+
+            jQuery('.toggle-menu').toggler('#content')
+        });
+        
+    </script>
+</%def>
+
+<%def name="content()">
+
+    <div id="root">
+        <table id="content" class="three-a open" width="100%">
+            <tr>
+                <%include file="header.mako"/>
+            </tr>
+            <tr>
+                <td id="main_nav" colspan="3">
+                    <div id="applications_menu">
+                        <ul>
+                            %for parent in parents:
+                                <li>
+                                    <a href="${parent['url']}"
+                                       target="_top" class="${parent.get('active', '')}">
+                                        <span>${parent['name']}</span>
+                                    </a>
+                                </li>
+                            % endfor
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            % if tools:
+                <tr>
+                    <td id="secondary" class="sidenav-open">
+                        <div class="wrap">
+                            <ul id="sidenav-a" class="accordion">
+                                % for tool in tools:
+                                    % if tool.get('action'):
+                                      <li class="accordion-title" id="${tool['id']}">
+                                    % else:
+                                      <li class="accordion-title">
+                                    % endif
+                                        <span>${tool['name']}</span>
+                                    </li>
+                                    <li class="accordion-content" id="content_${tool['id']}">
+                                       ${tool['tree'].display()}
+                                    </li>
+                                % endfor
+                            </ul>
+                            <script type="text/javascript">
+                                new Accordion("sidenav-a");
+                            </script>
+                        </div>
+                    </td>
+                    <td class="toggle-menu"></td>
+                    <td id="primary" width="100%">
+                        <div class="wrap">
+                            <div id="appContent"></div>
+                        </div>
+                    </td>
+                </tr>
+            % else:
+                <tr>
+                    <td id="primary" width="70%">
+                        <div class="wrap" style="padding: 10px;">
+                            <h1>
+                                ${_('Dashboard')}
+                            </h1>
+                            <ul class="sections-a">
+                                %for parent in parents:
+                                    <li class="${'-'.join(parent['name'].split(' ')).lower()}">
+                                        <span class="wrap">
+                                            <a href="${parent['url']}" target="_top">
+                                                <span>
+                                                    <strong>${parent['name']}</strong>
+                                                </span>
+                                            </a>
+                                        </span>
+                                    </li>
+                                % endfor
+                            </ul>
+                        </div>
+                    </td>
+                    <td class="tertiary">
+                        <div class="wrap">
+                            <ul class="split-a">
+                                <li class="one">
+                                    <a class="cta-a" href="http://www.openerp.com/services/subscribe-onsite"; target="_blank">
+                                        <span>
+                                            <strong>${_('Use On-Site')}</strong>
+                                            Get the openERP Warranty
+                                        </span>
+                                    </a>
+                                </li>
+                                <li class="two">
+                                    <a class="cta-a" href="http://www.openerp.com/online"; target="_blank">
+                                        <span>
+                                            <strong>${_('Use Online')}</strong>
+                                            Subscribe and start
+                                        </span>
+                                    </a>
+                                </li>
+                            </ul>
+                        </div>
+                        <div class="sideheader-a">
+                            <ul class="side">
+                                <li>
+                                    <a class="button-a" href="javascript: void(0)">${_('Add')}</a>
+                                </li>
+                            </ul>
+                            <h2>${_('Widgets')}</h2>
+                        </div>
+                    </td>
+                </tr>
+            % endif
+            <tr>
+                <td id="footer_section" colspan="3">
+                    % if cp.config('server.environment') == 'development':
+                        <div class="footer-a">
+                            <p class="one">
+                                <span>${rpc.session.protocol}://${_("%(user)s", user=rpc.session.loginname)}@${rpc.session.host}:${rpc.session.port}</span>
+                            </p>
+                            <p class="powered">${_("Powered by %(openerp)s ",
+                                                openerp="""<a target="_blank" href="http://www.openerp.com/";>openerp.com</a>""")|n}</p>
+                        </div>
+                    % else:
+                        <div class="footer-b">
+                            <p class="powered">${_("Powered by %(openerp)s ",
+                                                openerp="""<a target="_blank" href="http://www.openerp.com/";>openerp.com</a>""")|n}</p>
+                        </div>
+                    % endif
+                </td>
+            </tr>
+        </table>
+    </div>
+</%def>
+

=== removed file 'addons/openerp/controllers/templates/menu.mako'
--- addons/openerp/controllers/templates/menu.mako	2010-10-01 08:16:56 +0000
+++ addons/openerp/controllers/templates/menu.mako	1970-01-01 00:00:00 +0000
@@ -1,99 +0,0 @@
-<%inherit file="/openerp/controllers/templates/base_dispatch.mako"/>
-
-<%def name="header()">
-    <title>OpenERP</title>
-
-    <script type="text/javascript" src="/openerp/static/javascript/accordion.js"></script>
-    <script type="text/javascript" src="/openerp/static/javascript/treegrid.js"></script>
-    <script type="text/javascript" src="/openerp/static/javascript/notebook/notebook.js"></script>
-
-    <script type="text/javascript">
-        var DOCUMENT_TO_LOAD = "${load_content}";
-        var CAL_INSTANCE = null;
-
-        jQuery(document).ready(function () {
-            // Don't load doc if there is a hash-url, it takes precedence
-            if(DOCUMENT_TO_LOAD && !hashUrl()) {
-                openLink(DOCUMENT_TO_LOAD);
-            }
-
-            jQuery('.toggle-menu').toggler('#content')
-        });
-        
-    </script>
-</%def>
-
-<%def name="content()">
-
-    <div id="root">
-        <table id="content" class="three-a open" width="100%">
-            <tr>
-                <%include file="header.mako"/>
-            </tr>
-            <tr>
-                <td id="main_nav" colspan="3">
-                    <div id="applications_menu">
-                        <ul>
-                            %for parent in parents:
-                                <li>
-                                    <a href="${py.url('/openerp/menu', active=parent['id'])}"
-                                       target="_top" class="${parent.get('active', '')}">
-                                        <span>${parent['name']}</span>
-                                    </a>
-                                </li>
-                            % endfor
-                        </ul>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td id="secondary" class="sidenav-open">
-                    <div class="wrap">
-                        <ul id="sidenav-a" class="accordion">
-                            % for tool in tools:
-                                % if tool.get('action'):
-                                  <li class="accordion-title" id="${tool['id']}">
-                                % else:
-                                  <li class="accordion-title">
-                                % endif
-                                    <span>${tool['name']}</span>
-                                </li>
-                                <li class="accordion-content" id="content_${tool['id']}">
-                                   ${tool['tree'].display()}
-                                </li>
-                            % endfor
-                        </ul>
-                        <script type="text/javascript">
-                            new Accordion("sidenav-a");
-                        </script>
-                    </div>
-                </td>
-                <td class="toggle-menu"></td>
-                <td id="primary" width="100%">
-                    <div class="wrap">
-                        <div id="appContent"></div>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td id="footer_section" colspan="3">
-                    % if cp.config('server.environment') == 'development':
-                        <div class="footer-a">
-                            <p class="one">
-                                <span>${rpc.session.protocol}://${_("%(user)s", user=rpc.session.loginname)}@${rpc.session.host}:${rpc.session.port}</span>
-                            </p>
-                            <p class="powered">${_("Powered by %(openerp)s ",
-                                                openerp="""<a target="_blank" href="http://www.openerp.com/";>openerp.com</a>""")|n}</p>
-                        </div>
-                    % else:
-                        <div class="footer-b">
-                            <p class="powered">${_("Powered by %(openerp)s ",
-                                                openerp="""<a target="_blank" href="http://www.openerp.com/";>openerp.com</a>""")|n}</p>
-                        </div>
-                    % endif
-                </td>
-            </tr>
-        </table>
-    </div>
-</%def>
-

=== modified file 'addons/openerp/static/css/screen.css'
--- addons/openerp/static/css/screen.css	2010-10-01 08:16:56 +0000
+++ addons/openerp/static/css/screen.css	2010-10-04 08:54:39 +0000
@@ -2064,6 +2064,17 @@
 }
 
 /* sidebar */
+td.tertiary {
+    background: url(../images/tertiary-bg-a.gif) repeat-y scroll 0 0 #EAE7E7;
+    min-height: 100%;
+    border-left: 1px solid #D2CFCF;
+    vertical-align: top;
+}
+
+td.tertiary div.wrap {
+    margin-top: 39px;
+}
+
 #tertiary {
     position: relative;
     float: right;
@@ -2326,7 +2337,6 @@
 
 a.cta-a span {
     float: left;
-    width: 95px;
     padding: 7px 0 5px 32px;
     background-position: 0 50%;
     background-repeat: no-repeat;

=== modified file 'addons/openerp/static/javascript/openerp/openerp.ui.js'
--- addons/openerp/static/javascript/openerp/openerp.ui.js	2010-10-01 08:16:56 +0000
+++ addons/openerp/static/javascript/openerp/openerp.ui.js	2010-10-04 08:54:39 +0000
@@ -158,20 +158,6 @@
     }
 })(jQuery);
 
-function header_actions(url) {
-    // For shortcuts
-    if(arguments[1]) {
-            url = openobject.http.getURL(url, {'id': arguments[1], 'model': arguments[2]});
-    }
-    
-    if(jQuery('#appContent').length) {
-        openLink(url)
-    }
-    else {
-        window.location.href = openobject.http.getURL('/openerp/menu', {'next': url})
-    }
-}
-
 jQuery(document).ready(function () {
     jQuery('#applications_menu').scrollify();
     jQuery('#shortcuts').scrollify();


Follow ups