[MIG] web_widget_url_advanced: Migration to 18.0

pull/3021/head
Vang - Nguyen Phu 2024-12-14 20:49:34 +07:00
parent 0129157d47
commit 2de76dc911
7 changed files with 61 additions and 47 deletions

View File

@ -17,21 +17,22 @@ Web URL widget advanced
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3 :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github .. |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 :alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png .. |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 :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |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 By default, the URL, CopyClipboardURL widget will show the plain URL.
attribute to provide a static label too. 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 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 '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 Usage
===== =====
Use url widget as you do usually, then add an extra parameter text_field Use url, CopyClipboardURL widget as you do usually, then add an extra
to indicate which field (present in the view already) must be used for parameter text\_ field to indicate which field (present in the view
the anchor text. already) must be used for the anchor text.
.. code:: xml .. 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'}"/> <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 .. |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/17.0/web_widget_url_advanced/static/description/after.png .. |image2| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_widget_url_advanced/static/description/after.png
Bug Tracker Bug Tracker
=========== ===========
@ -94,7 +95,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_. 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. 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 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. Do not contact contributors directly about support or help with technical issues.
@ -109,16 +110,19 @@ Authors
Contributors Contributors
------------ ------------
- Simone Orsi <simone.orsi@camptocamp.com> - Simone Orsi <simone.orsi@camptocamp.com>
- `CorporateHub <https://corporatehub.eu/>`__ - `CorporateHub <https://corporatehub.eu/>`__
- Alexey Pelykh <alexey.pelykh@corphub.eu> - Alexey Pelykh <alexey.pelykh@corphub.eu>
- Jay Vora <jay.vora@serpentcs.com> - Jay Vora <jay.vora@serpentcs.com>
- Swapnesh Shah <s.shah.serpentcs@gmail.com> - Swapnesh Shah <s.shah.serpentcs@gmail.com>
- Joan Sisquella <joan.sisquella@forgeflow.com> - Joan Sisquella <joan.sisquella@forgeflow.com>
- Peerapong Supasompob <peerapong.supasompob@gmail.com> - Peerapong Supasompob <peerapong.supasompob@gmail.com>
- Nedas Žilinskas <nedas.zilinskas@avoin.systems> - Nedas Žilinskas <nedas.zilinskas@avoin.systems>
- `Komit <https://komit-consulting.com>`__:
- Vang Nguyen Phu
Maintainers 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 mission is to support the collaborative development of Odoo features and
promote its widespread use. 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. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -5,7 +5,7 @@
"summary": "This module extends URL widget " "summary": "This module extends URL widget "
"for displaying anchors with custom labels.", "for displaying anchors with custom labels.",
"category": "Web", "category": "Web",
"version": "17.0.1.0.0", "version": "18.0.1.0.0",
"license": "LGPL-3", "license": "LGPL-3",
"author": "Camptocamp, Odoo Community Association (OCA)", "author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web", "website": "https://github.com/OCA/web",

View File

@ -6,3 +6,5 @@
- Joan Sisquella \<<joan.sisquella@forgeflow.com>\> - Joan Sisquella \<<joan.sisquella@forgeflow.com>\>
- Peerapong Supasompob \<<peerapong.supasompob@gmail.com>\> - Peerapong Supasompob \<<peerapong.supasompob@gmail.com>\>
- Nedas Žilinskas \<<nedas.zilinskas@avoin.systems>\> - Nedas Žilinskas \<<nedas.zilinskas@avoin.systems>\>
- [Komit](https://komit-consulting.com):
- Vang Nguyen Phu

View File

@ -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. attribute to provide a static label too.
With this module, you can use a field for link's inner text using With this module, you can use a field for link's inner text using

View File

@ -1,5 +1,5 @@
Use url widget as you do usually, then add an extra parameter text_field Use url, CopyClipboardURL widget as you do usually, then add an extra parameter text_
to indicate which field (present in the view already) must be used for field to indicate which field (present in the view already) must be used for
the anchor text. the anchor text.
``` xml ``` xml

View File

@ -369,10 +369,11 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3596008f4a705be27d5f63123a0330ad2e83c021846d6fe34e6007e82d5988fe !! 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&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></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&amp;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 widget features to ease customization of anchors text.</p> <p>Extend URL, CopyClipboardURL widget features to ease customization of
<p>By default, the URL widget will show the plain URL. You can specify an anchors text.</p>
attribute to provide a static label too.</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 links inner text using <p>With this module, you can use a field for links inner text using
attribute text_field. You can also add a prefix to the link using attribute text_field. You can also add a prefix to the link using
attribute prefix_name.</p> attribute prefix_name.</p>
@ -393,9 +394,9 @@ attribute prefix_name.</p>
</div> </div>
<div class="section" id="usage"> <div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1> <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 <p>Use url, CopyClipboardURL widget as you do usually, then add an extra
to indicate which field (present in the view already) must be used for parameter text_ field to indicate which field (present in the view
the anchor text.</p> already) must be used for the anchor text.</p>
<pre class="code xml literal-block"> <pre class="code xml literal-block">
<span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;some_url&quot;</span><span class="w"> </span><span class="na">widget=</span><span class="s">&quot;url&quot;</span><span class="w"> </span><span class="na">text_field=</span><span class="s">&quot;another_field&quot;</span><span class="w"> </span><span class="nt">/&gt;</span> <span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;some_url&quot;</span><span class="w"> </span><span class="na">widget=</span><span class="s">&quot;url&quot;</span><span class="w"> </span><span class="na">text_field=</span><span class="s">&quot;another_field&quot;</span><span class="w"> </span><span class="nt">/&gt;</span>
</pre> </pre>
@ -406,9 +407,9 @@ link with partners name as anchor you can do:</p>
<span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;website&quot;</span><span class="w"> </span><span class="na">widget=</span><span class="s">&quot;url&quot;</span><span class="w"> </span><span class="na">text_field=</span><span class="s">&quot;name&quot;</span><span class="w"> </span><span class="na">placeholder=</span><span class="s">&quot;e.g. www.odoo.com&quot;</span><span class="nt">/&gt;</span> <span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;website&quot;</span><span class="w"> </span><span class="na">widget=</span><span class="s">&quot;url&quot;</span><span class="w"> </span><span class="na">text_field=</span><span class="s">&quot;name&quot;</span><span class="w"> </span><span class="na">placeholder=</span><span class="s">&quot;e.g. www.odoo.com&quot;</span><span class="nt">/&gt;</span>
</pre> </pre>
<p>This is going to change the rendering from</p> <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>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> <p>Or user can add any hyperlink text using prefix_name attribute</p>
<pre class="code xml literal-block"> <pre class="code xml literal-block">
<span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;skype_name&quot;</span><span class="w"> </span><span class="na">widget=</span><span class="s">&quot;url&quot;</span><span class="w"> </span><span class="na">prefix_name=</span><span class="s">&quot;skype&quot;</span><span class="nt">/&gt;</span> <span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;skype_name&quot;</span><span class="w"> </span><span class="na">widget=</span><span class="s">&quot;url&quot;</span><span class="w"> </span><span class="na">prefix_name=</span><span class="s">&quot;skype&quot;</span><span class="nt">/&gt;</span>
@ -423,7 +424,7 @@ link with partners 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>. <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. 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 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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <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 &lt;<a class="reference external" href="mailto:joan.sisquella&#64;forgeflow.com">joan.sisquella&#64;forgeflow.com</a>&gt;</li> <li>Joan Sisquella &lt;<a class="reference external" href="mailto:joan.sisquella&#64;forgeflow.com">joan.sisquella&#64;forgeflow.com</a>&gt;</li>
<li>Peerapong Supasompob &lt;<a class="reference external" href="mailto:peerapong.supasompob&#64;gmail.com">peerapong.supasompob&#64;gmail.com</a>&gt;</li> <li>Peerapong Supasompob &lt;<a class="reference external" href="mailto:peerapong.supasompob&#64;gmail.com">peerapong.supasompob&#64;gmail.com</a>&gt;</li>
<li>Nedas Žilinskas &lt;<a class="reference external" href="mailto:nedas.zilinskas&#64;avoin.systems">nedas.zilinskas&#64;avoin.systems</a>&gt;</li> <li>Nedas Žilinskas &lt;<a class="reference external" href="mailto:nedas.zilinskas&#64;avoin.systems">nedas.zilinskas&#64;avoin.systems</a>&gt;</li>
<li><a class="reference external" href="https://komit-consulting.com">Komit</a>:<ul>
<li>Vang Nguyen Phu</li>
</ul>
</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <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 <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> 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> <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>
</div> </div>

View File

@ -1,21 +1,23 @@
/** @odoo-module **/
/* Copyright 2018 Simone Orsi - Camptocamp SA /* Copyright 2018 Simone Orsi - Camptocamp SA
License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html). */ 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 {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}, text_field: {type: String, optional: true},
prefix_name: {type: String, optional: true}, prefix_name: {type: String, optional: true},
}); };
patch(UrlField.props, AdvancedUrlFieldProps);
patch(copyClipboardURLField.component.props, AdvancedUrlFieldProps);
patch(UrlField.prototype, { patch(UrlField.prototype, {
_get_text_field() { _get_text_field() {
if (this.props.text_field) { if (this.props.text_field) {
let field_value = this.props.record.data[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]; field_value = field_value[1];
} }
return field_value; return field_value;
@ -43,14 +45,15 @@ patch(UrlField.prototype, {
}, },
}); });
const patchExtractProps = { const patchExtractProps = () => ({
extractProps({attrs, options}) { extractProps({attrs, options}) {
const props = super.extractProps(...arguments); const props = super.extractProps(...arguments);
props.text_field = attrs.text_field || options.text_field; props.text_field = attrs.text_field || options.text_field;
props.prefix_name = attrs.prefix_name || options.prefix_name; props.prefix_name = attrs.prefix_name || options.prefix_name;
return props; return props;
}, },
}; });
patch(urlField, patchExtractProps); patch(urlField, patchExtractProps());
patch(formUrlField, patchExtractProps); patch(formUrlField, patchExtractProps());
patch(copyClipboardURLField, patchExtractProps());