Xavier (Open ERP) has proposed merging
lp:~openerp-dev/openerp-web/trunk-o2m-titles-xmo into lp:openerp-web.
Requested reviews:
OpenERP R&D Web Team (openerp-dev-web)
For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-o2m-titles-xmo/+merge/80345
Adds titles to o2m (and m2m, probably), based on the current view's @string.
The data this yields is identical to that produced by the GTK client.
+ This was done by moving the ability to have titles up from ViewManagerAction
to ViewManager, and adding a hook methods (`#display_title`) through which the
title to display is returned by the ViewManager instance
+ The title is checked (and set) every time a view is switched, this lets
different o2m views (for instance) have different titles. I don't know how the
GTK client behaves in that respect.
+ Seems to work correctly even when there is no @string on the arch (displays
nothing, as with GTK client)
- No styling has been setup, so titles for o2m in forms currently appear USING
A FONT SIZE OF 175%. Can it be merged as is and styled later, or should it be
styled now? (e.g. by reducing the font size any time we encounter a
`td.view-manager-main-content` around our title)
- The fetching of the title in the ViewManager looks absolutely terrible, but
I'm not sure we have any protocol for returning a view title. Do we? Should we
add one? (e.g. the same method as on ViewManager, but on View, and ViewManager
would just call the View's corresponding method, this way various views could
even customize what they return & stuff).
--
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-o2m-titles-xmo/+merge/80345
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openerp-web/trunk-o2m-titles-xmo.
=== modified file 'addons/web/static/src/js/views.js'
--- addons/web/static/src/js/views.js 2011-10-25 13:23:26 +0000
+++ addons/web/static/src/js/views.js 2011-10-25 14:50:29 +0000
@@ -271,6 +271,10 @@
}
}
}
+ $.when(view_promise).then(function () {
+ self.$element.find('.oe_view_title:first').text(
+ self.display_title());
+ });
return view_promise;
},
/**
@@ -331,7 +335,15 @@
/**
* Called by children view after executing an action
*/
- on_action_executed: function () {}
+ on_action_executed: function () {},
+ display_title: function () {
+ var view = this.views[this.active_view];
+ if (view) {
+ // ick
+ return view.controller.fields_view.arch.attrs.string;
+ }
+ return '';
+ }
});
session.web.ViewManagerAction = session.web.ViewManager.extend(/** @lends oepnerp.web.ViewManagerAction# */{
@@ -522,6 +534,9 @@
return false;
});
});
+ },
+ display_title: function () {
+ return this.action.name;
}
});
=== modified file 'addons/web/static/src/xml/base.xml'
--- addons/web/static/src/xml/base.xml 2011-10-25 10:59:25 +0000
+++ addons/web/static/src/xml/base.xml 2011-10-25 14:50:29 +0000
@@ -415,6 +415,9 @@
<tr>
<td class="view-manager-main-content">
<div class="oe-view-manager-header">
+ <h2 class="oe_view_title" t-if="self.flags.display_title !== false">
+ <t t-esc="self.display_title()"/>
+ </h2>
<div class="oe_vm_switch">
<t t-if="views.length != 1" t-foreach="views" t-as="view">
<button type="button" t-att-data-view-type="view.view_type">
@@ -452,9 +455,6 @@
<button t-if="self.session.debug" class="oe_get_xml_view">
View#<span></span>
</button>
- <h2 class="oe_view_title" t-if="self.flags.display_title !== false">
- <t t-if="self.flags.display_title !== false" t-esc="self.action.name"/>
- </h2>
</t>
<t t-jquery=".oe-view-manager-header" t-operation="after">
<ul class="oe-view-manager-logs"></ul>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp