mirror of https://github.com/OCA/web.git
[11.0] web_widget_open_tab: Allow to open tab on dashboards or trees inside other forms
parent
899791a2d3
commit
b824a1351e
|
@ -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).
|
||||
|
||||
{
|
||||
|
@ -9,10 +9,7 @@
|
|||
'license': 'AGPL-3',
|
||||
'author': 'Creu Blanca,Odoo Community Association (OCA)',
|
||||
'website': 'https://github.com/OCA/web',
|
||||
'depends': [
|
||||
'web'
|
||||
],
|
||||
'data': [
|
||||
'views/assets.xml',
|
||||
],
|
||||
'depends': ['web'],
|
||||
'data': ['templates/assets.xml'],
|
||||
'demo': ['demo/res_users_view.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({
|
||||
description: "",
|
||||
// We want to maintain it black in order to show nothing on the header
|
||||
supportedFieldTypes: ['integer'],
|
||||
events: _.extend({}, AbstractField.prototype.events, {
|
||||
'click': '_onClick',
|
||||
|
@ -19,13 +20,20 @@ odoo.define('web_widget_open_tab.FieldOpenTab', function(require) {
|
|||
return true;
|
||||
},
|
||||
_getReference: function () {
|
||||
var url = new URL(window.location.href);
|
||||
return url.hash.replace(/view_type=\w+/i, "view_type=form") + '&id=' + this.res_id;
|
||||
var url = window.location.href;
|
||||
var searchParams = new URLSearchParams(url.split('#')[1]);
|
||||
searchParams.set('view_type', 'form');
|
||||
searchParams.set('id', this.res_id);
|
||||
if (! searchParams.has('model')) {
|
||||
searchParams.set('model', this.model)
|
||||
}
|
||||
return url.split('#')[0] + '#' + searchParams.toString();
|
||||
},
|
||||
_renderReadonly: function () {
|
||||
var $content = $(
|
||||
'<a href="'+ this._getReference() + '">'
|
||||
).addClass('open_tab_widget fa fa-eye');
|
||||
var $content = $("<a/>", {
|
||||
"href": this._getReference(),
|
||||
"class": "open_tab_widget fa fa-eye",
|
||||
});
|
||||
var self = this;
|
||||
$content.tooltip({
|
||||
delay: { show: 1000, hide: 0 },
|
||||
|
@ -42,7 +50,7 @@ odoo.define('web_widget_open_tab.FieldOpenTab', function(require) {
|
|||
});
|
||||
},
|
||||
});
|
||||
this.$el.append($content)
|
||||
this.$el.append($content);
|
||||
},
|
||||
_onClick: function (ev) {
|
||||
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">
|
||||
<xpath expr="." position="inside">
|
||||
<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>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue