From 46bf047e86c2a5dd93aae3b6ac77873aa6180a1e Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 16 Jun 2015 11:38:20 +0200 Subject: [IMP] web, web_*, mail, board : New modals and dialogs --- .../web/static/src/js/framework/crash_manager.js | 30 +-- addons/web/static/src/js/framework/data.js | 4 +- addons/web/static/src/js/framework/dialog.js | 273 ++++++++++----------- 3 files changed, 138 insertions(+), 169 deletions(-) (limited to 'addons/web/static/src/js/framework') diff --git a/addons/web/static/src/js/framework/crash_manager.js b/addons/web/static/src/js/framework/crash_manager.js index 303cd66a4a3..4ab40f456bc 100644 --- a/addons/web/static/src/js/framework/crash_manager.js +++ b/addons/web/static/src/js/framework/crash_manager.js @@ -118,23 +118,17 @@ var CrashManager = core.Class.extend({ size: 'medium', title: "Odoo " + (_.str.capitalize(error.type) || _t("Warning")), subtitle: error.data.title, - buttons: [ - {text: _t("Ok"), click: function() { this.parents('.modal').modal('hide'); }} - ], - }, $('
' + QWeb.render('CrashManager.warning', {error: error}) + '
')).open(); + $content: $('
').html(QWeb.render('CrashManager.warning', {error: error})) + }).open(); }, show_error: function(error) { if (!this.active) { return; } - var buttons = {}; - buttons[_t("Ok")] = function() { - this.parents('.modal').modal('hide'); - }; new Dialog(this, { title: "Odoo " + _.str.capitalize(error.type), - buttons: buttons - }, QWeb.render('CrashManager.error', {session: session, error: error})).open(); + $content: QWeb.render('CrashManager.error', {session: session, error: error}) + }).open(); }, show_message: function(exception) { this.show_error({ @@ -181,16 +175,14 @@ var RedirectWarningHandler = Dialog.extend(ExceptionHandler, { size: 'medium', title: "Odoo " + (_.str.capitalize(error.type) || "Warning"), buttons: [ - {text: error.data.arguments[2], - oe_link_class : 'oe_highlight', - post_text : _t("or"), - click: function() { - window.location.href='#action='+error.data.arguments[1]; - self.destroy(); - }}, - {text: _t("Cancel"), oe_link_class: 'oe_link', click: function() { self.$el.parents('.modal').modal('hide'); self.destroy();}} + {text: error.data.arguments[2], classes : "btn-primary", click: function() { + window.location.href = '#action='+error.data.arguments[1]; + self.destroy(); + }}, + {text: _t("Cancel"), click: function() { self.destroy(); }, close: true} ], - }, QWeb.render('CrashManager.warning', {error: error})).open(); + $content: QWeb.render('CrashManager.warning', {error: error}) + }).open(); } }); diff --git a/addons/web/static/src/js/framework/data.js b/addons/web/static/src/js/framework/data.js index efbce3a5056..597af06118d 100644 --- a/addons/web/static/src/js/framework/data.js +++ b/addons/web/static/src/js/framework/data.js @@ -542,8 +542,8 @@ var DataSet = Class.extend(mixins.PropertiesMixin, { /** * @param name */ - name_create: function(name) { - return this._model.call('name_create', [name], {context: this.get_context()}); + name_create: function(name, context) { + return this._model.call('name_create', [name], {context: this.get_context(context)}); }, exec_workflow: function (id, signal) { return this._model.exec_workflow(id, signal); diff --git a/addons/web/static/src/js/framework/dialog.js b/addons/web/static/src/js/framework/dialog.js index 81d8860d4c3..45a00bcaa60 100644 --- a/addons/web/static/src/js/framework/dialog.js +++ b/addons/web/static/src/js/framework/dialog.js @@ -5,190 +5,167 @@ var core = require('web.core'); var Widget = require('web.Widget'); var QWeb = core.qweb; -var opened_modals = []; +var _t = core._t; /** A useful class to handle dialogs. Attributes: - - $buttons: A jQuery element targeting a dom part where buttons can be added. It always exists + - $footer: A jQuery element targeting a dom part where buttons can be added. It always exists during the lifecycle of the dialog. */ var Dialog = Widget.extend({ - dialog_title: "", /** Constructor. @param {Widget} parent - @param {dictionary} options A dictionary that will be forwarded to jQueryUI Dialog. Additionaly, that - dictionary can contain the following keys: + @param {dictionary} options + - title + - subtitle - size: one of the following: 'large', 'medium', 'small' - - dialogClass: class to add to the body of dialog - - buttons: Deprecated. The buttons key is not propagated to jQueryUI Dialog. It must be a dictionary (key = button - label, value = click handler) or a list of dictionaries (each element in the dictionary is send to the - corresponding method of a jQuery element targeting the