summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2011-12-21 14:43:06 +0100
committerFabien Meghazi <fme@openerp.com>2011-12-21 14:43:06 +0100
commit41cd88bfad1e61f244295fa3a2ac9e2abf01a100 (patch)
treecfa3f5e833affd6435cb90ce6f84e580833915a3 /addons/web/static/src
parent61b780a9a887d130dd9b772c8639fea064b7a605 (diff)
[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
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/chrome.js45
-rw-r--r--addons/web/static/src/js/data_export.js6
-rw-r--r--addons/web/static/src/js/data_import.js8
-rw-r--r--addons/web/static/src/js/view_editor.js17
4 files changed, 30 insertions, 46 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 = {};