summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2011-12-16 12:20:54 +0100
committerXavier Morel <xmo@openerp.com>2011-12-16 12:20:54 +0100
commit265d9e1ef4efebc15d5d04ef412de9f5452296c4 (patch)
tree010ad2c4193999d7663cb2b8cfbc282e9a5969a5 /addons/web/static/src
parentb3a04d317b078a474f8b6df8952cd039beacbde9 (diff)
[ADD] translatable name to views
lp bug: https://launchpad.net/bugs/904989 fixed bzr revid: xmo@openerp.com-20111216112054-xys9q3ap6dcatppr
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/core.js5
-rw-r--r--addons/web/static/src/js/view_form.js1
-rw-r--r--addons/web/static/src/js/view_list.js1
-rw-r--r--addons/web/static/src/js/view_page.js1
-rw-r--r--addons/web/static/src/js/view_tree.js4
-rw-r--r--addons/web/static/src/js/views.js15
-rw-r--r--addons/web/static/src/xml/base.xml2
7 files changed, 25 insertions, 4 deletions
diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js
index 3d66c4f4ccf..12422fb5434 100644
--- a/addons/web/static/src/js/core.js
+++ b/addons/web/static/src/js/core.js
@@ -254,14 +254,16 @@ openerp.web.Registry = openerp.web.Class.extend( /** @lends openerp.web.Registry
* Retrieves the object matching the provided key string.
*
* @param {String} key the key to fetch the object for
+ * @param {Boolean} [silent_error=false] returns undefined if the key or object is not found, rather than throwing an exception
* @returns {Class} the stored class, to initialize
*
* @throws {openerp.web.KeyNotFound} if the object was not in the mapping
* @throws {openerp.web.ObjectNotFound} if the object path was invalid
*/
- get_object: function (key) {
+ get_object: function (key, silent_error) {
var path_string = this.map[key];
if (path_string === undefined) {
+ if (silent_error) { return void 'nooo'; }
throw new openerp.web.KeyNotFound(key);
}
@@ -272,6 +274,7 @@ openerp.web.Registry = openerp.web.Class.extend( /** @lends openerp.web.Registry
object_match = object_match[path[i]];
if (object_match === undefined) {
+ if (silent_error) { return void 'noooooo'; }
throw new openerp.web.ObjectNotFound(path_string);
}
}
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 2e00e343b50..0d962353b78 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -13,6 +13,7 @@ openerp.web.FormView = openerp.web.View.extend( /** @lends openerp.web.FormView#
readonly : false,
form_template: "FormView",
identifier_prefix: 'formview-',
+ display_name: {toString: function () { return _t('Form'); }},
/**
* @constructs openerp.web.FormView
* @extends openerp.web.View
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
index 86749849053..8ed475c75f6 100644
--- a/addons/web/static/src/js/view_list.js
+++ b/addons/web/static/src/js/view_list.js
@@ -4,6 +4,7 @@ var QWeb = openerp.web.qweb;
openerp.web.views.add('list', 'openerp.web.ListView');
openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# */ {
_template: 'ListView',
+ display_name: {toString: function () { return _t('List'); }},
defaults: {
// records can be selected one by one
'selectable': true,
diff --git a/addons/web/static/src/js/view_page.js b/addons/web/static/src/js/view_page.js
index 060c95e86e3..1b23198da67 100644
--- a/addons/web/static/src/js/view_page.js
+++ b/addons/web/static/src/js/view_page.js
@@ -5,6 +5,7 @@ openerp.web.page = function (openerp) {
openerp.web.views.add('page', 'openerp.web.PageView');
openerp.web.PageView = openerp.web.FormView.extend({
form_template: "PageView",
+ display_name: {toString: function () { return _t('Page'); }},
init: function () {
this._super.apply(this, arguments);
this.registry = openerp.web.page.readonly;
diff --git a/addons/web/static/src/js/view_tree.js b/addons/web/static/src/js/view_tree.js
index 869e23fc16d..48f7290c8d9 100644
--- a/addons/web/static/src/js/view_tree.js
+++ b/addons/web/static/src/js/view_tree.js
@@ -3,10 +3,12 @@
*---------------------------------------------------------*/
openerp.web.view_tree = function(openerp) {
-var QWeb = openerp.web.qweb;
+var QWeb = openerp.web.qweb,
+ _t = openerp.web._t;
openerp.web.views.add('tree', 'openerp.web.TreeView');
openerp.web.TreeView = openerp.web.View.extend(/** @lends openerp.web.TreeView# */{
+ display_name: {toString: function () { return _t('Tree'); }},
/**
* Indicates that this view is not searchable, and thus that no search
* view should be displayed (if there is one active).
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index 579027a360a..5800939ec36 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -210,7 +210,18 @@ session.web.ViewManager = session.web.Widget.extend(/** @lends session.web.View
this.dataset = dataset;
this.searchview = null;
this.active_view = null;
- this.views_src = _.map(views, function(x) {return x instanceof Array? {view_id: x[0], view_type: x[1]} : x;});
+ this.views_src = _.map(views, function(x) {
+ if (x instanceof Array) {
+ var View = session.web.views.get_object(x[1], true);
+ return {
+ view_id: x[0],
+ view_type: x[1],
+ label: View ? View.prototype.display_name : (void 'nope')
+ };
+ } else {
+ return x;
+ }
+ });
this.views = {};
this.flags = flags || {};
this.registry = session.web.views;
@@ -967,6 +978,8 @@ session.web.TranslateDialog = session.web.Dialog.extend({
session.web.View = session.web.Widget.extend(/** @lends session.web.View# */{
template: "EmptyComponent",
+ // name displayed in view switchers
+ display_name: '',
set_default_options: function(options) {
this.options = options || {};
_.defaults(this.options, {
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index ff21856aeff..c7b32cef6d7 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -424,7 +424,7 @@
<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">
- <t t-esc="view.view_type"/>
+ <t t-esc="view.label || view.view_type"/>
</button>
</t>
</div>