diff --git a/src/screen.js b/src/screen.js index 0edc2a697e..08b873b15b 100644 --- a/src/screen.js +++ b/src/screen.js @@ -653,6 +653,11 @@ } this.model.add_fields(fields); var view_widget = Sao.View.parse(this, xml_view, view.field_childs); + // This call to set_name is in screen.js instead than in tab.js in + // order to prevent using a callback in the Tab code + if (jQuery.isEmptyObject(this.views) && (this.tab !== null)) { + this.tab.set_name(view_widget.attributes.string || ''); + } this.views.push(view_widget); return view_widget; diff --git a/src/tab.js b/src/tab.js index 2d2b85ceb9..b22ea9271c 100644 --- a/src/tab.js +++ b/src/tab.js @@ -8,6 +8,7 @@ Sao.Tab.tabs.push(this); this.buttons = {}; this.id = 'tab-' + Sao.Tab.counter++; + this.name_el = jQuery(''); }, create_tabcontent: function() { this.el = jQuery('
', { @@ -111,6 +112,9 @@ }, _close_allowed: function() { return jQuery.when(); + }, + set_name: function(name) { + this.name_el.text(name); } }); @@ -181,7 +185,7 @@ }).append('Close')).click(function() { tab.close(); })) - .append(tab.name); + .append(tab.name_el); jQuery('', { 'role': 'presentation', id: 'nav-' + tab.id @@ -204,7 +208,6 @@ screen.tab = this; this.screen = screen; this.attributes = jQuery.extend({}, attributes); - this.name = attributes.name; // XXX use screen current view title if (!Sao.common.MODELHISTORY.contains(model_name)) { this.menu_def = jQuery.extend([], this.menu_def); @@ -578,9 +581,9 @@ var time_format = '%H:%M:%S.%f'; revision = Sao.common.format_datetime(date_format, time_format, revision); - label = this.name + ' @ '+ revision; + label = this.name_el.text() + ' @ '+ revision; } else { - label = this.name; + label = this.name_el.text(); } this.title.html(label); ['new', 'save'].forEach(function(button) { @@ -628,10 +631,10 @@ init: function(wizard) { Sao.Tab.Wizard._super.init.call(this); this.wizard = wizard; - this.name = wizard.name; + this.set_name(wizard.name); wizard.tab = this; this.create_tabcontent(); - this.title.html(this.name); + this.title.html(this.name_el.text()); this.el.append(wizard.form); }, create_toolbar: function() {