mirror of https://github.com/OCA/web.git
[MIG] web_widget_url_advanced: Migration to 18.0
parent
0129157d47
commit
2de76dc911
|
@ -17,21 +17,22 @@ Web URL widget advanced
|
|||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
|
||||
:alt: License: LGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/web/tree/17.0/web_widget_url_advanced
|
||||
:target: https://github.com/OCA/web/tree/18.0/web_widget_url_advanced
|
||||
:alt: OCA/web
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_widget_url_advanced
|
||||
:target: https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_widget_url_advanced
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=17.0
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0
|
||||
:alt: Try me on Runboat
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
Extend URL widget features to ease customization of anchor's text.
|
||||
Extend URL, CopyClipboardURL widget features to ease customization of
|
||||
anchor's text.
|
||||
|
||||
By default, the URL widget will show the plain URL. You can specify an
|
||||
attribute to provide a static label too.
|
||||
By default, the URL, CopyClipboardURL 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 using
|
||||
attribute 'text_field'. You can also add a prefix to the link using
|
||||
|
@ -48,9 +49,9 @@ Until 13.0 this functionality was separated in modules
|
|||
Usage
|
||||
=====
|
||||
|
||||
Use url widget as you do usually, then add an extra parameter text_field
|
||||
to indicate which field (present in the view already) must be used for
|
||||
the anchor text.
|
||||
Use url, CopyClipboardURL widget as you do usually, then add an extra
|
||||
parameter text\_ field to indicate which field (present in the view
|
||||
already) must be used for the anchor text.
|
||||
|
||||
.. code:: xml
|
||||
|
||||
|
@ -85,8 +86,8 @@ both can be applied inside the options attribute too:
|
|||
|
||||
<field name="skype_name" widget="url" options="{'prefix_name': 'skype'}"/>
|
||||
|
||||
.. |image1| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_widget_url_advanced/static/description/before.png
|
||||
.. |image2| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_widget_url_advanced/static/description/after.png
|
||||
.. |image1| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_widget_url_advanced/static/description/before.png
|
||||
.. |image2| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_widget_url_advanced/static/description/after.png
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
@ -94,7 +95,7 @@ Bug Tracker
|
|||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_url_advanced%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_url_advanced%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
|
@ -109,16 +110,19 @@ Authors
|
|||
Contributors
|
||||
------------
|
||||
|
||||
- Simone Orsi <simone.orsi@camptocamp.com>
|
||||
- `CorporateHub <https://corporatehub.eu/>`__
|
||||
- Simone Orsi <simone.orsi@camptocamp.com>
|
||||
- `CorporateHub <https://corporatehub.eu/>`__
|
||||
|
||||
- Alexey Pelykh <alexey.pelykh@corphub.eu>
|
||||
- Alexey Pelykh <alexey.pelykh@corphub.eu>
|
||||
|
||||
- Jay Vora <jay.vora@serpentcs.com>
|
||||
- Swapnesh Shah <s.shah.serpentcs@gmail.com>
|
||||
- Joan Sisquella <joan.sisquella@forgeflow.com>
|
||||
- Peerapong Supasompob <peerapong.supasompob@gmail.com>
|
||||
- Nedas Žilinskas <nedas.zilinskas@avoin.systems>
|
||||
- Jay Vora <jay.vora@serpentcs.com>
|
||||
- Swapnesh Shah <s.shah.serpentcs@gmail.com>
|
||||
- Joan Sisquella <joan.sisquella@forgeflow.com>
|
||||
- Peerapong Supasompob <peerapong.supasompob@gmail.com>
|
||||
- Nedas Žilinskas <nedas.zilinskas@avoin.systems>
|
||||
- `Komit <https://komit-consulting.com>`__:
|
||||
|
||||
- Vang Nguyen Phu
|
||||
|
||||
Maintainers
|
||||
-----------
|
||||
|
@ -133,6 +137,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
|||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
This module is part of the `OCA/web <https://github.com/OCA/web/tree/17.0/web_widget_url_advanced>`_ project on GitHub.
|
||||
This module is part of the `OCA/web <https://github.com/OCA/web/tree/18.0/web_widget_url_advanced>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"summary": "This module extends URL widget "
|
||||
"for displaying anchors with custom labels.",
|
||||
"category": "Web",
|
||||
"version": "17.0.1.0.0",
|
||||
"version": "18.0.1.0.0",
|
||||
"license": "LGPL-3",
|
||||
"author": "Camptocamp, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/web",
|
||||
|
|
|
@ -6,3 +6,5 @@
|
|||
- Joan Sisquella \<<joan.sisquella@forgeflow.com>\>
|
||||
- Peerapong Supasompob \<<peerapong.supasompob@gmail.com>\>
|
||||
- Nedas Žilinskas \<<nedas.zilinskas@avoin.systems>\>
|
||||
- [Komit](https://komit-consulting.com):
|
||||
- Vang Nguyen Phu
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Extend URL widget features to ease customization of anchor's text.
|
||||
Extend URL, CopyClipboardURL widget features to ease customization of anchor's text.
|
||||
|
||||
By default, the URL widget will show the plain URL. You can specify an
|
||||
By default, the URL, CopyClipboardURL 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 using
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Use url widget as you do usually, then add an extra parameter text_field
|
||||
to indicate which field (present in the view already) must be used for
|
||||
Use url, CopyClipboardURL widget as you do usually, then add an extra parameter text_
|
||||
field to indicate which field (present in the view already) must be used for
|
||||
the anchor text.
|
||||
|
||||
``` xml
|
||||
|
|
|
@ -369,10 +369,11 @@ ul.auto-toc {
|
|||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:3596008f4a705be27d5f63123a0330ad2e83c021846d6fe34e6007e82d5988fe
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/17.0/web_widget_url_advanced"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_widget_url_advanced"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>Extend URL widget features to ease customization of anchor’s text.</p>
|
||||
<p>By default, the URL widget will show the plain URL. You can specify an
|
||||
attribute to provide a static label too.</p>
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/18.0/web_widget_url_advanced"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_widget_url_advanced"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>Extend URL, CopyClipboardURL widget features to ease customization of
|
||||
anchor’s text.</p>
|
||||
<p>By default, the URL, CopyClipboardURL widget will show the plain URL.
|
||||
You can specify an attribute to provide a static label too.</p>
|
||||
<p>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’.</p>
|
||||
|
@ -393,9 +394,9 @@ attribute ‘prefix_name’.</p>
|
|||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
|
||||
<p>Use url widget as you do usually, then add an extra parameter text_field
|
||||
to indicate which field (present in the view already) must be used for
|
||||
the anchor text.</p>
|
||||
<p>Use url, CopyClipboardURL widget as you do usually, then add an extra
|
||||
parameter text_ field to indicate which field (present in the view
|
||||
already) must be used for the anchor text.</p>
|
||||
<pre class="code xml literal-block">
|
||||
<span class="nt"><field</span><span class="w"> </span><span class="na">name=</span><span class="s">"some_url"</span><span class="w"> </span><span class="na">widget=</span><span class="s">"url"</span><span class="w"> </span><span class="na">text_field=</span><span class="s">"another_field"</span><span class="w"> </span><span class="nt">/></span>
|
||||
</pre>
|
||||
|
@ -406,9 +407,9 @@ link with partner’s name as anchor you can do:</p>
|
|||
<span class="nt"><field</span><span class="w"> </span><span class="na">name=</span><span class="s">"website"</span><span class="w"> </span><span class="na">widget=</span><span class="s">"url"</span><span class="w"> </span><span class="na">text_field=</span><span class="s">"name"</span><span class="w"> </span><span class="na">placeholder=</span><span class="s">"e.g. www.odoo.com"</span><span class="nt">/></span>
|
||||
</pre>
|
||||
<p>This is going to change the rendering from</p>
|
||||
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/web/17.0/web_widget_url_advanced/static/description/before.png" /></p>
|
||||
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/web/18.0/web_widget_url_advanced/static/description/before.png" /></p>
|
||||
<p>to</p>
|
||||
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/web/17.0/web_widget_url_advanced/static/description/after.png" /></p>
|
||||
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/web/18.0/web_widget_url_advanced/static/description/after.png" /></p>
|
||||
<p>Or user can add any hyperlink text using ‘prefix_name’ attribute</p>
|
||||
<pre class="code xml literal-block">
|
||||
<span class="nt"><field</span><span class="w"> </span><span class="na">name=</span><span class="s">"skype_name"</span><span class="w"> </span><span class="na">widget=</span><span class="s">"url"</span><span class="w"> </span><span class="na">prefix_name=</span><span class="s">"skype"</span><span class="nt">/></span>
|
||||
|
@ -423,7 +424,7 @@ link with partner’s name as anchor you can do:</p>
|
|||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_url_advanced%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_url_advanced%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
|
@ -447,6 +448,10 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|||
<li>Joan Sisquella <<a class="reference external" href="mailto:joan.sisquella@forgeflow.com">joan.sisquella@forgeflow.com</a>></li>
|
||||
<li>Peerapong Supasompob <<a class="reference external" href="mailto:peerapong.supasompob@gmail.com">peerapong.supasompob@gmail.com</a>></li>
|
||||
<li>Nedas Žilinskas <<a class="reference external" href="mailto:nedas.zilinskas@avoin.systems">nedas.zilinskas@avoin.systems</a>></li>
|
||||
<li><a class="reference external" href="https://komit-consulting.com">Komit</a>:<ul>
|
||||
<li>Vang Nguyen Phu</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
|
@ -458,7 +463,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/17.0/web_widget_url_advanced">OCA/web</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/18.0/web_widget_url_advanced">OCA/web</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
/* Copyright 2018 Simone Orsi - Camptocamp SA
|
||||
License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html). */
|
||||
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
import {UrlField, formUrlField, urlField} from "@web/views/fields/url/url_field";
|
||||
import {copyClipboardURLField} from "@web/views/fields/copy_clipboard/copy_clipboard_field";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(UrlField.props, {
|
||||
const AdvancedUrlFieldProps = {
|
||||
text_field: {type: String, optional: true},
|
||||
prefix_name: {type: String, optional: true},
|
||||
});
|
||||
};
|
||||
|
||||
patch(UrlField.props, AdvancedUrlFieldProps);
|
||||
patch(copyClipboardURLField.component.props, AdvancedUrlFieldProps);
|
||||
|
||||
patch(UrlField.prototype, {
|
||||
_get_text_field() {
|
||||
if (this.props.text_field) {
|
||||
let field_value = this.props.record.data[this.props.text_field];
|
||||
if (Array.isArray(field_value) && field_value.length == 2) {
|
||||
if (Array.isArray(field_value) && field_value.length === 2) {
|
||||
field_value = field_value[1];
|
||||
}
|
||||
return field_value;
|
||||
|
@ -43,14 +45,15 @@ patch(UrlField.prototype, {
|
|||
},
|
||||
});
|
||||
|
||||
const patchExtractProps = {
|
||||
const patchExtractProps = () => ({
|
||||
extractProps({attrs, options}) {
|
||||
const props = super.extractProps(...arguments);
|
||||
props.text_field = attrs.text_field || options.text_field;
|
||||
props.prefix_name = attrs.prefix_name || options.prefix_name;
|
||||
return props;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
patch(urlField, patchExtractProps);
|
||||
patch(formUrlField, patchExtractProps);
|
||||
patch(urlField, patchExtractProps());
|
||||
patch(formUrlField, patchExtractProps());
|
||||
patch(copyClipboardURLField, patchExtractProps());
|
||||
|
|
Loading…
Reference in New Issue