[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.
This commit is contained in:
@@ -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, {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 && !widget.get('effective_readonly')"
|
||||
class="btn btn-sm btn-primary o_form_field_domain_dialog_button">Edit domain</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user