generate url from the widget if needed
bzr revid: al@openerp.com-20120820234008-olfcnxj7np6hwwgz
This commit is contained in:
parent
f313d35c85
commit
72c5fe278b
|
@ -1,7 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from osv import fields, osv
|
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):
|
class company_pad(osv.osv):
|
||||||
_inherit = 'res.company'
|
_inherit = 'res.company'
|
||||||
|
|
|
@ -1,52 +1,39 @@
|
||||||
.oe_etherpad_head{
|
.oe_pad_head {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: block;
|
display: block;
|
||||||
padding-left:3px;
|
padding: 4px;
|
||||||
cursor:pointer;
|
|
||||||
}
|
}
|
||||||
.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_pad_fullscreen {
|
||||||
}
|
|
||||||
.oe_etherpad_fullscreen {
|
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
z-index:10001 !important;
|
z-index: 1000;
|
||||||
}
|
|
||||||
.etherpad_default{
|
|
||||||
width: 100%;
|
|
||||||
height: 450px;
|
|
||||||
}
|
|
||||||
.oe_etherpad_fullscreen .etherpad_default{
|
|
||||||
height: 100%
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.etherpad_body{
|
.oe_pad_fullscreen .oe_pad_content {
|
||||||
overflow:hidden;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etherpad_readonly{
|
.etherpad_readonly ul, .etherpad_readonly ol {
|
||||||
width: 100%;
|
margin-before: 1em;
|
||||||
height: 450px;
|
margin-after: 1em;
|
||||||
overflow:auto;
|
margin-start: 0px;
|
||||||
|
margin-end: 0px;
|
||||||
|
padding-start: 40px !important;
|
||||||
}
|
}
|
||||||
.etherpad_readonly ul,.etherpad_readonly ol{
|
.etherpad_readonly ul li{
|
||||||
-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{
|
|
||||||
list-style-type: disc;
|
list-style-type: disc;
|
||||||
}
|
}
|
||||||
.etherpad_readonly ol li{
|
.etherpad_readonly ol li{
|
||||||
list-style-type: decimal;
|
list-style-type: decimal;
|
||||||
}
|
}
|
||||||
.etherpad_readonly .indent li{
|
.etherpad_readonly .indent li{
|
||||||
|
|
|
@ -1,32 +1,47 @@
|
||||||
openerp.pad = function(instance) {
|
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',
|
template: 'FieldPad',
|
||||||
initialize_content: function() {
|
start: function() {
|
||||||
|
this._super();
|
||||||
var self = this;
|
var self = this;
|
||||||
this.$textarea = undefined;
|
this.$element.find('div.oe_pad_head').click(function(ev) {
|
||||||
this.$element.find('div.oe_etherpad_head').click(function(ev) {
|
self.$element.toggleClass('oe_pad_fullscreen');
|
||||||
self.$element.toggleClass('oe_etherpad_fullscreen').toggleClass('oe_etherpad_normal');
|
});
|
||||||
|
this.on("change:effective_readonly", this, function() {
|
||||||
|
this.render_value();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
set_value: function(value_) {
|
set_value: function(val) {
|
||||||
this._super(value_);
|
var self = this;
|
||||||
this.render_value();
|
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() {
|
render_value: function() {
|
||||||
|
console.log("display");
|
||||||
var self = this;
|
var self = this;
|
||||||
var value = this.get('value');
|
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")) {
|
if (!this.get("effective_readonly")) {
|
||||||
var pad_username = this.session.username;
|
var pad_username = this.session.username;
|
||||||
var code = '<iframe width="100%" height="100%" frameborder="0" src="'+url+'?showChat=false&userName='+pad_username+'"></iframe>';
|
var code = '<iframe width="100%" height="100%" frameborder="0" src="'+value+'?showChat=false&userName='+pad_username+'"></iframe>';
|
||||||
this.$element.find('div.oe_etherpad_default').html(code);
|
this.$('.oe_pad_content').html(code);
|
||||||
} else {
|
} else {
|
||||||
$.get(url+'/export/html').success(function(data) {
|
$.get(value+'/export/html').success(function(data) {
|
||||||
self.$element.html('<div class="etherpad_readonly">'+data+'</div>');
|
self.$('.oe_pad_content').html('<div class="oe_pad_readonly">'+data+'</div>');
|
||||||
}).error(function() {
|
}).error(function() {
|
||||||
self.$element.text('Unable to load pad');
|
self.$('.oe_pad_content').text('Unable to load pad');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,19 @@
|
||||||
<!-- vim:fdl=1:
|
<!-- vim:fdl=1:
|
||||||
-->
|
-->
|
||||||
<templates id="template" xml:space="preserve">
|
<templates id="template" xml:space="preserve">
|
||||||
|
|
||||||
<t t-name="FieldPad">
|
<t t-name="FieldPad">
|
||||||
<t t-if="!widget.get('effective_readonly')">
|
<div class="oe_form_field_text oe_pad">
|
||||||
<div class="oe_form_field_text oe_etherpad_normal">
|
<div class="oe_pad_head">
|
||||||
<div class="oe_etherpad_head">
|
<span class="oe_pad_switch">Fullscreen</span>
|
||||||
<span class="oe_normal">Fullscreen</span>
|
|
||||||
<span class="oe_fullscreen">Return to Record</span>
|
|
||||||
</div>
|
|
||||||
<div class="oe_etherpad_default" ></div>
|
|
||||||
</div>
|
</div>
|
||||||
</t>
|
<div class="oe_pad_content"></div>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
<t t-name="FieldPad.unconfigured">
|
||||||
|
Please configure your etherpad server.<br/>
|
||||||
|
OpenERP Entreprise customers may safely use pad.openerp.com as a server using the following template:<br/>
|
||||||
|
<blockquote>
|
||||||
|
http://pad.openerp.com/p/%(db)s-%(model)s-%(salt)s
|
||||||
|
</blockquote>
|
||||||
</t>
|
</t>
|
||||||
|
|
||||||
</templates>
|
</templates>
|
||||||
|
|
|
@ -9,6 +9,3 @@ class task(osv.osv):
|
||||||
_columns = {
|
_columns = {
|
||||||
'description_pad': fields.char('Description PAD', size=250)
|
'description_pad': fields.char('Description PAD', size=250)
|
||||||
}
|
}
|
||||||
_defaults = {
|
|
||||||
'description_pad': lambda self, cr, uid, context: self.pad_generate_url(cr, uid, context),
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue