diff options
| author | Olivier Dony <odo@openerp.com> | 2014-03-14 15:39:11 +0100 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2014-03-14 15:39:11 +0100 |
| commit | 6a14fddc35348d7c8b8f91c76285925e853d5002 (patch) | |
| tree | 90290537d84c2207a5ba6d7109ac6d929a30463e /addons | |
| parent | 8820d9f1886868bb4b874e96185535ebd9a6c35d (diff) | |
| parent | 02459f8d4a97ef8ee82464389b269fafac7fec21 (diff) | |
[MERGE] Forward port of saas-2 fixes up to rev 9152 rev-id odo@openerp.com-20140314143519-x6rzcfkkqxwc0e1g
bzr revid: odo@openerp.com-20140314143911-c2mxesg31xezeyr9
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/pad/pad.py | 4 | ||||
| -rw-r--r-- | addons/pad/static/src/css/etherpad.css | 1 | ||||
| -rw-r--r-- | addons/pad/static/src/js/pad.js | 96 | ||||
| -rw-r--r-- | addons/share/wizard/share_wizard.py | 2 |
4 files changed, 63 insertions, 40 deletions
diff --git a/addons/pad/pad.py b/addons/pad/pad.py index 474321edb1d..ab6f3d6b18c 100644 --- a/addons/pad/pad.py +++ b/addons/pad/pad.py @@ -14,6 +14,10 @@ _logger = logging.getLogger(__name__) class pad_common(osv.osv_memory): _name = 'pad.common' + def pad_is_configured(self, cr, uid, context=None): + user = self.pool.get('res.users').browse(cr, uid, uid, context=context) + return bool(user.company_id.pad_server) + def pad_generate_url(self, cr, uid, context=None): company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id; diff --git a/addons/pad/static/src/css/etherpad.css b/addons/pad/static/src/css/etherpad.css index d8281ef4d48..a076cdfc6f4 100644 --- a/addons/pad/static/src/css/etherpad.css +++ b/addons/pad/static/src/css/etherpad.css @@ -70,6 +70,7 @@ .oe_pad_loading{ text-align: center; opacity: 0.75; + font-style: italic; } .etherpad_readonly ul, .etherpad_readonly ol { diff --git a/addons/pad/static/src/js/pad.js b/addons/pad/static/src/js/pad.js index 4c8b7d6fa26..d3a6394ee5d 100644 --- a/addons/pad/static/src/js/pad.js +++ b/addons/pad/static/src/js/pad.js @@ -1,64 +1,82 @@ openerp.pad = function(instance) { + var _t = instance.web._t; instance.web.form.FieldPad = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeWidgetMixin, { template: 'FieldPad', content: "", init: function() { + var self = this; this._super.apply(this, arguments); - this.set("configured", true); - this.on("change:configured", this, this.switch_configured); + this._configured_deferred = this.view.dataset.call('pad_is_configured').done(function(data) { + self.set("configured", !!data); + }).fail(function(data, event) { + event.preventDefault(); + self.set("configured", true); + }); }, initialize_content: function() { var self = this; - this.switch_configured(); this.$('.oe_pad_switch').click(function() { self.$el.toggleClass('oe_pad_fullscreen'); self.$el.find('.oe_pad_switch').toggleClass('fa-expand fa-compress'); self.view.$el.find('.oe_chatter').toggle(); }); + this._configured_deferred.always(function() { + var configured = self.get('configured'); + self.$(".oe_unconfigured").toggle(!configured); + self.$(".oe_configured").toggle(configured); + }); this.render_value(); }, - switch_configured: function() { - this.$(".oe_unconfigured").toggle(! this.get("configured")); - this.$(".oe_configured").toggle(this.get("configured")); - }, render_value: function() { - var self = this; - if (this.get("configured") && ! this.get("value")) { - self.view.dataset.call('pad_generate_url', { - context: { - model: self.view.model, - field_name: self.name, - object_id: self.view.datarecord.id - }, - }).done(function(data) { - if (! data.url) { - self.set("configured", false); + var self = this; + this._configured_deferred.always(function() { + if (! self.get('configured')) { + return; + }; + var value = self.get('value'); + if (self.get('effective_readonly')) { + if (_.str.startsWith(value, 'http')) { + this.pad_loading_request = self.view.dataset.call('pad_get_content', {url: value}).done(function(data) { + self.$('.oe_pad_content').removeClass('oe_pad_loading').html('<div class="oe_pad_readonly"><div>'); + self.$('.oe_pad_readonly').html(data); + }).fail(function() { + self.$('.oe_pad_content').text(_t('Unable to load pad')); + }); } else { - self.set("value", data.url); + self.$('.oe_pad_content').addClass('oe_pad_loading').show().text(_t("This pad will be initialized on first edit")); + } + } + else { + var def = $.when(); + if (! value || !_.str.startsWith(value, 'http')) { + def = self.view.dataset.call('pad_generate_url', { + context: { + model: self.view.model, + field_name: self.name, + object_id: self.view.datarecord.id + }, + }).done(function(data) { + if (! data.url) { + self.set("configured", false); + } else { + self.set("value", data.url); + } + }); } - }); - } - this.$('.oe_pad_content').html(""); - var value = this.get('value'); - if (this.pad_loading_request) { - this.pad_loading_request.abort(); - } - if (_.str.startsWith(value, 'http')) { - if (! this.get('effective_readonly')) { - var content = '<iframe width="100%" height="100%" frameborder="0" src="' + value + '?showChat=false&userName=' + this.session.username + '"></iframe>'; - this.$('.oe_pad_content').html(content); - this._dirty_flag = true; - } else { - this.content = '<div class="oe_pad_loading">... Loading pad ...</div>'; - this.pad_loading_request = self.view.dataset.call('pad_get_content', {url: value}).done(function(data) { - self.$('.oe_pad_content').html('<div class="oe_pad_readonly"><div>'); - self.$('.oe_pad_readonly').html(data); - }).fail(function() { - self.$('.oe_pad_content').text('Unable to load pad'); + def.then(function() { + value = self.get('value'); + if (_.str.startsWith(value, 'http')) { + var content = '<iframe width="100%" height="100%" frameborder="0" src="' + value + '?showChat=false&userName=' + self.session.username + '"></iframe>'; + self.$('.oe_pad_content').html(content); + self._dirty_flag = true; + } + else { + self.$('.oe_pad_content').text(value); + } }); } - } + }); }, }); diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index 22b880956cc..10937015dd6 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -906,7 +906,7 @@ class share_result_line(osv.osv_memory): 'login': fields.related('user_id', 'login', string='Login', type='char', size=64, required=True, readonly=True), 'password': fields.char('Password', size=64, readonly=True), 'share_url': fields.function(_share_url, string='Share URL', type='char', size=512), - 'share_wizard_id': fields.many2one('share.wizard', 'Share Wizard', required=True), + 'share_wizard_id': fields.many2one('share.wizard', 'Share Wizard', required=True, ondelete='cascade'), 'newly_created': fields.boolean('Newly created', readonly=True), } _defaults = { |
