mirror of https://github.com/OCA/web.git
[12.0] web_widget_open_tab: Allow to open tab on dashboards or trees inside other forms
parent
3fc9b800fe
commit
5e9e204e41
|
@ -1,4 +1,4 @@
|
||||||
# Copyright 2019 Creu Blanca
|
# Copyright 2019-2020 Creu Blanca
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -9,10 +9,7 @@
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'author': 'Creu Blanca,Odoo Community Association (OCA)',
|
'author': 'Creu Blanca,Odoo Community Association (OCA)',
|
||||||
'website': 'https://github.com/OCA/web',
|
'website': 'https://github.com/OCA/web',
|
||||||
'depends': [
|
'depends': ['web'],
|
||||||
'web'
|
'data': ['templates/assets.xml'],
|
||||||
],
|
'demo': ['demo/res_users_view.xml'],
|
||||||
'data': [
|
|
||||||
'views/assets.xml',
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="view_users_tree" model="ir.ui.view">
|
||||||
|
<field name="model">res.users</field>
|
||||||
|
<field name="inherit_id" ref="base.view_users_tree" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="name" position="before">
|
||||||
|
<field name="id" widget="open_tab"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
|
@ -11,6 +11,7 @@ odoo.define('web_widget_open_tab.FieldOpenTab', function(require) {
|
||||||
|
|
||||||
var FieldOpenTab = AbstractField.extend({
|
var FieldOpenTab = AbstractField.extend({
|
||||||
description: "",
|
description: "",
|
||||||
|
// We want to maintain it black in order to show nothing on the header
|
||||||
supportedFieldTypes: ['integer'],
|
supportedFieldTypes: ['integer'],
|
||||||
events: _.extend({}, AbstractField.prototype.events, {
|
events: _.extend({}, AbstractField.prototype.events, {
|
||||||
'click': '_onClick',
|
'click': '_onClick',
|
||||||
|
@ -19,13 +20,21 @@ odoo.define('web_widget_open_tab.FieldOpenTab', function(require) {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
_getReference: function () {
|
_getReference: function () {
|
||||||
var url = new URL(window.location.href);
|
var url = window.location.href;
|
||||||
return url.hash.replace(/view_type=\w+/i, "view_type=form") + '&id=' + this.res_id;
|
var searchParams = new URLSearchParams(url.split('#')[1]);
|
||||||
|
searchParams.set('view_type', 'form');
|
||||||
|
searchParams.set('id', this.res_id);
|
||||||
|
if (! searchParams.has('model') || searchParams.get('model') !== this.model) {
|
||||||
|
searchParams.set('model', this.model);
|
||||||
|
searchParams.delete('action');
|
||||||
|
}
|
||||||
|
return url.split('#')[0] + '#' + searchParams.toString();
|
||||||
},
|
},
|
||||||
_renderReadonly: function () {
|
_renderReadonly: function () {
|
||||||
var $content = $(
|
var $content = $("<a/>", {
|
||||||
'<a href="'+ this._getReference() + '">'
|
"href": this._getReference(),
|
||||||
).addClass('open_tab_widget fa fa-eye');
|
"class": "open_tab_widget fa fa-eye",
|
||||||
|
});
|
||||||
var self = this;
|
var self = this;
|
||||||
$content.tooltip({
|
$content.tooltip({
|
||||||
delay: { show: 1000, hide: 0 },
|
delay: { show: 1000, hide: 0 },
|
||||||
|
@ -42,7 +51,7 @@ odoo.define('web_widget_open_tab.FieldOpenTab', function(require) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.$el.append($content)
|
this.$el.append($content);
|
||||||
},
|
},
|
||||||
_onClick: function (ev) {
|
_onClick: function (ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
.open_tab_widget {
|
|
||||||
.child {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
&:hover {
|
|
||||||
.child {
|
|
||||||
visibility: visible;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,6 @@
|
||||||
<template id="assets_backend" name="tree icon assets" inherit_id="web.assets_backend">
|
<template id="assets_backend" name="tree icon assets" inherit_id="web.assets_backend">
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
<script type="text/javascript" src="/web_widget_open_tab/static/src/js/widget.js"/>
|
<script type="text/javascript" src="/web_widget_open_tab/static/src/js/widget.js"/>
|
||||||
<link href="/web_widget_open_tab/static/src/less/open_tab.less" rel="stylesheet" type="text/less"/>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue