[IMP] Merge 'web_widget_prefixed_url'

pull/1541/head
Joan Sisquella 2020-03-03 11:30:34 +01:00
parent e79b46bb63
commit b8d28ba8cf
4 changed files with 35 additions and 3 deletions

View File

@ -1,2 +1,5 @@
* Simone Orsi <simone.orsi@camptocamp.com>
* Alexey Pelykh <alexey.pelykh@brainbeanapps.com>
* Jay Vora <jay.vora@serpentcs.com>
* Swapnesh Shah <s.shah.serpentcs@gmail.com>
* Joan Sisquella <joan.sisquella@forgeflow.com>

View File

@ -1,6 +1,11 @@
Extend URL widget features to ease customization of anchor's text.
By default the URL widget will show the plain URL.
You can specify an attribute `text` to provide a static label too.
By default, the URL widget will show the plain URL.
You can specify an attribute to provide a static label too.
With this module you can use a field for link's inner text.
With this module, you can use a field for link's inner text using attribute
'text_field'. You can also add a prefix to the link using attribute
'prefix_name'.
Until 13.0 this functionality was separated in modules 'web_widget_url_advanced'
and 'web_widget_prefixed_url'

View File

@ -25,3 +25,15 @@ This is going to change the rendering from
to
.. figure:: ../static/description/after.png
Or user can add any hyperlink text using 'prefix_name' attribute
.. code-block:: xml
<field name="skype_name" widget="url" 'prefix_name': 'skype'/>
both can be applied inside the options attribute too:
.. code-block:: xml
<field name="skype_name" widget="url" options="{'prefix_name': 'skype'}"/>

View File

@ -23,5 +23,17 @@ odoo.define("web_widget_url_advanced", function(require) {
this.attrs.text = field_value;
}
},
/**
*
* @override
* @private
*/
_renderReadonly: function() {
this._super.apply(this, arguments);
var prefix = this.attrs.prefix_name || this.attrs.options.prefix_name;
if (prefix) {
this.$el.attr("href", prefix + ":" + this.value);
}
},
});
});