mirror of https://github.com/OCA/web.git
[MIG] web_widget_url_advanced: Migration to 17.0
parent
c85c6ed415
commit
7a357dd55d
|
@ -77,7 +77,7 @@ Or user can add any hyperlink text using 'prefix_name' attribute
|
||||||
|
|
||||||
.. code:: xml
|
.. code:: xml
|
||||||
|
|
||||||
<field name="skype_name" widget="url" 'prefix_name': 'skype'/>
|
<field name="skype_name" widget="url" prefix_name="skype"/>
|
||||||
|
|
||||||
both can be applied inside the options attribute too:
|
both can be applied inside the options attribute too:
|
||||||
|
|
||||||
|
@ -88,11 +88,6 @@ both can be applied inside the options attribute too:
|
||||||
.. |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/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
|
.. |image2| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_widget_url_advanced/static/description/after.png
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
- ``<field text_field="foo"/>`` is not supported in tree views.
|
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
@ -123,6 +118,7 @@ Contributors
|
||||||
- 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>
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
-----------
|
-----------
|
||||||
|
|
|
@ -5,14 +5,16 @@
|
||||||
"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": "15.0.1.0.0",
|
"version": "17.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",
|
||||||
"depends": ["web"],
|
"depends": ["web"],
|
||||||
"data": [],
|
"data": [],
|
||||||
"assets": {
|
"assets": {
|
||||||
"web.assets_backend": ["web_widget_url_advanced/static/src/js/url_widget.js"],
|
"web.assets_backend": [
|
||||||
|
"web_widget_url_advanced/static/src/fields/**/*",
|
||||||
|
],
|
||||||
},
|
},
|
||||||
"installable": True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,3 +5,4 @@
|
||||||
- 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>\>
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
- `<field text_field="foo"/>` is not supported in tree views.
|
|
|
@ -26,7 +26,7 @@ to
|
||||||
Or user can add any hyperlink text using 'prefix_name' attribute
|
Or user can add any hyperlink text using 'prefix_name' attribute
|
||||||
|
|
||||||
``` xml
|
``` xml
|
||||||
<field name="skype_name" widget="url" 'prefix_name': 'skype'/>
|
<field name="skype_name" widget="url" prefix_name="skype"/>
|
||||||
```
|
```
|
||||||
|
|
||||||
both can be applied inside the options attribute too:
|
both can be applied inside the options attribute too:
|
||||||
|
|
|
@ -8,10 +8,11 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
:Author: David Goodger (goodger@python.org)
|
:Author: David Goodger (goodger@python.org)
|
||||||
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
|
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
|
||||||
:Copyright: This stylesheet has been placed in the public domain.
|
:Copyright: This stylesheet has been placed in the public domain.
|
||||||
|
|
||||||
Default cascading style sheet for the HTML output of Docutils.
|
Default cascading style sheet for the HTML output of Docutils.
|
||||||
|
Despite the name, some widely supported CSS2 features are used.
|
||||||
|
|
||||||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
||||||
customize this style sheet.
|
customize this style sheet.
|
||||||
|
@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||||
margin-left: 2em ;
|
margin-left: 2em ;
|
||||||
margin-right: 2em }
|
margin-right: 2em }
|
||||||
|
|
||||||
pre.code .ln { color: grey; } /* line numbers */
|
pre.code .ln { color: gray; } /* line numbers */
|
||||||
pre.code, code { background-color: #eeeeee }
|
pre.code, code { background-color: #eeeeee }
|
||||||
pre.code .comment, code .comment { color: #5C6576 }
|
pre.code .comment, code .comment { color: #5C6576 }
|
||||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||||
|
@ -300,7 +301,7 @@ span.option {
|
||||||
span.pre {
|
span.pre {
|
||||||
white-space: pre }
|
white-space: pre }
|
||||||
|
|
||||||
span.problematic {
|
span.problematic, pre.problematic {
|
||||||
color: red }
|
color: red }
|
||||||
|
|
||||||
span.section-subtitle {
|
span.section-subtitle {
|
||||||
|
@ -381,12 +382,11 @@ attribute ‘prefix_name’.</p>
|
||||||
<div class="contents local topic" id="contents">
|
<div class="contents local topic" id="contents">
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
|
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
|
||||||
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-2">Known issues / Roadmap</a></li>
|
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
|
||||||
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
|
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
|
||||||
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
|
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
|
||||||
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
|
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
|
||||||
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
|
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
|
||||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -411,21 +411,15 @@ link with partner’s name as anchor you can do:</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/17.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"><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="err">'prefix_name':</span><span class="w"> </span><span class="err">'skype'</span><span class="nt">/></span>
|
<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>
|
||||||
</pre>
|
</pre>
|
||||||
<p>both can be applied inside the options attribute too:</p>
|
<p>both can be applied inside the options attribute too:</p>
|
||||||
<pre class="code xml literal-block">
|
<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">options=</span><span class="s">"{'prefix_name': 'skype'}"</span><span class="nt">/></span>
|
<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">options=</span><span class="s">"{'prefix_name': 'skype'}"</span><span class="nt">/></span>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="known-issues-roadmap">
|
|
||||||
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
|
|
||||||
<ul class="simple">
|
|
||||||
<li><tt class="docutils literal"><field <span class="pre">text_field="foo"/></span></tt> is not supported in tree views.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
|
||||||
<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
|
||||||
|
@ -433,15 +427,15 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
<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">
|
||||||
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
|
||||||
<div class="section" id="authors">
|
<div class="section" id="authors">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Camptocamp</li>
|
<li>Camptocamp</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="contributors">
|
<div class="section" id="contributors">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Simone Orsi <<a class="reference external" href="mailto:simone.orsi@camptocamp.com">simone.orsi@camptocamp.com</a>></li>
|
<li>Simone Orsi <<a class="reference external" href="mailto:simone.orsi@camptocamp.com">simone.orsi@camptocamp.com</a>></li>
|
||||||
<li><a class="reference external" href="https://corporatehub.eu/">CorporateHub</a><ul>
|
<li><a class="reference external" href="https://corporatehub.eu/">CorporateHub</a><ul>
|
||||||
|
@ -452,12 +446,15 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
<li>Swapnesh Shah <<a class="reference external" href="mailto:s.shah.serpentcs@gmail.com">s.shah.serpentcs@gmail.com</a>></li>
|
<li>Swapnesh Shah <<a class="reference external" href="mailto:s.shah.serpentcs@gmail.com">s.shah.serpentcs@gmail.com</a>></li>
|
||||||
<li>Joan Sisquella <<a class="reference external" href="mailto:joan.sisquella@forgeflow.com">joan.sisquella@forgeflow.com</a>></li>
|
<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>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>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
|
||||||
<p>This module is maintained by the OCA.</p>
|
<p>This module is maintained by the OCA.</p>
|
||||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
<a class="reference external image-reference" href="https://odoo-community.org">
|
||||||
|
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
||||||
|
</a>
|
||||||
<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>
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/** @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";
|
||||||
|
|
||||||
|
patch(UrlField.props, {
|
||||||
|
text_field: {type: String, optional: true},
|
||||||
|
prefix_name: {type: String, optional: true},
|
||||||
|
});
|
||||||
|
|
||||||
|
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) {
|
||||||
|
field_value = field_value[1];
|
||||||
|
}
|
||||||
|
return field_value;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
get title() {
|
||||||
|
return (
|
||||||
|
this._get_text_field() ||
|
||||||
|
this.props.text ||
|
||||||
|
this.props.record.data[this.props.name] ||
|
||||||
|
""
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
get formattedHrefWithPrefix() {
|
||||||
|
let value = this.formattedHref;
|
||||||
|
|
||||||
|
if (this.props.prefix_name) {
|
||||||
|
value = this.props.prefix_name + ":" + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<templates id="template" xml:space="preserve">
|
||||||
|
|
||||||
|
<t
|
||||||
|
t-name="web_widget_url_advanced.UrlField"
|
||||||
|
t-inherit="web.UrlField"
|
||||||
|
t-inherit-mode="extension"
|
||||||
|
>
|
||||||
|
|
||||||
|
<xpath expr="//a[hasclass('o_field_widget')]" position="attributes">
|
||||||
|
<attribute name="t-esc">title</attribute>
|
||||||
|
<attribute name="t-att-href">formattedHrefWithPrefix</attribute>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
</t>
|
||||||
|
|
||||||
|
<t
|
||||||
|
t-name="web_widget_url_advanced.FormUrlField"
|
||||||
|
t-inherit="web.FormUrlField"
|
||||||
|
t-inherit-mode="extension"
|
||||||
|
>
|
||||||
|
|
||||||
|
<xpath expr="//a[hasclass('o_field_widget')]" position="attributes">
|
||||||
|
<attribute name="t-esc">title</attribute>
|
||||||
|
<attribute name="t-att-href">formattedHrefWithPrefix</attribute>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
</t>
|
||||||
|
|
||||||
|
</templates>
|
|
@ -1,50 +0,0 @@
|
||||||
/* Copyright 2018 Simone Orsi - Camptocamp SA
|
|
||||||
License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html). */
|
|
||||||
|
|
||||||
odoo.define("web_widget_url_advanced", function (require) {
|
|
||||||
"use strict";
|
|
||||||
var basic_fields = require("web.basic_fields");
|
|
||||||
|
|
||||||
basic_fields.UrlWidget.include({
|
|
||||||
/**
|
|
||||||
* @override
|
|
||||||
*/
|
|
||||||
init: function () {
|
|
||||||
this._super.apply(this, arguments);
|
|
||||||
// Retrieve customized `<a />` text from a field
|
|
||||||
// via `text_field` attribute or `options.text_field`
|
|
||||||
this.text_field = this.attrs.text_field || this.attrs.options.text_field;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* Retrieve anchor text based on options.
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
|
||||||
_get_text: function () {
|
|
||||||
if (this.text_field) {
|
|
||||||
var field_value = this.recordData[this.text_field];
|
|
||||||
if (_.isObject(field_value) && _.has(field_value.data)) {
|
|
||||||
field_value = field_value.data.display_name;
|
|
||||||
}
|
|
||||||
return field_value;
|
|
||||||
}
|
|
||||||
return this.attrs.text;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @override
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
_renderReadonly: function () {
|
|
||||||
// Base widget uses `this.attrs.text` instead of `this.value` when available.
|
|
||||||
// TODO: To check better way for update link
|
|
||||||
this.attrs.text = this._get_text();
|
|
||||||
this._super.apply(this, arguments);
|
|
||||||
var prefix = this.attrs.prefix_name || this.attrs.options.prefix_name;
|
|
||||||
if (prefix) {
|
|
||||||
this.$el.html(
|
|
||||||
$(this.$el.html()).attr("href", prefix + ":" + this.value)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in New Issue