mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[11.0][IMP] child_selection_clear
This commit is contained in:
@@ -13,7 +13,7 @@ odoo.define('web.web_widget_child_selector', function(require) {
|
||||
'click .o_child_selection_button': '_onChildSelectionClick',
|
||||
}),
|
||||
start: function () {
|
||||
// booleean indicating that the content of the input isn't synchronized
|
||||
// boolean indicating that the content of the input isn't synchronized
|
||||
// with the current m2o value (for instance, the user is currently
|
||||
// typing something in the input, and hasn't selected a value yet).
|
||||
|
||||
@@ -41,7 +41,11 @@ odoo.define('web.web_widget_child_selector', function(require) {
|
||||
this._rpc({
|
||||
model: this.field.relation,
|
||||
method: 'get_record_direct_childs_parents',
|
||||
args: [ resources, this.nodeOptions],
|
||||
args: [
|
||||
resources,
|
||||
this.nodeOptions,
|
||||
this.record.getDomain({fieldName: this.name}),
|
||||
],
|
||||
context: this.record.getContext(this.recordParams),
|
||||
})
|
||||
.then(function (data) {
|
||||
@@ -59,31 +63,17 @@ odoo.define('web.web_widget_child_selector', function(require) {
|
||||
}));
|
||||
});
|
||||
},
|
||||
_onChildSelectionParent: function(event) {
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: this.field.relation,
|
||||
method: 'get_record_parent',
|
||||
args: [[this.value.res_id || false]],
|
||||
context: this.record.getContext(this.recordParams),
|
||||
})
|
||||
.then(function (parent) {
|
||||
if (parent)
|
||||
self._setValue({
|
||||
id: parent[0], display_name: parent[1]
|
||||
})
|
||||
else
|
||||
self._setValue({
|
||||
id: false, display_name: false
|
||||
});
|
||||
});
|
||||
},
|
||||
_onChildSelectionClick: function(event) {
|
||||
var target = $(event.target);
|
||||
var index = target.data('index');
|
||||
var type = target.data('type');
|
||||
var value = (type === 'child') ? this.childs[index]: this.parents[index];
|
||||
this._setValue({id: value[0], display_name: value[1]});
|
||||
if (type === 'clear') {
|
||||
this._setValue({id: false});
|
||||
}
|
||||
else {
|
||||
var index = target.data('index');
|
||||
var value = (type === 'child') ? this.childs[index]: this.parents[index];
|
||||
this._setValue({id: value[0], display_name: value[1]});
|
||||
}
|
||||
},
|
||||
_renderEdit: function() {
|
||||
this._set_childs();
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
.btn.o_child_selection_button {
|
||||
white-space:normal;
|
||||
width:100%;
|
||||
margin:2px;
|
||||
}
|
||||
a.o_child_selection_button {
|
||||
.o_child_selection_button {
|
||||
cursor: pointer,
|
||||
}
|
||||
|
||||
.o_child_selection_label {
|
||||
cursor: pointer,
|
||||
}
|
||||
|
||||
.o_child_selection_clear {
|
||||
opacity: 0.6;
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
<t t-name="FieldChildSelectorChild">
|
||||
<div class="row">
|
||||
<div t-foreach="childs" t-as="key" class="col-xs-12">
|
||||
<button t-att-data-id="childs[key][0]" t-att-data-index="key"
|
||||
data-type="child" class="o_child_selection_button btn">
|
||||
<t t-set="id_for_label" t-value="'o_child_hierarchy_selector_' + _.uniqueId()"/>
|
||||
<input type="radio" t-att-data-id="childs[key][0]" t-att-data-index="key"
|
||||
t-att-id="id_for_label" data-type="child" class="o_child_selection_button"/>
|
||||
<label class="o_form_label o_child_selection_label" t-att-for="id_for_label">
|
||||
<t t-esc="childs[key][1]"/>
|
||||
</button>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
@@ -31,6 +33,9 @@
|
||||
<t t-esc="parents[key][1]"/>
|
||||
</a>
|
||||
</t>
|
||||
<t t-if="Object.keys(parents).length > 0">
|
||||
<i class="fa fa-times o_child_selection_button o_child_selection_clear" aria-hidden="true" data-type="clear"/>
|
||||
</t>
|
||||
</span>
|
||||
</t>
|
||||
</templates>
|
||||
|
||||
Reference in New Issue
Block a user