Implemented read only mode

bzr revid: nicolas.vanhoren@openerp.com-20120813154011-hgq3vxxdps5s9w91
This commit is contained in:
niv-openerp 2012-08-13 17:40:11 +02:00
parent 8c7b192ab7
commit 235f8996bf
2 changed files with 36 additions and 22 deletions

View File

@ -2397,33 +2397,44 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
instance.web.form.FieldTextHtml = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, { instance.web.form.FieldTextHtml = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
template: 'FieldTextHtml', template: 'FieldTextHtml',
initialize_content: function() { initialize_content: function() {
this.$textarea = this.$element.find('textarea'); var self = this;
var width = ((this.node.attrs || {}).editor_width || 468); if (! this.get("effective_readonly")) {
var height = ((this.node.attrs || {}).editor_height || 100); self._updating_editor = false;
this.$textarea.cleditor({ this.$textarea = this.$element.find('textarea');
width: width, // width not including margins, borders or padding var width = ((this.node.attrs || {}).editor_width || 468);
height: height, // height not including margins, borders or padding var height = ((this.node.attrs || {}).editor_height || 100);
controls: // controls to add to the toolbar this.$textarea.cleditor({
"bold italic underline strikethrough " + width: width, // width not including margins, borders or padding
"| removeformat | bullets numbering | outdent " + height: height, // height not including margins, borders or padding
"indent | link unlink | source", controls: // controls to add to the toolbar
bodyStyle: // style to assign to document body contained within the editor "bold italic underline strikethrough " +
"margin:4px; font:12px monospace; cursor:text; color:#1F1F1F" "| removeformat | bullets numbering | outdent " +
}); "indent | link unlink | source",
this.$cleditor = this.$textarea.cleditor()[0]; bodyStyle: // style to assign to document body contained within the editor
"margin:4px; font:12px monospace; cursor:text; color:#1F1F1F"
});
this.$cleditor = this.$textarea.cleditor()[0];
this.$cleditor.change(function() {
if (! self._updating_editor) {
self.$cleditor.updateTextArea();
self.set({'value': self.$textarea.val()});
}
});
}
}, },
set_value: function(value_) { set_value: function(value_) {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this._dirty_flag = true;
this.render_value(); this.render_value();
}, },
render_value: function() { render_value: function() {
this.$textarea.val(this.get('value')); if (! this.get("effective_readonly")) {
this.$cleditor.updateFrame(); this.$textarea.val(this.get('value'));
}, this._updating_editor = true;
get_value: function() { this.$cleditor.updateFrame();
this.$cleditor.updateTextArea(); this._updating_editor = false;
return this.$textarea.val(); } else {
this.$element.html(this.get('value'));
}
}, },
}); });

View File

@ -976,8 +976,11 @@
</div> </div>
</t> </t>
<t t-name="FieldTextHtml"> <t t-name="FieldTextHtml">
<div class="oe_form_field oe_form_field_text" t-att-style="widget.node.attrs.style"> <div t-att-class="'oe_form_field oe_form_field_html' + (widget.get('effective_readonly') ? ' oe_form_embedded_html' : '')"
t-att-style="widget.node.attrs.style">
<t t-if="! widget.get('effective_readonly')">
<textarea/> <textarea/>
</t>
</div> </div>
</t> </t>
<t t-name="web.datepicker"> <t t-name="web.datepicker">