From 41cd88bfad1e61f244295fa3a2ac9e2abf01a100 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 21 Dec 2011 14:43:06 +0100 Subject: [PATCH] [FIX] Reworked dialogs lp bug: https://launchpad.net/bugs/892248 fixed lp bug: https://launchpad.net/bugs/885507 fixed bzr revid: fme@openerp.com-20111221134306-k5w0g0oih3uvhy34 --- addons/web/static/src/js/chrome.js | 45 ++++++++++--------- addons/web/static/src/js/data_export.js | 6 +-- addons/web/static/src/js/data_import.js | 8 +--- addons/web/static/src/js/view_editor.js | 17 ++----- addons/web_calendar/static/src/js/calendar.js | 6 ++- addons/web_diagram/static/src/js/diagram.js | 3 +- addons/web_process/static/src/js/process.js | 1 - 7 files changed, 36 insertions(+), 50 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 64a7e417dad..caca234c5aa 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -51,15 +51,19 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# this._super(parent); this.dialog_options = { modal: true, - width: 'auto', + destroy_on_close: true, + width: $(window).width() * (($(window).width() > 1024) ? 0.5 : 0.75), min_width: 0, - max_width: '100%', + max_width: '95%', height: 'auto', min_height: 0, - max_height: '100%', + max_height: '95%', autoOpen: false, + position: [false, 50], + autoResize : 'auto', buttons: {}, - beforeClose: function () { self.on_close(); } + beforeClose: function () { self.on_close(); }, + resizeStop: this.on_resized }; for (var f in this) { if (f.substr(0, 10) == 'on_button_') { @@ -77,7 +81,7 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# options.max_width = this.get_width(options.max_width || this.dialog_options.max_width); options.height = this.get_height(options.height || this.dialog_options.height); options.min_height = this.get_height(options.min_height || this.dialog_options.min_height); - options.max_height = this.get_height(options.max_height || this.dialog_options.max_width); + options.max_height = this.get_height(options.max_height || this.dialog_options.max_height); if (options.width !== 'auto') { if (options.width > options.max_width) options.width = options.max_width; @@ -108,7 +112,7 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# } }, start: function () { - this.$dialog = $(this.$element).dialog(this.dialog_options); + this.$element.dialog(this.dialog_options); this._super(); return this; }, @@ -118,19 +122,26 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog# this.$element.html(this.render()); } this.set_options(dialog_options); - this.$dialog.dialog(this.dialog_options).dialog('open'); + this.$element.dialog(this.dialog_options).dialog('open'); return this; }, close: function() { - // Closes the dialog but leave it in a state where it could be opened again. - this.$dialog.dialog('close'); + this.$element.dialog('close'); }, on_close: function() { + if (this.dialog_options.destroy_on_close) { + this.$element.dialog('destroy'); + } + }, + on_resized: function() { + if (openerp.connection.debug) { + console.log("Dialog resized to %d x %d", this.$element.width(), this.$element.height()); + } }, stop: function () { // Destroy widget this.close(); - this.$dialog.dialog('destroy'); + this.$element.dialog('destroy'); this._super(); } }); @@ -167,10 +178,6 @@ openerp.web.CrashManager = openerp.web.CallbackEnabled.extend({ var dialog = new openerp.web.Dialog(this, { title: "OpenERP " + _.str.capitalize(error.type), autoOpen: true, - width: '90%', - height: '90%', - min_width: '800px', - min_height: '600px', buttons: [ {text: _t("Ok"), click: function() { $(this).dialog("close"); }} ] @@ -744,10 +751,8 @@ openerp.web.Header = openerp.web.Widget.extend(/** @lends openerp.web.Header# * }); }); this.dialog = new openerp.web.Dialog(this,{ - modal: true, title: _t("Preferences"), - width: 600, - height: 500, + width: '700px', buttons: [ {text: _t("Change password"), click: function(){ self.change_password(); }}, {text: _t("Cancel"), click: function(){ $(this).dialog('destroy'); }}, @@ -769,11 +774,9 @@ openerp.web.Header = openerp.web.Widget.extend(/** @lends openerp.web.Header# * change_password :function() { var self = this; - this.dialog = new openerp.web.Dialog(this,{ - modal : true, + this.dialog = new openerp.web.Dialog(this, { title: _t("Change Password"), - width : 'auto', - height : 'auto' + width : 'auto' }); this.dialog.start().open(); this.dialog.$element.html(QWeb.render("Change_Pwd", self)); diff --git a/addons/web/static/src/js/data_export.js b/addons/web/static/src/js/data_export.js index 8a2d2c8594b..78dc3bef1f9 100644 --- a/addons/web/static/src/js/data_export.js +++ b/addons/web/static/src/js/data_export.js @@ -15,10 +15,6 @@ openerp.web.DataExport = openerp.web.Dialog.extend({ var self = this; this._super.apply(this, arguments); this.open({ - modal: true, - width: '55%', - height: 'auto', - position: 'top', buttons : [ {text: _t("Close"), click: function() { self.close(); }}, {text: _t("Export To File"), click: function() { self.on_click_export_data(); }} @@ -385,7 +381,7 @@ openerp.web.DataExport = openerp.web.Dialog.extend({ }); }, close: function() { - $(this.$dialog).remove(); + this.$element.remove(); this._super(); } }); diff --git a/addons/web/static/src/js/data_import.js b/addons/web/static/src/js/data_import.js index 3d626db125d..2b252454869 100644 --- a/addons/web/static/src/js/data_import.js +++ b/addons/web/static/src/js/data_import.js @@ -65,10 +65,6 @@ openerp.web.DataImport = openerp.web.Dialog.extend({ var self = this; this._super(); this.open({ - modal: true, - width: '70%', - height: 'auto', - position: 'top', buttons: [ {text: _t("Close"), click: function() { self.stop(); }}, {text: _t("Import File"), click: function() { self.do_import(); }, 'class': 'oe-dialog-import-button'} @@ -144,7 +140,7 @@ openerp.web.DataImport = openerp.web.Dialog.extend({ }); }, toggle_import_button: function (newstate) { - this.$dialog.dialog('widget') + this.$element.dialog('widget') .find('.oe-dialog-import-button') .button('option', 'disabled', !newstate); }, @@ -352,7 +348,7 @@ openerp.web.DataImport = openerp.web.Dialog.extend({ return true; }, stop: function() { - $(this.$dialog).remove(); + this.$element.remove(); this._super(); } }); diff --git a/addons/web/static/src/js/view_editor.js b/addons/web/static/src/js/view_editor.js index f925a6416eb..649f324744d 100644 --- a/addons/web/static/src/js/view_editor.js +++ b/addons/web/static/src/js/view_editor.js @@ -38,10 +38,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ } }; this.view_edit_dialog = new openerp.web.Dialog(this, { - modal: true, title: _t("ViewEditor"), - width: 750, - height: 500, + width: 850, buttons: [ {text: _t("Create"), click: function() { self.on_create_view(); }}, {text: _t("Edit"), click: function() { self.xml_element_id = 0; self.get_arch(); }}, @@ -67,10 +65,7 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ on_create_view: function() { var self = this; this.create_view_dialog = new openerp.web.Dialog(this, { - modal: true, title: _.str.sprintf(_t("Create a view (%s)"), self.model), - width: 500, - height: 400, buttons: [ {text: _t("Save"), click: function () { var view_values = {}; @@ -363,10 +358,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ var self = this; this.one_object = one_object; this.edit_xml_dialog = new openerp.web.Dialog(this, { - modal: true, title: _.str.sprintf(_t("View Editor %d - %s"), self.main_view_id, self.model), - width: 750, - height: 500, + height: '90%', buttons: [ {text: _t("Preview"), click: function() { var action = { @@ -752,10 +745,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ on_edit_node: function(properties){ var self = this; this.edit_node_dialog = new openerp.web.Dialog(this,{ - modal: true, title: _t("Properties"), - width: 500, - height: 400, + width: 450, buttons: [ {text: _t("Update"), click: function () { var warn = false, update_values = []; @@ -879,10 +870,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({ {'name': 'position','selection': ['After','Before','Inside'], 'value': false, 'string': 'Position','type': 'selection'}]; this.add_widget = []; this.add_node_dialog = new openerp.web.Dialog(this,{ - modal: true, title: _t("Properties"), width: 450, - height: 190, buttons: [ {text: _t("Update"), click: function() { var check_add_node = true, values = {}; diff --git a/addons/web_calendar/static/src/js/calendar.js b/addons/web_calendar/static/src/js/calendar.js index 750e367f22c..13bd7455c36 100644 --- a/addons/web_calendar/static/src/js/calendar.js +++ b/addons/web_calendar/static/src/js/calendar.js @@ -21,7 +21,11 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({ this.has_been_loaded = $.Deferred(); this.creating_event_id = null; this.dataset_events = []; - this.form_dialog = new openerp.web_calendar.CalendarFormDialog(this, {}, this.options.action_views_ids.form, dataset); + this.form_dialog = new openerp.web_calendar.CalendarFormDialog(this, { + destroy_on_close: false, + width: '80%', + min_width: 850 + }, this.options.action_views_ids.form, dataset); this.form_dialog.start(); this.COLOR_PALETTE = ['#f57900', '#cc0000', '#d400a8', '#75507b', '#3465a4', '#73d216', '#c17d11', '#edd400', '#fcaf3e', '#ef2929', '#ff00c9', '#ad7fa8', '#729fcf', '#8ae234', '#e9b96e', '#fce94f', diff --git a/addons/web_diagram/static/src/js/diagram.js b/addons/web_diagram/static/src/js/diagram.js index 93c41dbf5dc..4ba59628c0d 100644 --- a/addons/web_diagram/static/src/js/diagram.js +++ b/addons/web_diagram/static/src/js/diagram.js @@ -204,8 +204,7 @@ openerp.web.DiagramView = openerp.web.View.extend({ id = parseInt(id, 10); var action_manager = new openerp.web.ActionManager(this); var dialog = new openerp.web.Dialog(this, { - width: 800, - height: 600, + width: 850, buttons : [ {text: _t("Cancel"), click: function() { $(this).dialog('destroy'); }}, {text: _t("Save"), click: function() { diff --git a/addons/web_process/static/src/js/process.js b/addons/web_process/static/src/js/process.js index e650530a914..8d4396ba403 100644 --- a/addons/web_process/static/src/js/process.js +++ b/addons/web_process/static/src/js/process.js @@ -275,7 +275,6 @@ openerp.web_process = function (openerp) { var action_manager = new openerp.web.ActionManager(this); var dialog = new openerp.web.Dialog(this, { width: 800, - height: 600, buttons : [ {text: _t("Cancel"), click: function() { $(this).dialog('destroy'); }}, {text: _t("Save"), click: function() {