diff options
| author | Antony Lesuisse <al@openerp.com> | 2012-12-19 03:50:47 +0100 |
|---|---|---|
| committer | Antony Lesuisse <al@openerp.com> | 2012-12-19 03:50:47 +0100 |
| commit | 7826bd85f8e2bee372b3e0df9f2a30eb84a116b6 (patch) | |
| tree | ce379fbf79b8aed913cb9d20c8e6a733082fe400 /addons/web/static/src/js | |
| parent | 3e1bce4badab7a2c38d68d6ff409c6093a3aacd9 (diff) | |
| parent | 677b783dc5a7214e47e8a11ec1fb84ea630fee8a (diff) | |
[MERGE] trunk
bzr revid: al@openerp.com-20121219025047-og0v9r8x09y0wmd3
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 83 | ||||
| -rw-r--r-- | addons/web/static/src/js/coresetup.js | 4 | ||||
| -rw-r--r-- | addons/web/static/src/js/search.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 173 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_list.js | 4 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_tree.js | 5 | ||||
| -rw-r--r-- | addons/web/static/src/js/views.js | 47 |
7 files changed, 212 insertions, 106 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index a2ff00c5f03..632e782c67c 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -565,8 +565,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({ }, do_exit: function () { this.$el.remove(); - instance.webclient.toggle_bars(false); - this.do_action('login'); + instance.webclient.show_login(); } }); instance.web.client_actions.add("database_manager", "instance.web.DatabaseManager"); @@ -805,13 +804,14 @@ instance.web.Menu = instance.web.Widget.extend({ this.has_been_loaded = $.Deferred(); this.maximum_visible_links = 'auto'; // # of menu to show. 0 = do not crop, 'auto' = algo this.data = {data:{children:[]}}; - this.on("menu_loaded", this, function (e) { + this.on("menu_loaded", this, function (menu_data) { // launch the fetch of needaction counters, asynchronous - this.rpc("/web/menu/load_needaction", {menu_ids: false}).done(function(r) { - self.on_needaction_loaded(r); - }); + if (!_.isEmpty(menu_data.all_menu_ids)) { + this.rpc("/web/menu/load_needaction", {menu_ids: menu_data.all_menu_ids}).done(function(r) { + self.on_needaction_loaded(r); + }); + } }); - }, start: function() { this._super.apply(this, arguments); @@ -827,7 +827,7 @@ instance.web.Menu = instance.web.Widget.extend({ }, menu_loaded: function(data) { var self = this; - this.data = data; + this.data = {data: data}; this.renderElement(); this.limit_entries(); // Hide toplevel item if there is only one @@ -848,7 +848,7 @@ instance.web.Menu = instance.web.Widget.extend({ on_needaction_loaded: function(data) { var self = this; this.needaction_data = data; - _.each(this.needaction_data.data, function (item, menu_id) { + _.each(this.needaction_data, function (item, menu_id) { var $item = self.$secondary_menus.find('a[data-menu="' + menu_id + '"]'); $item.remove('oe_menu_counter'); if (item.needaction_counter && item.needaction_counter > 0) { @@ -1119,9 +1119,14 @@ instance.web.Client = instance.web.Widget.extend({ instance.web.WebClient = instance.web.Client.extend({ _template: 'WebClient', + events: { + 'click .oe_logo_edit_admin': 'logo_edit' + }, init: function(parent) { this._super(parent); this._current_state = null; + this.menu_dm = new instance.web.DropMisordered(); + this.action_mutex = new $.Mutex(); }, start: function() { var self = this; @@ -1173,6 +1178,7 @@ instance.web.WebClient = instance.web.Client.extend({ show_application: function() { var self = this; self.toggle_bars(true); + self.update_logo(); self.menu = new instance.web.Menu(self); self.menu.replace(this.$el.find('.oe_menu_placeholder')); self.menu.on('menu_click', this, this.on_menu_action); @@ -1184,6 +1190,32 @@ instance.web.WebClient = instance.web.Client.extend({ self.set_title(); self.check_timezone(); }, + update_logo: function() { + var img = this.session.url('/web/binary/company_logo'); + this.$('.oe_logo img').attr('src', '').attr('src', img); + this.$('.oe_logo_edit').toggleClass('oe_logo_edit_admin', this.session.uid === 1); + }, + logo_edit: function(ev) { + var self = this; + new instance.web.Model("res.users").get_func("read")(this.session.uid, ["company_id"]).then(function(res) { + self.rpc("/web/action/load", { action_id: "base.action_res_company_form" }).done(function(result) { + result.res_id = res['company_id'][0]; + result.target = "new"; + result.views = [[false, 'form']]; + result.flags = { + action_buttons: true, + }; + self.action_manager.do_action(result); + var form = self.action_manager.dialog_widget.views.form.controller; + form.on("on_button_cancel", self.action_manager.dialog, self.action_manager.dialog.close); + form.on('record_saved', self, function() { + self.action_manager.dialog.close(); + self.update_logo(); + }); + }); + }); + return false; + }, check_timezone: function() { var self = this; return new instance.web.Model('res.users').call('read', [[this.session.uid], ['tz_offset']]).then(function(result) { @@ -1287,18 +1319,29 @@ instance.web.WebClient = instance.web.Client.extend({ }, on_menu_action: function(options) { var self = this; - return this.rpc("/web/action/load", { action_id: options.action_id }) + return this.menu_dm.add(this.rpc("/web/action/load", { action_id: options.action_id })) .then(function (result) { - if (options.needaction) { - result.context = new instance.web.CompoundContext( - result.context, - {search_default_message_unread: true}); - } - return $.when(self.action_manager.do_action(result, { - clear_breadcrumbs: true, - action_menu_id: self.menu.current_menu, - })).fail(function() { - self.menu.open_menu(options.previous_menu_id); + return self.action_mutex.exec(function() { + if (options.needaction) { + result.context = new instance.web.CompoundContext( + result.context, + {search_default_message_unread: true}); + } + var completed = $.Deferred(); + $.when(self.action_manager.do_action(result, { + clear_breadcrumbs: true, + action_menu_id: self.menu.current_menu, + })).fail(function() { + self.menu.open_menu(options.previous_menu_id); + }).always(function() { + completed.resolve(); + }); + setTimeout(function() { + completed.resolve(); + }, 2000); + // We block the menu when clicking on an element until the action has correctly finished + // loading. If something crash, there is a 2 seconds timeout before it's unblocked. + return completed; }); }); }, diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index c28a51ebe6b..eac26520301 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -125,9 +125,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess }, session_logout: function() { this.set_cookie('session_id', ''); - var url = "#"; - $.bbq.pushState(url); - window.location.search = ""; + $.bbq.removeState(); return this.rpc("/web/session/destroy", {}); }, get_cookie: function (name) { diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index eea8bba726d..34ab101fea7 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -640,7 +640,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea .then(this.proxy('setup_default_query')); return $.when(drawer_started, defaults_fetched) - .done(function () { + .then(function () { self.trigger("search_view_loaded", data); self.ready.resolve(); }); diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 814995da5f7..299d579803d 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -128,13 +128,15 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM self.init_pager(); }); self.on("load_record", self, self.load_record); - this.on('view_loaded', self, self.load_form); instance.web.bus.on('clear_uncommitted_changes', this, function(e) { if (!this.can_be_discarded()) { e.preventDefault(); } }); }, + view_loading: function(r) { + return this.load_form(r); + }, destroy: function() { _.each(this.get_widgets(), function(w) { w.off('focused blurred'); @@ -194,7 +196,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } this.sidebar.add_items('other', _.compact([ self.is_action_enabled('delete') && { label: _t('Delete'), callback: self.on_button_delete }, - self.is_action_enabled('create') && { label: _t('Duplicate'), callback: self.on_button_duplicate }, + self.is_action_enabled('create') && { label: _t('Duplicate'), callback: self.on_button_duplicate } ])); } @@ -211,7 +213,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }); //bounce effect on red button when click on statusbar. this.$el.find(".oe_form_field_status:not(.oe_form_status_clickable)").on('click', function (e) { - if((self.get("actual_mode") == "view")) { + if((self.get("actual_mode") == "view")) { var $button = self.$el.find(".oe_highlight:not(.oe_form_invisible)").css({'float':'left','clear':'none'}); $button.effect('bounce', {distance:18, times: 5}, 150); e.stopPropagation(); @@ -917,7 +919,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM this.do_update_pager(); if (this.sidebar) { this.sidebar.do_attachement_update(this.dataset, this.datarecord.id); - } + } //openerp.log("The record has been created with id #" + this.datarecord.id); return $.when(this.reload()).then(function () { self.trigger('record_created', r); @@ -1694,6 +1696,10 @@ instance.web.form.compute_domain = function(expr, fields) { return _.all(stack, _.identity); }; +instance.web.form.is_bin_size = function(v) { + return /^\d+(\.\d*)? \w+$/.test(v); +}; + /** * Must be applied over an class already possessing the PropertiesMixin. * @@ -2216,19 +2222,28 @@ instance.web.form.ReinitializeFieldMixin = _.extend({}, instance.web.form.Reini instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, { template: 'FieldChar', widget_class: 'oe_form_field_char', + events: { + 'change input': 'store_dom_value', + }, init: function (field_manager, node) { this._super(field_manager, node); this.password = this.node.attrs.password === 'True' || this.node.attrs.password === '1'; }, initialize_content: function() { - var self = this; - var $input = this.$el.find('input'); - $input.change(function() { - if(self.is_syntax_valid()){ - self.internal_set_value(self.parse_value($input.val())); - } - }); - this.setupFocus($input); + this.setupFocus(this.$('input')); + }, + store_dom_value: function () { + if (!this.get('effective_readonly') + && this.$('input').length + && this.is_syntax_valid()) { + this.internal_set_value( + this.parse_value( + this.$('input').val())); + } + }, + commit_value: function () { + this.store_dom_value(); + return this._super(); }, render_value: function() { var show_value = this.format_value(this.get('value'), ''); @@ -2244,7 +2259,7 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we is_syntax_valid: function() { if (!this.get("effective_readonly") && this.$("input").size() > 0) { try { - var value_ = this.parse_value(this.$el.find('input').val(), ''); + this.parse_value(this.$('input').val(), ''); return true; } catch(e) { return false; @@ -2262,7 +2277,7 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we return this.get('value') === '' || this._super(); }, focus: function() { - this.$('input:first').focus(); + this.$('input:first')[0].focus(); }, set_dimensions: function (height, width) { this._super(height, width); @@ -2274,7 +2289,10 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we }); instance.web.form.FieldID = instance.web.form.FieldChar.extend({ - + process_modifiers: function () { + this._super(); + this.set({ readonly: true }); + }, }); instance.web.form.FieldEmail = instance.web.form.FieldChar.extend({ @@ -2363,6 +2381,9 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ template: "web.datepicker", jqueryui_object: 'datetimepicker', type_of_date: "datetime", + events: { + 'change .oe_datepicker_master': 'change_datetime', + }, init: function(parent) { this._super(parent); this.name = parent.name; @@ -2371,10 +2392,7 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ var self = this; this.$input = this.$el.find('input.oe_datepicker_master'); this.$input_picker = this.$el.find('input.oe_datepicker_container'); - this.$input.change(function(){ - self.change_datetime(); - }); - + this.picker({ onClose: this.on_picker_select, onSelect: this.on_picker_select, @@ -2447,7 +2465,10 @@ instance.web.DateTimeWidget = instance.web.Widget.extend({ this.set_value_from_ui_(); this.trigger("datetime_changed"); } - } + }, + commit_value: function () { + this.change_datetime(); + }, }); instance.web.DateWidget = instance.web.DateTimeWidget.extend({ @@ -2494,7 +2515,7 @@ instance.web.form.FieldDatetime = instance.web.form.AbstractField.extend(instanc }, focus: function() { if (this.datewidget && this.datewidget.$input) { - this.datewidget.$input.focus(); + this.datewidget.$input[0].focus(); } }, set_dimensions: function (height, width) { @@ -2512,40 +2533,56 @@ instance.web.form.FieldDate = instance.web.form.FieldDatetime.extend({ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, { template: 'FieldText', + events: { + 'keyup': function (e) { + if (e.which === $.ui.keyCode.ENTER) { + e.stopPropagation(); + } + }, + 'change textarea': 'store_dom_value', + }, init: function (field_manager, node) { this._super(field_manager, node); }, initialize_content: function() { var self = this; this.$textarea = this.$el.find('textarea'); + this.auto_sized = false; this.default_height = this.$textarea.css('height'); - if (!this.get("effective_readonly")) { - this.$textarea.change(_.bind(function() { - self.internal_set_value(instance.web.parse_value(self.$textarea.val(), self)); - }, this)); - } else { + if (this.get("effective_readonly")) { this.$textarea.attr('disabled', 'disabled'); } - this.$el.keyup(function (e) { - if (e.which === $.ui.keyCode.ENTER) { - e.stopPropagation(); - } - }); this.setupFocus(this.$textarea); }, + commit_value: function () { + this.store_dom_value(); + return this._super(); + }, + store_dom_value: function () { + if (!this.get('effective_readonly') && this.$('textarea').length) { + this.internal_set_value( + instance.web.parse_value( + this.$textarea.val(), + this)); + } + }, render_value: function() { - $(window).resize(); var show_value = instance.web.format_value(this.get('value'), this, ''); if (show_value === '') { this.$textarea.css('height', parseInt(this.default_height)+"px"); } this.$textarea.val(show_value); - this.$textarea.autosize(); + if (! this.auto_sized) { + this.auto_sized = true; + this.$textarea.autosize(); + } else { + this.$textarea.trigger("autosize"); + } }, is_syntax_valid: function() { if (!this.get("effective_readonly") && this.$textarea) { try { - var value_ = instance.web.parse_value(this.$textarea.val(), this, ''); + instance.web.parse_value(this.$textarea.val(), this, ''); return true; } catch(e) { return false; @@ -2557,7 +2594,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we return this.get('value') === '' || this._super(); }, focus: function($el) { - this.$textarea.focus(); + this.$textarea[0].focus(); }, set_dimensions: function (height, width) { this._super(height, width); @@ -2638,7 +2675,7 @@ instance.web.form.FieldBoolean = instance.web.form.AbstractField.extend({ this.$checkbox[0].checked = this.get('value'); }, focus: function() { - this.$checkbox.focus(); + this.$checkbox[0].focus(); } }); @@ -2660,6 +2697,9 @@ instance.web.form.FieldProgressBar = instance.web.form.AbstractField.extend({ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, { template: 'FieldSelection', + events: { + 'change select': 'store_dom_value', + }, init: function(field_manager, node) { var self = this; this._super(field_manager, node); @@ -2682,9 +2722,6 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan // row var ischanging = false; var $select = this.$el.find('select') - .change(_.bind(function() { - this.internal_set_value(this.values[this.$el.find('select')[0].selectedIndex][0]); - }, this)) .change(function () { ischanging = true; }) .click(function () { ischanging = false; }) .keyup(function (e) { @@ -2694,6 +2731,16 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan }); this.setupFocus($select); }, + commit_value: function () { + this.store_dom_value(); + return this._super(); + }, + store_dom_value: function () { + if (!this.get('effective_readonly') && this.$('select').length) { + this.internal_set_value( + this.values[this.$('select')[0].selectedIndex][0]); + } + }, set_value: function(value_) { value_ = value_ === null ? false : value_; value_ = value_ instanceof Array ? value_[0] : value_; @@ -2714,7 +2761,7 @@ instance.web.form.FieldSelection = instance.web.form.AbstractField.extend(instan } }, focus: function() { - this.$el.find('select:first').focus(); + this.$('select:first')[0].focus(); }, set_dimensions: function (height, width) { this._super(height, width); @@ -3200,7 +3247,7 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc }, focus: function () { if (!this.get('effective_readonly')) { - this.$input.focus(); + this.$input[0].focus(); } }, _quick_create: function() { @@ -4050,6 +4097,9 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in add_id: function(id) { this.set({'value': _.uniq(this.get('value').concat([id]))}); }, + focus: function () { + this.$text[0].focus(); + }, }); /** @@ -4386,7 +4436,7 @@ instance.web.form.Many2ManyQuickCreate = instance.web.Widget.extend({ }); }, focus: function() { - this.$text.focus(); + this.$text[0].focus(); }, add_id: function(id) { var self = this; @@ -4834,11 +4884,6 @@ instance.web.form.FieldBinary = instance.web.form.AbstractField.extend(instance. if (!value) { this.do_warn(_t("Save As..."), _t("The field is empty, there's nothing to save !")); ev.stopPropagation(); - } else if (this._dirty_flag) { - var link = this.$('.oe_form_binary_file_save_data')[0]; - link.download = this.filename || "download.bin"; // Works on only on Google Chrome - //link.target = '_blank'; - link.href = "data:application/octet-stream;base64," + value; } else { instance.web.blockUI(); var c = instance.webclient.crashmanager; @@ -4849,6 +4894,7 @@ instance.web.form.FieldBinary = instance.web.form.AbstractField.extend(instance. id: (this.view.datarecord.id || ''), field: this.name, filename_field: (this.node.attrs.filename || ''), + data: instance.web.form.is_bin_size(value) ? null : value, context: this.view.dataset.get_context() })}, complete: instance.web.unblockUI, @@ -4928,7 +4974,7 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({ render_value: function() { var self = this; var url; - if (this.get('value') && ! /^\d+(\.\d*)? \w+$/.test(this.get('value'))) { + if (this.get('value') && !instance.web.form.is_bin_size(this.get('value'))) { url = 'data:image/png;base64,' + this.get('value'); } else if (this.get('value')) { var id = JSON.stringify(this.view.datarecord.id || null); @@ -5029,7 +5075,7 @@ instance.web.form.FieldMany2ManyBinaryMultiFiles = instance.web.form.AbstractFie this._super( ids ); }, get_value: function() { - return _.map(this.get('value'), function (value) { return commands.link_to( value.id ); }); + return _.map(this.get('value'), function (value) { return commands.link_to( isNaN(value) ? value.id : value ); }); }, get_file_url: function (attachment) { return this.session.url('/web/binary/saveas', {model: 'ir.attachment', field: 'datas', filename_field: 'datas_fname', id: attachment['id']}); @@ -5049,7 +5095,7 @@ instance.web.form.FieldMany2ManyBinaryMultiFiles = instance.web.form.AbstractFie _.each(datas, function (data) { data.no_unlink = true; data.url = self.session.url('/web/binary/saveas', {model: 'ir.attachment', field: 'datas', filename_field: 'datas_fname', id: data.id}); - + _.each(self.get('value'), function (val, key) { if(val == data.id) { self.get('value')[key] = data; @@ -5123,6 +5169,8 @@ instance.web.form.FieldMany2ManyBinaryMultiFiles = instance.web.form.AbstractFie } }, on_file_loaded: function (event, result) { + var files = this.get('value'); + // unblock UI if(this.node.attrs.blockui>0) { instance.web.unblockUI(); @@ -5130,15 +5178,19 @@ instance.web.form.FieldMany2ManyBinaryMultiFiles = instance.web.form.AbstractFie // TODO : activate send on wizard and form - var files = this.get('value'); - for(var i in files){ - if(files[i].filename == result.filename && files[i].upload) { - files[i] = { - 'id': result.id, - 'name': result.name, - 'filename': result.filename, - 'url': this.get_file_url(result) - }; + if (result.error || !result.id ) { + this.do_warn( _t('Uploading error'), result.error); + files = _.filter(files, function (val) { return !val.upload; }); + } else { + for(var i in files){ + if(files[i].filename == result.filename && files[i].upload) { + files[i] = { + 'id': result.id, + 'name': result.name, + 'filename': result.filename, + 'url': this.get_file_url(result) + }; + } } } @@ -5209,7 +5261,8 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ if (this.field.type == "many2one") { var domain = []; if(!_.isEmpty(this.field.domain) || !_.isEmpty(this.node.attrs.domain)) { - domain = new instance.web.CompoundDomain(['|'], self.build_domain(), [['id', '=', self.get('value')]]); + var d = instance.web.pyeval.eval('domain', self.build_domain()); + domain = ['|', ['id', '=', self.get('value')]].concat(d); } var ds = new instance.web.DataSetSearch(this, this.field.relation, self.build_context(), domain); return ds.read_slice(['name'], {}).then(function (records) { diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 04ff8b48923..f6794bd435c 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -90,7 +90,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi this.no_leaf = false; this.grouped = false; - this.on('view_loaded', self, self.load_list); + }, + view_loading: function(r) { + return this.load_list(r); }, set_default_options: function (options) { this._super(options); diff --git a/addons/web/static/src/js/view_tree.js b/addons/web/static/src/js/view_tree.js index acac93f1842..2f9efad9171 100644 --- a/addons/web/static/src/js/view_tree.js +++ b/addons/web/static/src/js/view_tree.js @@ -37,7 +37,10 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie this.options = _.extend({}, this.defaults, options || {}); _.bindAll(this, 'color_for'); - this.on('view_loaded', this, this.load_tree); + }, + + view_loading: function(r) { + return this.load_tree(r); }, /** diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index c0c6ae1f31d..92f66849fec 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -467,6 +467,7 @@ instance.web.ViewManager = instance.web.Widget.extend({ this.flags = flags || {}; this.registry = instance.web.views; this.views_history = []; + this.view_completely_inited = $.Deferred(); }, /** * @returns {jQuery.Deferred} initial view loading promise @@ -586,6 +587,8 @@ instance.web.ViewManager = instance.web.Widget.extend({ && self.flags.auto_search && view.controller.searchable !== false) { self.searchview.ready.done(self.searchview.do_search); + } else { + self.view_completely_inited.resolve(); } self.trigger("controller_inited",view_type,controller); }); @@ -700,7 +703,9 @@ instance.web.ViewManager = instance.web.Widget.extend({ if (_.isString(groupby)) { groupby = [groupby]; } - controller.do_search(results.domain, results.context, groupby || []); + $.when(controller.do_search(results.domain, results.context, groupby || [])).then(function() { + self.view_completely_inited.resolve(); + }); }); }, /** @@ -782,7 +787,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({ var main_view_loaded = this._super(); - var manager_ready = $.when(searchview_loaded, main_view_loaded); + var manager_ready = $.when(searchview_loaded, main_view_loaded, this.view_completely_inited); this.$el.find('.oe_debug_view').change(this.on_debug_changed); this.$el.addClass("oe_view_manager_" + (this.action.target || 'current')); @@ -1027,6 +1032,11 @@ instance.web.Sidebar = instance.web.Widget.extend({ this.$('.oe_form_dropdown_section').each(function() { $(this).toggle(!!$(this).find('li').length); }); + + self.$("[title]").tipsy({ + 'html': true, + 'delayIn': 500, + }) }, /** * For each item added to the section: @@ -1110,27 +1120,19 @@ instance.web.Sidebar = instance.web.Widget.extend({ }); }); }, - do_attachement_update: function(dataset, model_id,args) { + do_attachement_update: function(dataset, model_id, args) { var self = this; this.dataset = dataset; this.model_id = model_id; - if (args && args[0]["erorr"]) { - instance.web.dialog($('<div>'),{ - modal: true, - title: "OpenERP " + _.str.capitalize(args[0]["title"]), - buttons: [{ - text: _t("Ok"), - click: function(){ - $(this).dialog("close"); - }}] - }).html(args[0]["erorr"]); + if (args && args[0].error) { + this.do_warn( instance.web.qweb.render('message_error_uploading'), args[0].error); } if (!model_id) { this.on_attachments_loaded([]); } else { var dom = [ ['res_model', '=', dataset.model], ['res_id', '=', model_id], ['type', 'in', ['binary', 'url']] ]; var ds = new instance.web.DataSetSearch(this, 'ir.attachment', dataset.get_context(), dom); - ds.read_slice(['name', 'url', 'type'], {}).done(this.on_attachments_loaded); + ds.read_slice(['name', 'url', 'type', 'create_uid', 'create_date', 'write_uid', 'write_date'], {}).done(this.on_attachments_loaded); } }, on_attachments_loaded: function(attachments) { @@ -1189,31 +1191,36 @@ instance.web.View = instance.web.Widget.extend({ }, load_view: function(context) { var self = this; - var view_loaded; + var view_loaded_def; if (this.embedded_view) { - view_loaded = $.Deferred(); + view_loaded_def = $.Deferred(); $.async_when().done(function() { - view_loaded.resolve(self.embedded_view); + view_loaded_def.resolve(self.embedded_view); }); } else { if (! this.view_type) console.warn("view_type is not defined", this); - view_loaded = instance.web.fields_view_get({ + view_loaded_def = instance.web.fields_view_get({ "model": this.dataset._model, "view_id": this.view_id, "view_type": this.view_type, "toolbar": !!this.options.$sidebar, }); } - return view_loaded.then(function(r) { - self.trigger('view_loaded', r); + return view_loaded_def.then(function(r) { + self.fields_view = r; // add css classes that reflect the (absence of) access rights self.$el.addClass('oe_view') .toggleClass('oe_cannot_create', !self.is_action_enabled('create')) .toggleClass('oe_cannot_edit', !self.is_action_enabled('edit')) .toggleClass('oe_cannot_delete', !self.is_action_enabled('delete')); + return $.when(self.view_loading(r)).then(function() { + self.trigger('view_loaded', r); + }); }); }, + view_loading: function(r) { + }, set_default_options: function(options) { this.options = options || {}; _.defaults(this.options, { |
