summaryrefslogtreecommitdiff
path: root/addons/web/static
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2017-01-04 17:57:21 +0100
committerqsm-odoo <qsm@odoo.com>2017-01-06 16:03:09 +0100
commit20b109fac982cee000b65db2d3a17b4f856f8d5c (patch)
tree345d6354d52bbdf67a98cd51a9c831dd3a69cb57 /addons/web/static
parentb8eb821f1353700dac26383d5d4950232305c852 (diff)
[IMP] web: add new DomainSelectorDialog dialog widget
The DomainSelectorDialog widget allows the use of a DomainSelector widget inside a modal.
Diffstat (limited to 'addons/web/static')
-rw-r--r--addons/web/static/src/js/widgets/domain_selector_dialog.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/addons/web/static/src/js/widgets/domain_selector_dialog.js b/addons/web/static/src/js/widgets/domain_selector_dialog.js
new file mode 100644
index 00000000000..47bfa4e1359
--- /dev/null
+++ b/addons/web/static/src/js/widgets/domain_selector_dialog.js
@@ -0,0 +1,48 @@
+odoo.define("web.DomainSelectorDialog", function (require) {
+"use strict";
+
+var core = require("web.core");
+var Dialog = require("web.Dialog");
+var DomainSelector = require("web.DomainSelector");
+
+var _t = core._t;
+
+return Dialog.extend({
+ init: function (parent, model, domain, options) {
+ this.model = model;
+ this.options = _.extend({
+ readonly: true,
+ fs_filters: {},
+ debugMode: false,
+ }, options || {});
+
+ var buttons;
+ if (this.options.readonly) {
+ buttons = [
+ {text: _t("Close"), close: true},
+ ];
+ } else {
+ buttons = [
+ {text: _t("Save"), classes: "btn-primary", close: true, click: function () {
+ this.trigger_up("domain_selected", {domain: this.domainSelector.getDomain()});
+ }},
+ {text: _t("Discard"), close: true},
+ ];
+ }
+
+ this._super(parent, _.extend({}, {
+ title: _t("Domain"),
+ buttons: buttons,
+ }, options || {}));
+
+ this.domainSelector = new DomainSelector(this, model, domain, options);
+ },
+ start: function () {
+ this.$el.css("overflow", "visible").closest(".modal-dialog").css("height", "auto"); // This restores default modal height (bootstrap) and allows field selector to overflow
+ return $.when(
+ this._super.apply(this, arguments),
+ this.domainSelector.appendTo(this.$el)
+ );
+ },
+});
+});