From 72c5fe278bab4c52f5efb70364534b3ad54936fd Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Tue, 21 Aug 2012 01:40:08 +0200 Subject: [PATCH] generate url from the widget if needed bzr revid: al@openerp.com-20120820234008-olfcnxj7np6hwwgz --- addons/pad/res_company.py | 3 +- addons/pad/static/src/css/etherpad.css | 51 ++++++++++---------------- addons/pad/static/src/js/pad.js | 45 +++++++++++++++-------- addons/pad/static/src/xml/pad.xml | 22 ++++++----- addons/pad_project/project_task.py | 3 -- 5 files changed, 63 insertions(+), 61 deletions(-) diff --git a/addons/pad/res_company.py b/addons/pad/res_company.py index bd955cd0481..703e655219b 100644 --- a/addons/pad/res_company.py +++ b/addons/pad/res_company.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- from osv import fields, osv -DEFAULT_PAD_TEMPLATE = 'http://beta.etherpad.org/p/%(db)s-%(model)s-%(salt)s' +DEFAULT_PAD_TEMPLATE = 'http://pad.openerp.com/p/%(db)s-%(model)s-%(salt)s' +DEFAULT_PAD_TEMPLATE = '' class company_pad(osv.osv): _inherit = 'res.company' diff --git a/addons/pad/static/src/css/etherpad.css b/addons/pad/static/src/css/etherpad.css index a0240afcab7..8ea7972071e 100644 --- a/addons/pad/static/src/css/etherpad.css +++ b/addons/pad/static/src/css/etherpad.css @@ -1,52 +1,39 @@ -.oe_etherpad_head{ +.oe_pad_head { width: 100%; display: block; - padding-left:3px; - cursor:pointer; + padding: 4px; } -.oe_etherpad_fullscreen div.oe_etherpad_head .oe_normal { - display: none; + +.oe_pad_readonly { + border: 1px solid #ddd; + padding: 8px; } -.oe_etherpad_normal div.oe_etherpad_head .oe_fullscreen { - display: none; -} -.oe_etherpad_fullscreen { + +.oe_pad_fullscreen { position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; background-color: white; - z-index:10001 !important; -} -.etherpad_default{ - width: 100%; - height: 450px; -} -.oe_etherpad_fullscreen .etherpad_default{ - height: 100% + z-index: 1000; } -.etherpad_body{ - overflow:hidden; +.oe_pad_fullscreen .oe_pad_content { + height: 100%; } -.etherpad_readonly{ - width: 100%; - height: 450px; - overflow:auto; +.etherpad_readonly ul, .etherpad_readonly ol { + margin-before: 1em; + margin-after: 1em; + margin-start: 0px; + margin-end: 0px; + padding-start: 40px !important; } -.etherpad_readonly ul,.etherpad_readonly ol{ - -webkit-margin-before: 1em; - -webkit-margin-after: 1em; - -webkit-margin-start: 0px; - -webkit-margin-end: 0px; - -webkit-padding-start: 40px !important; -} -.etherpad_readonly ul li{ +.etherpad_readonly ul li{ list-style-type: disc; } -.etherpad_readonly ol li{ +.etherpad_readonly ol li{ list-style-type: decimal; } .etherpad_readonly .indent li{ diff --git a/addons/pad/static/src/js/pad.js b/addons/pad/static/src/js/pad.js index 6384eb72da8..314c751785a 100644 --- a/addons/pad/static/src/js/pad.js +++ b/addons/pad/static/src/js/pad.js @@ -1,32 +1,47 @@ openerp.pad = function(instance) { -instance.web.form.FieldPad = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, { +instance.web.form.FieldPad = instance.web.form.AbstractField.extend({ template: 'FieldPad', - initialize_content: function() { + start: function() { + this._super(); var self = this; - this.$textarea = undefined; - this.$element.find('div.oe_etherpad_head').click(function(ev) { - self.$element.toggleClass('oe_etherpad_fullscreen').toggleClass('oe_etherpad_normal'); + this.$element.find('div.oe_pad_head').click(function(ev) { + self.$element.toggleClass('oe_pad_fullscreen'); + }); + this.on("change:effective_readonly", this, function() { + this.render_value(); }); }, - set_value: function(value_) { - this._super(value_); - this.render_value(); + set_value: function(val) { + var self = this; + var _super = self._super; + _super.apply(self,[val]); + if (val === false || val === "") { + self.field_manager.dataset.call('pad_generate_url').then(function(r) { + _super.apply(self,[r]); + self.render_value(); + }); + } else { + self.render_value(); + } }, render_value: function() { + console.log("display"); var self = this; var value = this.get('value'); - if(value !== false) { - var url = value.split('\n')[0]; + + if (!_.str.startsWith(value, "http")) { + self.$('.oe_pad_content').html(instance.web.qweb.render('FieldPad.unconfigured')); + } else { if (!this.get("effective_readonly")) { var pad_username = this.session.username; - var code = ''; - this.$element.find('div.oe_etherpad_default').html(code); + var code = ''; + this.$('.oe_pad_content').html(code); } else { - $.get(url+'/export/html').success(function(data) { - self.$element.html('
'+data+'
'); + $.get(value+'/export/html').success(function(data) { + self.$('.oe_pad_content').html('
'+data+'
'); }).error(function() { - self.$element.text('Unable to load pad'); + self.$('.oe_pad_content').text('Unable to load pad'); }); } } diff --git a/addons/pad/static/src/xml/pad.xml b/addons/pad/static/src/xml/pad.xml index e128fb183fb..58266a2594a 100644 --- a/addons/pad/static/src/xml/pad.xml +++ b/addons/pad/static/src/xml/pad.xml @@ -2,17 +2,19 @@ - - -
-
- Fullscreen - Return to Record -
-
+
+
+ Fullscreen
- +
+
+ + + Please configure your etherpad server.
+ OpenERP Entreprise customers may safely use pad.openerp.com as a server using the following template:
+
+ http://pad.openerp.com/p/%(db)s-%(model)s-%(salt)s +
- diff --git a/addons/pad_project/project_task.py b/addons/pad_project/project_task.py index 46c2c54cd46..513fc3fef5d 100644 --- a/addons/pad_project/project_task.py +++ b/addons/pad_project/project_task.py @@ -9,6 +9,3 @@ class task(osv.osv): _columns = { 'description_pad': fields.char('Description PAD', size=250) } - _defaults = { - 'description_pad': lambda self, cr, uid, context: self.pad_generate_url(cr, uid, context), - }