[FIX] pad: problem about pad title not being updated correctly, was solved by solving another, more serious, bug that didn't updated correctly the database backup of the pad
lp bug: https://launchpad.net/bugs/1155039 fixed bzr revid: nicolas.vanhoren@openerp.com-20130419143529-jku5titoacaajft0
This commit is contained in:
parent
230b23e6cb
commit
ea2544e432
|
@ -84,10 +84,15 @@ class pad_common(osv.osv_memory):
|
|||
|
||||
# Set the pad content in vals
|
||||
def _set_pad_value(self, cr, uid, vals, context=None):
|
||||
for k,v in vals.items():
|
||||
for k in self._all_columns.keys():
|
||||
field = self._all_columns[k].column
|
||||
if hasattr(field,'pad_content_field'):
|
||||
vals[field.pad_content_field] = self.pad_get_content(cr, uid, v, context=context)
|
||||
url = vals.get(k)
|
||||
if not url and ("id" in vals):
|
||||
url = self.read(cr, uid, vals["id"], [k], context=context)[k]
|
||||
if url:
|
||||
vals[field.pad_content_field] = self.pad_get_content(cr, uid, url, context=context)
|
||||
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
if not default:
|
||||
|
|
|
@ -1,67 +1,63 @@
|
|||
openerp.pad = function(instance) {
|
||||
|
||||
instance.web.form.FieldPad = instance.web.form.AbstractField.extend({
|
||||
instance.web.form.FieldPad = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeWidgetMixin, {
|
||||
template: 'FieldPad',
|
||||
configured: false,
|
||||
content: "",
|
||||
start: function() {
|
||||
this._super();
|
||||
var self = this;
|
||||
this.on('change:effective_readonly',this,function(){
|
||||
self.renderElement();
|
||||
init: function() {
|
||||
this._super.apply(this, arguments);
|
||||
this.set("configured", true);
|
||||
this.on("change:configured", this, this.switch_configured);
|
||||
},
|
||||
initialize_content: function() {
|
||||
this.switch_configured();
|
||||
this.$('.oe_pad_switch').click(function() {
|
||||
self.$el.toggleClass('oe_pad_fullscreen');
|
||||
});
|
||||
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;
|
||||
var _super = _.bind(this._super, this);
|
||||
if (this.get("value") === false || this.get("value") === "") {
|
||||
self.view.dataset.call('pad_generate_url',{context:{
|
||||
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&&data.url){
|
||||
self.set({value: data.url});
|
||||
_super(data.url);
|
||||
self.renderElement();
|
||||
},
|
||||
}).done(function(data) {
|
||||
if (! data.url) {
|
||||
self.set("configured", false);
|
||||
} else {
|
||||
self.set("value", data.url);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
self.renderElement();
|
||||
}
|
||||
this._dirty_flag = true;
|
||||
},
|
||||
renderElement: function(){
|
||||
var self = this;
|
||||
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')){
|
||||
this.configured = false;
|
||||
this.content = "";
|
||||
}else{
|
||||
this.configured = true;
|
||||
if(!this.get('effective_readonly')){
|
||||
this.content = '<iframe width="100%" height="100%" frameborder="0" src="'+value+'?showChat=false&userName='+this.session.username+'"></iframe>';
|
||||
}else{
|
||||
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 = $.get(value+'/export/html')
|
||||
.done(function(data){
|
||||
this.pad_loading_request = $.get(value + '/export/html').done(function(data) {
|
||||
groups = /\<\s*body\s*\>(.*?)\<\s*\/body\s*\>/.exec(data);
|
||||
data = (groups || []).length >= 2 ? groups[1] : '';
|
||||
self.$('.oe_pad_content').html('<div class="oe_pad_readonly"><div>');
|
||||
self.$('.oe_pad_readonly').html(data);
|
||||
}).error(function(){
|
||||
}).fail(function() {
|
||||
self.$('.oe_pad_content').text('Unable to load pad');
|
||||
});
|
||||
}
|
||||
}
|
||||
this._super();
|
||||
this.$('.oe_pad_content').html(this.content);
|
||||
this.$('.oe_pad_switch').click(function(){
|
||||
self.$el.toggleClass('oe_pad_fullscreen');
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -5,32 +5,25 @@
|
|||
|
||||
<t t-name="FieldPad">
|
||||
|
||||
<t t-if="!widget.configured">
|
||||
<div class="oe_form_field_text oe_pad oe_unconfigured">
|
||||
<p>
|
||||
You must configure the etherpad through the menu Settings > Companies > Companies, in the configuration tab of your company.
|
||||
</p>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-if="widget.configured">
|
||||
<div class="oe_form_field_text oe_pad">
|
||||
<p class="oe_unconfigured">
|
||||
You must configure the etherpad through the menu Settings > Companies > Companies, in the configuration tab of your company.
|
||||
</p>
|
||||
<t t-if="widget.get('effective_readonly')">
|
||||
<div class="oe_form_field_text oe_pad oe_configured">
|
||||
<div class="oe_pad_content etherpad_readonly">
|
||||
</div>
|
||||
<div class="oe_pad_content etherpad_readonly oe_configured">
|
||||
</div>
|
||||
</t>
|
||||
<t t-if="! widget.get('effective_readonly')">
|
||||
<div class="oe_pad_switch_positioner oe_configured">
|
||||
<span class="oe_pad_switch oe_e">&Ntilde;</span>
|
||||
</div>
|
||||
<div class="oe_pad_content oe_editing oe_configured">
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<t t-if="!widget.get('effective_readonly')">
|
||||
<div class="oe_form_field_text oe_pad oe_configured">
|
||||
<div class="oe_pad_switch_positioner">
|
||||
<span class="oe_pad_switch oe_e">&Ntilde;</span>
|
||||
</div>
|
||||
<div class="oe_pad_content oe_editing">
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
Loading…
Reference in New Issue