Browse Source

Add the functionality to the text widget

pull/218/head
Nikolina Todorova 9 years ago
parent
commit
e2dfadf713
  1. 3
      web_text_widget/__openerp__.py
  2. 16
      web_text_widget/static/src/js/text_limited.js
  3. 8
      web_text_widget/static/src/xml/text_limited.xml

3
web_text_widget/__openerp__.py

@ -26,7 +26,7 @@
'category': '',
'description': """
* Add new 'text_limited' widget for TextField, but data are limited to
* Add new functionality for TextField, but data are limited to
10 lines or 500 characters (by default).
You can change default values by context varibles 'limit_lines' and
'limit_chars'.
@ -49,7 +49,6 @@ Example of usage:
'static/src/js/text_limited.js',
],
'qweb': [
'static/src/xml/text_limited.xml',
],
'css': [
'static/src/css/text_limited.css',

16
web_text_widget/static/src/js/text_limited.js

@ -5,8 +5,7 @@ var QWeb = instance.web.qweb;
var _t = instance.web._t;
instance.web_text_widget.FieldTextLimited = instance.web.form.FieldText.extend(
instance.web.form.ReinitializeFieldMixin, {
instance.web.form.FieldText.include({
template: 'FieldText',
LIMIT_LINES_CONTEXT_KEY: 'limit_lines',
LIMIT_LINES_DEFAULT: 10,
@ -53,16 +52,5 @@ instance.web_text_widget.FieldTextLimited = instance.web.form.FieldText.extend(
this.$el.find('span.length_limit').html(value.length + '/' + limit_chars);
},
initialize_content: function() {
return this._super();
},
store_dom_value: function () {
this.limit_value(this.$textarea);
return this._super();
},
});
instance.web.form.widgets.add('text_limited',
'instance.web_text_widget.FieldTextLimited');
};
}

8
web_text_widget/static/src/xml/text_limited.xml

@ -1,8 +0,0 @@
<?xml version='1.0' encoding='UTF-8' ?>
<templates id="template" xml:space="preserve">
<t t-extend="FieldText">
<t t-jquery=".oe_form_field_text" t-operation="append">
<span class="length_limit"></span>
</t>
</t>
</templates>
Loading…
Cancel
Save