mirror of https://github.com/OCA/web.git
[FIX] web_dialog_size: Fix usage for non-admins and reduce calls (#954)
This addon had 2 problems after migrating to v11: 1. One call to backend's `ir.config_parameter.get_param` was done for each instantiated dialog, while the setting served for the whole session equally. 2. That model is now readable only by admin users, so non-admins couldn't use the default at all. Fixed now.pull/880/head
parent
d59becba8a
commit
2810ad33f3
|
@ -1,67 +0,0 @@
|
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: https://www.gnu.org/licenses/agpl
|
||||
:alt: License: AGPL-3
|
||||
|
||||
=============
|
||||
Expand Dialog
|
||||
=============
|
||||
|
||||
A module that lets the user expand/restore the dialog box size through a button
|
||||
in the upper right corner (mimicking most windows managers).
|
||||
It does also add draggable support to the dialogs.
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
By default, the module respects the caller's `dialog_size` option. If you want
|
||||
to override this and have all dialogs maximized by default, set the configuration
|
||||
parameter `web_dialog_size.default_maximize` to `1`.
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/162/11.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
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. If you spotted it first,
|
||||
help us smash it by providing detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Images
|
||||
------
|
||||
|
||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Anthony Muschang <anthony.muschang@acsone.eu>
|
||||
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
|
||||
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||
* Holger Brunn <hbrunn@therp.nl>
|
||||
* Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
|
||||
* Wolfgang Pichler <wpichler@callino.at>
|
||||
* David Vidal <david.vidal@tecnativa.com>
|
||||
* Quentin Theuret <quentin.theuret@amaris.com>
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
To contribute to this module, please visit https://odoo-community.org.
|
|
@ -1,2 +1 @@
|
|||
# Copyright 2018 Quentin Theuret <quentin.theuret@amaris.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import models
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
"Tecnativa, "
|
||||
"Amaris, "
|
||||
"Odoo Community Association (OCA)",
|
||||
'website': "http://acsone.eu",
|
||||
'website': "http://github.com/OCA/web",
|
||||
'category': 'web',
|
||||
'version': '11.0.1.0.2',
|
||||
'version': '11.0.1.0.3',
|
||||
'license': 'AGPL-3',
|
||||
'depends': [
|
||||
'web',
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
from . import ir_config_parameter
|
|
@ -0,0 +1,17 @@
|
|||
# Copyright 2018 Tecnativa - Jairo Llopis
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.models import api, Model
|
||||
from odoo.tools.safe_eval import const_eval
|
||||
|
||||
|
||||
class IrConfigParameter(Model):
|
||||
_inherit = "ir.config_parameter"
|
||||
|
||||
@api.model
|
||||
def get_web_dialog_size_config(self):
|
||||
get_param = self.sudo().get_param
|
||||
return {
|
||||
key: const_eval(get_param("web_dialog_size.%s" % key, "False"))
|
||||
for key in ["default_maximize"]
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
By default, the module respects the caller's ``dialog_size`` option.
|
||||
If you want to override this and have all dialogs maximized by default,
|
||||
set the configuration parameter ``web_dialog_size.default_maximize`` to ``1``.
|
|
@ -0,0 +1,14 @@
|
|||
Contributors
|
||||
------------
|
||||
|
||||
* Anthony Muschang <anthony.muschang@acsone.eu>
|
||||
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
|
||||
* Holger Brunn <hbrunn@therp.nl>
|
||||
* Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
|
||||
* Wolfgang Pichler <wpichler@callino.at>
|
||||
* David Vidal <david.vidal@tecnativa.com>
|
||||
* Quentin Theuret <quentin.theuret@amaris.com>
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||
* Jairo Llopis <jairo.llopis@tecnativa.com>
|
|
@ -0,0 +1,3 @@
|
|||
A module that lets the user expand/restore the dialog box size through a button
|
||||
in the upper right corner (imitating most windows managers).
|
||||
It also adds draggable support to the dialogs.
|
|
@ -4,6 +4,11 @@ odoo.define('web_dialog_size.web_dialog_size', function (require) {
|
|||
var rpc = require('web.rpc');
|
||||
var Dialog = require('web.Dialog');
|
||||
|
||||
var config = rpc.query({
|
||||
model: 'ir.config_parameter',
|
||||
method: 'get_web_dialog_size_config',
|
||||
});
|
||||
|
||||
Dialog.include({
|
||||
|
||||
willStart: function () {
|
||||
|
@ -11,12 +16,8 @@ Dialog.include({
|
|||
return this._super.apply(this, arguments).then(function () {
|
||||
self.$modal.find('.dialog_button_extend').on('click', self.proxy('_extending'));
|
||||
self.$modal.find('.dialog_button_restore').on('click', self.proxy('_restore'));
|
||||
return rpc.query({
|
||||
model: 'ir.config_parameter',
|
||||
method: 'get_param',
|
||||
args: ['web_dialog_size.default_maximize',],
|
||||
}).then(function(default_maximize) {
|
||||
if (default_maximize === "True" || default_maximize === 1) {
|
||||
return config.done(function(default_maximize) {
|
||||
if (default_maximize) {
|
||||
self._extending();
|
||||
} else {
|
||||
self._restore();
|
||||
|
@ -32,7 +33,7 @@ Dialog.include({
|
|||
handle: '.modal-header',
|
||||
helper: false
|
||||
});
|
||||
};
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue