summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2017-01-05 14:01:48 +0100
committerqsm-odoo <qsm@odoo.com>2017-01-06 16:03:09 +0100
commit11a4e17c9c129d103d551661ec2b06efeda21bc4 (patch)
treeeaf38ac551f2ec8521dbdfeda962285b0e4147ec
parentf64c1c6b7457ca73ac01b6dd3cebdbaa2889baa1 (diff)
[IMP] web: add a dialog option to the FieldDomain
Now, the form FieldDomain has an option "dialog" which allows to force the domain *edition* in a new dialog. This allows the field to be positioned in smaller area of the form view in some contexts.
-rw-r--r--addons/web/static/src/js/views/form_widgets.js19
-rw-r--r--addons/web/static/src/less/form_view_layout.less2
-rw-r--r--addons/web/static/src/xml/base.xml4
3 files changed, 22 insertions, 3 deletions
diff --git a/addons/web/static/src/js/views/form_widgets.js b/addons/web/static/src/js/views/form_widgets.js
index a3c7bcaaff3..78d8ea7c5d1 100644
--- a/addons/web/static/src/js/views/form_widgets.js
+++ b/addons/web/static/src/js/views/form_widgets.js
@@ -11,6 +11,7 @@ var Priority = require('web.Priority');
var ProgressBar = require('web.ProgressBar');
var Dialog = require('web.Dialog');
var DomainSelector = require("web.DomainSelector");
+var DomainSelectorDialog = require("web.DomainSelectorDialog");
var common = require('web.form_common');
var formats = require('web.formats');
var framework = require('web.framework');
@@ -400,11 +401,19 @@ var FieldDomain = common.AbstractField.extend(common.ReinitializeFieldMixin).ext
e.preventDefault();
this._showSelection();
},
+ "click .o_form_field_domain_dialog_button": function (e) {
+ e.preventDefault();
+ this.openDomainDialog();
+ },
},
custom_events: {
"domain_changed": function (e) {
+ if (this.options.in_dialog) return;
this.set_value(this.domainSelector.getDomain(), true);
},
+ "domain_selected": function (e) {
+ this.set_value(e.data.domain);
+ },
},
init: function () {
this._super.apply(this, arguments);
@@ -412,6 +421,7 @@ var FieldDomain = common.AbstractField.extend(common.ReinitializeFieldMixin).ext
this.valid = true;
this.debug = session.debug;
this.options = _.defaults(this.options || {}, {
+ in_dialog: false,
model: undefined, // this option is mandatory !
fs_filters: {}, // Field selector filters (to only show a subset of available fields @see FieldSelector)
});
@@ -457,7 +467,7 @@ var FieldDomain = common.AbstractField.extend(common.ReinitializeFieldMixin).ext
this.domainSelector.destroy();
}
this.domainSelector = new DomainSelector(this, this.model, domain, {
- readonly: this.get("effective_readonly"),
+ readonly: this.get("effective_readonly") || this.options.in_dialog,
fs_filters: this.options.fs_filters,
debugMode: session.debug,
});
@@ -492,6 +502,13 @@ var FieldDomain = common.AbstractField.extend(common.ReinitializeFieldMixin).ext
disable_multiple_selection: true,
}).open();
},
+ openDomainDialog: function () {
+ new DomainSelectorDialog(this, this.model, this.get("value"), {
+ readonly: this.get("effective_readonly"),
+ fs_filters: this.options.fs_filters,
+ debugMode: session.debug,
+ }).open();
+ },
});
var FieldDate = common.AbstractField.extend(common.ReinitializeFieldMixin, {
diff --git a/addons/web/static/src/less/form_view_layout.less b/addons/web/static/src/less/form_view_layout.less
index 9b286f9e8fa..fc5522035e5 100644
--- a/addons/web/static/src/less/form_view_layout.less
+++ b/addons/web/static/src/less/form_view_layout.less
@@ -281,7 +281,7 @@
> .o_form_field_domain_panel {
margin-top: 8px;
}
- &.o_edit_mode {
+ &.o_inline_mode.o_edit_mode {
position: relative;
> .o_form_field_domain_panel {
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index 34387d9f507..47254cebb09 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -669,7 +669,7 @@
t-att-maxlength="widget.field.size"/>
</t>
-<div t-name="FieldDomain" t-attf-class="o_form_field_domain#{widget.get('effective_readonly') ? '' : ' o_edit_mode'}">
+<div t-name="FieldDomain" t-attf-class="o_form_field_domain#{widget.get('effective_readonly') ? '' : ' o_edit_mode'}#{widget.options.in_dialog ? '' : ' o_inline_mode'}">
<!-- domain selector will be instantiated here -->
<div class="o_form_field_domain_panel">
<i class="fa fa-arrow-right"/>
@@ -677,6 +677,8 @@
<span class="o_domain_records_count"/> record(s)
</button>
<span class="text-warning o_domain_error_message hidden"><i class="fa fa-exclamation-triangle"/> Invalid domain</span>
+ <button t-if="widget.options.in_dialog &amp;&amp; !widget.get('effective_readonly')"
+ class="btn btn-sm btn-primary o_form_field_domain_dialog_button">Edit domain</button>
</div>
</div>