From 7f80626fc49cc73c4e62b8dd0e5cc8eceb322081 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 6 Apr 2016 20:33:56 +0200 Subject: [PATCH 1/3] [IMP] web_dialog_size: Select default dialog size by config * [IMP] web_dialog_size: Put dialog size expanded by default * [REM] web_popup_large: By duplication of the functionality * [IMP] web_dialog_size: README and contributors * [ADD] configuration parameter for default behavior [FIX] return super's promise [IMP] use fontawesome icons for buttons --- web_dialog_size/README.rst | 27 ++++---- web_dialog_size/__openerp__.py | 5 +- .../static/src/css/web_dialog_size.css | 14 ++-- .../static/src/js/web_dialog_size.js | 68 +++++++++++++------ .../static/src/xml/web_dialog_size.xml | 11 +-- 5 files changed, 77 insertions(+), 48 deletions(-) diff --git a/web_dialog_size/README.rst b/web_dialog_size/README.rst index f508aa0a..c7e30bf0 100644 --- a/web_dialog_size/README.rst +++ b/web_dialog_size/README.rst @@ -1,19 +1,16 @@ Expand Dialog ============= -A module that lets the user expand a dialog box to the full screen width. +A module that lets the user expand/restore the dialog box size through a button +in the upper right corner (mimicking most windows managers). By default, +all dialog boxes are expanded. -It is named web_dialog_size as it could be extended to propose other dialog size management feature. - - -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 -`here `_. +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`. Credits ======= @@ -23,6 +20,8 @@ Contributors * Anthony Muschang * Stéphane Bidoul +* Pedro M. Baeza +* Holger Brunn Maintainer ---------- @@ -33,6 +32,8 @@ Maintainer 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. +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 http://odoo-community.org. \ No newline at end of file +To contribute to this module, please visit http://odoo-community.org. diff --git a/web_dialog_size/__openerp__.py b/web_dialog_size/__openerp__.py index e0d53fb1..a1d3db35 100644 --- a/web_dialog_size/__openerp__.py +++ b/web_dialog_size/__openerp__.py @@ -28,7 +28,10 @@ A module that lets the user expand a dialog box to the full screen width.""", - 'author': "ACSONE SA/NV,Odoo Community Association (OCA)", + 'author': "ACSONE SA/NV," + "Serv. Tecnol. Avanzados - Pedro M. Baeza," + "Therp BV," + "Odoo Community Association (OCA)", 'website': "http://acsone.eu", 'category': 'web', diff --git a/web_dialog_size/static/src/css/web_dialog_size.css b/web_dialog_size/static/src/css/web_dialog_size.css index 10fba0f0..74f829ec 100644 --- a/web_dialog_size/static/src/css/web_dialog_size.css +++ b/web_dialog_size/static/src/css/web_dialog_size.css @@ -1,17 +1,15 @@ .modal .modal-header button.dialog_button_extend { - padding-top: 0px; padding-right: 3px; } .modal .modal-header button.dialog_button_restore { - padding-top: 1px; - padding-right: 5px; -} - -.modal .modal-header .dialog_button_hide { - display: none; + padding-right: 3px; } .dialog_full_screen { width: calc(100% - 50px); -} \ No newline at end of file +} + +.modal .modal-header button.close { + font-size: 14px; +} diff --git a/web_dialog_size/static/src/js/web_dialog_size.js b/web_dialog_size/static/src/js/web_dialog_size.js index d1d0299c..c2d1910c 100644 --- a/web_dialog_size/static/src/js/web_dialog_size.js +++ b/web_dialog_size/static/src/js/web_dialog_size.js @@ -1,34 +1,58 @@ openerp.web_dialog_size= function (instance) { instance.web.Dialog = instance.web.Dialog.extend({ - init_dialog: function () { - var self = this; - this._super(); - self.$dialog_box.find('.dialog_button_restore').addClass('dialog_button_hide'); - if (this.dialog_options.size !== 'large'){ - self.$dialog_box.find('.dialog_button_extend').addClass('dialog_button_hide'); - } - else{ - self.$dialog_box.find('.dialog_button_extend').on('click', self._extending); - self.$dialog_box.find('.dialog_button_restore').on('click', self._restore); + var self = this, + result = this._super(); + self.$dialog_box.find('.dialog_button_extend') + .on('click', self.proxy('_extending')); + self.$dialog_box.find('.dialog_button_restore') + .on('click', self.proxy('_restore')); + if(this.dialog_options.size == 'large') + { + self._extending(); + return result; } + return jQuery.when(result).then(function() + { + var deferred = null; + if(openerp.web_dialog_size.default_maximize === undefined) + { + deferred = (new openerp.web.Model('ir.config_parameter')) + .call('get_param', + ['web_dialog_size.default_maximize']) + .then(function(default_maximize) + { + openerp.web_dialog_size.default_maximize = + default_maximize; + }); + } + return jQuery.when(deferred).then(function() + { + if(openerp.web_dialog_size.default_maximize) + { + self._extending(); + } + else + { + self._restore(); + } + }); + }); }, - _extending: function() { - var self = this; - $(this).parents('.modal-dialog').addClass('dialog_full_screen'); - $(this).addClass('dialog_button_hide'); - - $(this).parents('.modal-dialog').find('.dialog_button_restore').removeClass('dialog_button_hide') + _extending: function(e) { + var dialog = this.$el.parents('.modal-dialog'); + dialog.addClass('dialog_full_screen'); + dialog.find('.dialog_button_extend').hide(); + dialog.find('.dialog_button_restore').show(); }, - _restore: function() { - var self = this; - $(this).parents('.modal-dialog').removeClass('dialog_full_screen'); - $(this).addClass('dialog_button_hide'); - - $(this).parents('.modal-dialog').find('.dialog_button_extend').removeClass('dialog_button_hide') + _restore: function(e) { + var dialog = this.$el.parents('.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/xml/web_dialog_size.xml b/web_dialog_size/static/src/xml/web_dialog_size.xml index 1808dd2a..51e6fd6a 100644 --- a/web_dialog_size/static/src/xml/web_dialog_size.xml +++ b/web_dialog_size/static/src/xml/web_dialog_size.xml @@ -1,9 +1,12 @@ - - - + + + + + + - \ No newline at end of file + From 6fc0f52b0edf792676d13baf14efbfe63f3a510c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 27 May 2016 21:53:29 +0200 Subject: [PATCH 2/3] [FIX] web_dialog_size: do not expand by default and correctly honor default_maximize parameter --- web_dialog_size/README.rst | 3 +-- web_dialog_size/static/src/js/web_dialog_size.js | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/web_dialog_size/README.rst b/web_dialog_size/README.rst index c7e30bf0..3d409a60 100644 --- a/web_dialog_size/README.rst +++ b/web_dialog_size/README.rst @@ -2,8 +2,7 @@ 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). By default, -all dialog boxes are expanded. +in the upper right corner (mimicking most windows managers). Configuration ============= diff --git a/web_dialog_size/static/src/js/web_dialog_size.js b/web_dialog_size/static/src/js/web_dialog_size.js index c2d1910c..ff3708e5 100644 --- a/web_dialog_size/static/src/js/web_dialog_size.js +++ b/web_dialog_size/static/src/js/web_dialog_size.js @@ -8,11 +8,6 @@ openerp.web_dialog_size= function (instance) { .on('click', self.proxy('_extending')); self.$dialog_box.find('.dialog_button_restore') .on('click', self.proxy('_restore')); - if(this.dialog_options.size == 'large') - { - self._extending(); - return result; - } return jQuery.when(result).then(function() { var deferred = null; From b1d0f12ba1afc74621dfd8f169abc481265e99d0 Mon Sep 17 00:00:00 2001 From: Siddharth Bhalgami Date: Sun, 12 Jun 2016 16:32:31 +0530 Subject: [PATCH 3/3] [MIG] web_dialog_siza: Migrate to v9.0 --- web_dialog_size/README.rst | 1 + web_dialog_size/__openerp__.py | 15 +-- .../static/src/css/web_dialog_size.css | 6 +- .../static/src/js/web_dialog_size.js | 95 ++++++++----------- web_dialog_size/view/qweb.xml | 19 ++-- 5 files changed, 61 insertions(+), 75 deletions(-) diff --git a/web_dialog_size/README.rst b/web_dialog_size/README.rst index 3d409a60..d30b2f01 100644 --- a/web_dialog_size/README.rst +++ b/web_dialog_size/README.rst @@ -21,6 +21,7 @@ Contributors * Stéphane Bidoul * Pedro M. Baeza * Holger Brunn +* Siddharth Bhalgami Maintainer ---------- diff --git a/web_dialog_size/__openerp__.py b/web_dialog_size/__openerp__.py index a1d3db35..7c5696f0 100644 --- a/web_dialog_size/__openerp__.py +++ b/web_dialog_size/__openerp__.py @@ -28,14 +28,15 @@ A module that lets the user expand a dialog box to the full screen width.""", - 'author': "ACSONE SA/NV," - "Serv. Tecnol. Avanzados - Pedro M. Baeza," - "Therp BV," - "Odoo Community Association (OCA)", - 'website': "http://acsone.eu", + 'author': "ACSONE SA/NV, " + "Serv. Tecnol. Avanzados - Pedro M. Baeza, " + "Therp BV, " + "Odoo Community Association (OCA), " + "Siddharth Bhalgami", + 'website': "http://acsone.eu", 'category': 'web', - 'version': '8.0.0.1.0', + 'version': '9.0.1.0.0', 'license': 'AGPL-3', 'depends': [ @@ -47,5 +48,5 @@ 'data': [ 'view/qweb.xml', ], - 'installable': False, + 'installable': True, } diff --git a/web_dialog_size/static/src/css/web_dialog_size.css b/web_dialog_size/static/src/css/web_dialog_size.css index 74f829ec..bd7fdb2e 100644 --- a/web_dialog_size/static/src/css/web_dialog_size.css +++ b/web_dialog_size/static/src/css/web_dialog_size.css @@ -1,9 +1,9 @@ .modal .modal-header button.dialog_button_extend { - padding-right: 3px; + padding-right: 5px; } .modal .modal-header button.dialog_button_restore { - padding-right: 3px; + padding-right: 5px; } .dialog_full_screen { @@ -11,5 +11,5 @@ } .modal .modal-header button.close { - font-size: 14px; + font-size: 18px; } diff --git a/web_dialog_size/static/src/js/web_dialog_size.js b/web_dialog_size/static/src/js/web_dialog_size.js index ff3708e5..56e070f2 100644 --- a/web_dialog_size/static/src/js/web_dialog_size.js +++ b/web_dialog_size/static/src/js/web_dialog_size.js @@ -1,56 +1,41 @@ -openerp.web_dialog_size= function (instance) { - - instance.web.Dialog = instance.web.Dialog.extend({ - init_dialog: function () { - var self = this, - result = this._super(); - self.$dialog_box.find('.dialog_button_extend') - .on('click', self.proxy('_extending')); - self.$dialog_box.find('.dialog_button_restore') - .on('click', self.proxy('_restore')); - return jQuery.when(result).then(function() - { - var deferred = null; - if(openerp.web_dialog_size.default_maximize === undefined) - { - deferred = (new openerp.web.Model('ir.config_parameter')) - .call('get_param', - ['web_dialog_size.default_maximize']) - .then(function(default_maximize) - { - openerp.web_dialog_size.default_maximize = - default_maximize; - }); - } - return jQuery.when(deferred).then(function() - { - if(openerp.web_dialog_size.default_maximize) - { - self._extending(); - } - else - { - self._restore(); - } - }); - }); - }, - - _extending: function(e) { - var dialog = this.$el.parents('.modal-dialog'); - dialog.addClass('dialog_full_screen'); - dialog.find('.dialog_button_extend').hide(); - dialog.find('.dialog_button_restore').show(); - }, - - _restore: function(e) { - var dialog = this.$el.parents('.modal-dialog'); - dialog.removeClass('dialog_full_screen'); - dialog.find('.dialog_button_restore').hide(); - dialog.find('.dialog_button_extend').show(); - }, - - }); - -}; +odoo.define('web_dialog_size.web_dialog_size', function (require) { +'use strict'; +var Model = require('web.DataModel'); +var Dialog = require('web.Dialog'); + +Dialog.include({ + + init: function (parent, options) { + var self = this; + this._super.apply(this, arguments); + self.$modal.find('.dialog_button_extend').on('click', self.proxy('_extending')); + self.$modal.find('.dialog_button_restore').on('click', self.proxy('_restore')); + + new Model('ir.config_parameter').query(['key', 'value']). + filter([['key', '=', 'web_dialog_size.default_maximize']]).all().then(function(default_maximize) { + if (default_maximize.length && default_maximize[0]['value'] == 1) { + self._extending(); + } else { + self._restore(); + } + }); + }, + + _extending: function() { + var dialog = this.$el.parents('.modal-dialog'); + dialog.addClass('dialog_full_screen'); + dialog.find('.dialog_button_extend').hide(); + dialog.find('.dialog_button_restore').show(); + }, + + _restore: function() { + var dialog = this.$el.parents('.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/view/qweb.xml b/web_dialog_size/view/qweb.xml index 31dcd70f..103b3d97 100644 --- a/web_dialog_size/view/qweb.xml +++ b/web_dialog_size/view/qweb.xml @@ -1,10 +1,9 @@ - - - - - \ No newline at end of file + + + +