diff --git a/web_dialog_size/README.rst b/web_dialog_size/README.rst new file mode 100644 index 00000000..ee62e181 --- /dev/null +++ b/web_dialog_size/README.rst @@ -0,0 +1,99 @@ +=============== +Web Dialog Size +=============== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/12.0/web_dialog_size + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_dialog_size + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +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. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +If you want to set dialog boxes maximized by default, you need to: + +#. Go to *Settings -> Technical -> Parameters -> System Parameters* +#. Add a new record with the text *web_dialog_size.default_maximize* in + the *Key* field and the text *True* in the *Value* field + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV +* Therp BV +* Siddharth Bhalgami +* Tecnativa +* Amaris + +Contributors +~~~~~~~~~~~~ + +* Anthony Muschang +* Stéphane Bidoul +* Holger Brunn +* Siddharth Bhalgami +* Wolfgang Pichler +* David Vidal +* Quentin Theuret +* `Tecnativa `_: + + * Pedro M. Baeza + * Jairo Llopis + * Ernesto Tejeda + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_dialog_size/__init__.py b/web_dialog_size/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/web_dialog_size/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/web_dialog_size/__manifest__.py b/web_dialog_size/__manifest__.py new file mode 100644 index 00000000..31f85ac9 --- /dev/null +++ b/web_dialog_size/__manifest__.py @@ -0,0 +1,30 @@ +# Copyright 2015 ACSONE SA/NV +# Copyright 2018 Amaris +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': "Web Dialog Size", + 'summary': """ + A module that lets the user expand a + dialog box to the full screen width.""", + 'author': "ACSONE SA/NV, " + "Therp BV, " + "Siddharth Bhalgami," + "Tecnativa, " + "Amaris, " + "Odoo Community Association (OCA)", + 'website': "http://github.com/OCA/web", + 'category': 'web', + 'version': '12.0.1.0.0', + 'license': 'AGPL-3', + 'depends': [ + 'web', + ], + 'qweb': [ + 'static/src/xml/web_dialog_size.xml', + ], + 'data': [ + 'templates/assets.xml', + ], + 'installable': True, +} diff --git a/web_dialog_size/i18n/web_dialog_size.pot b/web_dialog_size/i18n/web_dialog_size.pot new file mode 100644 index 00000000..ab1f7385 --- /dev/null +++ b/web_dialog_size/i18n/web_dialog_size.pot @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_dialog_size +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: web_dialog_size +#: model:ir.model,name:web_dialog_size.model_ir_config_parameter +msgid "ir.config_parameter" +msgstr "" + diff --git a/web_dialog_size/models/__init__.py b/web_dialog_size/models/__init__.py new file mode 100644 index 00000000..bd3aa9f1 --- /dev/null +++ b/web_dialog_size/models/__init__.py @@ -0,0 +1 @@ +from . import ir_config_parameter diff --git a/web_dialog_size/models/ir_config_parameter.py b/web_dialog_size/models/ir_config_parameter.py new file mode 100644 index 00000000..4de06e32 --- /dev/null +++ b/web_dialog_size/models/ir_config_parameter.py @@ -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 { + "default_maximize": const_eval( + get_param("web_dialog_size.default_maximize", "False")) + } diff --git a/web_dialog_size/readme/CONFIGURATION.rst b/web_dialog_size/readme/CONFIGURATION.rst new file mode 100644 index 00000000..18b1ad07 --- /dev/null +++ b/web_dialog_size/readme/CONFIGURATION.rst @@ -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``. diff --git a/web_dialog_size/readme/CONFIGURE.rst b/web_dialog_size/readme/CONFIGURE.rst new file mode 100644 index 00000000..902f3316 --- /dev/null +++ b/web_dialog_size/readme/CONFIGURE.rst @@ -0,0 +1,5 @@ +If you want to set dialog boxes maximized by default, you need to: + +#. Go to *Settings -> Technical -> Parameters -> System Parameters* +#. Add a new record with the text *web_dialog_size.default_maximize* in + the *Key* field and the text *True* in the *Value* field diff --git a/web_dialog_size/readme/CONTRIBUTORS.rst b/web_dialog_size/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..e78168e4 --- /dev/null +++ b/web_dialog_size/readme/CONTRIBUTORS.rst @@ -0,0 +1,12 @@ +* Anthony Muschang +* Stéphane Bidoul +* Holger Brunn +* Siddharth Bhalgami +* Wolfgang Pichler +* David Vidal +* Quentin Theuret +* `Tecnativa `_: + + * Pedro M. Baeza + * Jairo Llopis + * Ernesto Tejeda diff --git a/web_dialog_size/readme/DESCRIPTION.rst b/web_dialog_size/readme/DESCRIPTION.rst new file mode 100644 index 00000000..398e72f5 --- /dev/null +++ b/web_dialog_size/readme/DESCRIPTION.rst @@ -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. diff --git a/web_dialog_size/static/description/icon.png b/web_dialog_size/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/web_dialog_size/static/description/icon.png differ diff --git a/web_dialog_size/static/description/index.html b/web_dialog_size/static/description/index.html new file mode 100644 index 00000000..64208125 --- /dev/null +++ b/web_dialog_size/static/description/index.html @@ -0,0 +1,450 @@ + + + + + + +Web Dialog Size + + + +
+

Web Dialog Size

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

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.

+

Table of contents

+ +
+

Configuration

+

If you want to set dialog boxes maximized by default, you need to:

+
    +
  1. Go to Settings -> Technical -> Parameters -> System Parameters
  2. +
  3. +
    Add a new record with the text web_dialog_size.default_maximize in
    +
    the Key field and the text True in the Value field
    +
    +
  4. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
  • Therp BV
  • +
  • Siddharth Bhalgami
  • +
  • Tecnativa
  • +
  • Amaris
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_dialog_size/static/src/js/web_dialog_size.js b/web_dialog_size/static/src/js/web_dialog_size.js new file mode 100644 index 00000000..7c5ab7c5 --- /dev/null +++ b/web_dialog_size/static/src/js/web_dialog_size.js @@ -0,0 +1,66 @@ +odoo.define('web_dialog_size.web_dialog_size', function (require) { +'use strict'; + +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 () { + var self = this; + 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 config.done(function(r) { + if (r.default_maximize) { + self._extending(); + } else { + self._restore(); + } + }); + }); + }, + + opened: function(handler) { + return this._super.apply(this, arguments).then(function(){ + if (this.$modal) { + this.$modal.draggable({ + handle: '.modal-header', + helper: false + }); + } + }.bind(this)); + }, + + close: function() { + if (this.$modal) { + var draggable = this.$modal.draggable("instance"); + if (draggable) { + this.$modal.draggable("destroy"); + } + } + return this._super.apply(this, arguments); + }, + + _extending: function() { + var dialog = this.$modal.find('.modal-dialog'); + dialog.addClass('dialog_full_screen'); + dialog.find('.dialog_button_extend').hide(); + dialog.find('.dialog_button_restore').show(); + }, + + _restore: function() { + var dialog = this.$modal.find('.modal-dialog'); + dialog.removeClass('dialog_full_screen'); + dialog.find('.dialog_button_restore').hide(); + dialog.find('.dialog_button_extend').show(); + }, + +}); + +}); diff --git a/web_dialog_size/static/src/scss/web_dialog_size.scss b/web_dialog_size/static/src/scss/web_dialog_size.scss new file mode 100644 index 00000000..8e5e86b8 --- /dev/null +++ b/web_dialog_size/static/src/scss/web_dialog_size.scss @@ -0,0 +1,24 @@ + +.modal { + .dialog_full_screen { + @include media-breakpoint-up(sm) { + max-width: 100%; + width: calc(100% - 50px); + } + } + .modal-header button.close { + font-size: 18px; + + &:not(.dialog_button_extend):not(.dialog_button_restore) { + @include media-breakpoint-up(sm) { + margin-left: 15px; + } + } + + &.dialog_button_extend, .dialog_button_restore { + @include media-breakpoint-down(sm) { + display: none !important; + } + } + } +} diff --git a/web_dialog_size/static/src/xml/web_dialog_size.xml b/web_dialog_size/static/src/xml/web_dialog_size.xml new file mode 100644 index 00000000..1ef058fe --- /dev/null +++ b/web_dialog_size/static/src/xml/web_dialog_size.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/web_dialog_size/templates/assets.xml b/web_dialog_size/templates/assets.xml new file mode 100644 index 00000000..0845e502 --- /dev/null +++ b/web_dialog_size/templates/assets.xml @@ -0,0 +1,9 @@ + + + + diff --git a/web_dialog_size/tests/__init__.py b/web_dialog_size/tests/__init__.py new file mode 100644 index 00000000..79d02635 --- /dev/null +++ b/web_dialog_size/tests/__init__.py @@ -0,0 +1 @@ +from . import test_web_dialog_size diff --git a/web_dialog_size/tests/test_web_dialog_size.py b/web_dialog_size/tests/test_web_dialog_size.py new file mode 100644 index 00000000..6d6014d0 --- /dev/null +++ b/web_dialog_size/tests/test_web_dialog_size.py @@ -0,0 +1,20 @@ +# Copyright 2018 Tecnativa - Ernesto Tejeda +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 + +from odoo.tests.common import TransactionCase + + +class TestWebDialogSize(TransactionCase): + def setUp(self): + super(TestWebDialogSize, self).setUp() + + def test_get_web_dialog_size_config(self): + obj = self.env['ir.config_parameter'] + + self.assertFalse(obj.get_web_dialog_size_config()['default_maximize']) + + obj.set_param("web_dialog_size.default_maximize", "True") + self.assertTrue(obj.get_web_dialog_size_config()['default_maximize']) + + obj.set_param("web_dialog_size.default_maximize", "False") + self.assertFalse(obj.get_web_dialog_size_config()['default_maximize'])