diff --git a/addons/board/static/src/js/dashboard.js b/addons/board/static/src/js/dashboard.js index 72c4eee1eca..568a6e2babd 100644 --- a/addons/board/static/src/js/dashboard.js +++ b/addons/board/static/src/js/dashboard.js @@ -90,13 +90,14 @@ var DashBoard = form_common.FormWidget.extend({ var qdict = { current_layout : this.$el.find('.oe_dashboard').attr('data-layout') }; - var $dialog = new Dialog(this, { - title: _t("Edit Layout"), - }, QWeb.render('DashBoard.layouts', qdict)).open(); - $dialog.$el.find('li').click(function() { + var dialog = new Dialog(this, { + title: _t("Edit Layout"), + $content: QWeb.render('DashBoard.layouts', qdict) + }).open(); + dialog.$el.find('li').click(function() { var layout = $(this).attr('data-layout'); self.do_change_layout(layout); - $dialog.$dialog_box.modal('hide'); + dialog.close(); }); }, do_change_layout: function(new_layout) { diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index e29feecf414..21ac9d5e171 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -1266,18 +1266,17 @@ var ComposeMessage = Attachment.extend ({ var partner_id = partner_info.partner_id; var parsed_email = mail_utils.parse_email(partner_name); - var pop = new form_common.FormOpenPopup(this); - pop.show_element( - 'res.partner', - partner_id, - { 'force_email': true, + var pop = new form_common.FormViewDialog(this, { + res_model: 'res.partner', + res_id: partner_id, + context: { + 'force_email': true, 'ref': "compound_context", 'default_name': parsed_email[0], 'default_email': parsed_email[1], - }, { - title: _t("Please complete partner's informations"), - } - ); + }, + title: _t("Please complete partner's informations"), + }).open(); pop.on('closed', self, function () { deferred.resolve(); }); diff --git a/addons/mail/static/src/js/many2many_tags_email.js b/addons/mail/static/src/js/many2many_tags_email.js index 604c1662579..2250935e1da 100644 --- a/addons/mail/static/src/js/many2many_tags_email.js +++ b/addons/mail/static/src/js/many2many_tags_email.js @@ -61,15 +61,12 @@ var FieldMany2ManyTagsEmail = form_relational.FieldMany2ManyTags.extend({ // unvalid partner _.each(record_ids, function (id) { - var pop = new form_common.FormOpenPopup(self); - pop.show_element( - 'res.partner', - id, - self.build_context(), - { - title: _t("Please complete partner's informations and Email"), - } - ); + var pop = new form_common.FormViewDialog(self, { + res_model: 'res.partner', + res_id: id, + context: self.build_context(), + title: _t("Please complete partner's informations and Email"), + }).open(); pop.on('write_completed', self, function () { this.values.push(id); this.values_checking = _.without(this.values_checking, id); diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 81a1460b0bd..440c83cd14b 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1105,21 +1105,6 @@ .openerp .oe-control-panel .oe-pager-buttons { min-height: 30px; } -.openerp .o-modal-header > div { - margin-left: 45%; -} -.openerp .oe_popup_form { - display: none; -} -.openerp .oe_popup_form .oe_formview .oe_form_pager { - display: none !important; -} -.openerp .oe_popup_form table label { - font-weight: normal; -} -.openerp .oe_popup_list_pager { - float: right; -} .openerp .oe_searchview { cursor: text; position: relative; @@ -3189,49 +3174,6 @@ body.oe_single_form .oe_single_form_container { background-image: url("/web/static/lib/jquery.ui/images/ui-icons_ffffff_256x240.png"); } -.modal .modal-header button.close { - border: none; - background: none; - padding: 1px; - height: 18px; - font-size: 20px; -} -.modal .modal-body { - overflow: auto; - padding: 0; -} -.modal .modal-body .oe_application { - width: 100%; -} -.modal .modal-body .oe_popup_list { - display: none; - min-height: 150px; -} -.modal .modal-body .oe-view-manager { - min-height: 150px; -} -.modal .modal-body .oe_form_sheetbg .oe_form_sheet { - padding: 0; -} -.modal .modal-footer { - text-align: left; -} -.modal .oe_button { - margin: 0 4px 0 0; -} -.modal .oe_act_window.modal-body { - padding: 0; -} -.modal .oe-view-manager-content { - position: static !important; -} - -@media (min-width: 768px) { - .modal .modal-body { - max-height: -webkit-calc(100vh - 170px); - max-height: calc(100vh - 170px); - } -} .ui-datepicker { z-index: 1500 !important; } diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 1f7a0c1560f..4ecea186b4b 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -954,21 +954,6 @@ $sheet-padding: 16px min-height: 30px // }}} - // FormPopup {{{ - .o-modal-header - > div - margin-left: 45% - .oe_popup_form - display: none - .oe_formview .oe_form_pager - display: none !important - // Customize label weight for popup wizard appear from another wizard according bootstrap3 - table label - font-weight: normal - // End of customize - .oe_popup_list_pager - float: right - // }}} // SearchView {{{ .oe_searchview cursor: text @@ -2628,41 +2613,6 @@ body.oe_single_form background-image: url("/web/static/lib/jquery.ui/images/ui-icons_ffffff_256x240.png") // End jquery-ui override}}} -// Customized modal according bootstrap3 -.modal - .modal-header button.close - border: none - background: none - padding: 1px - height: 18px - font-size: 20px - .modal-body - overflow: auto - padding: 0 - .oe_application - width: 100% - .oe_popup_list - display: none - min-height: 150px - .oe-view-manager - min-height: 150px - .oe_form_sheetbg - .oe_form_sheet - padding: 0 - .modal-footer - text-align: left - .oe_button - margin: 0 4px 0 0 - .oe_act_window.modal-body - padding: 0 - .oe-view-manager-content - position: static !important - -@media (min-width: 768px) - .modal .modal-body - max-height: -webkit-calc(100vh - 170px) - max-height: calc(100vh - 170px) - .ui-datepicker z-index: 1500 !important diff --git a/addons/web/static/src/js/action_manager.js b/addons/web/static/src/js/action_manager.js index 6700932b4bc..68a81a9dc68 100644 --- a/addons/web/static/src/js/action_manager.js +++ b/addons/web/static/src/js/action_manager.js @@ -529,14 +529,13 @@ var ActionManager = Widget.extend({ * @return {*} */ ir_actions_common: function(executor, options) { - var widget; if (executor.action.target === 'new') { var pre_dialog = (this.dialog && !this.dialog.isDestroyed()) ? this.dialog : null; if (pre_dialog){ // prevent previous dialog to consider itself closed, // right now, as we're opening a new one (prevents // reload of original form view) - pre_dialog.off('closing', null, pre_dialog.on_close); + pre_dialog.off('closed', null, pre_dialog.on_close); } if (this.dialog_widget && !this.dialog_widget.isDestroyed()) { this.dialog_widget.destroy(); @@ -547,6 +546,7 @@ var ActionManager = Widget.extend({ this.dialog = new Dialog(this, { title: executor.action.name, dialogClass: executor.klass, + buttons: [] }); // chain on_close triggers with previous dialog, if any @@ -560,34 +560,32 @@ var ActionManager = Widget.extend({ pre_dialog.on_close(); } }; - this.dialog.on("closing", null, this.dialog.on_close); - widget = executor.widget(); - if (widget instanceof ViewManager) { - _.extend(widget.flags, { - $buttons: this.dialog.$buttons, + this.dialog.on("closed", null, this.dialog.on_close); + this.dialog_widget = executor.widget(); + if (this.dialog_widget instanceof ViewManager) { + _.extend(this.dialog_widget.flags, { + $buttons: this.dialog.$footer, footer_to_buttons: true, }); - if (widget.action.view_mode === 'form') { - widget.flags.headless = true; + if (this.dialog_widget.action.view_mode === 'form') { + this.dialog_widget.flags.headless = true; } } - if (widget.need_control_panel) { + if (this.dialog_widget.need_control_panel) { // Set a fake bus to Dialogs needing a ControlPanel as they should not // communicate with the main ControlPanel - widget.set_cp_bus(new core.Bus()); + this.dialog_widget.set_cp_bus(new core.Bus()); } - this.dialog_widget = widget; this.dialog_widget.setParent(this.dialog); - var initialized = this.dialog_widget.appendTo(this.dialog.$el); this.dialog.open(); - return $.when(initialized); + + return this.dialog_widget.appendTo(this.dialog.$el); } if (this.inner_widget && this.webclient.has_uncommitted_changes()) { return $.Deferred().reject(); } - widget = executor.widget(); this.dialog_stop(executor.action); - return this.push_action(widget, executor.action, options); + return this.push_action(executor.widget(), executor.action, options); }, ir_actions_act_window: function (action, options) { var self = this; @@ -596,7 +594,7 @@ var ActionManager = Widget.extend({ return new ViewManager(self, null, null, null, action); }, action: action, - klass: 'oe_act_window', + klass: 'o_act_window', }, options); }, ir_actions_client: function (action, options) { diff --git a/addons/web/static/src/js/control_panel.js b/addons/web/static/src/js/control_panel.js index 5e607d86a5c..64b493b5270 100644 --- a/addons/web/static/src/js/control_panel.js +++ b/addons/web/static/src/js/control_panel.js @@ -159,7 +159,7 @@ var ControlPanel = Widget.extend({ function make_breadcrumb (bc, is_last) { var $bc = $('
  • ') - .append(is_last ? bc.title : $('').text(bc.title)) + .append(is_last ? bc.title : $('').html(bc.title)) .toggleClass('active', is_last); if (!is_last) { $bc.click(function () { 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 - -
    - + - - - - -
    -

    - - var message = d.message ? d.message : d.error.data.message; - d.html_error = context.engine.tools.html_escape(message) - .replace(/\n/g, '
    '); -
    - -

    -
    +
    + + var message = d.message ? d.message : d.error.data.message; + d.html_error = context.engine.tools.html_escape(message).replace(/\n/g, '
    '); +
    + +
    -
    +
    -
    @@ -330,7 +322,6 @@ - or @@ -815,7 +806,7 @@
    - +
    @@ -1175,12 +1166,10 @@
    - - + +
    @@ -1497,8 +1486,7 @@ - - - @@ -1542,51 +1529,13 @@ - -
    -
    -