mirror of https://github.com/OCA/web.git
[11.0][FIX] open_tab: Open new tab with the wheel
parent
0ab3b1493d
commit
e601f26589
|
@ -38,7 +38,7 @@ Usage
|
||||||
Edit the tree view and add the widget as the first field, usually, we should use:
|
Edit the tree view and add the widget as the first field, usually, we should use:
|
||||||
.. code-block:: xml
|
.. code-block:: xml
|
||||||
|
|
||||||
<field name="id" widget="open"/>
|
<field name="id" widget="open_tab"/>
|
||||||
|
|
||||||
Now, we can open when clicking with the mouse wheel over the eye.
|
Now, we can open when clicking with the mouse wheel over the eye.
|
||||||
On a usual click the record will be opened without changes (keeping the breadcrumbs).
|
On a usual click the record will be opened without changes (keeping the breadcrumbs).
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Edit the tree view and add the widget as the first field, usually, we should use:
|
Edit the tree view and add the widget as the first field, usually, we should use:
|
||||||
.. code-block:: xml
|
.. code-block:: xml
|
||||||
|
|
||||||
<field name="id" widget="open"/>
|
<field name="id" widget="open_tab"/>
|
||||||
|
|
||||||
Now, we can open when clicking with the mouse wheel over the eye.
|
Now, we can open when clicking with the mouse wheel over the eye.
|
||||||
On a usual click the record will be opened without changes (keeping the breadcrumbs).
|
On a usual click the record will be opened without changes (keeping the breadcrumbs).
|
||||||
|
|
|
@ -387,7 +387,7 @@ ul.auto-toc {
|
||||||
<p>Edit the tree view and add the widget as the first field, usually, we should use:
|
<p>Edit the tree view and add the widget as the first field, usually, we should use:
|
||||||
.. code-block:: xml</p>
|
.. code-block:: xml</p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<field name=”id” widget=”open”/></blockquote>
|
<field name=”id” widget=”open_tab”/></blockquote>
|
||||||
<p>Now, we can open when clicking with the mouse wheel over the eye.
|
<p>Now, we can open when clicking with the mouse wheel over the eye.
|
||||||
On a usual click the record will be opened without changes (keeping the breadcrumbs).</p>
|
On a usual click the record will be opened without changes (keeping the breadcrumbs).</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
odoo.define('web_widget_open_tab.FieldOpen', function(require) {
|
odoo.define('web_widget_open_tab.FieldOpenTab', function(require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var AbstractField = require('web.AbstractField');
|
var AbstractField = require('web.AbstractField');
|
||||||
var field_registry = require('web.field_registry');
|
var field_registry = require('web.field_registry');
|
||||||
var ListRenderer = require('web.ListRenderer');
|
var ListRenderer = require('web.ListRenderer');
|
||||||
|
var core = require('web.core');
|
||||||
|
var config = require('web.config');
|
||||||
|
var qweb = core.qweb;
|
||||||
|
var _t = core._t;
|
||||||
|
|
||||||
var FieldOpen = AbstractField.extend({
|
var FieldOpenTab = AbstractField.extend({
|
||||||
description: "",
|
description: "",
|
||||||
supportedFieldTypes: ['integer'],
|
supportedFieldTypes: ['integer'],
|
||||||
events: _.extend({}, AbstractField.prototype.events, {
|
events: _.extend({}, AbstractField.prototype.events, {
|
||||||
|
@ -14,10 +18,30 @@ odoo.define('web_widget_open_tab.FieldOpen', function(require) {
|
||||||
isSet: function () {
|
isSet: function () {
|
||||||
return true;
|
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;
|
||||||
|
},
|
||||||
_renderReadonly: function () {
|
_renderReadonly: function () {
|
||||||
var $content = $(
|
var $content = $(
|
||||||
'<a href="#">'
|
'<a href="'+ this._getReference() + '">'
|
||||||
).addClass('fa fa-eye');
|
).addClass('open_tab_widget fa fa-eye');
|
||||||
|
var self = this;
|
||||||
|
$content.tooltip({
|
||||||
|
delay: { show: 1000, hide: 0 },
|
||||||
|
title: function () {
|
||||||
|
return qweb.render('WidgetButton.tooltip', {
|
||||||
|
debug: config.debug,
|
||||||
|
state: self.record,
|
||||||
|
node: {
|
||||||
|
attrs: {
|
||||||
|
'help': _t('Click in order to open on new tab'),
|
||||||
|
'type': _t('Widget')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
this.$el.append($content)
|
this.$el.append($content)
|
||||||
},
|
},
|
||||||
_onClick: function (ev) {
|
_onClick: function (ev) {
|
||||||
|
@ -25,9 +49,7 @@ odoo.define('web_widget_open_tab.FieldOpen', function(require) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
var element = $(ev.currentTarget).find('a');
|
var element = $(ev.currentTarget).find('a');
|
||||||
if (element != null && element[0].href != null) {
|
if (element != null && element[0].href != null) {
|
||||||
var url = new URL(window.location.href);
|
window.open(this._getReference());
|
||||||
var href = url.hash.replace("list", "form") + '&id=' + this.res_id;
|
|
||||||
window.open(href);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -36,7 +58,7 @@ odoo.define('web_widget_open_tab.FieldOpen', function(require) {
|
||||||
// and disallow sorting
|
// and disallow sorting
|
||||||
_renderHeaderCell: function (node) {
|
_renderHeaderCell: function (node) {
|
||||||
var $th = this._super.apply(this, arguments);
|
var $th = this._super.apply(this, arguments);
|
||||||
if (node.attrs.widget === 'open') {
|
if (node.attrs.widget === 'open_tab') {
|
||||||
$th.removeClass('o_column_sortable');
|
$th.removeClass('o_column_sortable');
|
||||||
$th[0].width = 1;
|
$th[0].width = 1;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +66,7 @@ odoo.define('web_widget_open_tab.FieldOpen', function(require) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
field_registry.add('open', FieldOpen);
|
field_registry.add('open_tab', FieldOpenTab);
|
||||||
return FieldOpen;
|
return FieldOpenTab;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
.open_tab_widget {
|
||||||
|
.child {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
|
.child {
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
<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