[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
This commit is contained in:
parent
61b780a9a8
commit
41cd88bfad
|
@ -51,15 +51,19 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog#
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.dialog_options = {
|
this.dialog_options = {
|
||||||
modal: true,
|
modal: true,
|
||||||
width: 'auto',
|
destroy_on_close: true,
|
||||||
|
width: $(window).width() * (($(window).width() > 1024) ? 0.5 : 0.75),
|
||||||
min_width: 0,
|
min_width: 0,
|
||||||
max_width: '100%',
|
max_width: '95%',
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
min_height: 0,
|
min_height: 0,
|
||||||
max_height: '100%',
|
max_height: '95%',
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
|
position: [false, 50],
|
||||||
|
autoResize : 'auto',
|
||||||
buttons: {},
|
buttons: {},
|
||||||
beforeClose: function () { self.on_close(); }
|
beforeClose: function () { self.on_close(); },
|
||||||
|
resizeStop: this.on_resized
|
||||||
};
|
};
|
||||||
for (var f in this) {
|
for (var f in this) {
|
||||||
if (f.substr(0, 10) == 'on_button_') {
|
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.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.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.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 !== 'auto') {
|
||||||
if (options.width > options.max_width) options.width = options.max_width;
|
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 () {
|
start: function () {
|
||||||
this.$dialog = $(this.$element).dialog(this.dialog_options);
|
this.$element.dialog(this.dialog_options);
|
||||||
this._super();
|
this._super();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -118,19 +122,26 @@ openerp.web.Dialog = openerp.web.OldWidget.extend(/** @lends openerp.web.Dialog#
|
||||||
this.$element.html(this.render());
|
this.$element.html(this.render());
|
||||||
}
|
}
|
||||||
this.set_options(dialog_options);
|
this.set_options(dialog_options);
|
||||||
this.$dialog.dialog(this.dialog_options).dialog('open');
|
this.$element.dialog(this.dialog_options).dialog('open');
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
close: function() {
|
close: function() {
|
||||||
// Closes the dialog but leave it in a state where it could be opened again.
|
this.$element.dialog('close');
|
||||||
this.$dialog.dialog('close');
|
|
||||||
},
|
},
|
||||||
on_close: function() {
|
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 () {
|
stop: function () {
|
||||||
// Destroy widget
|
// Destroy widget
|
||||||
this.close();
|
this.close();
|
||||||
this.$dialog.dialog('destroy');
|
this.$element.dialog('destroy');
|
||||||
this._super();
|
this._super();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -167,10 +178,6 @@ openerp.web.CrashManager = openerp.web.CallbackEnabled.extend({
|
||||||
var dialog = new openerp.web.Dialog(this, {
|
var dialog = new openerp.web.Dialog(this, {
|
||||||
title: "OpenERP " + _.str.capitalize(error.type),
|
title: "OpenERP " + _.str.capitalize(error.type),
|
||||||
autoOpen: true,
|
autoOpen: true,
|
||||||
width: '90%',
|
|
||||||
height: '90%',
|
|
||||||
min_width: '800px',
|
|
||||||
min_height: '600px',
|
|
||||||
buttons: [
|
buttons: [
|
||||||
{text: _t("Ok"), click: function() { $(this).dialog("close"); }}
|
{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,{
|
this.dialog = new openerp.web.Dialog(this,{
|
||||||
modal: true,
|
|
||||||
title: _t("Preferences"),
|
title: _t("Preferences"),
|
||||||
width: 600,
|
width: '700px',
|
||||||
height: 500,
|
|
||||||
buttons: [
|
buttons: [
|
||||||
{text: _t("Change password"), click: function(){ self.change_password(); }},
|
{text: _t("Change password"), click: function(){ self.change_password(); }},
|
||||||
{text: _t("Cancel"), click: function(){ $(this).dialog('destroy'); }},
|
{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() {
|
change_password :function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.dialog = new openerp.web.Dialog(this,{
|
this.dialog = new openerp.web.Dialog(this, {
|
||||||
modal : true,
|
|
||||||
title: _t("Change Password"),
|
title: _t("Change Password"),
|
||||||
width : 'auto',
|
width : 'auto'
|
||||||
height : 'auto'
|
|
||||||
});
|
});
|
||||||
this.dialog.start().open();
|
this.dialog.start().open();
|
||||||
this.dialog.$element.html(QWeb.render("Change_Pwd", self));
|
this.dialog.$element.html(QWeb.render("Change_Pwd", self));
|
||||||
|
|
|
@ -15,10 +15,6 @@ openerp.web.DataExport = openerp.web.Dialog.extend({
|
||||||
var self = this;
|
var self = this;
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.open({
|
this.open({
|
||||||
modal: true,
|
|
||||||
width: '55%',
|
|
||||||
height: 'auto',
|
|
||||||
position: 'top',
|
|
||||||
buttons : [
|
buttons : [
|
||||||
{text: _t("Close"), click: function() { self.close(); }},
|
{text: _t("Close"), click: function() { self.close(); }},
|
||||||
{text: _t("Export To File"), click: function() { self.on_click_export_data(); }}
|
{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() {
|
close: function() {
|
||||||
$(this.$dialog).remove();
|
this.$element.remove();
|
||||||
this._super();
|
this._super();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -65,10 +65,6 @@ openerp.web.DataImport = openerp.web.Dialog.extend({
|
||||||
var self = this;
|
var self = this;
|
||||||
this._super();
|
this._super();
|
||||||
this.open({
|
this.open({
|
||||||
modal: true,
|
|
||||||
width: '70%',
|
|
||||||
height: 'auto',
|
|
||||||
position: 'top',
|
|
||||||
buttons: [
|
buttons: [
|
||||||
{text: _t("Close"), click: function() { self.stop(); }},
|
{text: _t("Close"), click: function() { self.stop(); }},
|
||||||
{text: _t("Import File"), click: function() { self.do_import(); }, 'class': 'oe-dialog-import-button'}
|
{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) {
|
toggle_import_button: function (newstate) {
|
||||||
this.$dialog.dialog('widget')
|
this.$element.dialog('widget')
|
||||||
.find('.oe-dialog-import-button')
|
.find('.oe-dialog-import-button')
|
||||||
.button('option', 'disabled', !newstate);
|
.button('option', 'disabled', !newstate);
|
||||||
},
|
},
|
||||||
|
@ -352,7 +348,7 @@ openerp.web.DataImport = openerp.web.Dialog.extend({
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
stop: function() {
|
stop: function() {
|
||||||
$(this.$dialog).remove();
|
this.$element.remove();
|
||||||
this._super();
|
this._super();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,10 +38,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.view_edit_dialog = new openerp.web.Dialog(this, {
|
this.view_edit_dialog = new openerp.web.Dialog(this, {
|
||||||
modal: true,
|
|
||||||
title: _t("ViewEditor"),
|
title: _t("ViewEditor"),
|
||||||
width: 750,
|
width: 850,
|
||||||
height: 500,
|
|
||||||
buttons: [
|
buttons: [
|
||||||
{text: _t("Create"), click: function() { self.on_create_view(); }},
|
{text: _t("Create"), click: function() { self.on_create_view(); }},
|
||||||
{text: _t("Edit"), click: function() { self.xml_element_id = 0; self.get_arch(); }},
|
{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() {
|
on_create_view: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.create_view_dialog = new openerp.web.Dialog(this, {
|
this.create_view_dialog = new openerp.web.Dialog(this, {
|
||||||
modal: true,
|
|
||||||
title: _.str.sprintf(_t("Create a view (%s)"), self.model),
|
title: _.str.sprintf(_t("Create a view (%s)"), self.model),
|
||||||
width: 500,
|
|
||||||
height: 400,
|
|
||||||
buttons: [
|
buttons: [
|
||||||
{text: _t("Save"), click: function () {
|
{text: _t("Save"), click: function () {
|
||||||
var view_values = {};
|
var view_values = {};
|
||||||
|
@ -363,10 +358,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({
|
||||||
var self = this;
|
var self = this;
|
||||||
this.one_object = one_object;
|
this.one_object = one_object;
|
||||||
this.edit_xml_dialog = new openerp.web.Dialog(this, {
|
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),
|
title: _.str.sprintf(_t("View Editor %d - %s"), self.main_view_id, self.model),
|
||||||
width: 750,
|
height: '90%',
|
||||||
height: 500,
|
|
||||||
buttons: [
|
buttons: [
|
||||||
{text: _t("Preview"), click: function() {
|
{text: _t("Preview"), click: function() {
|
||||||
var action = {
|
var action = {
|
||||||
|
@ -752,10 +745,8 @@ openerp.web.ViewEditor = openerp.web.Widget.extend({
|
||||||
on_edit_node: function(properties){
|
on_edit_node: function(properties){
|
||||||
var self = this;
|
var self = this;
|
||||||
this.edit_node_dialog = new openerp.web.Dialog(this,{
|
this.edit_node_dialog = new openerp.web.Dialog(this,{
|
||||||
modal: true,
|
|
||||||
title: _t("Properties"),
|
title: _t("Properties"),
|
||||||
width: 500,
|
width: 450,
|
||||||
height: 400,
|
|
||||||
buttons: [
|
buttons: [
|
||||||
{text: _t("Update"), click: function () {
|
{text: _t("Update"), click: function () {
|
||||||
var warn = false, update_values = [];
|
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'}];
|
{'name': 'position','selection': ['After','Before','Inside'], 'value': false, 'string': 'Position','type': 'selection'}];
|
||||||
this.add_widget = [];
|
this.add_widget = [];
|
||||||
this.add_node_dialog = new openerp.web.Dialog(this,{
|
this.add_node_dialog = new openerp.web.Dialog(this,{
|
||||||
modal: true,
|
|
||||||
title: _t("Properties"),
|
title: _t("Properties"),
|
||||||
width: 450,
|
width: 450,
|
||||||
height: 190,
|
|
||||||
buttons: [
|
buttons: [
|
||||||
{text: _t("Update"), click: function() {
|
{text: _t("Update"), click: function() {
|
||||||
var check_add_node = true, values = {};
|
var check_add_node = true, values = {};
|
||||||
|
|
|
@ -21,7 +21,11 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
|
||||||
this.has_been_loaded = $.Deferred();
|
this.has_been_loaded = $.Deferred();
|
||||||
this.creating_event_id = null;
|
this.creating_event_id = null;
|
||||||
this.dataset_events = [];
|
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.form_dialog.start();
|
||||||
this.COLOR_PALETTE = ['#f57900', '#cc0000', '#d400a8', '#75507b', '#3465a4', '#73d216', '#c17d11', '#edd400',
|
this.COLOR_PALETTE = ['#f57900', '#cc0000', '#d400a8', '#75507b', '#3465a4', '#73d216', '#c17d11', '#edd400',
|
||||||
'#fcaf3e', '#ef2929', '#ff00c9', '#ad7fa8', '#729fcf', '#8ae234', '#e9b96e', '#fce94f',
|
'#fcaf3e', '#ef2929', '#ff00c9', '#ad7fa8', '#729fcf', '#8ae234', '#e9b96e', '#fce94f',
|
||||||
|
|
|
@ -204,8 +204,7 @@ openerp.web.DiagramView = openerp.web.View.extend({
|
||||||
id = parseInt(id, 10);
|
id = parseInt(id, 10);
|
||||||
var action_manager = new openerp.web.ActionManager(this);
|
var action_manager = new openerp.web.ActionManager(this);
|
||||||
var dialog = new openerp.web.Dialog(this, {
|
var dialog = new openerp.web.Dialog(this, {
|
||||||
width: 800,
|
width: 850,
|
||||||
height: 600,
|
|
||||||
buttons : [
|
buttons : [
|
||||||
{text: _t("Cancel"), click: function() { $(this).dialog('destroy'); }},
|
{text: _t("Cancel"), click: function() { $(this).dialog('destroy'); }},
|
||||||
{text: _t("Save"), click: function() {
|
{text: _t("Save"), click: function() {
|
||||||
|
|
|
@ -275,7 +275,6 @@ openerp.web_process = function (openerp) {
|
||||||
var action_manager = new openerp.web.ActionManager(this);
|
var action_manager = new openerp.web.ActionManager(this);
|
||||||
var dialog = new openerp.web.Dialog(this, {
|
var dialog = new openerp.web.Dialog(this, {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
|
||||||
buttons : [
|
buttons : [
|
||||||
{text: _t("Cancel"), click: function() { $(this).dialog('destroy'); }},
|
{text: _t("Cancel"), click: function() { $(this).dialog('destroy'); }},
|
||||||
{text: _t("Save"), click: function() {
|
{text: _t("Save"), click: function() {
|
||||||
|
|
Loading…
Reference in New Issue