Show dynamic readonly widget in editable tree
We must render such widget to be able to display them when they are no more readonly. And we must ensure they are loaded and the states is computed when displayed. issue8626 review280041002
This commit is contained in:
1 parent
ad7e4b9592
commit
43b8eca5b4
1 file changed
+16
-12
+16
-12
@@ -1290,15 +1290,28 @@
|
||||
|
||||
Sao.View.Tree.RowEditable._super.redraw.call(this, selected,
|
||||
expanded);
|
||||
var display_callback = function(widget) {
|
||||
var record = this.record;
|
||||
return function() {
|
||||
var field = record.model.fields[widget.field_name];
|
||||
field.set_state(record);
|
||||
widget.display(record, field);
|
||||
};
|
||||
}.bind(this);
|
||||
// The autocompletion widget do not call display thus we have to
|
||||
// call it when redrawing the row
|
||||
for (i = 0; i < this.tree.columns.length; i++) {
|
||||
var column = this.tree.columns[i];
|
||||
td = this._get_column_td(i);
|
||||
tr = td.find('tr');
|
||||
widget = jQuery(tr.children('.widget-editable')).data('widget');
|
||||
if (widget) {
|
||||
field = this.record.model.fields[widget.field_name];
|
||||
widget.display(this.record, field);
|
||||
var callback = display_callback(widget);
|
||||
if (!this.record.is_loaded(column.attributes.name)) {
|
||||
this.record.load(column.attributes.name).done(callback);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1369,18 +1382,9 @@
|
||||
if (!col.field) {
|
||||
continue;
|
||||
}
|
||||
var state_attrs = col.field.get_state_attrs(this.record);
|
||||
var readonly = col.attributes.readonly;
|
||||
if (readonly === undefined) {
|
||||
readonly = state_attrs.readonly;
|
||||
if (readonly === undefined) {
|
||||
readonly = false;
|
||||
}
|
||||
}
|
||||
|
||||
var EditableBuilder = Sao.View.EditableTree.WIDGETS[
|
||||
col.attributes.widget];
|
||||
if (!readonly && EditableBuilder) {
|
||||
if (!col.attributes.readonly && EditableBuilder) {
|
||||
var widget = new EditableBuilder(
|
||||
this.tree, col.attributes);
|
||||
widget.el.on('keydown', this.key_press.bind(this));
|
||||
|
||||
Reference in new issue
Block a user