From b1d0f12ba1afc74621dfd8f169abc481265e99d0 Mon Sep 17 00:00:00 2001 From: Siddharth Bhalgami Date: Sun, 12 Jun 2016 16:32:31 +0530 Subject: [PATCH] [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 + + + +